summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'saltstack-adapter/saltstack-adapter-provider/src')
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/SaltstackAdapter.java8
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java8
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java84
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java13
-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.java110
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResult.java8
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResultCodes.java8
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackServerEmulator.java8
-rwxr-xr-xsaltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml2
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/main/resources/saltstack-adapter.properties8
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java8
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java309
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java8
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/model/TestJsonParser.java2
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/resources/org/onap/ccsdk/default.properties8
16 files changed, 429 insertions, 165 deletions
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/SaltstackAdapter.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/SaltstackAdapter.java
index cdfe4ff7..346910a3 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/SaltstackAdapter.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/SaltstackAdapter.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java
index bd811fff..f6b3b70c 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
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 acd3db20..5373c227 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
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
@@ -26,6 +26,8 @@ package org.onap.ccsdk.sli.adaptors.saltstack.impl;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.onap.ccsdk.sli.adaptors.saltstack.SaltstackAdapter;
import org.onap.ccsdk.sli.adaptors.saltstack.SaltstackAdapterPropertiesProvider;
import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackMessageParser;
@@ -61,6 +63,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
public static final String OUTCOME_SUCCESS = "success";
public static final String CONNECTION_RETRY_DELAY = "retryDelay";
public static final String CONNECTION_RETRY_COUNT = "retryCount";
+ private static final String APPC_EXCEPTION_CAUGHT = "APPCException caught";
/**
* Adapter Name
*/
@@ -74,6 +77,10 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
private static final String SS_SERVER_USERNAME = "org.onap.appc.adapter.saltstack.userName";
private static final String SS_SERVER_PASSWD = "org.onap.appc.adapter.saltstack.userPasswd";
private static final String SS_SERVER_SSH_KEY = "org.onap.appc.adapter.saltstack.sshKey";
+
+ private static final String COMMAND_IN_JSON_OUT = " --out=json --static ";
+ private static final String COMMAND_CHANGE_DEFAULT_DIR = " cd /srv/salt/ ;";
+
/**
* The logger to be used
*/
@@ -135,7 +142,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
*/
@SuppressWarnings("static-method")
private void doFailure(SvcLogicContext svcLogic, int code, String message) throws SvcLogicException {
-
+ logger.error(APPC_EXCEPTION_CAUGHT, message);
svcLogic.setStatus(OUTCOME_FAILURE);
svcLogic.setAttribute(RESULT_CODE_ATTRIBUTE_NAME, Integer.toString(code));
svcLogic.setAttribute(MESSAGE_ATTRIBUTE_NAME, message);
@@ -219,9 +226,35 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
}
}
+ private String parseEnvParam(JSONObject envParams) {
+ StringBuilder envParamBuilder = new StringBuilder();
+ if (envParams != null) {
+ for(Object key : envParams.keySet()) {
+ if(envParamBuilder.length() > 0) {
+ envParamBuilder.append(", ");
+ }
+ envParamBuilder.append(key+"="+envParams.get((String) key));
+ logger.info("EnvParameters : " + envParamBuilder);
+ }
+ }
+ return envParamBuilder.toString();
+ }
+
+ private String parseFileParam(JSONObject fileParams) {
+ StringBuilder fileParamBuilder = new StringBuilder();
+ if (fileParams != null) {
+ for(Object key : fileParams.keySet()) {
+ fileParamBuilder.append("echo -e \"" + fileParams.get((String) key) + "\" > /srv/salt/" + key).append("; ");
+ logger.info("FileParameters : " + fileParamBuilder);
+ }
+ }
+ return fileParamBuilder.toString();
+ }
+
private String putToCommands(SvcLogicContext ctx, String slsFileName,
- String applyTo) throws SvcLogicException {
- String constructedCommand = "";
+ String applyTo, JSONObject envParams, JSONObject fileParams) throws SvcLogicException {
+
+ StringBuilder constructedCommand = new StringBuilder();
try {
File file = new File(slsFileName);
String slsFile = file.getName();
@@ -236,8 +269,12 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
String str = new String(data, "UTF-8");
in.close();
String slsWithoutExtn = stripExtension(slsFile);
- constructedCommand = "echo -e \""+str+"\" > /srv/salt/"+slsFile+"; cd /srv/salt/; salt '"+
- applyTo+"' state.apply "+slsWithoutExtn+" --out=json --static";
+ constructedCommand.append(parseFileParam(fileParams)).append("echo -e \"").append(str).append("\" > /srv/salt/").
+ append(slsFile).append("; ").append(COMMAND_CHANGE_DEFAULT_DIR).append(" salt '").
+ append(applyTo).append("' state.apply ").append(slsWithoutExtn).append(" ").append(parseEnvParam(envParams)).append(COMMAND_IN_JSON_OUT);
+
+ logger.info("Command to be executed on server : " + constructedCommand.toString());
+
} catch (FileNotFoundException e) {
doFailure(ctx, SaltstackResultCodes.IO_EXCEPTION.getValue(), "Input SLS file " +
"not found in path : " + slsFileName+". "+ e.getMessage());
@@ -248,8 +285,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
doFailure(ctx, SaltstackResultCodes.IO_EXCEPTION.getValue(), "Input file " +
"is not of type .sls");
}
- logger.info("Command to be executed on server : " + constructedCommand);
- return constructedCommand;
+ return constructedCommand.toString();
}
private String stripExtension (String str) {
@@ -259,12 +295,15 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
return str.substring(0, pos);
}
- private String putToCommands(String slsName, String applyTo) {
- String
- constructedCommand = "cd /srv/salt/; salt '"+applyTo+"' state.apply "+slsName+" --out=json --static";
+ private String putToCommands(String slsName, String applyTo, JSONObject envParams, JSONObject fileParams) {
+
+ StringBuilder constructedCommand = new StringBuilder();
+
+ constructedCommand.append(parseFileParam(fileParams)).append(COMMAND_CHANGE_DEFAULT_DIR).append(" salt '").append(applyTo)
+ .append("' state.apply ").append(slsName).append(" ").append(parseEnvParam(envParams)).append(COMMAND_IN_JSON_OUT);
- logger.info("Command to be executed on server : " + constructedCommand);
- return constructedCommand;
+ logger.info("Command to be executed on server : " + constructedCommand.toString());
+ return constructedCommand.toString();
}
private void checkResponseStatus(SaltstackResult testResult, SvcLogicContext ctx, String reqID, boolean slsExec)
@@ -274,7 +313,6 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
if (testResult.getStatusCode() != SaltstackResultCodes.FINAL_SUCCESS.getValue()) {
ctx.setAttribute(ID_ATTRIBUTE_NAME, reqID);
doFailure(ctx, testResult.getStatusCode(), "Request for execution of command failed. Reason = " + testResult.getStatusMessage());
- return;
} else {
logger.info(String.format("Execution of request : successful."));
ctx.setAttribute(RESULT_CODE_ATTRIBUTE_NAME, Integer.toString(testResult.getStatusCode()));
@@ -326,13 +364,18 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
String slsName = messageProcessor.reqSlsName(params);
String applyTo = messageProcessor.reqApplyToDevices(params);
long execTimeout = messageProcessor.reqExecTimeout(params);
- String commandToExecute = putToCommands(slsName, applyTo);
+ JSONObject envParams = messageProcessor.reqEnvParameters(params);
+ JSONObject fileParams = messageProcessor.reqFileParameters(params);
+
+ String commandToExecute = putToCommands(slsName, applyTo, envParams, fileParams);
testResult = execCommand(ctx, params, commandToExecute, execTimeout);
testResult = messageProcessor.parseResponse(ctx, reqID, testResult, true);
checkResponseStatus(testResult, ctx, reqID, true);
} catch (IOException e) {
doFailure(ctx, SaltstackResultCodes.IO_EXCEPTION.getValue(),
"IOException in file stream : "+ e.getMessage());
+ } catch (JSONException e) {
+ doFailure(ctx, SaltstackResultCodes.INVALID_COMMAND.getValue(), e.getMessage());
}
}
@@ -354,7 +397,10 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
String slsFile = messageProcessor.reqSlsFile(params);
String applyTo = messageProcessor.reqApplyToDevices(params);
long execTimeout = messageProcessor.reqExecTimeout(params);
- String commandToExecute = putToCommands(ctx, slsFile, applyTo);
+ JSONObject envParams = messageProcessor.reqEnvParameters(params);
+ JSONObject fileParams = messageProcessor.reqFileParameters(params);
+
+ String commandToExecute = putToCommands(ctx, slsFile, applyTo, envParams, fileParams);
testResult = execCommand(ctx, params, commandToExecute, execTimeout);
testResult = messageProcessor.parseResponse(ctx, reqID, testResult, true);
checkResponseStatus(testResult, ctx, reqID, true);
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java
index d8616920..62724c36 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
@@ -50,7 +50,7 @@ class SshConnection {
public static final int DEFAULT_CONNECTION_RETRY_COUNT = 5;
private static final EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
private static final long AUTH_TIMEOUT = 60000;
- private static final long EXEC_TIMEOUT = 120000;
+ private static final long EXEC_TIMEOUT = 120;
private String host;
private int port;
private String username;
@@ -162,7 +162,8 @@ class SshConnection {
}
public void setExecTimeout(long timeout) {
- this.timeout = timeout;
+ //convert seconds to milliseconds
+ this.timeout = timeout*1000;
}
public SaltstackResult execCommand(String cmd, OutputStream out, OutputStream err, SaltstackResult result ) {
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 be1fa574..0eb1fc0e 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018 Samsung Electronics. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
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 f7c513c9..3095fca9 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
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
@@ -30,7 +30,9 @@ package org.onap.ccsdk.sli.adaptors.saltstack.model;
*/
import com.google.common.base.Strings;
-import org.codehaus.jettison.json.JSONException;
+import org.json.JSONException;
+import org.json.JSONArray;
+import org.json.JSONObject;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.slf4j.Logger;
@@ -41,8 +43,11 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import java.util.UUID;
/**
@@ -55,13 +60,15 @@ public class SaltstackMessageParser {
private static final String SS_AGENT_PORT_KEY = "Port";
private static final String PASS_KEY = "Password";
private static final String USER_KEY = "User";
- private static final String CMD_EXEC = "cmd";
- private static final String IS_SLS_EXEC = "slsExec";
+ private static final String CMD_EXEC = "Cmd"; //cmd
+ private static final String IS_SLS_EXEC = "SlsExec"; //slsExec
private static final String SS_REQ_ID = "Id";
- private static final String SLS_FILE_LOCATION = "slsFile";
- private static final String SLS_NAME = "slsName";
- private static final String MINION_TO_APPLY = "applyTo";
- private static final String EXEC_TIMEOUT_TO_APPLY = "execTimeout";
+ private static final String SLS_FILE_LOCATION = "SlsFile"; //slsFile
+ private static final String SLS_NAME = "SlsName"; //slsName
+ private static final String MINION_TO_APPLY = "NodeList"; //applyTo
+ private static final String EXEC_TIMEOUT_TO_APPLY = "Timeout"; //execTimeout
+ private static final String FILE_PARAMETERS_OPT_KEY = "FileParameters";
+ private static final String ENV_PARAMETERS_OPT_KEY = "EnvParameters";
private static final Logger LOGGER = LoggerFactory.getLogger(SaltstackMessageParser.class);
@@ -181,7 +188,7 @@ public class SaltstackMessageParser {
/**
* Method that validates that the Map has enough information
* to query Saltstack server for a result. If so, it returns
- * the appropriate minions/vnfc to execute the SLS file to.
+ * the appropriate minions/vnfc to execute the SLS file.
*/
public String reqApplyToDevices(Map<String, String> params) {
@@ -196,7 +203,7 @@ public class SaltstackMessageParser {
/**
* Method that validates that the Map has enough information
* to query Saltstack server for a result. If so, it returns
- * the appropriate minions/vnfc to execute the SLS file to.
+ * the appropriate minions/vnfc to execute the SLS file.
*/
public long reqExecTimeout(Map<String, String> params) {
@@ -211,6 +218,77 @@ public class SaltstackMessageParser {
/**
* Method that validates that the Map has enough information
* to query Saltstack server for a result. If so, it returns
+ * the appropriate EnvParameters to execute the SLS file.
+ */
+ public JSONObject reqEnvParameters(Map<String, String> params) throws JSONException {
+
+ JSONObject jsonPayload = new JSONObject();
+ final String[] optionalTestParam = { SaltstackMessageParser.ENV_PARAMETERS_OPT_KEY };
+ parseParam(params, optionalTestParam, jsonPayload);
+
+ return (JSONObject) jsonPayload.remove(SaltstackMessageParser.ENV_PARAMETERS_OPT_KEY);
+ }
+
+ /**
+ * Method that validates that the Map has enough information
+ * to query Saltstack server for a result. If so, it returns
+ * the appropriate EnvParameters to execute the SLS file.
+ */
+ public JSONObject reqFileParameters(Map<String, String> params) throws JSONException {
+
+ JSONObject jsonPayload = new JSONObject();
+ final String[] optionalTestParam = { SaltstackMessageParser.FILE_PARAMETERS_OPT_KEY };
+ parseParam(params, optionalTestParam, jsonPayload);
+
+ return (JSONObject) jsonPayload.remove(SaltstackMessageParser.FILE_PARAMETERS_OPT_KEY);
+ }
+
+ private void parseParam(Map<String, String> params, String[] optionalTestParams, JSONObject jsonPayload)
+ throws JSONException {
+
+ Set<String> optionalParamsSet = new HashSet<>();
+ Collections.addAll(optionalParamsSet, optionalTestParams);
+
+ //@formatter:off
+ params.entrySet()
+ .stream()
+ .filter(entry -> optionalParamsSet.contains(entry.getKey()))
+ .filter(entry -> !Strings.isNullOrEmpty(entry.getValue()))
+ .forEach(entry -> parseParam(entry, jsonPayload));
+ //@formatter:on
+ }
+
+ private void parseParam(Map.Entry<String, String> params, JSONObject jsonPayload)
+ throws JSONException {
+ String key = params.getKey();
+ String payload = params.getValue();
+
+ switch (key) {
+ case ENV_PARAMETERS_OPT_KEY:
+ JSONObject paramsJson = new JSONObject(payload);
+ jsonPayload.put(key, paramsJson);
+ break;
+
+ case FILE_PARAMETERS_OPT_KEY:
+ jsonPayload.put(key, getFilePayload(payload));
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Return payload with escaped newlines
+ */
+ private JSONObject getFilePayload(String payload) {
+ String formattedPayload = payload.replace("\n", "\\n").replace("\r", "\\r");
+ return new JSONObject(formattedPayload);
+ }
+
+ /**
+ * Method that validates that the Map has enough information
+ * to query Saltstack server for a result. If so, it returns
* the appropriate IsSLSExec true or false.
*/
public boolean reqIsSLSExec(Map<String, String> params) throws SvcLogicException {
@@ -291,7 +369,7 @@ public class SaltstackMessageParser {
} catch (FileNotFoundException e) {
return new SaltstackResult(SaltstackResultCodes.INVALID_RESPONSE_FILE.getValue(), "error parsing response file "
+ saltstackResult.getOutputFileName() + " : " + e.getMessage());
- } catch (JSONException e) {
+ } catch (org.codehaus.jettison.json.JSONException e) {
LOGGER.info("Output not in JSON format");
return putToProperties(ctx, pfx, saltstackResult);
} catch (Exception e) {
@@ -305,11 +383,11 @@ public class SaltstackMessageParser {
if (slsExec) {
if (!retCodeFound) {
return new SaltstackResult(SaltstackResultCodes.COMMAND_EXEC_FAILED_STATUS.getValue(),
- "error in executing configuration at the server");
+ "error in executing configuration at the server, check your command input");
}
if (!executionStatus) {
return new SaltstackResult(SaltstackResultCodes.COMMAND_EXEC_FAILED_STATUS.getValue(),
- "error in executing configuration at the server");
+ "error in executing configuration at the server, check your command input");
}
}
saltstackResult.setStatusCode(SaltstackResultCodes.FINAL_SUCCESS.getValue());
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResult.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResult.java
index f6ea0b42..b29dd8e8 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResult.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResult.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResultCodes.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResultCodes.java
index 32871ff0..92a61168 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResultCodes.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackResultCodes.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackServerEmulator.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackServerEmulator.java
index 1b62e4bd..55beb229 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackServerEmulator.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackServerEmulator.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
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 df5c46d3..2c3b7b04 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
@@ -3,7 +3,7 @@
============LICENSE_START=======================================================
openECOMP : SDN-C
================================================================================
- Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights
+ Copyright (C) 2017 - 2018 Samsung Electronics. All rights
reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/resources/saltstack-adapter.properties b/saltstack-adapter/saltstack-adapter-provider/src/main/resources/saltstack-adapter.properties
index ccaea20c..0b077524 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/main/resources/saltstack-adapter.properties
+++ b/saltstack-adapter/saltstack-adapter-provider/src/main/resources/saltstack-adapter.properties
@@ -1,10 +1,10 @@
###
# ============LICENSE_START=======================================================
-# ONAP : APPC
+# ONAP : CCSDK
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2018 Samsung Electronics. All rights reserved.
# ================================================================================
-# Copyright (C) 2017 Amdocs
+#
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
# ============LICENSE_END=========================================================
###
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java
index 933f3fcf..266147aa 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java
index 50bf7582..a0d36046 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
@@ -158,8 +158,8 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
try {
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -181,8 +181,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("retryDelay", "10");
params.put("retryCount", "10");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
try {
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -204,8 +204,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("retryDelay", "0");
params.put("retryCount", "0");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
try {
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -227,8 +227,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("retryDelay", "-1");
params.put("retryCount", "-1");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
try {
adapter.reqExecCommand(params, svcContext);
@@ -248,8 +248,8 @@ public class TestSaltstackAdapterImpl {
params.put("Port", "10");
params.put("User", "test");
params.put("Password", "test");
- params.put("cmd", "test");
- params.put("slsExec", "test");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "test");
params.put("Test", "fail");
try {
adapter.reqExecCommand(params, svcContext);
@@ -272,8 +272,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("fileName", "src/test/resources/test.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -293,8 +293,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("slsExec", "true");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "true");
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -314,8 +314,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("fileName", "src/test/resources/test.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("slsExec", "true");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "true");
adapter.reqExecCommand(params, svcContext);
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
@@ -333,8 +333,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("fileName", "src/test/resources/test.txt");
params.put("Id", "txt");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -354,8 +354,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("fileName", "src/test/resources/test");
params.put("Id", "txt");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -375,8 +375,8 @@ public class TestSaltstackAdapterImpl {
params.put("Test", "success");
params.put("fileName", "src/test/resources/test-invalid.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -409,8 +409,8 @@ public class TestSaltstackAdapterImpl {
params.put("Password", "test");
params.put("Test", "success");
params.put("fileName", "src/test/resources/test.json");
- params.put("cmd", "test");
- params.put("slsExec", "false");
+ params.put("Cmd", "test");
+ params.put("SlsExec", "false");
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -427,10 +427,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.sls");
+ params.put("SlsFile", "src/test/resources/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
+ params.put("Cmd", "test");
adapter.reqExecSLSFile(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -448,7 +448,7 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test-none.sls");
+ params.put("SlsFile", "src/test/resources/test-none.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
@@ -466,7 +466,7 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test-none");
+ params.put("SlsFile", "src/test/resources/test-none");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
@@ -484,7 +484,7 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.json");
+ params.put("SlsFile", "src/test/resources/test.json");
params.put("fileName", "src/test/resources/test-none.json");
params.put("Id", "test1");
@@ -502,11 +502,11 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.json");
+ params.put("SlsFile", "src/test/resources/test.json");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("applyTo", "minion1");
+ params.put("Cmd", "test");
+ params.put("NodeList", "minion1");
adapter.reqExecSLSFile(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -524,11 +524,11 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.sls");
+ params.put("SlsFile", "src/test/resources/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("applyTo", "minion1");
+ params.put("Cmd", "test");
+ params.put("NodeList", "minion1");
adapter.reqExecSLSFile(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -546,10 +546,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test-none.json");
+ params.put("SlsFile", "src/test/resources/test-none.json");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("applyTo", "minion1");
+ params.put("NodeList", "minion1");
adapter.reqExecSLSFile(params, svcContext);
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
@@ -565,10 +565,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.json");
+ params.put("SlsFile", "src/test/resources/test.json");
params.put("fileName", "src/test/resources/test-none.json");
params.put("Id", "test1");
- params.put("applyTo", "minion1");
+ params.put("NodeList", "minion1");
adapter.reqExecSLSFile(params, svcContext);
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
@@ -584,11 +584,11 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.sls");
+ params.put("SlsFile", "src/test/resources/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("applyTo", "*");
+ params.put("Cmd", "test");
+ params.put("NodeList", "*");
adapter.reqExecSLSFile(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -606,10 +606,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test-none.json");
+ params.put("SlsFile", "src/test/resources/test-none.json");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("applyTo", "*");
+ params.put("NodeList", "*");
adapter.reqExecSLSFile(params, svcContext);
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
@@ -625,10 +625,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.json");
+ params.put("SlsFile", "src/test/resources/test.json");
params.put("fileName", "src/test/resources/test-none.json");
params.put("Id", "test1");
- params.put("applyTo", "*");
+ params.put("NodeList", "*");
adapter.reqExecSLSFile(params, svcContext);
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
@@ -645,10 +645,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsName", "src/test.sls");
+ params.put("SlsName", "src/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
+ params.put("Cmd", "test");
adapter.reqExecSLS(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -666,10 +666,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsName", "src/test");
+ params.put("SlsName", "src/test");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
+ params.put("Cmd", "test");
adapter.reqExecSLS(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -687,7 +687,7 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsName", "src/test/resources/test.json");
+ params.put("SlsName", "src/test/resources/test.json");
params.put("fileName", "src/test/resources/test-none.json");
params.put("Id", "test1");
@@ -706,11 +706,11 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsName", "src/test/resources/test.sls");
+ params.put("SlsName", "src/test/resources/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("applyTo", "minion1");
+ params.put("Cmd", "test");
+ params.put("NodeList", "minion1");
adapter.reqExecSLS(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -729,10 +729,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsName", "src/test/resources/test.json");
+ params.put("SlsName", "src/test/resources/test.json");
params.put("fileName", "src/test/resources/test-none.json");
params.put("Id", "test1");
- params.put("applyTo", "minion1");
+ params.put("NodeList", "minion1");
adapter.reqExecSLS(params, svcContext);
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
@@ -748,11 +748,11 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsName", "src/test/resources/test.sls");
+ params.put("SlsName", "src/test/resources/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("applyTo", "*");
+ params.put("Cmd", "test");
+ params.put("NodeList", "*");
adapter.reqExecSLS(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
@@ -771,10 +771,10 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsName", "src/test/resources/test.json");
+ params.put("SlsName", "src/test/resources/test.json");
params.put("fileName", "src/test/resources/test-none.json");
params.put("Id", "test1");
- params.put("applyTo", "*");
+ params.put("NodeList", "*");
adapter.reqExecSLS(params, svcContext);
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
@@ -791,9 +791,9 @@ public class TestSaltstackAdapterImpl {
params.put("User", "sdn");
params.put("Password", "foo");
params.put("Id", "test1");
- params.put("cmd", "ls -l");
- params.put("slsExec", "false");
- params.put("execTimeout", "12000");
+ params.put("Cmd", "ls -l");
+ params.put("SlsExec", "false");
+ params.put("Timeout", "120");
adapter = new SaltstackAdapterImpl();
try {
adapter.reqExecCommand(params, svcContext);
@@ -803,7 +803,7 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "test1");
} catch (Exception e){
//if local ssh is not enabled
- return;
+ System.out.print(e.getMessage());
}
}
@@ -816,9 +816,9 @@ public class TestSaltstackAdapterImpl {
params.put("User", "root");
params.put("Password", "vagrant");
params.put("Id", "test1");
- params.put("cmd", "salt '*' test.ping --out=json --static");
- params.put("slsExec", "false");
- params.put("execTimeout", "12000");
+ params.put("Cmd", "salt '*' test.ping --out=json --static");
+ params.put("SlsExec", "false");
+ params.put("Timeout", "120");
adapter = new SaltstackAdapterImpl();
try {
@@ -831,7 +831,7 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "true");
} catch (Exception e){
//if saltstack ssh IP is not enabled
- return;
+ System.out.print(e.getMessage());
}
}
@@ -844,9 +844,9 @@ public class TestSaltstackAdapterImpl {
params.put("User", "root");
params.put("Password", "vagrant");
params.put("Id", "test1");
- params.put("cmd", "cd /srv/salt/; salt '*' state.apply vim --out=json --static");
- params.put("slsExec", "true");
- params.put("execTimeout", "12000");
+ params.put("Cmd", "cd /srv/salt/; salt '*' state.apply vim --out=json --static");
+ params.put("SlsExec", "true");
+ params.put("Timeout", "120");
adapter = new SaltstackAdapterImpl();
try {
@@ -857,7 +857,7 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "test1");
} catch (Exception e){
//if saltstack ssh IP is not enabled
- return;
+ System.out.print(e.getMessage());
}
}
@@ -870,9 +870,64 @@ public class TestSaltstackAdapterImpl {
params.put("User", "root");
params.put("Password", "vagrant");
params.put("Id", "test1");
- params.put("slsName", "vim");
- params.put("execTimeout", "12000");
- params.put("applyTo", "minion1");
+ params.put("SlsName", "vim");
+ params.put("Timeout", "120");
+ params.put("NodeList", "minion1");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ System.out.print(e.getMessage());
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessEnvParam() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "<IP>");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("SlsName", "vim");
+ params.put("Timeout", "120");
+ params.put("NodeList", "minion1");
+ params.put("EnvParameters", "{\"exclude\": bar*}");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ System.out.print(e.getMessage());
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessFileParam() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "<IP>");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("SlsName", "vim");
+ params.put("Timeout", "120");
+ params.put("NodeList", "minion1");
+ params.put("EnvParameters", "{\"exclude\": \"bar,baz\"}");
+ params.put("FileParameters", "{\"config.txt\":\"db_ip=10.1.1.1, sip_timer=10000\"}");
adapter = new SaltstackAdapterImpl();
try {
@@ -883,7 +938,63 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "test1");
} catch (Exception e){
//if saltstack ssh IP is not enabled
- return;
+ System.out.print(e.getMessage());
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessPillarParam() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "<IP>");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("SlsName", "vim");
+ params.put("Timeout", "120");
+ params.put("NodeList", "minion1");
+ params.put("EnvParameters", "{\"exclude\": \"bar,baz\", \"pillar\":\"'{\\\"foo\\\": \\\"bar\\\"}'\"}");
+ params.put("FileParameters", "{\"config.txt\":\"db_ip=10.1.1.1, sip_timer=10000\"}");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ System.out.print(e.getMessage());
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessMultiFileParam() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "<IP>");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("SlsName", "vim");
+ params.put("Timeout", "120");
+ params.put("NodeList", "minion1");
+ params.put("EnvParameters", "{\"exclude\": bar*}");
+ params.put("FileParameters", "{\"config.txt\":\"db_ip=10.1.1.1, sip_timer=10000\" , \"config-tep.txt\":\"db_ip=10.1.1.1, sip_timer=10000\"}");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ System.out.print(e.getMessage());
}
}
@@ -896,9 +1007,37 @@ public class TestSaltstackAdapterImpl {
params.put("User", "root");
params.put("Password", "vagrant");
params.put("Id", "test1");
- params.put("execTimeout", "12000");
- params.put("applyTo", "minion1");
- params.put("slsFile", "src/test/resources/config.sls");
+ params.put("Timeout", "120");
+ params.put("NodeList", "minion1");
+ params.put("SlsFile", "src/test/resources/config.sls");
+
+ adapter = new SaltstackAdapterImpl();
+ try {
+ adapter.reqExecSLSFile(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ } catch (Exception e){
+ //if saltstack ssh IP is not enabled
+ System.out.print(e.getMessage());
+ }
+ }
+
+ @Test
+ public void reqExecCommand_shouldSetSuccessSSLFileMultiFileParam() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "<IP>");
+ params.put("Port", "2222");
+ params.put("User", "root");
+ params.put("Password", "vagrant");
+ params.put("Id", "test1");
+ params.put("Timeout", "120");
+ params.put("NodeList", "minion1");
+ params.put("SlsFile", "src/test/resources/config.sls");
+ params.put("EnvParameters", "{\"exclude\": bar, \"pillar\":\"'{\\\"foo\\\": \\\"bar\\\"}'\"}");
+ params.put("FileParameters", "{\"config.txt\":\"db_ip=10.1.1.1, sip_timer=10000\" , \"config-tep.txt\":\"db_ip=10.1.1.1, sip_timer=10000\"}");
adapter = new SaltstackAdapterImpl();
try {
@@ -909,7 +1048,7 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "test1");
} catch (Exception e){
//if saltstack ssh IP is not enabled
- return;
+ System.out.print(e.getMessage());
}
}
}
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java
index d5699c4c..deb46534 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java
@@ -1,10 +1,10 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP : APPC
+ * ONAP : CCSDK
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs
+ *
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/model/TestJsonParser.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/model/TestJsonParser.java
index 74e7ed0c..ed1e02c4 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/model/TestJsonParser.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/model/TestJsonParser.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* openECOMP : SDN-C
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018 Samsung Electronics. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/resources/org/onap/ccsdk/default.properties b/saltstack-adapter/saltstack-adapter-provider/src/test/resources/org/onap/ccsdk/default.properties
index 2f8fb458..3e7e2bcc 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/resources/org/onap/ccsdk/default.properties
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/resources/org/onap/ccsdk/default.properties
@@ -1,10 +1,10 @@
###
# ============LICENSE_START=======================================================
-# ONAP : APPC
+# ONAP : CCSDK
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2018 Samsung Electronics. All rights reserved.
# ================================================================================
-# Copyright (C) 2017 Amdocs
+#
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#
# ============LICENSE_END=========================================================
###