diff options
author | Ganesh Chandrasekaran <ganesh.c@samsung.com> | 2018-07-18 15:27:52 +0900 |
---|---|---|
committer | Ganesh Chandrasekaran <ganesh.c@samsung.com> | 2018-07-19 09:34:59 +0900 |
commit | f8ebec657389d40a88442b5a9be1a18254bbdbfd (patch) | |
tree | f5bbf92bd7054771c051f42575db1f7f589b127d | |
parent | 43a3f54d5ac9ab15025910a575df9fd4be6237d8 (diff) |
saltstack to take env and file param
Issue-ID: CCSDK-383
Change-Id: Id069d77d8f11203a2f604470c116bcf3cc618c2f
Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
46 files changed, 2204 insertions, 466 deletions
diff --git a/saltstack-adapter/README.md b/saltstack-adapter/README.md index 87c43f98..6d40af7a 100644 --- a/saltstack-adapter/README.md +++ b/saltstack-adapter/README.md @@ -74,16 +74,16 @@ 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 = "cd /srv/salt/; salt '*' state.apply <sls-file-name> --out=json --static" +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 = "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. "Password"; -> Saltstack server's SSH UserName. "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). + "SlsExec"; -> this variable should be set to true. + "Timeout"; -> set large timeout if your SLS file will take large time to finish executing (in Seconds). 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) @@ -99,10 +99,13 @@ Method to execute a single sls on SaltState server (Where the SLS file already l 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 "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 the context set the "SlsName" to "test.sls" + In the context set the "Timeout"; -> set large timeout if your SLS file will take large time to finish executing (in Seconds). + In the context set the "NodeList" to "minion1" //to the minions or VNFCs you want to apply the SLS file to. + "NodeList" can be empty or set to "*" is the SLS has to be applied to all the minions or VNFCs. + In the context set the "FileParameters: A JSON dictionary where keys are filenames and values are contents of files. The Saltstack Server will utilize this feature to generate files with keys as filenames and values as content. This attribute can be used to generate files that a SSL file may require as part of execution (Optional). + In the context set the "EnvParameters: A JSON dictionary which should list key value pairs to be passed to the Salstack command to run SLS. These values would correspond to instance specific parameters that a playbook may need to execute an action. + 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) Message at: org.onap.appc.adapter.saltstack.message @@ -115,14 +118,19 @@ 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 "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 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 "Timeout"; -> set large timeout if your SLS file will take large time to finish executing (in Seconds). + In the context set the "NodeList" to "minion1" //to the minions or VNFCs you want to apply the SLS file to. + "NodeList" can be empty or set to 'minion*' (pattern matching) or set to "*" is the SLS has to be applied to all the minions or VNFCs. + In the context set the "FileParameters: A JSON dictionary where keys are filenames and values are contents of files. The Saltstack Server will utilize this feature to generate files with keys as filenames and values as content. This attribute can be used to generate files that a SSL file may require as part of execution (Optional). + In the context set the "EnvParameters: A JSON dictionary which should list key value pairs to be passed to the Salstack command to run SLS. These values would correspond to instance specific parameters that a playbook may need to execute an action. + 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) Message at: org.onap.appc.adapter.saltstack.message Both user inputted/auto generated req Id at: org.onap.appc.adapter.saltstack.Id The result code here will be the execution of configuration SLS file on the server. +Control the state system on the minion: by specifying Env Params (pillars) and Files. +https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.state.html
\ No newline at end of file diff --git a/saltstack-adapter/pom.xml b/saltstack-adapter/pom.xml index c8c1db26..34688dee 100644 --- a/saltstack-adapter/pom.xml +++ b/saltstack-adapter/pom.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ============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. @@ -19,7 +19,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-features/.gitignore b/saltstack-adapter/saltstack-adapter-features/.gitignore index 8820cee5..e1ca0dee 100644 --- a/saltstack-adapter/saltstack-adapter-features/.gitignore +++ b/saltstack-adapter/saltstack-adapter-features/.gitignore @@ -1,7 +1,7 @@ # ============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. # =================================================================== # # Unless otherwise specified, all software contained herein is licensed @@ -17,7 +17,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============================================ /target/ /target-ide/ diff --git a/saltstack-adapter/saltstack-adapter-features/pom.xml b/saltstack-adapter/saltstack-adapter-features/pom.xml index 3b94b2fd..6f765c8f 100644 --- a/saltstack-adapter/saltstack-adapter-features/pom.xml +++ b/saltstack-adapter/saltstack-adapter-features/pom.xml @@ -1,16 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ============LICENSE_START======================================================= - ONAP : APPC ================================================================================ - Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. ================================================================================ - Copyright (C) 2017 Amdocs ============================================================================= + ONAP : CCSDK ================================================================================ + Copyright (C) 2018 Samsung Electronics. All rights reserved. ================================================================================ + ============================================================================= 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========================================================= --> + language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml b/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml index 5359d808..6eef6d27 100644 --- a/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml +++ b/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ============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. @@ -19,7 +19,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-installer/pom.xml b/saltstack-adapter/saltstack-adapter-installer/pom.xml index 0853179f..b600aed6 100644 --- a/saltstack-adapter/saltstack-adapter-installer/pom.xml +++ b/saltstack-adapter/saltstack-adapter-installer/pom.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ============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. @@ -19,7 +19,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========================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> diff --git a/saltstack-adapter/saltstack-adapter-installer/src/assembly/assemble_installer_zip.xml b/saltstack-adapter/saltstack-adapter-installer/src/assembly/assemble_installer_zip.xml index 322fa76e..7d212cbb 100644 --- a/saltstack-adapter/saltstack-adapter-installer/src/assembly/assemble_installer_zip.xml +++ b/saltstack-adapter/saltstack-adapter-installer/src/assembly/assemble_installer_zip.xml @@ -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-installer/src/assembly/assemble_mvnrepo_zip.xml b/saltstack-adapter/saltstack-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml index ec65e79e..93df6602 100644 --- a/saltstack-adapter/saltstack-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/saltstack-adapter/saltstack-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml @@ -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-installer/src/main/resources/scripts/install-feature.sh b/saltstack-adapter/saltstack-adapter-installer/src/main/resources/scripts/install-feature.sh index c8214c52..38782cab 100644 --- a/saltstack-adapter/saltstack-adapter-installer/src/main/resources/scripts/install-feature.sh +++ b/saltstack-adapter/saltstack-adapter-installer/src/main/resources/scripts/install-feature.sh @@ -2,9 +2,9 @@ # ============LICENSE_START======================================================= # ONAP : APPC # ================================================================================ -# 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/.gitignore b/saltstack-adapter/saltstack-adapter-provider/.gitignore index 255b5409..4e1ad823 100644 --- a/saltstack-adapter/saltstack-adapter-provider/.gitignore +++ b/saltstack-adapter/saltstack-adapter-provider/.gitignore @@ -1,7 +1,7 @@ # ============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. # =================================================================== # # Unless otherwise specified, all software contained herein is licensed @@ -17,7 +17,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============================================ /bin/ /target/ diff --git a/saltstack-adapter/saltstack-adapter-provider/pom.xml b/saltstack-adapter/saltstack-adapter-provider/pom.xml index 41bf7c67..c93558e8 100644 --- a/saltstack-adapter/saltstack-adapter-provider/pom.xml +++ b/saltstack-adapter/saltstack-adapter-provider/pom.xml @@ -1,17 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ============LICENSE_START======================================================= - ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + ONAP : CCSDK ================================================================================ + 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. 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========================================================= --> + language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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========================================================= ### diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.json index 3a287e34..562c24ad 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.json @@ -37,7 +37,7 @@ "id": "d40bf650.8338e8", "type": "returnFailure", "name": "return failure", - "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", "comments": "", "x": 1007, "y": 373, @@ -48,7 +48,7 @@ "id": "38662e01.1d3c22", "type": "execute", "name": "execute", - "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='cmd' value='cd /srv/salt; ls -l'/>\n <parameter name='slsExec' value='false'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n", + "xml": "<execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='Cmd' value='cd /srv/salt; ls -l'/>\n <parameter name='SlsExec' value='false'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", "comments": "", "outputs": 1, "x": 700, @@ -146,7 +146,7 @@ "id": "1f81a3db.54cd1c", "type": "returnSuccess", "name": "return success", - "xml": "<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>\n", + "xml": "<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.saltstack.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.saltstack.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.saltstack.results`'/>\n", "comments": "", "x": 887, "y": 460, diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.xml index eadf3361..e28bbc2a 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.xml @@ -3,16 +3,16 @@ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
module='APPC' version='2.0.1'>
<method rpc='saltstack-adapter-1.0-exe-nonSLS' mode='sync'>
- <execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter'
+ <execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter'
method='reqExecCommand'>
<parameter name='HostName' value='`$AgentUrl`'/>
<parameter name='Port' value='`$Port`'/>
<parameter name='User' value='`$User`'/>
<parameter name='Password' value='`$Password`'/>
<parameter name='Id' value='test1'/>
- <parameter name='cmd' value='cd /srv/salt; ls -l'/>
- <parameter name='slsExec' value='false'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
+ <parameter name='Cmd' value='cd /srv/salt; ls -l'/>
+ <parameter name='SlsExec' value='false'/>
+ <parameter name='Timeout' value='`$Timeout`'/>
<outcome value='failure'>
<return status='failure'>
<parameter name='error-code' value='200'/>
diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.json index 95178ac2..deefddf3 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.json @@ -48,7 +48,7 @@ "id": "65cc87e2.a95188", "type": "execute", "name": "execute", - "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='slsExec' value='false'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n", + "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='Cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='SlsExec' value='false'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", "comments": "", "outputs": 1, "x": 761, @@ -209,7 +209,7 @@ "id": "770411a5.18825", "type": "execute", "name": "execute", - "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='cmd' value='cd /srv/salt/; salt 'minion1' state.apply vim --out=json --static'/>\n <parameter name='slsExec' value='true'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n", + "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='Cmd' value='cd /srv/salt/; salt 'minion1' state.apply vim --out=json --static'/>\n <parameter name='SlsExec' value='true'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", "comments": "", "outputs": 1, "x": 773, diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.xml index c112723c..9861351d 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.xml @@ -3,17 +3,17 @@ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
module='APPC' version='2.0.1'>
<method rpc='saltstack-adapter-1.0-exec-SLSFile' mode='sync'>
- <execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter'
+ <execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter'
method='reqExecCommand'>
<parameter name='HostName' value='`$AgentUrl`'/>
<parameter name='Port' value='`$Port`'/>
<parameter name='User' value='`$User`'/>
<parameter name='Password' value='`$Password`'/>
<parameter name='Id' value='test1'/>
- <parameter name='cmd'
+ <parameter name='Cmd'
value='salt '*' test.ping --out=json --static'/>
- <parameter name='slsExec' value='false'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
+ <parameter name='SlsExec' value='false'/>
+ <parameter name='Timeout' value='`$Timeout`'/>
<outcome value='failure'>
<return status='failure'>
<parameter name='error-code' value='200'/>
@@ -47,7 +47,7 @@ </outcome>
<outcome value='true'>
<execute
- plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter'
+ plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter'
method='reqExecCommand'>
<parameter name='HostName'
value='`$AgentUrl`'/>
@@ -56,10 +56,10 @@ <parameter name='Password'
value='`$Password`'/>
<parameter name='Id' value='test2'/>
- <parameter name='cmd'
+ <parameter name='Cmd'
value='cd /srv/salt/; salt 'minion1' state.apply vim --out=json --static'/>
- <parameter name='slsExec' value='true'/>
- <parameter name='execTimeout'
+ <parameter name='SlsExec' value='true'/>
+ <parameter name='Timeout'
value='`$Timeout`'/>
<outcome value='failure'>
<return status='failure'>
diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.json index 85254587..1b891a20 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.json @@ -48,7 +48,7 @@ "id": "c332cb01.51a3e8", "type": "execute", "name": "execute", - "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='slsExec' value='false'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n", + "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='Cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='SlsExec' value='false'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", "comments": "", "outputs": 1, "x": 824, @@ -209,7 +209,7 @@ "id": "df0c0907.d17838", "type": "execute", "name": "execute", - "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='cmd' value='salt 'minion1' pkg.install vim --out=json --static'/>\n <parameter name='slsExec' value='false'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n", + "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='Cmd' value='salt 'minion1' pkg.install vim --out=json --static'/>\n <parameter name='SlsExec' value='false'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", "comments": "", "outputs": 1, "x": 836, diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.xml index 0e5e17c4..404ac7ac 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.xml @@ -3,24 +3,24 @@ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
module='APPC' version='2.0.1'>
<method rpc='saltstack-adapter-1.0-exec-multi-sls' mode='sync'>
- <execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter'
+ <execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
method='reqExecCommand'>
<parameter name='HostName' value='`$AgentUrl`'/>
<parameter name='Port' value='`$Port`'/>
<parameter name='User' value='`$User`'/>
<parameter name='Password' value='`$Password`'/>
<parameter name='Id' value='test1'/>
- <parameter name='cmd'
+ <parameter name='Cmd'
value='salt '*' test.ping --out=json --static'/>
- <parameter name='slsExec' value='false'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
+ <parameter name='SlsExec' value='false'/>
+ <parameter name='Timeout' value='`$Timeout`'/>
<outcome value='failure'>
<return status='failure'>
<parameter name='error-code' value='200'/>
<parameter name='error-message'
- value='`$org.openecomp.appc.adapter.ansible.message`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
<parameter name='output.status.results'
- value='`$org.openecomp.appc.adapter.ansible.results`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
</return>
</outcome>
<outcome value='Other'>
@@ -29,9 +29,9 @@ <return status='failure'>
<parameter name='error-code' value='200'/>
<parameter name='error-message'
- value='`$org.openecomp.appc.adapter.ansible.message`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
<parameter name='output.status.results'
- value='`$org.openecomp.appc.adapter.ansible.results`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
</return>
</outcome>
<outcome value='200'>
@@ -40,14 +40,14 @@ <return status='failure'>
<parameter name='error-code' value='200'/>
<parameter name='error-message'
- value='`$org.openecomp.appc.adapter.ansible.message`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
<parameter name='output.status.results'
- value='`$org.openecomp.appc.adapter.ansible.results`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
</return>
</outcome>
<outcome value='true'>
<execute
- plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter'
+ plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
method='reqExecCommand'>
<parameter name='HostName'
value='`$AgentUrl`'/>
@@ -56,20 +56,20 @@ <parameter name='Password'
value='`$Password`'/>
<parameter name='Id' value='test2'/>
- <parameter name='cmd'
+ <parameter name='Cmd'
value='salt 'minion1' pkg.install vim --out=json --static'/>
- <parameter name='slsExec' value='false'/>
- <parameter name='execTimeout'
+ <parameter name='SlsExec' value='false'/>
+ <parameter name='Timeout'
value='`$Timeout`'/>
<outcome value='failure'>
<return status='failure'>
<parameter name='error-code'
value='200'/>
<parameter name='error-message'
- value='`$org.openecomp.appc.adapter.ansible.message`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
<parameter
name='output.status.results'
- value='`$org.openecomp.appc.adapter.ansible.results`'/>
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
</return>
</outcome>
<outcome value='Other'>
diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.json index a8535d00..920e1145 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.json @@ -48,7 +48,7 @@ "id": "f4e59dd0.ee45f", "type": "execute", "name": "execute", - "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='slsExec' value='false'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n", + "xml": "<execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='Cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='SlsExec' value='false'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", "comments": "", "outputs": 1, "x": 735, diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.xml index 57620f58..dfc4691d 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.xml @@ -3,17 +3,17 @@ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
module='APPC' version='2.0.1'>
<method rpc='saltstack-adapter-1.0-exec-single-SLSComm' mode='sync'>
- <execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter'
+ <execute plugin='org.openecomp.appc.adapter.ansible.SaltstackAdapter'
method='reqExecCommand'>
<parameter name='HostName' value='`$AgentUrl`'/>
<parameter name='Port' value='`$Port`'/>
<parameter name='User' value='`$User`'/>
<parameter name='Password' value='`$Password`'/>
<parameter name='Id' value='test1'/>
- <parameter name='cmd'
+ <parameter name='Cmd'
value='salt '*' test.ping --out=json --static'/>
- <parameter name='slsExec' value='false'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
+ <parameter name='SlsExec' value='false'/>
+ <parameter name='Timeout' value='`$Timeout`'/>
<outcome value='failure'>
<return status='failure'>
<parameter name='error-code' value='200'/>
diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.json index 875c6faa..7fe88f06 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.json @@ -1 +1,214 @@ -[{"id":"b9234075.7e20b","type":"method","name":"saltstack-adapter-1.0","xml":"<method rpc='saltstack-adapter-1.0' mode='sync'>\n","comments":"","outputs":1,"x":589,"y":221,"z":"8c500c8b.91561","wires":[["a9f084e0.590cc8"]]},{"id":"159aca46.2fdf66","type":"service-logic","name":"APPC 2.0.1","module":"APPC","version":"2.0.1","comments":"","xml":"<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>","outputs":1,"x":366,"y":220,"z":"8c500c8b.91561","wires":[["b9234075.7e20b"]]},{"id":"f809843e.12d3b8","type":"returnSuccess","name":"return success","xml":"<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>\n","comments":"","x":968,"y":313,"z":"8c500c8b.91561","wires":[]},{"id":"cad8db4d.3d8978","type":"dgstart","name":"DGSTART","outputs":1,"x":197,"y":219,"z":"8c500c8b.91561","wires":[["159aca46.2fdf66"]]},{"id":"96da3695.f3ade8","type":"comment","name":"SaltStack Adaptor DG","info":"","comments":"","x":574,"y":98,"z":"8c500c8b.91561","wires":[]},{"id":"f3c2409c.90b75","type":"comment","name":"request-method = reqExecSLS, req-action = \"execute SLS\"","info":"This would be the ideal adaptor the orchestrator DG will call, this just takes in slsName.","comments":"","x":585,"y":183,"z":"8c500c8b.91561","wires":[]},{"id":"206ad453.90dcdc","type":"comment","name":"Assumptions for this DG (example-server)","info":"Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ","comments":"","x":577,"y":139,"z":"8c500c8b.91561","wires":[]},{"id":"a9f084e0.590cc8","type":"execute","name":"execute","xml":"<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='slsName' value='test-file.sls'/>\n","comments":"","outputs":1,"x":279,"y":350,"z":"8c500c8b.91561","wires":[["953d6f9.633bc9","2b0177ad.6a0c88"]]},{"id":"953d6f9.633bc9","type":"failure","name":"failure","xml":"<outcome value='failure'>\n","comments":"","outputs":1,"x":472,"y":311,"z":"8c500c8b.91561","wires":[["56ac40b9.ab7d9"]]},{"id":"2b0177ad.6a0c88","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":470,"y":383,"z":"8c500c8b.91561","wires":[["245f2c0b.5f8894"]]},{"id":"245f2c0b.5f8894","type":"switchNode","name":"switch","xml":"<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n","comments":"","outputs":1,"x":622,"y":371,"z":"8c500c8b.91561","wires":[["9cb78c41.7c1fc","a2c5d59b.172848"]]},{"id":"a2c5d59b.172848","type":"success","name":"success","xml":"<outcome value='200'>\n","comments":"","outputs":1,"x":785,"y":317,"z":"8c500c8b.91561","wires":[["f809843e.12d3b8"]]},{"id":"9cb78c41.7c1fc","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":782,"y":386,"z":"8c500c8b.91561","wires":[["2ca5c925.6ee136"]]},{"id":"56ac40b9.ab7d9","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":632,"y":295,"z":"8c500c8b.91561","wires":[]},{"id":"2ca5c925.6ee136","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":952,"y":383,"z":"8c500c8b.91561","wires":[]}]
\ No newline at end of file +[ + { + "id": "80b83851.e527b8", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "<method rpc='saltstack-adapter-1.0' mode='sync'>\n", + "comments": "", + "outputs": 1, + "x": 676, + "y": 277, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "83c8d47e.cb9c98" + ] + ] + }, + { + "id": "41231c44.5d1324", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>", + "outputs": 1, + "x": 453, + "y": 276, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "80b83851.e527b8" + ] + ] + }, + { + "id": "1f4a794d.fb3be7", + "type": "returnSuccess", + "name": "return success", + "xml": "<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.saltstack.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.saltstack.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.saltstack.results`'/>\n", + "comments": "", + "x": 1055, + "y": 369, + "z": "1f6661d7.1ebd2e", + "wires": [] + }, + { + "id": "5a85036.5a9e2fc", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 284, + "y": 275, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "41231c44.5d1324" + ] + ] + }, + { + "id": "b38fc61c.a23438", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 661, + "y": 154, + "z": "1f6661d7.1ebd2e", + "wires": [] + }, + { + "id": "6a821d83.4070e4", + "type": "comment", + "name": "request-method = reqExecSLS, req-action = \"execute SLS\"", + "info": "This would be the ideal adaptor the orchestrator DG will call, this just takes in SlsName.", + "comments": "", + "x": 672, + "y": 239, + "z": "1f6661d7.1ebd2e", + "wires": [] + }, + { + "id": "ba16960c.36bad8", + "type": "comment", + "name": "Assumptions for this DG (example-server)", + "info": "Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ", + "comments": "", + "x": 664, + "y": 195, + "z": "1f6661d7.1ebd2e", + "wires": [] + }, + { + "id": "83c8d47e.cb9c98", + "type": "execute", + "name": "execute", + "xml": "<execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='SlsName' value='test-file.sls'/>\n <parameter name='NodeList' value='`$NodeList`'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n <parameter name='FileParameters' value='`$FileParameters`'/>\n <parameter name='EnvParameters' value='`$EnvParameters`'/>\n", + "comments": "", + "outputs": 1, + "x": 366, + "y": 406, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "b83f5a23.33f938", + "3354190.eb450e8" + ] + ] + }, + { + "id": "b83f5a23.33f938", + "type": "failure", + "name": "failure", + "xml": "<outcome value='failure'>\n", + "comments": "", + "outputs": 1, + "x": 559, + "y": 367, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "efc02e73.0cf1d" + ] + ] + }, + { + "id": "3354190.eb450e8", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 557, + "y": 439, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "88b53985.e42758" + ] + ] + }, + { + "id": "88b53985.e42758", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n", + "comments": "", + "outputs": 1, + "x": 709, + "y": 427, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "195a294e.61efb7", + "bc1bfd78.146bc" + ] + ] + }, + { + "id": "bc1bfd78.146bc", + "type": "success", + "name": "success", + "xml": "<outcome value='200'>\n", + "comments": "", + "outputs": 1, + "x": 872, + "y": 373, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "1f4a794d.fb3be7" + ] + ] + }, + { + "id": "195a294e.61efb7", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 869, + "y": 442, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "81ddc2e0.dce24" + ] + ] + }, + { + "id": "efc02e73.0cf1d", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 719, + "y": 351, + "z": "1f6661d7.1ebd2e", + "wires": [] + }, + { + "id": "81ddc2e0.dce24", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 1039, + "y": 439, + "z": "1f6661d7.1ebd2e", + "wires": [] + } +]
\ No newline at end of file diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.xml index 8a237f3f..23ec7856 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0 IDEAL.xml @@ -1,26 +1,52 @@ -<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'><method rpc='saltstack-adapter-1.0' mode='sync'>
-<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >
- <parameter name='HostName' value='`$AgentUrl`'/>
- <parameter name='Port' value='`$Port`'/>
- <parameter name='User' value='`$User`'/>
- <parameter name='Password' value='`$Password`'/>
- <parameter name='Id' value='test2'/>
- <parameter name='slsName' value='test-file.sls'/>
-<outcome value='failure'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome><outcome value='Other'>
-<switch test="`$org.onap.appc.adapter.saltstack.result.code`">
-<outcome value='200'>
-<return status='success'>
-<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />
-<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>
-<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>
-</return></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome></execute></method></service-logic>
\ No newline at end of file +<service-logic xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns='http://www.onap.org/sdnc/svclogic'
+ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
+ module='APPC' version='2.0.1'>
+ <method rpc='saltstack-adapter-1.0' mode='sync'>
+ <execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
+ method='reqExecCommand'>
+ <parameter name='HostName' value='`$AgentUrl`'/>
+ <parameter name='Port' value='`$Port`'/>
+ <parameter name='User' value='`$User`'/>
+ <parameter name='Password' value='`$Password`'/>
+ <parameter name='Id' value='test2'/>
+ <parameter name='SlsName' value='test-file.sls'/>
+ <parameter name='NodeList' value='`$NodeList`'/>
+ <parameter name='Timeout' value='`$Timeout`'/>
+ <parameter name='FileParameters' value='`$FileParameters`'/>
+ <parameter name='EnvParameters' value='`$EnvParameters`'/>
+ <outcome value='failure'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <switch test="`$org.onap.appc.adapter.saltstack.result.code`">
+ <outcome value='200'>
+ <return status='success'>
+ <parameter name='output.status.code'
+ value='`$org.openecomp.appc.adapter.saltstack.result.code`'/>
+ <parameter name='output.status.message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ </execute>
+ </method>
+</service-logic>
\ No newline at end of file diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.json index f8c6a015..b276f381 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.json @@ -1 +1,372 @@ -[{"id":"edb39979.b1ccd8","type":"method","name":"saltstack-adapter-1.0","xml":"<method rpc='saltstack-adapter-1.0-exec-SLS-applyTo' mode='sync'>\n","comments":"","outputs":1,"x":476,"y":245,"z":"671ca899.284f68","wires":[["95c9ba42.6e4aa8"]]},{"id":"a16ea11e.f8d1c","type":"service-logic","name":"APPC 2.0.1","module":"APPC","version":"2.0.1","comments":"","xml":"<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>","outputs":1,"x":267,"y":323,"z":"671ca899.284f68","wires":[["edb39979.b1ccd8"]]},{"id":"1591f92e.029ca7","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":1191,"y":315,"z":"671ca899.284f68","wires":[]},{"id":"95c9ba42.6e4aa8","type":"execute","name":"execute","xml":"<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='slsExec' value='false'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n","comments":"","outputs":1,"x":684,"y":251,"z":"671ca899.284f68","wires":[["cd0c458a.2430b8","69e531e3.4efc3"]]},{"id":"38b44d70.9c85d2","type":"switchNode","name":"switch","xml":"<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n","comments":"","outputs":1,"x":472,"y":405,"z":"671ca899.284f68","wires":[["505df598.069b9c","5d7292e.22ec06c"]]},{"id":"505df598.069b9c","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":658,"y":463,"z":"671ca899.284f68","wires":[["1591f92e.029ca7"]]},{"id":"cd0c458a.2430b8","type":"failure","name":"failure","xml":"<outcome value='failure'>\n","comments":"","outputs":1,"x":935,"y":244,"z":"671ca899.284f68","wires":[["1591f92e.029ca7"]]},{"id":"69e531e3.4efc3","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":282,"y":412,"z":"671ca899.284f68","wires":[["38b44d70.9c85d2"]]},{"id":"5d7292e.22ec06c","type":"success","name":"success","xml":"<outcome value='200'>\n","comments":"","outputs":1,"x":661,"y":405,"z":"671ca899.284f68","wires":[["c9df0cea.f2361"]]},{"id":"e4f7eb59.0abb58","type":"returnSuccess","name":"return success","xml":"<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>\n","comments":"","x":1079,"y":564,"z":"671ca899.284f68","wires":[]},{"id":"8e586da4.570f1","type":"dgstart","name":"DGSTART","outputs":1,"x":245,"y":223,"z":"671ca899.284f68","wires":[["a16ea11e.f8d1c"]]},{"id":"71387074.137c1","type":"comment","name":"SaltStack Adaptor DG","info":"","comments":"","x":623,"y":110,"z":"671ca899.284f68","wires":[]},{"id":"c5e8c62d.021758","type":"comment","name":"request-method = reqExecSLS, req-action = \"execute SLS\"","info":"Here we basically test if minion1 is active by pinging to it, then respective sls file is executed on to it. \n","comments":"","x":634,"y":195,"z":"671ca899.284f68","wires":[]},{"id":"1805797.a241487","type":"comment","name":"Assumptions for this DG (example-server)","info":"Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ","comments":"","x":626,"y":151,"z":"671ca899.284f68","wires":[]},{"id":"c9df0cea.f2361","type":"switchNode","name":"switch","xml":"<switch test=\"`$test1.minion1`\">\n","comments":"","outputs":1,"x":825,"y":405,"z":"671ca899.284f68","wires":[["d83d6024.2454d","f4d70bbc.f0bc38"]]},{"id":"d83d6024.2454d","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":991,"y":459,"z":"671ca899.284f68","wires":[["1591f92e.029ca7"]]},{"id":"f4d70bbc.f0bc38","type":"other","name":"outcome","xml":"<outcome value='true'>\n","comments":"","outputs":1,"x":994,"y":401,"z":"671ca899.284f68","wires":[["e86d9995.b65c58"]]},{"id":"e86d9995.b65c58","type":"execute","name":"execute","xml":"<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='slsName' value='test-file.sls'/>\n <parameter name='applyTo' value='minion1'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n","comments":"","outputs":1,"x":398,"y":593,"z":"671ca899.284f68","wires":[["89ff1c2a.08f52","e20c4c85.43d3c"]]},{"id":"89ff1c2a.08f52","type":"failure","name":"failure","xml":"<outcome value='failure'>\n","comments":"","outputs":1,"x":583,"y":562,"z":"671ca899.284f68","wires":[["6032e33e.5b044c"]]},{"id":"e20c4c85.43d3c","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":581,"y":634,"z":"671ca899.284f68","wires":[["8bb4c177.499c8"]]},{"id":"8bb4c177.499c8","type":"switchNode","name":"switch","xml":"<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n","comments":"","outputs":1,"x":733,"y":622,"z":"671ca899.284f68","wires":[["905334fe.934d68","9c217c10.9d539"]]},{"id":"9c217c10.9d539","type":"success","name":"success","xml":"<outcome value='200'>\n","comments":"","outputs":1,"x":896,"y":568,"z":"671ca899.284f68","wires":[["e4f7eb59.0abb58"]]},{"id":"905334fe.934d68","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":893,"y":637,"z":"671ca899.284f68","wires":[["7026a88c.5bffd8"]]},{"id":"6032e33e.5b044c","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":735,"y":559,"z":"671ca899.284f68","wires":[]},{"id":"7026a88c.5bffd8","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":1054,"y":637,"z":"671ca899.284f68","wires":[]}]
\ No newline at end of file +[ + { + "id": "edb39979.b1ccd8", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "<method rpc='saltstack-adapter-1.0-exec-SLS-NodeList' mode='sync'>\n", + "comments": "", + "outputs": 1, + "x": 476, + "y": 245, + "z": "671ca899.284f68", + "wires": [ + [ + "95c9ba42.6e4aa8" + ] + ] + }, + { + "id": "a16ea11e.f8d1c", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>", + "outputs": 1, + "x": 267, + "y": 323, + "z": "671ca899.284f68", + "wires": [ + [ + "edb39979.b1ccd8" + ] + ] + }, + { + "id": "1591f92e.029ca7", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 1191, + "y": 315, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "95c9ba42.6e4aa8", + "type": "execute", + "name": "execute", + "xml": "<execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='Cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='SlsExec' value='false'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", + "comments": "", + "outputs": 1, + "x": 684, + "y": 251, + "z": "671ca899.284f68", + "wires": [ + [ + "cd0c458a.2430b8", + "69e531e3.4efc3" + ] + ] + }, + { + "id": "38b44d70.9c85d2", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n", + "comments": "", + "outputs": 1, + "x": 472, + "y": 405, + "z": "671ca899.284f68", + "wires": [ + [ + "505df598.069b9c", + "5d7292e.22ec06c" + ] + ] + }, + { + "id": "505df598.069b9c", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 658, + "y": 463, + "z": "671ca899.284f68", + "wires": [ + [ + "1591f92e.029ca7" + ] + ] + }, + { + "id": "cd0c458a.2430b8", + "type": "failure", + "name": "failure", + "xml": "<outcome value='failure'>\n", + "comments": "", + "outputs": 1, + "x": 935, + "y": 244, + "z": "671ca899.284f68", + "wires": [ + [ + "1591f92e.029ca7" + ] + ] + }, + { + "id": "69e531e3.4efc3", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 282, + "y": 412, + "z": "671ca899.284f68", + "wires": [ + [ + "38b44d70.9c85d2" + ] + ] + }, + { + "id": "5d7292e.22ec06c", + "type": "success", + "name": "success", + "xml": "<outcome value='200'>\n", + "comments": "", + "outputs": 1, + "x": 661, + "y": 405, + "z": "671ca899.284f68", + "wires": [ + [ + "c9df0cea.f2361" + ] + ] + }, + { + "id": "e4f7eb59.0abb58", + "type": "returnSuccess", + "name": "return success", + "xml": "<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.saltstack.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.saltstack.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.saltstack.results`'/>\n", + "comments": "", + "x": 1079, + "y": 564, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "8e586da4.570f1", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 245, + "y": 223, + "z": "671ca899.284f68", + "wires": [ + [ + "a16ea11e.f8d1c" + ] + ] + }, + { + "id": "71387074.137c1", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 623, + "y": 110, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "c5e8c62d.021758", + "type": "comment", + "name": "request-method = reqExecSLS, req-action = \"execute SLS\"", + "info": "Here we basically test if minion1 is active by pinging to it, then respective sls file is executed on to it. \n", + "comments": "", + "x": 634, + "y": 195, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "1805797.a241487", + "type": "comment", + "name": "Assumptions for this DG (example-server)", + "info": "Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ", + "comments": "", + "x": 626, + "y": 151, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "c9df0cea.f2361", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$test1.minion1`\">\n", + "comments": "", + "outputs": 1, + "x": 825, + "y": 405, + "z": "671ca899.284f68", + "wires": [ + [ + "d83d6024.2454d", + "f4d70bbc.f0bc38" + ] + ] + }, + { + "id": "d83d6024.2454d", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 991, + "y": 459, + "z": "671ca899.284f68", + "wires": [ + [ + "1591f92e.029ca7" + ] + ] + }, + { + "id": "f4d70bbc.f0bc38", + "type": "other", + "name": "outcome", + "xml": "<outcome value='true'>\n", + "comments": "", + "outputs": 1, + "x": 994, + "y": 401, + "z": "671ca899.284f68", + "wires": [ + [ + "e86d9995.b65c58" + ] + ] + }, + { + "id": "e86d9995.b65c58", + "type": "execute", + "name": "execute", + "xml": "<execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='SlsName' value='test-file.sls'/>\n <parameter name='NodeList' value='minion1'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", + "comments": "", + "outputs": 1, + "x": 398, + "y": 593, + "z": "671ca899.284f68", + "wires": [ + [ + "89ff1c2a.08f52", + "e20c4c85.43d3c" + ] + ] + }, + { + "id": "89ff1c2a.08f52", + "type": "failure", + "name": "failure", + "xml": "<outcome value='failure'>\n", + "comments": "", + "outputs": 1, + "x": 583, + "y": 562, + "z": "671ca899.284f68", + "wires": [ + [ + "6032e33e.5b044c" + ] + ] + }, + { + "id": "e20c4c85.43d3c", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 581, + "y": 634, + "z": "671ca899.284f68", + "wires": [ + [ + "8bb4c177.499c8" + ] + ] + }, + { + "id": "8bb4c177.499c8", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n", + "comments": "", + "outputs": 1, + "x": 733, + "y": 622, + "z": "671ca899.284f68", + "wires": [ + [ + "905334fe.934d68", + "9c217c10.9d539" + ] + ] + }, + { + "id": "9c217c10.9d539", + "type": "success", + "name": "success", + "xml": "<outcome value='200'>\n", + "comments": "", + "outputs": 1, + "x": 896, + "y": 568, + "z": "671ca899.284f68", + "wires": [ + [ + "e4f7eb59.0abb58" + ] + ] + }, + { + "id": "905334fe.934d68", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 893, + "y": 637, + "z": "671ca899.284f68", + "wires": [ + [ + "7026a88c.5bffd8" + ] + ] + }, + { + "id": "6032e33e.5b044c", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 735, + "y": 559, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "7026a88c.5bffd8", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 1054, + "y": 637, + "z": "671ca899.284f68", + "wires": [] + } +]
\ No newline at end of file diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.xml index a8262885..cc4538ca 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLS/APPC_saltstack-adapter-1.0-exec-SLS-applyTo.xml @@ -1,57 +1,112 @@ -<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'><method rpc='saltstack-adapter-1.0-exec-SLS-applyTo' mode='sync'>
-<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >
- <parameter name='HostName' value='`$AgentUrl`'/>
- <parameter name='Port' value='`$Port`'/>
- <parameter name='User' value='`$User`'/>
- <parameter name='Password' value='`$Password`'/>
- <parameter name='Id' value='test1'/>
- <parameter name='cmd' value='salt '*' test.ping --out=json --static'/>
- <parameter name='slsExec' value='false'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
-<outcome value='failure'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome><outcome value='Other'>
-<switch test="`$org.onap.appc.adapter.saltstack.result.code`">
-<outcome value='200'>
-<switch test="`$test1.minion1`">
-<outcome value='true'>
-<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >
- <parameter name='HostName' value='`$AgentUrl`'/>
- <parameter name='Port' value='`$Port`'/>
- <parameter name='User' value='`$User`'/>
- <parameter name='Password' value='`$Password`'/>
- <parameter name='Id' value='test2'/>
- <parameter name='slsName' value='test-file.sls'/>
- <parameter name='applyTo' value='minion1'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
-<outcome value='failure'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome><outcome value='Other'>
-<switch test="`$org.onap.appc.adapter.saltstack.result.code`">
-<outcome value='200'>
-<return status='success'>
-<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />
-<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>
-<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>
-</return></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome></execute></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome></execute></method></service-logic>
\ No newline at end of file +<service-logic xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns='http://www.onap.org/sdnc/svclogic'
+ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
+ module='APPC' version='2.0.1'>
+ <method rpc='saltstack-adapter-1.0-exec-SLS-NodeList' mode='sync'>
+ <execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
+ method='reqExecCommand'>
+ <parameter name='HostName' value='`$AgentUrl`'/>
+ <parameter name='Port' value='`$Port`'/>
+ <parameter name='User' value='`$User`'/>
+ <parameter name='Password' value='`$Password`'/>
+ <parameter name='Id' value='test1'/>
+ <parameter name='Cmd'
+ value='salt '*' test.ping --out=json --static'/>
+ <parameter name='SlsExec' value='false'/>
+ <parameter name='Timeout' value='`$Timeout`'/>
+ <outcome value='failure'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <switch test="`$org.onap.appc.adapter.saltstack.result.code`">
+ <outcome value='200'>
+ <switch test="`$test1.minion1`">
+ <outcome value='true'>
+ <execute
+ plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
+ method='reqExecCommand'>
+ <parameter name='HostName'
+ value='`$AgentUrl`'/>
+ <parameter name='Port' value='`$Port`'/>
+ <parameter name='User' value='`$User`'/>
+ <parameter name='Password'
+ value='`$Password`'/>
+ <parameter name='Id' value='test2'/>
+ <parameter name='SlsName'
+ value='test-file.sls'/>
+ <parameter name='NodeList' value='minion1'/>
+ <parameter name='Timeout'
+ value='`$Timeout`'/>
+ <outcome value='failure'>
+ <return status='failure'>
+ <parameter name='error-code'
+ value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter
+ name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <switch test="`$org.onap.appc.adapter.saltstack.result.code`">
+ <outcome value='200'>
+ <return status='success'>
+ <parameter
+ name='output.status.code'
+ value='`$org.openecomp.appc.adapter.saltstack.result.code`'/>
+ <parameter
+ name='output.status.message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter
+ name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code'
+ value='200'/>
+ <parameter
+ name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter
+ name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ </execute>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ </execute>
+ </method>
+</service-logic>
\ No newline at end of file diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.json index a4ec6f1b..b20e7e8d 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.json @@ -1 +1,214 @@ -[{"id":"3228200a.5dc1a","type":"method","name":"saltstack-adapter-1.0","xml":"<method rpc='saltstack-adapter-1.0-SLSFILE' mode='sync'>\n","comments":"","outputs":1,"x":679,"y":282,"z":"6d4f912d.f07bc","wires":[["50b2729f.712eac"]]},{"id":"9fb54163.4fb28","type":"service-logic","name":"APPC 2.0.1","module":"APPC","version":"2.0.1","comments":"","xml":"<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>","outputs":1,"x":456,"y":281,"z":"6d4f912d.f07bc","wires":[["3228200a.5dc1a"]]},{"id":"49109fbc.a7a14","type":"returnSuccess","name":"return success","xml":"<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>\n","comments":"","x":1058,"y":374,"z":"6d4f912d.f07bc","wires":[]},{"id":"d030a396.56232","type":"dgstart","name":"DGSTART","outputs":1,"x":287,"y":280,"z":"6d4f912d.f07bc","wires":[["9fb54163.4fb28"]]},{"id":"281900c4.fd3e8","type":"comment","name":"SaltStack Adaptor DG","info":"","comments":"","x":664,"y":159,"z":"6d4f912d.f07bc","wires":[]},{"id":"431a69db.2d2c58","type":"comment","name":"request-method = reqExecSLS, req-action = \"execute SLS\"","info":"This would be the ideal adaptor the orchestrator DG will call, this just takes in slsName.","comments":"","x":675,"y":244,"z":"6d4f912d.f07bc","wires":[]},{"id":"4202e1ce.09495","type":"comment","name":"Assumptions for this DG (example-server)","info":"Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ","comments":"","x":667,"y":200,"z":"6d4f912d.f07bc","wires":[]},{"id":"50b2729f.712eac","type":"execute","name":"execute","xml":"<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='slsFile' value='file/location/test-file.sls'/>\n","comments":"","outputs":1,"x":369,"y":411,"z":"6d4f912d.f07bc","wires":[["71746570.35f0dc","3e4f7a4a.ae0dc6"]]},{"id":"71746570.35f0dc","type":"failure","name":"failure","xml":"<outcome value='failure'>\n","comments":"","outputs":1,"x":562,"y":372,"z":"6d4f912d.f07bc","wires":[["e59a1a81.112a08"]]},{"id":"3e4f7a4a.ae0dc6","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":560,"y":444,"z":"6d4f912d.f07bc","wires":[["59e320fa.12908"]]},{"id":"59e320fa.12908","type":"switchNode","name":"switch","xml":"<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n","comments":"","outputs":1,"x":712,"y":432,"z":"6d4f912d.f07bc","wires":[["f81ed07.2135c3","eb55b5a9.f0d2f8"]]},{"id":"eb55b5a9.f0d2f8","type":"success","name":"success","xml":"<outcome value='200'>\n","comments":"","outputs":1,"x":875,"y":378,"z":"6d4f912d.f07bc","wires":[["49109fbc.a7a14"]]},{"id":"f81ed07.2135c3","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":872,"y":447,"z":"6d4f912d.f07bc","wires":[["6549631f.8e516c"]]},{"id":"e59a1a81.112a08","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":722,"y":356,"z":"6d4f912d.f07bc","wires":[]},{"id":"6549631f.8e516c","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":1042,"y":444,"z":"6d4f912d.f07bc","wires":[]}]
\ No newline at end of file +[ + { + "id": "3228200a.5dc1a", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "<method rpc='saltstack-adapter-1.0-SLSFILE' mode='sync'>\n", + "comments": "", + "outputs": 1, + "x": 679, + "y": 282, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "50b2729f.712eac" + ] + ] + }, + { + "id": "9fb54163.4fb28", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>", + "outputs": 1, + "x": 456, + "y": 281, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "3228200a.5dc1a" + ] + ] + }, + { + "id": "49109fbc.a7a14", + "type": "returnSuccess", + "name": "return success", + "xml": "<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.saltstack.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.saltstack.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.saltstack.results`'/>\n", + "comments": "", + "x": 1058, + "y": 374, + "z": "6d4f912d.f07bc", + "wires": [] + }, + { + "id": "d030a396.56232", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 287, + "y": 280, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "9fb54163.4fb28" + ] + ] + }, + { + "id": "281900c4.fd3e8", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 664, + "y": 159, + "z": "6d4f912d.f07bc", + "wires": [] + }, + { + "id": "431a69db.2d2c58", + "type": "comment", + "name": "request-method = reqExecSLS, req-action = \"execute SLS\"", + "info": "This would be the ideal adaptor the orchestrator DG will call, this just takes in SlsName.", + "comments": "", + "x": 675, + "y": 244, + "z": "6d4f912d.f07bc", + "wires": [] + }, + { + "id": "4202e1ce.09495", + "type": "comment", + "name": "Assumptions for this DG (example-server)", + "info": "Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ", + "comments": "", + "x": 667, + "y": 200, + "z": "6d4f912d.f07bc", + "wires": [] + }, + { + "id": "50b2729f.712eac", + "type": "execute", + "name": "execute", + "xml": "<execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='SlsFile' value='file/location/test-file.sls'/>\n", + "comments": "", + "outputs": 1, + "x": 369, + "y": 411, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "71746570.35f0dc", + "3e4f7a4a.ae0dc6" + ] + ] + }, + { + "id": "71746570.35f0dc", + "type": "failure", + "name": "failure", + "xml": "<outcome value='failure'>\n", + "comments": "", + "outputs": 1, + "x": 562, + "y": 372, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "e59a1a81.112a08" + ] + ] + }, + { + "id": "3e4f7a4a.ae0dc6", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 560, + "y": 444, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "59e320fa.12908" + ] + ] + }, + { + "id": "59e320fa.12908", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n", + "comments": "", + "outputs": 1, + "x": 712, + "y": 432, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "f81ed07.2135c3", + "eb55b5a9.f0d2f8" + ] + ] + }, + { + "id": "eb55b5a9.f0d2f8", + "type": "success", + "name": "success", + "xml": "<outcome value='200'>\n", + "comments": "", + "outputs": 1, + "x": 875, + "y": 378, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "49109fbc.a7a14" + ] + ] + }, + { + "id": "f81ed07.2135c3", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 872, + "y": 447, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "6549631f.8e516c" + ] + ] + }, + { + "id": "e59a1a81.112a08", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 722, + "y": 356, + "z": "6d4f912d.f07bc", + "wires": [] + }, + { + "id": "6549631f.8e516c", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 1042, + "y": 444, + "z": "6d4f912d.f07bc", + "wires": [] + } +]
\ No newline at end of file diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.xml index bd3325b3..2c5e600f 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-SLSFILE.xml @@ -1,26 +1,48 @@ -<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'><method rpc='saltstack-adapter-1.0-SLSFILE' mode='sync'>
-<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >
- <parameter name='HostName' value='`$AgentUrl`'/>
- <parameter name='Port' value='`$Port`'/>
- <parameter name='User' value='`$User`'/>
- <parameter name='Password' value='`$Password`'/>
- <parameter name='Id' value='test2'/>
- <parameter name='slsFile' value='file/location/test-file.sls'/>
-<outcome value='failure'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome><outcome value='Other'>
-<switch test="`$org.onap.appc.adapter.saltstack.result.code`">
-<outcome value='200'>
-<return status='success'>
-<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />
-<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>
-<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>
-</return></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome></execute></method></service-logic>
\ No newline at end of file +<service-logic xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns='http://www.onap.org/sdnc/svclogic'
+ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
+ module='APPC' version='2.0.1'>
+ <method rpc='saltstack-adapter-1.0-SLSFILE' mode='sync'>
+ <execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
+ method='reqExecCommand'>
+ <parameter name='HostName' value='`$AgentUrl`'/>
+ <parameter name='Port' value='`$Port`'/>
+ <parameter name='User' value='`$User`'/>
+ <parameter name='Password' value='`$Password`'/>
+ <parameter name='Id' value='test2'/>
+ <parameter name='SlsFile' value='file/location/test-file.sls'/>
+ <outcome value='failure'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <switch test="`$org.onap.appc.adapter.saltstack.result.code`">
+ <outcome value='200'>
+ <return status='success'>
+ <parameter name='output.status.code'
+ value='`$org.openecomp.appc.adapter.saltstack.result.code`'/>
+ <parameter name='output.status.message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ </execute>
+ </method>
+</service-logic>
\ No newline at end of file diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.json b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.json index de4f0fbb..264950d5 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.json +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.json @@ -1 +1,372 @@ -[{"id":"9a6bf94f.d969f8","type":"method","name":"saltstack-adapter-1.0","xml":"<method rpc='saltstack-adapter-1.0-exec-SLSFile-applyTo' mode='sync'>\n","comments":"","outputs":1,"x":498,"y":240,"z":"723548c7.652d78","wires":[["138ad7ed.403248"]]},{"id":"4bb87049.3f546","type":"service-logic","name":"APPC 2.0.1","module":"APPC","version":"2.0.1","comments":"","xml":"<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>","outputs":1,"x":289,"y":318,"z":"723548c7.652d78","wires":[["9a6bf94f.d969f8"]]},{"id":"6c593992.106038","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":1202,"y":280,"z":"723548c7.652d78","wires":[]},{"id":"138ad7ed.403248","type":"execute","name":"execute","xml":"<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='slsExec' value='false'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n","comments":"","outputs":1,"x":706,"y":246,"z":"723548c7.652d78","wires":[["167273ed.f0577c","954a34ea.701368"]]},{"id":"d5841e65.537ba","type":"switchNode","name":"switch","xml":"<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n","comments":"","outputs":1,"x":494,"y":400,"z":"723548c7.652d78","wires":[["ede42371.2f52b","d306d7a0.c830e8"]]},{"id":"ede42371.2f52b","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":680,"y":458,"z":"723548c7.652d78","wires":[["6c593992.106038"]]},{"id":"167273ed.f0577c","type":"failure","name":"failure","xml":"<outcome value='failure'>\n","comments":"","outputs":1,"x":957,"y":239,"z":"723548c7.652d78","wires":[["6c593992.106038"]]},{"id":"954a34ea.701368","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":304,"y":407,"z":"723548c7.652d78","wires":[["d5841e65.537ba"]]},{"id":"d306d7a0.c830e8","type":"success","name":"success","xml":"<outcome value='200'>\n","comments":"","outputs":1,"x":683,"y":400,"z":"723548c7.652d78","wires":[["5b12ba31.94b3b4"]]},{"id":"9ef7fcc3.69279","type":"returnSuccess","name":"return success","xml":"<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>\n","comments":"","x":1101,"y":559,"z":"723548c7.652d78","wires":[]},{"id":"7803eeaf.1e31d","type":"dgstart","name":"DGSTART","outputs":1,"x":267,"y":218,"z":"723548c7.652d78","wires":[["4bb87049.3f546"]]},{"id":"9c6f1e7c.2a3d9","type":"comment","name":"SaltStack Adaptor DG","info":"","comments":"","x":645,"y":105,"z":"723548c7.652d78","wires":[]},{"id":"93ea02a5.4e792","type":"comment","name":"request-method = reqExecSLS, req-action = \"execute SLS FILE\"","info":"Here we basically test if minion1 is active by pinging to it, then respective sls file is executed on to it. \n","comments":"","x":656,"y":190,"z":"723548c7.652d78","wires":[]},{"id":"243edbf.f35fc24","type":"comment","name":"Assumptions for this DG (example-server)","info":"Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ","comments":"","x":648,"y":146,"z":"723548c7.652d78","wires":[]},{"id":"5b12ba31.94b3b4","type":"switchNode","name":"switch","xml":"<switch test=\"`$test1.minion1`\">\n","comments":"","outputs":1,"x":847,"y":400,"z":"723548c7.652d78","wires":[["9bf0915.96f217","f6e533d.95d99d"]]},{"id":"9bf0915.96f217","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":1013,"y":454,"z":"723548c7.652d78","wires":[["6c593992.106038"]]},{"id":"f6e533d.95d99d","type":"other","name":"outcome","xml":"<outcome value='true'>\n","comments":"","outputs":1,"x":1016,"y":396,"z":"723548c7.652d78","wires":[["eb57ba41.1d7328"]]},{"id":"eb57ba41.1d7328","type":"execute","name":"execute","xml":"<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='slsFile' value='file/location/test.sls'/>\n <parameter name='applyTo' value='minion1'/>\n <parameter name='execTimeout' value='`$Timeout`'/>\n","comments":"","outputs":1,"x":420,"y":588,"z":"723548c7.652d78","wires":[["892a8f1d.7d77f","74be8a6e.975f24"]]},{"id":"892a8f1d.7d77f","type":"failure","name":"failure","xml":"<outcome value='failure'>\n","comments":"","outputs":1,"x":605,"y":557,"z":"723548c7.652d78","wires":[["8c091fe.c6cbfe"]]},{"id":"74be8a6e.975f24","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":603,"y":629,"z":"723548c7.652d78","wires":[["3875d695.fd37ca"]]},{"id":"3875d695.fd37ca","type":"switchNode","name":"switch","xml":"<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n","comments":"","outputs":1,"x":755,"y":617,"z":"723548c7.652d78","wires":[["2e60af80.ea3a6","24ed6dd2.6624c2"]]},{"id":"24ed6dd2.6624c2","type":"success","name":"success","xml":"<outcome value='200'>\n","comments":"","outputs":1,"x":918,"y":563,"z":"723548c7.652d78","wires":[["9ef7fcc3.69279"]]},{"id":"2e60af80.ea3a6","type":"other","name":"other","xml":"<outcome value='Other'>\n","comments":"","outputs":1,"x":915,"y":632,"z":"723548c7.652d78","wires":[["2e4414a7.ba6d4c"]]},{"id":"8c091fe.c6cbfe","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":757,"y":554,"z":"723548c7.652d78","wires":[]},{"id":"2e4414a7.ba6d4c","type":"returnFailure","name":"return failure","xml":"<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />\n","comments":"","x":1076,"y":632,"z":"723548c7.652d78","wires":[]}]
\ No newline at end of file +[ + { + "id": "9a6bf94f.d969f8", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "<method rpc='saltstack-adapter-1.0-exec-SLSFile-SlsName' mode='sync'>\n", + "comments": "", + "outputs": 1, + "x": 498, + "y": 240, + "z": "723548c7.652d78", + "wires": [ + [ + "138ad7ed.403248" + ] + ] + }, + { + "id": "4bb87049.3f546", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'>", + "outputs": 1, + "x": 289, + "y": 318, + "z": "723548c7.652d78", + "wires": [ + [ + "9a6bf94f.d969f8" + ] + ] + }, + { + "id": "6c593992.106038", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 1202, + "y": 280, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "138ad7ed.403248", + "type": "execute", + "name": "execute", + "xml": "<execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test1'/>\n <parameter name='Cmd' value='salt '*' test.ping --out=json --static'/>\n <parameter name='SlsExec' value='false'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", + "comments": "", + "outputs": 1, + "x": 706, + "y": 246, + "z": "723548c7.652d78", + "wires": [ + [ + "167273ed.f0577c", + "954a34ea.701368" + ] + ] + }, + { + "id": "d5841e65.537ba", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n", + "comments": "", + "outputs": 1, + "x": 494, + "y": 400, + "z": "723548c7.652d78", + "wires": [ + [ + "ede42371.2f52b", + "d306d7a0.c830e8" + ] + ] + }, + { + "id": "ede42371.2f52b", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 680, + "y": 458, + "z": "723548c7.652d78", + "wires": [ + [ + "6c593992.106038" + ] + ] + }, + { + "id": "167273ed.f0577c", + "type": "failure", + "name": "failure", + "xml": "<outcome value='failure'>\n", + "comments": "", + "outputs": 1, + "x": 957, + "y": 239, + "z": "723548c7.652d78", + "wires": [ + [ + "6c593992.106038" + ] + ] + }, + { + "id": "954a34ea.701368", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 304, + "y": 407, + "z": "723548c7.652d78", + "wires": [ + [ + "d5841e65.537ba" + ] + ] + }, + { + "id": "d306d7a0.c830e8", + "type": "success", + "name": "success", + "xml": "<outcome value='200'>\n", + "comments": "", + "outputs": 1, + "x": 683, + "y": 400, + "z": "723548c7.652d78", + "wires": [ + [ + "5b12ba31.94b3b4" + ] + ] + }, + { + "id": "9ef7fcc3.69279", + "type": "returnSuccess", + "name": "return success", + "xml": "<return status='success'>\n<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.saltstack.result.code`' />\n<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.saltstack.message`'/>\n<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.saltstack.results`'/>\n", + "comments": "", + "x": 1101, + "y": 559, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "7803eeaf.1e31d", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 267, + "y": 218, + "z": "723548c7.652d78", + "wires": [ + [ + "4bb87049.3f546" + ] + ] + }, + { + "id": "9c6f1e7c.2a3d9", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 645, + "y": 105, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "93ea02a5.4e792", + "type": "comment", + "name": "request-method = reqExecSLS, req-action = \"execute SLS FILE\"", + "info": "Here we basically test if minion1 is active by pinging to it, then respective sls file is executed on to it. \n", + "comments": "", + "x": 656, + "y": 190, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "243edbf.f35fc24", + "type": "comment", + "name": "Assumptions for this DG (example-server)", + "info": "Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controllers minion1 and minion2. ", + "comments": "", + "x": 648, + "y": 146, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "5b12ba31.94b3b4", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$test1.minion1`\">\n", + "comments": "", + "outputs": 1, + "x": 847, + "y": 400, + "z": "723548c7.652d78", + "wires": [ + [ + "9bf0915.96f217", + "f6e533d.95d99d" + ] + ] + }, + { + "id": "9bf0915.96f217", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 1013, + "y": 454, + "z": "723548c7.652d78", + "wires": [ + [ + "6c593992.106038" + ] + ] + }, + { + "id": "f6e533d.95d99d", + "type": "other", + "name": "outcome", + "xml": "<outcome value='true'>\n", + "comments": "", + "outputs": 1, + "x": 1016, + "y": 396, + "z": "723548c7.652d78", + "wires": [ + [ + "eb57ba41.1d7328" + ] + ] + }, + { + "id": "eb57ba41.1d7328", + "type": "execute", + "name": "execute", + "xml": "<execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter' method='reqExecCommand' >\n <parameter name='HostName' value='`$AgentUrl`'/>\n <parameter name='Port' value='`$Port`'/>\n <parameter name='User' value='`$User`'/>\n <parameter name='Password' value='`$Password`'/>\n <parameter name='Id' value='test2'/>\n <parameter name='SlsFile' value='file/location/test.sls'/>\n <parameter name='NodeList' value='minion1'/>\n <parameter name='Timeout' value='`$Timeout`'/>\n", + "comments": "", + "outputs": 1, + "x": 420, + "y": 588, + "z": "723548c7.652d78", + "wires": [ + [ + "892a8f1d.7d77f", + "74be8a6e.975f24" + ] + ] + }, + { + "id": "892a8f1d.7d77f", + "type": "failure", + "name": "failure", + "xml": "<outcome value='failure'>\n", + "comments": "", + "outputs": 1, + "x": 605, + "y": 557, + "z": "723548c7.652d78", + "wires": [ + [ + "8c091fe.c6cbfe" + ] + ] + }, + { + "id": "74be8a6e.975f24", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 603, + "y": 629, + "z": "723548c7.652d78", + "wires": [ + [ + "3875d695.fd37ca" + ] + ] + }, + { + "id": "3875d695.fd37ca", + "type": "switchNode", + "name": "switch", + "xml": "<switch test=\"`$org.onap.appc.adapter.saltstack.result.code`\">\n", + "comments": "", + "outputs": 1, + "x": 755, + "y": 617, + "z": "723548c7.652d78", + "wires": [ + [ + "2e60af80.ea3a6", + "24ed6dd2.6624c2" + ] + ] + }, + { + "id": "24ed6dd2.6624c2", + "type": "success", + "name": "success", + "xml": "<outcome value='200'>\n", + "comments": "", + "outputs": 1, + "x": 918, + "y": 563, + "z": "723548c7.652d78", + "wires": [ + [ + "9ef7fcc3.69279" + ] + ] + }, + { + "id": "2e60af80.ea3a6", + "type": "other", + "name": "other", + "xml": "<outcome value='Other'>\n", + "comments": "", + "outputs": 1, + "x": 915, + "y": 632, + "z": "723548c7.652d78", + "wires": [ + [ + "2e4414a7.ba6d4c" + ] + ] + }, + { + "id": "8c091fe.c6cbfe", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 757, + "y": 554, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "2e4414a7.ba6d4c", + "type": "returnFailure", + "name": "return failure", + "xml": "<return status='failure'>\n<parameter name='error-code' value='200' />\n<parameter name='error-message' value='`$org.openecomp.appc.adapter.saltstack.message`' />\n<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.saltstack.results`' />\n", + "comments": "", + "x": 1076, + "y": 632, + "z": "723548c7.652d78", + "wires": [] + } +]
\ No newline at end of file diff --git a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.xml b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.xml index 314cd345..16c573ad 100644 --- a/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.xml +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecSLSFile/APPC_saltstack-adapter-1.0-exec-SLSFile-applyTo.xml @@ -1,57 +1,112 @@ -<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='APPC' version='2.0.1'><method rpc='saltstack-adapter-1.0-exec-SLSFile-applyTo' mode='sync'>
-<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >
- <parameter name='HostName' value='`$AgentUrl`'/>
- <parameter name='Port' value='`$Port`'/>
- <parameter name='User' value='`$User`'/>
- <parameter name='Password' value='`$Password`'/>
- <parameter name='Id' value='test1'/>
- <parameter name='cmd' value='salt '*' test.ping --out=json --static'/>
- <parameter name='slsExec' value='false'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
-<outcome value='failure'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome><outcome value='Other'>
-<switch test="`$org.onap.appc.adapter.saltstack.result.code`">
-<outcome value='200'>
-<switch test="`$test1.minion1`">
-<outcome value='true'>
-<execute plugin='org.openecomp.appc.adapter.ansible.AnsibleAdapter' method='reqExecCommand' >
- <parameter name='HostName' value='`$AgentUrl`'/>
- <parameter name='Port' value='`$Port`'/>
- <parameter name='User' value='`$User`'/>
- <parameter name='Password' value='`$Password`'/>
- <parameter name='Id' value='test2'/>
- <parameter name='slsFile' value='file/location/test.sls'/>
- <parameter name='applyTo' value='minion1'/>
- <parameter name='execTimeout' value='`$Timeout`'/>
-<outcome value='failure'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome><outcome value='Other'>
-<switch test="`$org.onap.appc.adapter.saltstack.result.code`">
-<outcome value='200'>
-<return status='success'>
-<parameter name='output.status.code' value='`$org.openecomp.appc.adapter.ansible.result.code`' />
-<parameter name='output.status.message' value='`$org.openecomp.appc.adapter.ansible.message`'/>
-<parameter name='output.status.results' value = '`$org.openecomp.appc.adapter.ansible.results`'/>
-</return></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome></execute></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome><outcome value='Other'>
-<return status='failure'>
-<parameter name='error-code' value='200' />
-<parameter name='error-message' value='`$org.openecomp.appc.adapter.ansible.message`' />
-<parameter name='output.status.results' value='`$org.openecomp.appc.adapter.ansible.results`' />
-</return></outcome></switch></outcome></execute></method></service-logic>
\ No newline at end of file +<service-logic xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns='http://www.onap.org/sdnc/svclogic'
+ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
+ module='APPC' version='2.0.1'>
+ <method rpc='saltstack-adapter-1.0-exec-SLSFile-NodeList' mode='sync'>
+ <execute plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
+ method='reqExecCommand'>
+ <parameter name='HostName' value='`$AgentUrl`'/>
+ <parameter name='Port' value='`$Port`'/>
+ <parameter name='User' value='`$User`'/>
+ <parameter name='Password' value='`$Password`'/>
+ <parameter name='Id' value='test1'/>
+ <parameter name='Cmd'
+ value='salt '*' test.ping --out=json --static'/>
+ <parameter name='SlsExec' value='false'/>
+ <parameter name='Timeout' value='`$Timeout`'/>
+ <outcome value='failure'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <switch test="`$org.onap.appc.adapter.saltstack.result.code`">
+ <outcome value='200'>
+ <switch test="`$test1.minion1`">
+ <outcome value='true'>
+ <execute
+ plugin='org.openecomp.appc.adapter.saltstack.SaltstackAdapter'
+ method='reqExecCommand'>
+ <parameter name='HostName'
+ value='`$AgentUrl`'/>
+ <parameter name='Port' value='`$Port`'/>
+ <parameter name='User' value='`$User`'/>
+ <parameter name='Password'
+ value='`$Password`'/>
+ <parameter name='Id' value='test2'/>
+ <parameter name='SlsFile'
+ value='file/location/test.sls'/>
+ <parameter name='NodeList' value='minion1'/>
+ <parameter name='Timeout'
+ value='`$Timeout`'/>
+ <outcome value='failure'>
+ <return status='failure'>
+ <parameter name='error-code'
+ value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter
+ name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <switch test="`$org.onap.appc.adapter.saltstack.result.code`">
+ <outcome value='200'>
+ <return status='success'>
+ <parameter
+ name='output.status.code'
+ value='`$org.openecomp.appc.adapter.saltstack.result.code`'/>
+ <parameter
+ name='output.status.message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter
+ name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code'
+ value='200'/>
+ <parameter
+ name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter
+ name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ </execute>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ <outcome value='Other'>
+ <return status='failure'>
+ <parameter name='error-code' value='200'/>
+ <parameter name='error-message'
+ value='`$org.openecomp.appc.adapter.saltstack.message`'/>
+ <parameter name='output.status.results'
+ value='`$org.openecomp.appc.adapter.saltstack.results`'/>
+ </return>
+ </outcome>
+ </switch>
+ </outcome>
+ </execute>
+ </method>
+</service-logic>
\ No newline at end of file diff --git a/saltstack-adapter/staltstack-example-server/README.md b/saltstack-adapter/staltstack-example-server/README.md index beaf32f4..7d944223 100644 --- a/saltstack-adapter/staltstack-example-server/README.md +++ b/saltstack-adapter/staltstack-example-server/README.md @@ -1,11 +1,11 @@ ''' /*- * ============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. @@ -19,7 +19,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========================================================= */ ''' @@ -59,7 +59,7 @@ 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 { @@ -69,19 +69,47 @@ TESTING: Sample Saltstack server command execution. 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", "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("200", status); assertEquals(TestId, "test1"); } catch (Exception e){ //if local ssh is not enabled - return; + System.out.print(e.getMessage()); + } + } + + @Test + public void reqExecCommand_shouldSetSuccessRealSLSCommand() 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", "salt '*' test.ping --out=json --static"); + params.put("SlsExec", "false"); + params.put("Timeout", "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"); + TestId = svcContext.getAttribute("test1.minion1"); + assertEquals(TestId, "true"); + } catch (Exception e){ + //if saltstack ssh IP is not enabled + System.out.print(e.getMessage()); } } @@ -89,14 +117,14 @@ TESTING: Sample Saltstack server command execution. public void reqExecCommand_shouldSetSuccessRealCommand() throws SvcLogicException, IllegalStateException, IllegalArgumentException { - params.put("HostName", "<IP address of SS server>"); + 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"); + params.put("Cmd", "cd /srv/salt/; salt '*' state.apply vim --out=json --static"); + params.put("SlsExec", "true"); + params.put("Timeout", "12000"); adapter = new SaltstackAdapterImpl(); try { @@ -107,7 +135,7 @@ TESTING: Sample Saltstack server command execution. assertEquals(TestId, "test1"); } catch (Exception e){ //if saltstack ssh IP is not enabled - return; + System.out.print(e.getMessage()); } } @@ -115,14 +143,14 @@ TESTING: Sample Saltstack server command execution. public void reqExecCommand_shouldSetSuccessRealSSL() throws SvcLogicException, IllegalStateException, IllegalArgumentException { - params.put("HostName", "10.251.92.17"); + 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("execTimeout", "12000"); - params.put("applyTo", "minion1"); + params.put("SlsName", "vim"); + params.put("Timeout", "12000"); + params.put("NodeList", "minion1"); adapter = new SaltstackAdapterImpl(); try { @@ -133,21 +161,23 @@ TESTING: Sample Saltstack server command execution. assertEquals(TestId, "test1"); } catch (Exception e){ //if saltstack ssh IP is not enabled - return; + System.out.print(e.getMessage()); } } @Test - public void reqExecCommand_shouldSetSuccessRealSSLNoApplyTo() throws SvcLogicException, + public void reqExecCommand_shouldSetSuccessEnvParam() throws SvcLogicException, IllegalStateException, IllegalArgumentException { - params.put("HostName", "10.251.92.17"); + 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("execTimeout", "12000"); + params.put("SlsName", "vim"); + params.put("Timeout", "12000"); + params.put("NodeList", "minion1"); + params.put("EnvParameters", "{\"exclude\": bar*}"); adapter = new SaltstackAdapterImpl(); try { @@ -158,22 +188,106 @@ TESTING: Sample Saltstack server command execution. assertEquals(TestId, "test1"); } catch (Exception e){ //if saltstack ssh IP is not enabled - return; + 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", "12000"); + 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 { + 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_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", "12000"); + 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", "12000"); + 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()); + } + } + @Test public void reqExecCommand_shouldSetSuccessSSLFile() throws SvcLogicException, IllegalStateException, IllegalArgumentException { - params.put("HostName", "10.251.92.17"); + params.put("HostName", "<IP>"); 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"); + params.put("Timeout", "12000"); + params.put("NodeList", "minion1"); + params.put("SlsFile", "src/test/resources/config.sls"); adapter = new SaltstackAdapterImpl(); try { @@ -184,6 +298,34 @@ TESTING: Sample Saltstack server command execution. assertEquals(TestId, "test1"); } catch (Exception e){ //if saltstack ssh IP is not enabled - return; + System.out.print(e.getMessage()); } - }
\ No newline at end of file + } + + @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", "12000"); + 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 { + 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()); + } + }
\ 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 index 468d2a24..b96773e1 100644 --- a/saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml +++ b/saltstack-adapter/staltstack-example-server/saltstack_sample_sls-2.yml @@ -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/staltstack-example-server/saltstact_sample_sls.yml b/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml index bcc7fda9..84cc917b 100644 --- a/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml +++ b/saltstack-adapter/staltstack-example-server/saltstact_sample_sls.yml @@ -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========================================================= # */ |