Saltstack sample server config doc 79/56479/1
authorGanesh Chandrasekaran <ganesh.c@samsung.com>
Mon, 16 Jul 2018 07:08:08 +0000 (16:08 +0900)
committerGanesh Chandrasekaran <ganesh.c@samsung.com>
Mon, 16 Jul 2018 07:24:56 +0000 (16:24 +0900)
Issue-ID: CCSDK-361

Change-Id: I6a5407d7359dd84ea5fb71d5c7fab417abd31c55
Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
12 files changed:
saltstack-adapter/README.md
saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java
saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java
saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java
saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java
saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java
saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls [new file with mode: 0644]
saltstack-adapter/staltstack-example-server/README [deleted file]
saltstack-adapter/staltstack-example-server/README.md [new file with mode: 0644]
saltstack-adapter/staltstack-example-server/Vagrantfile-sample [new file with mode: 0644]
saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml [new file with mode: 0644]
saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml [new file with mode: 0644]

index 5eaf1cc..87c43f9 100644 (file)
@@ -31,7 +31,8 @@ Create an Adaptor to communicate with the SaltStack server:
 
 ***Requirements and benefits of the chosen SSH method:***
 1) The SaltStack server should have it’s SSH enabled.
-2) Such execution method will give the DGs and adaptor with more refined control on the SaltStack server.
+2) Via ssh user account we should have the access to run saltstack command. 
+3) Such execution method will give the DGs and adaptor with more refined control on the SaltStack server.
 ==================================================================================================================
 
 
@@ -74,7 +75,7 @@ here for instance, in 1.1) the user should check if $reqId.<minion-name> is set
 2) Execute a SLS file located on the server : Example command will look like:
 Knowing the saltstack server has vim.sls file located at "/srv/salt" directory then user can execute the following commands:
 1.1) Command to run the vim.sls file on saltstack server: cmd = "salt '*' state.apply vim --out=json --static"
-1.2) Command to run the nettools.sls file on saltstack server: cmd = "salt '*' state.apply nettools --out=json --static"
+1.2) Command to run the nettools.sls file on saltstack server: cmd = "cd /srv/salt/; salt '*' state.apply <sls-file-name> --out=json --static"
 Important thing to note: If the reqExecCommand is used to execute sls file then along with following, 
     "HostName";  ->  Saltstack server's host name IP address.
     "Port"; ->  Saltstack server's port to make SSH connection to.
@@ -82,6 +83,7 @@ Important thing to note: If the reqExecCommand is used to execute sls file then
     "User"; ->  Saltstack server's SSH Password.
 the param should contain,
     "slsExec"; ->  this variable should be set to true.
+    "execTimeout"; -> set large timeout if your SLS file will take large time to finish executing (in milliseconds). 
 
 In this case, params that will hold the command execution result for DG access in Key:
 Result code at: org.onap.appc.adapter.saltstack.result.code (On success: This will be 200, this means the command was executed successfully and also configuration change made using the SLS file was also successful) 
@@ -98,6 +100,7 @@ The response from Saltstack comes in json format and it is automatically put to
 If request Id (Id) is not passed as part of input param, then a random Id will be generated and put to properties in "org.onap.appc.adapter.saltstack.Id" field. All the output message from the execution will be appended with reqId. 
 1) Execute a single command on SaltState server : Example command will look like: 
     In the context set the "slsName" to "test.sls"
+    In the context set the "execTimeout"; -> set large timeout if your SLS file will take large time to finish executing (in milliseconds). 
     In the context set the "applyTo" to "minion1" //to the minions or VNFCs you want to apply the SLS file to.
     "applyTo" can be empty or set to "*" is the SLS has to be applied to all the minions or VNFCs. 
 In this case, params that will hold the command execution result for DG access in Key:
@@ -112,7 +115,8 @@ Method to execute a single sls on SaltState server (Where the SLS file in the ad
 The response from Saltstack comes in json format and it is automatically put to context for DGs access, with a certain request-ID as prefix.
 If request Id (Id) is not passed as part of input param, then a random Id will be generated and put to properties in "org.onap.appc.adapter.saltstack.Id" field. All the output message from the execution will be appended with reqId. 
 1) Execute a single command on SaltState server : Example command will look like: 
-    In the context set the "slsFile" to "/path/to/test.sls" //mention the path of the SLS file in ODL container.
+    In the context set the "slsFile" to "/path/to/test.sls" //mention the path of the SLS file in ODL container.    
+    In the context set the "execTimeout"; -> set large timeout if your SLS file will take large time to finish executing (in milliseconds). 
     In the context set the "applyTo" to "minion1" //to the minions or VNFCs you want to apply the SLS file to.
     "applyTo" can be empty or set to "*" is the SLS has to be applied to all the minions or VNFCs. 
 In this case, params that will hold the command execution result for DG access in Key:
index cc4ce95..3469103 100644 (file)
@@ -84,8 +84,8 @@ public class ConnectionBuilder {
      * @param cmd Commands to execute
      * @return command execution status
      */
-    public SaltstackResult connectNExecute(String cmd) throws IOException {
-        return connectNExecute(cmd, -1, -1);
+    public SaltstackResult connectNExecute(String cmd, long execTimeout) throws IOException {
+        return connectNExecute(cmd, -1, -1, execTimeout);
     }
 
     /**
@@ -98,12 +98,16 @@ public class ConnectionBuilder {
      * @param retryCount number of count retry to make a SSH connection.
      * @return command execution status
      */
-    public SaltstackResult connectNExecute(String cmd, int retryCount, int retryDelay)
+    public SaltstackResult connectNExecute(String cmd, int retryCount, int retryDelay, long execTimeout)
                             throws IOException{
 
         SaltstackResult result = new SaltstackResult();
         OutputStream out = null;
         OutputStream errs = null;
+        if (execTimeout >= 0) {
+            sshConnection.setExecTimeout(execTimeout);
+        }
+
         try {
             if (retryCount != -1) {
                 result = sshConnection.connectWithRetry(retryCount, retryDelay);
@@ -117,7 +121,7 @@ public class ConnectionBuilder {
             String errFilePath = "/tmp/" + RandomStringUtils.random(5, true, true);
             out = new FileOutputStream(outFilePath);
             errs = new FileOutputStream(errFilePath);
-            result = sshConnection.execCommand(cmd, out, errs);
+            result = sshConnection.execCommand(cmd, out, errs, result);
             sshConnection.disconnect();
             if (result.getSshExitStatus() != 0) {
                 return sortExitStatus(result.getSshExitStatus(), errFilePath, cmd);
index 0b6a5bb..e4bceb5 100644 (file)
@@ -318,7 +318,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
             reqID = messageProcessor.reqId(params);
             String commandToExecute = messageProcessor.reqCmd(params);
             slsExec = messageProcessor.reqIsSLSExec(params);
-            testResult = execCommand(ctx, params, commandToExecute);
+            testResult = execCommand(ctx, params, commandToExecute, -1);
             testResult = messageProcessor.parseResponse(ctx, reqID, testResult, slsExec);
             checkResponseStatus(testResult, ctx, reqID, slsExec);
         } catch (IOException e) {
@@ -344,8 +344,9 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
             reqID = messageProcessor.reqId(params);
             String slsName = messageProcessor.reqSlsName(params);
             String applyTo = messageProcessor.reqApplyToDevices(params);
+            long execTimeout = messageProcessor.reqExecTimeout(params);
             String commandToExecute = putToCommands(slsName, applyTo);
-            testResult = execCommand(ctx, params, commandToExecute);
+            testResult = execCommand(ctx, params, commandToExecute, execTimeout);
             testResult = messageProcessor.parseResponse(ctx, reqID, testResult, true);
             checkResponseStatus(testResult, ctx, reqID, true);
         } catch (IOException e) {
@@ -371,8 +372,9 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
             reqID = messageProcessor.reqId(params);
             String slsFile = messageProcessor.reqSlsFile(params);
             String applyTo = messageProcessor.reqApplyToDevices(params);
+            long execTimeout = messageProcessor.reqExecTimeout(params);
             String commandToExecute = putToCommands(ctx, slsFile, applyTo);
-            testResult = execCommand(ctx, params, commandToExecute);
+            testResult = execCommand(ctx, params, commandToExecute, execTimeout);
             testResult = messageProcessor.parseResponse(ctx, reqID, testResult, true);
             checkResponseStatus(testResult, ctx, reqID, true);
         } catch (IOException e) {
@@ -394,7 +396,8 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
 
     }
 
-    public SaltstackResult execCommand(SvcLogicContext ctx, Map<String, String> params, String commandToExecute)
+    public SaltstackResult execCommand(SvcLogicContext ctx, Map<String, String> params, String commandToExecute,
+                                       long execTimeout)
                                     throws SvcLogicException{
 
         SaltstackResult testResult = new SaltstackResult();
@@ -403,13 +406,13 @@ public class SaltstackAdapterImpl implements SaltstackAdapter {
                 int retryDelay = Integer.parseInt(params.get(CONNECTION_RETRY_DELAY));
                 int retryCount = Integer.parseInt(params.get(CONNECTION_RETRY_COUNT));
                 if (!testMode) {
-                    testResult = sshClient.connectNExecute(commandToExecute, retryCount, retryDelay);
+                    testResult = sshClient.connectNExecute(commandToExecute, retryCount, retryDelay, execTimeout);
                 } else {
                     testResult = testServer.mockReqExec(params);
                 }
             } else {
                 if (!testMode) {
-                    testResult = sshClient.connectNExecute(commandToExecute);
+                    testResult = sshClient.connectNExecute(commandToExecute, execTimeout);
                 } else {
                     testResult = testServer.mockReqExec(params);
                 }
index 96ed7d2..fd66eb1 100644 (file)
@@ -50,6 +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;
+    //TODO : change back to 120000
     private static final long EXEC_TIMEOUT = 120000;
     private String host;
     private int port;
@@ -165,16 +166,17 @@ class SshConnection {
         this.timeout = timeout;
     }
 
-    public SaltstackResult execCommand(String cmd, OutputStream out, OutputStream err) {
-        return execCommand(cmd, out, err, false);
+    public SaltstackResult execCommand(String cmd, OutputStream out, OutputStream err, SaltstackResult result ) {
+        return execCommand(cmd, out, err, false, result);
     }
 
-    public SaltstackResult execCommandWithPty(String cmd, OutputStream out) {
-        return execCommand(cmd, out, out, true);
+    public SaltstackResult execCommandWithPty(String cmd, OutputStream out, SaltstackResult result ) {
+        return execCommand(cmd, out, out, true, result);
     }
 
-    private SaltstackResult execCommand(String cmd, OutputStream out, OutputStream err, boolean usePty) {
-        SaltstackResult result = new SaltstackResult();
+    private SaltstackResult execCommand(String cmd, OutputStream out, OutputStream err,
+                                        boolean usePty, SaltstackResult result ) {
+
         try {
             if (logger.isDebugEnabled()) {
                 logger.debug("SSH: executing command");
index 0a6e4eb..16ab8dc 100644 (file)
@@ -72,6 +72,7 @@ public class SaltstackMessageParser {
     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 LOCAL_PARAMETERS_OPT_KEY = "LocalParameters";
     private static final String FILE_PARAMETERS_OPT_KEY = "FileParameters";
@@ -237,6 +238,21 @@ public class SaltstackMessageParser {
         return params.get(SaltstackMessageParser.MINION_TO_APPLY);
     }
 
+    /**
+     * 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.
+     */
+    public long reqExecTimeout(Map<String, String> params) {
+
+        if (params.get(SaltstackMessageParser.EXEC_TIMEOUT_TO_APPLY) == null) {
+            return -1;
+        } else if (params.get(SaltstackMessageParser.EXEC_TIMEOUT_TO_APPLY).equalsIgnoreCase("")) {
+            return -1;
+        }
+        return Long.parseLong(params.get(SaltstackMessageParser.EXEC_TIMEOUT_TO_APPLY));
+    }
+
     /**
      * Method that validates that the Map has enough information
      * to query Saltstack server for a result. If so, it returns
@@ -333,10 +349,10 @@ public class SaltstackMessageParser {
         if (slsExec) {
             if (!retCodeFound)
                 return new SaltstackResult(SaltstackResultCodes.COMMAND_EXEC_FAILED_STATUS.getValue(),
-                                           "error in parsing response Json after SLS file execution in server");
+                                           "error in executing configuration at the server");
             if (!executionStatus)
                 return new SaltstackResult(SaltstackResultCodes.COMMAND_EXEC_FAILED_STATUS.getValue(),
-                                           "error in parsing response Json after SLS file execution in server");
+                                           "error in executing configuration at the server");
         }
         saltstackResult.setStatusCode(SaltstackResultCodes.FINAL_SUCCESS.getValue());
         return saltstackResult;
@@ -355,8 +371,8 @@ public class SaltstackMessageParser {
                 String name = (String) key;
                 String value = prop.getProperty(name);
                 if (value != null && value.trim().length() > 0) {
-                    ctx.setAttribute(pfx + name, value.trim());
-                    LOGGER.info("+++ " + pfx + name + ": [" + value + "]");
+                    ctx.setAttribute(pfx + "." + name, value.trim());
+                    LOGGER.info("+++ " + pfx + "." + name + ": [" + value + "]");
                 }
             }
         } catch (Exception e) {
index 0622a47..48f5c20 100644 (file)
@@ -799,4 +799,107 @@ public class TestSaltstackAdapterImpl {
             fail(e.getMessage() + " Unknown exception encountered ");
         }
     }
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessReal() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "127.0.0.1");
+        params.put("Port", "22");
+        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");
+        adapter = new SaltstackAdapterImpl();
+        try {
+            adapter.reqExecCommand(params, svcContext);
+            String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+            TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+            assertEquals("250", status);
+            assertEquals(TestId, "test1");
+        } catch (Exception e){
+            //if local ssh is not enabled
+            return;
+        }
+    }
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessRealCommand() 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("cmd", "cd /srv/salt/; salt '*' state.apply vim --out=json --static");
+        params.put("slsExec", "true");
+        params.put("execTimeout", "12000");
+
+        adapter = new SaltstackAdapterImpl();
+        try {
+            adapter.reqExecCommand(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
+            return;
+        }
+    }
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessRealSSL() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "10.251.92.17");
+        params.put("Port", "2222");
+        params.put("User", "root");
+        params.put("Password", "vagrant");
+        params.put("Id", "test1");
+        params.put("slsName", "vim");
+        params.put("execTimeout", "12000");
+        params.put("applyTo", "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
+            return;
+        }
+    }
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessSSLFile() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "10.251.92.17");
+        params.put("Port", "2222");
+        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");
+
+        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
+            return;
+        }
+    }
 }
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls b/saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls
new file mode 100644 (file)
index 0000000..aff0593
--- /dev/null
@@ -0,0 +1,2 @@
+vim:
+  pkg.installed
diff --git a/saltstack-adapter/staltstack-example-server/README b/saltstack-adapter/staltstack-example-server/README
deleted file mode 100644 (file)
index 687f52d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-'''
-/*-
-* ============LICENSE_START=======================================================
-* ONAP : APPC
-* ================================================================================
-* Copyright (C) 2017 AT&T Intellectual Property.  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.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* 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=========================================================
-*/
-'''
-
-============
-INSTALLATION:
-============
-TODO: Instruction to build saltstack and enable SSH for adaptor communication.
\ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/README.md b/saltstack-adapter/staltstack-example-server/README.md
new file mode 100644 (file)
index 0000000..beaf32f
--- /dev/null
@@ -0,0 +1,189 @@
+'''
+/*-
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright (C) 2017 AT&T Intellectual Property.  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.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* 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=========================================================
+*/
+'''
+
+<CREATING saltstack environment is outside the scope of this adaptor, however the requirement is as follows>
+a. The SaltStack server should have it’s SSH enabled.
+b. Via ssh user account we should have the access to run saltstack command (here we will see how to enable root access via ssh and connect to server via root user).
+============
+INSTALLATION: Saltstack DEMO Environment creation:
+============
+
+1, Install VirtualBox.
+2, Install Vagrant.
+3, Download https://github.com/UtahDave/salt-vagrant-demo. You can use git or download a zip of the project directly from GitHub (sample Vagrant attached).
+4, Extract the zip file you downloaded, and then open a command prompt to the extracted directory.
+5, Run vagrant up to start the demo environment: vagrant up
+   After Vagrant ups (~10 minutes) and you are back at the command prompt, you are ready to continue.
+   More info: https://docs.saltstack.com/en/getstarted/fundamentals/
+
+============
+Configuration: Sample Saltstack server execution configuration requirement.
+============
+1, login to Master Saltstack server node:
+"sudo vi /etc/ssh/sshd_config" and SET the following
+PermitEmptyPasswords yes
+PermitRootLogin yes
+
+SAVE and close.
+
+2, Run: "sudo passwd root"
+and set the root password.
+Then run: "sudo reboot"
+
+3, On the host machine, open the virtual box set a port forwarding to the master server for 2222 -> 22 
+This will redirect messages to host machine to the Vagarant Master server.  
+
+============
+TESTING: Sample Saltstack server command execution.
+============
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessReal() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "127.0.0.1");
+        params.put("Port", "22");
+        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");
+        adapter = new SaltstackAdapterImpl();
+        try {
+            adapter.reqExecCommand(params, svcContext);
+            String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+            TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+            assertEquals("250", status);
+            assertEquals(TestId, "test1");
+        } catch (Exception e){
+            //if local ssh is not enabled
+            return;
+        }
+    }
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessRealCommand() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "<IP address of SS server>");
+        params.put("Port", "2222");
+        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");
+
+        adapter = new SaltstackAdapterImpl();
+        try {
+            adapter.reqExecCommand(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
+            return;
+        }
+    }
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessRealSSL() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "10.251.92.17");
+        params.put("Port", "2222");
+        params.put("User", "root");
+        params.put("Password", "vagrant");
+        params.put("Id", "test1");
+        params.put("slsName", "vim");
+        params.put("execTimeout", "12000");
+        params.put("applyTo", "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
+            return;
+        }
+    }
+
+    @Test
+    public void reqExecCommand_shouldSetSuccessRealSSLNoApplyTo() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "10.251.92.17");
+        params.put("Port", "2222");
+        params.put("User", "root");
+        params.put("Password", "vagrant");
+        params.put("Id", "test1");
+        params.put("slsName", "vim");
+        params.put("execTimeout", "12000");
+
+        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
+            return;
+        }
+    }
+    
+    @Test
+    public void reqExecCommand_shouldSetSuccessSSLFile() throws SvcLogicException,
+            IllegalStateException, IllegalArgumentException {
+
+        params.put("HostName", "10.251.92.17");
+        params.put("Port", "2222");
+        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");
+
+        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
+            return;
+        }
+    }
\ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/Vagrantfile-sample b/saltstack-adapter/staltstack-example-server/Vagrantfile-sample
new file mode 100644 (file)
index 0000000..5fbcfbb
--- /dev/null
@@ -0,0 +1,69 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+  os = "bento/ubuntu-16.04"
+  net_ip = "192.168.50"
+
+  config.vm.define :master, primary: true do |master_config|
+    master_config.vm.provider "virtualbox" do |vb|
+        vb.memory = "2048"
+        vb.cpus = 1
+        vb.name = "master"
+    end
+      master_config.vm.box = "#{os}"
+      master_config.vm.host_name = 'saltmaster.local'
+      master_config.vm.network "private_network", ip: "#{net_ip}.10"
+      master_config.vm.synced_folder "saltstack/salt/", "/srv/salt"
+      master_config.vm.synced_folder "saltstack/pillar/", "/srv/pillar"
+
+      master_config.vm.provision :salt do |salt|
+        salt.master_config = "saltstack/etc/master"
+        salt.master_key = "saltstack/keys/master_minion.pem"
+        salt.master_pub = "saltstack/keys/master_minion.pub"
+        salt.minion_key = "saltstack/keys/master_minion.pem"
+        salt.minion_pub = "saltstack/keys/master_minion.pub"
+        salt.seed_master = {
+                            "minion1" => "saltstack/keys/minion1.pub",
+                            "minion2" => "saltstack/keys/minion2.pub"
+                           }
+
+        salt.install_type = "stable"
+        salt.install_master = true
+        salt.no_minion = true
+        salt.verbose = true
+        salt.colorize = true
+        salt.bootstrap_options = "-P -c /tmp"
+      end
+    end
+
+
+    [
+      ["minion1",    "#{net_ip}.11",    "1024",    os ],
+      ["minion2",    "#{net_ip}.12",    "1024",    os ],
+    ].each do |vmname,ip,mem,os|
+      config.vm.define "#{vmname}" do |minion_config|
+        minion_config.vm.provider "virtualbox" do |vb|
+            vb.memory = "#{mem}"
+            vb.cpus = 1
+            vb.name = "#{vmname}"
+        end
+        minion_config.vm.box = "#{os}"
+        minion_config.vm.hostname = "#{vmname}"
+        minion_config.vm.network "private_network", ip: "#{ip}"
+
+        minion_config.vm.provision :salt do |salt|
+          salt.minion_config = "saltstack/etc/#{vmname}"
+          salt.minion_key = "saltstack/keys/#{vmname}.pem"
+          salt.minion_pub = "saltstack/keys/#{vmname}.pub"
+          salt.install_type = "stable"
+          salt.verbose = true
+          salt.colorize = true
+          salt.bootstrap_options = "-P -c /tmp"
+        end
+      end
+    end
+  end
\ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml b/saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml
new file mode 100644 (file)
index 0000000..468d2a2
--- /dev/null
@@ -0,0 +1,34 @@
+# /*-
+# * ============LICENSE_START=======================================================
+# * ONAP : APPC
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property.  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.
+# * You may obtain a copy of the License at
+# *
+# *      http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * 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=========================================================
+# */
+
+my-vim:
+  git.latest:
+    - name: https://github.com/nbari/my-vim
+    - target: /usr/local/share/my-vim
+    - rev: master
+    - submodules: True
+  cmd.wait:
+    - name: 'cd /usr/local/share/my-vim; git submodule init; git submodule foreach git pull origin master; git submodule update'
+    - watch:
+      - git: my-vim
\ No newline at end of file
diff --git a/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml b/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml
new file mode 100644 (file)
index 0000000..bcc7fda
--- /dev/null
@@ -0,0 +1,26 @@
+# /*-
+# * ============LICENSE_START=======================================================
+# * ONAP : APPC
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property.  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.
+# * You may obtain a copy of the License at
+# *
+# *      http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * 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=========================================================
+# */
+
+vim:
+  pkg.installed