aboutsummaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src/main
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-20 17:53:04 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-20 18:27:39 +0900
commite70da25135855b88571b19c108089b74181996a6 (patch)
tree6f2321abe60457cf5092676d9bee5e624ba3ff22 /saltstack-adapter/saltstack-adapter-provider/src/main
parent77ee1a55c18e1992bcf2b17b09bc874ab8bc8f6a (diff)
Saltstack port not mandatory
Issue-ID: CCSDK-390 Change-Id: Ie9448d3a3fbbc7e52e8103ca5da1e2a3e080d58c Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'saltstack-adapter/saltstack-adapter-provider/src/main')
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java16
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java2
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java51
-rwxr-xr-xsaltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml2
4 files changed, 22 insertions, 49 deletions
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java
index 5373c227..5e0cc77e 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java
@@ -176,7 +176,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
logger.info("Creating ssh client connection");
// set path to keystore file
String sshHost = props.getProperty(SS_SERVER_HOSTNAME);
- String sshPort = props.getProperty(SS_SERVER_PORT);
+ String sshPort = reqServerPort(props) ;
String sshUserName = props.getProperty(SS_SERVER_USERNAME);
String sshPassword = props.getProperty(SS_SERVER_PASSWD);
sshClient = new ConnectionBuilder(sshHost, sshPort, sshUserName, sshPassword);
@@ -184,7 +184,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
// set path to keystore file
String sshKey = props.getProperty(SS_SERVER_SSH_KEY);
String sshHost = props.getProperty(SS_SERVER_HOSTNAME);
- String sshPort = props.getProperty(SS_SERVER_PORT);
+ String sshPort = reqServerPort(props);
logger.info("Creating ssh client with ssh KEY from " + sshKey);
sshClient = new ConnectionBuilder(sshHost, sshPort, sshKey);
} else if ("BOTH".equalsIgnoreCase(clientType)) {
@@ -193,7 +193,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
String sshHost = props.getProperty(SS_SERVER_HOSTNAME);
String sshUserName = props.getProperty(SS_SERVER_USERNAME);
String sshPassword = props.getProperty(SS_SERVER_PASSWD);
- String sshPort = props.getProperty(SS_SERVER_PORT);
+ String sshPort = reqServerPort(props);
logger.info("Creating ssh client with ssh KEY from " + sshKey);
sshClient = new ConnectionBuilder(sshHost, sshPort, sshUserName, sshPassword, sshKey);
} else {
@@ -204,13 +204,19 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
logger.error("Error Initializing Saltstack Adapter due to Unknown Exception", e);
throw new SvcLogicException("Saltstack Adapter Property file parsing Error = port in property file has to be an integer.");
} catch (Exception e) {
- logger.error("Error Initializing Saltstack Adapter due to Unknown Exception", e);
+ logger.error("Error Initializing Saltstack Adapter due to Exception", e);
throw new SvcLogicException("Saltstack Adapter Property file parsing Error = " + e.getMessage());
}
-
logger.info("Initialized Saltstack Adapter");
}
+ private String reqServerPort(Properties props) {
+ // use default port if null
+ if (props.getProperty(SS_SERVER_PORT) == null)
+ return "22";
+ return props.getProperty(SS_SERVER_PORT);
+ }
+
private void setSSHClient(Map<String, String> params) throws SvcLogicException {
if (sshClient == null) {
logger.info("saltstack-adapter.properties not defined so reading saltstack host and " +
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java
index 0eb1fc0e..3eb353a1 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * openECOMP : SDN-C
+ * ONAP : CCSDK
* ================================================================================
* Copyright (C) 2018 Samsung Electronics. All rights
* reserved.
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java
index 3095fca9..8548efc0 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java
@@ -78,13 +78,9 @@ public class SaltstackMessageParser {
* the appropriate PORT number.
*/
public String reqPortResult(Map<String, String> params) throws SvcLogicException {
-
- final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY,
- PASS_KEY};
-
- for (String key : mandatoryTestParams) {
- throwIfMissingMandatoryParam(params, key);
- }
+ // use default port if null
+ if (params.get(SS_AGENT_PORT_KEY) == null)
+ return "22";
return params.get(SS_AGENT_PORT_KEY);
}
@@ -95,12 +91,7 @@ public class SaltstackMessageParser {
*/
public String reqHostNameResult(Map<String, String> params) throws SvcLogicException {
- final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY,
- PASS_KEY};
-
- for (String key : mandatoryTestParams) {
- throwIfMissingMandatoryParam(params, key);
- }
+ throwIfMissingMandatoryParam(params, SS_AGENT_HOSTNAME_KEY);
return params.get(SS_AGENT_HOSTNAME_KEY);
}
@@ -126,12 +117,7 @@ public class SaltstackMessageParser {
*/
public String reqCmd(Map<String, String> params) throws SvcLogicException {
- final String[] mandatoryTestParams = {CMD_EXEC, IS_SLS_EXEC};
-
- for (String key : mandatoryTestParams) {
- throwIfMissingMandatoryParam(params, key);
- }
-
+ throwIfMissingMandatoryParam(params, CMD_EXEC);
return params.get(SaltstackMessageParser.CMD_EXEC);
}
@@ -142,12 +128,7 @@ public class SaltstackMessageParser {
*/
public String reqSlsFile(Map<String, String> params) throws SvcLogicException {
- final String[] mandatoryTestParams = {SLS_FILE_LOCATION};
-
- for (String key : mandatoryTestParams) {
- throwIfMissingMandatoryParam(params, key);
- }
-
+ throwIfMissingMandatoryParam(params, SLS_FILE_LOCATION);
return params.get(SaltstackMessageParser.SLS_FILE_LOCATION);
}
@@ -158,11 +139,7 @@ public class SaltstackMessageParser {
*/
public String reqSlsName(Map<String, String> params) throws SvcLogicException {
- final String[] mandatoryTestParams = {SLS_NAME};
-
- for (String key : mandatoryTestParams) {
- throwIfMissingMandatoryParam(params, key);
- }
+ throwIfMissingMandatoryParam(params, SLS_NAME);
String slsName = params.get(SaltstackMessageParser.SLS_NAME);
try {
if (slsName.substring(slsName.lastIndexOf("."), slsName.length()).equalsIgnoreCase(".sls")) {
@@ -309,12 +286,7 @@ public class SaltstackMessageParser {
*/
public String reqUserNameResult(Map<String, String> params) throws SvcLogicException {
- final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY,
- PASS_KEY};
-
- for (String key : mandatoryTestParams) {
- throwIfMissingMandatoryParam(params, key);
- }
+ throwIfMissingMandatoryParam(params, USER_KEY);
return params.get(USER_KEY);
}
@@ -325,12 +297,7 @@ public class SaltstackMessageParser {
*/
public String reqPasswordResult(Map<String, String> params) throws SvcLogicException {
- final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY,
- PASS_KEY};
-
- for (String key : mandatoryTestParams) {
- throwIfMissingMandatoryParam(params, key);
- }
+ throwIfMissingMandatoryParam(params, PASS_KEY);
return params.get(PASS_KEY);
}
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml b/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml
index 2c3b7b04..446ab3e4 100755
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- openECOMP : SDN-C
+ ONAP : CCSDK
================================================================================
Copyright (C) 2017 - 2018 Samsung Electronics. All rights
reserved.