From b08a1b8cf2440fac7fc3d7eb7580a58d977524a2 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Tue, 17 Jul 2018 11:02:17 +0900 Subject: saltstack adaptor DGs addition Issue-ID: CCSDK-368 Change-Id: I5f66693109c14eb64e4576caeeb84440a940fffa Signed-off-by: Ganesh Chandrasekaran --- .../APPC_saltstack-adapter-1.0-exe-nonSLS.json | 203 +++++++++++ .../APPC_saltstack-adapter-1.0-exe-nonSLS.xml | 50 +++ .../APPC_saltstack-adapter-1.0-exec-SLSFile.json | 350 ++++++++++++++++++ .../APPC_saltstack-adapter-1.0-exec-SLSFile.xml | 112 ++++++ .../APPC_saltstack-adapter-1.0-exec-multi-sls.json | 399 +++++++++++++++++++++ .../APPC_saltstack-adapter-1.0-exec-multi-sls.xml | 129 +++++++ ..._saltstack-adapter-1.0-exec-single-SLSComm.json | 203 +++++++++++ ...C_saltstack-adapter-1.0-exec-single-SLSComm.xml | 51 +++ 8 files changed, 1497 insertions(+) create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.json create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.xml create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.json create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.xml create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.json create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.xml create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.json create mode 100644 saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.xml (limited to 'saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand') 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 new file mode 100644 index 000000000..3a287e341 --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.json @@ -0,0 +1,203 @@ +[ + { + "id": "d86e7ee4.ee3f1", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 492, + "y": 216, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "38662e01.1d3c22" + ] + ] + }, + { + "id": "9997883e.ec9028", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "", + "outputs": 1, + "x": 283, + "y": 289, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "d86e7ee4.ee3f1" + ] + ] + }, + { + "id": "d40bf650.8338e8", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 1007, + "y": 373, + "z": "5945fc3c.78efc4", + "wires": [] + }, + { + "id": "38662e01.1d3c22", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 700, + "y": 212, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "7b75e382.6344dc", + "6f108926.d7baf8" + ] + ] + }, + { + "id": "24fb9f79.a6c6c", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 486, + "y": 372, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "c526c44.c850738", + "9c394980.2a56a8" + ] + ] + }, + { + "id": "c526c44.c850738", + "type": "other", + "name": "outcome", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 675, + "y": 371, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "d40bf650.8338e8" + ] + ] + }, + { + "id": "7b75e382.6344dc", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 951, + "y": 210, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "d40bf650.8338e8" + ] + ] + }, + { + "id": "6f108926.d7baf8", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 298, + "y": 378, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "24fb9f79.a6c6c" + ] + ] + }, + { + "id": "9c394980.2a56a8", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 667, + "y": 460, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "1f81a3db.54cd1c" + ] + ] + }, + { + "id": "1f81a3db.54cd1c", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\n", + "comments": "", + "x": 887, + "y": 460, + "z": "5945fc3c.78efc4", + "wires": [] + }, + { + "id": "fcad80f8.ba2d9", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 261, + "y": 189, + "z": "5945fc3c.78efc4", + "wires": [ + [ + "9997883e.ec9028" + ] + ] + }, + { + "id": "b86e624d.49f0f", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 630, + "y": 75, + "z": "5945fc3c.78efc4", + "wires": [] + }, + { + "id": "83c0578d.061f98", + "type": "comment", + "name": "request-method = reqExecCommand, req-action = \"execute a single non SLS command\"", + "info": "", + "comments": "", + "x": 650, + "y": 155, + "z": "5945fc3c.78efc4", + "wires": [] + }, + { + "id": "f104feb6.558f7", + "type": "comment", + "name": "Assumptions for this DG", + "info": "Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controlls minion1 and minion2. ", + "comments": "", + "x": 627, + "y": 115, + "z": "5945fc3c.78efc4", + "wires": [] + } +] \ No newline at end of file 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 new file mode 100644 index 000000000..eadf33619 --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exe-nonSLS.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..95178ac26 --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.json @@ -0,0 +1,350 @@ +[ + { + "id": "d0ad0305.352fc", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 552, + "y": 183, + "z": "b84dc629.83cd08", + "wires": [ + [ + "65cc87e2.a95188" + ] + ] + }, + { + "id": "22aefec.e8c7902", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "", + "outputs": 1, + "x": 343, + "y": 261, + "z": "b84dc629.83cd08", + "wires": [ + [ + "d0ad0305.352fc" + ] + ] + }, + { + "id": "31587001.4259e", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 1262, + "y": 365, + "z": "b84dc629.83cd08", + "wires": [] + }, + { + "id": "65cc87e2.a95188", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 761, + "y": 185, + "z": "b84dc629.83cd08", + "wires": [ + [ + "f9bf6ee7.cf954", + "7b51c357.a852cc" + ] + ] + }, + { + "id": "42fa1258.aa570c", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 544, + "y": 345, + "z": "b84dc629.83cd08", + "wires": [ + [ + "a7cf236a.84c03", + "c45d597b.20b4c8" + ] + ] + }, + { + "id": "a7cf236a.84c03", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 735, + "y": 343, + "z": "b84dc629.83cd08", + "wires": [ + [ + "31587001.4259e" + ] + ] + }, + { + "id": "f9bf6ee7.cf954", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 1011, + "y": 182, + "z": "b84dc629.83cd08", + "wires": [ + [ + "31587001.4259e" + ] + ] + }, + { + "id": "7b51c357.a852cc", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 366, + "y": 343, + "z": "b84dc629.83cd08", + "wires": [ + [ + "42fa1258.aa570c" + ] + ] + }, + { + "id": "c45d597b.20b4c8", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 351, + "y": 459, + "z": "b84dc629.83cd08", + "wires": [ + [ + "30d5f0f7.0e3c8" + ] + ] + }, + { + "id": "2856792.c401a86", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\n", + "comments": "", + "x": 1042, + "y": 656, + "z": "b84dc629.83cd08", + "wires": [] + }, + { + "id": "6c359fdc.3b566", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 321, + "y": 161, + "z": "b84dc629.83cd08", + "wires": [ + [ + "22aefec.e8c7902" + ] + ] + }, + { + "id": "b5342c59.29f74", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 693, + "y": 44, + "z": "b84dc629.83cd08", + "wires": [] + }, + { + "id": "19202194.8ff55e", + "type": "comment", + "name": "request-method = reqExecCommand, req-action = \"execute multiple SLS commands\"", + "info": "Here we basically test if minion1 is active by pinging to it, then install vim package to it. \n", + "comments": "", + "x": 711, + "y": 127, + "z": "b84dc629.83cd08", + "wires": [] + }, + { + "id": "a2ebc17e.fa03a", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 396, + "y": 661, + "z": "b84dc629.83cd08", + "wires": [ + [ + "c9345fbb.d6d19" + ] + ] + }, + { + "id": "770411a5.18825", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 773, + "y": 548, + "z": "b84dc629.83cd08", + "wires": [ + [ + "e09a3e12.87428", + "a2ebc17e.fa03a" + ] + ] + }, + { + "id": "e09a3e12.87428", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 991, + "y": 554, + "z": "b84dc629.83cd08", + "wires": [ + [ + "31587001.4259e" + ] + ] + }, + { + "id": "c9345fbb.d6d19", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 578, + "y": 658, + "z": "b84dc629.83cd08", + "wires": [ + [ + "485e453d.36c75c", + "f1adcf2a.2c456" + ] + ] + }, + { + "id": "485e453d.36c75c", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 783, + "y": 732, + "z": "b84dc629.83cd08", + "wires": [ + [ + "31587001.4259e" + ] + ] + }, + { + "id": "f1adcf2a.2c456", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 776, + "y": 658, + "z": "b84dc629.83cd08", + "wires": [ + [ + "2856792.c401a86" + ] + ] + }, + { + "id": "30d5f0f7.0e3c8", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 523, + "y": 459, + "z": "b84dc629.83cd08", + "wires": [ + [ + "15e9ff68.9812a1", + "17d9d7e.4d9a928" + ] + ] + }, + { + "id": "17d9d7e.4d9a928", + "type": "other", + "name": "outcome", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 593, + "y": 550, + "z": "b84dc629.83cd08", + "wires": [ + [ + "770411a5.18825" + ] + ] + }, + { + "id": "15e9ff68.9812a1", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 717, + "y": 459, + "z": "b84dc629.83cd08", + "wires": [ + [ + "31587001.4259e" + ] + ] + }, + { + "id": "b764890c.ed0018", + "type": "comment", + "name": "Assumptions for this DG (example-server)", + "info": "1) Here we assume, the saltstack server is the example-vagrant based server. Where, the master saltstact controlls minion1 and minion2. \n2) We assume that sls file called vim.sls is already present in the path /srv/salt on the server.", + "comments": "", + "x": 693, + "y": 86, + "z": "b84dc629.83cd08", + "wires": [] + } +] \ No newline at end of file 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 new file mode 100644 index 000000000..c112723c3 --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-SLSFile.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..852545879 --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.json @@ -0,0 +1,399 @@ +[ + { + "id": "65f5c0d6.9c4ce", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 615, + "y": 273, + "z": "6df02477.0463cc", + "wires": [ + [ + "c332cb01.51a3e8" + ] + ] + }, + { + "id": "bf71bd6e.1be5b", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "", + "outputs": 1, + "x": 406, + "y": 351, + "z": "6df02477.0463cc", + "wires": [ + [ + "65f5c0d6.9c4ce" + ] + ] + }, + { + "id": "40ce8a6.5f7d174", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 1325, + "y": 455, + "z": "6df02477.0463cc", + "wires": [] + }, + { + "id": "c332cb01.51a3e8", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 824, + "y": 275, + "z": "6df02477.0463cc", + "wires": [ + [ + "5b387684.e51be8", + "4bb6b32e.adfc2c" + ] + ] + }, + { + "id": "16dfbd4f.b6da73", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 607, + "y": 435, + "z": "6df02477.0463cc", + "wires": [ + [ + "24d22f52.ef59a", + "ac765880.a6c548" + ] + ] + }, + { + "id": "24d22f52.ef59a", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 798, + "y": 433, + "z": "6df02477.0463cc", + "wires": [ + [ + "40ce8a6.5f7d174" + ] + ] + }, + { + "id": "5b387684.e51be8", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 1074, + "y": 272, + "z": "6df02477.0463cc", + "wires": [ + [ + "40ce8a6.5f7d174" + ] + ] + }, + { + "id": "4bb6b32e.adfc2c", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 429, + "y": 433, + "z": "6df02477.0463cc", + "wires": [ + [ + "16dfbd4f.b6da73" + ] + ] + }, + { + "id": "ac765880.a6c548", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 414, + "y": 549, + "z": "6df02477.0463cc", + "wires": [ + [ + "2dda30fc.8747" + ] + ] + }, + { + "id": "e45accfe.91615", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\n", + "comments": "", + "x": 1345, + "y": 757, + "z": "6df02477.0463cc", + "wires": [] + }, + { + "id": "11a891ad.55bc1e", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 384, + "y": 251, + "z": "6df02477.0463cc", + "wires": [ + [ + "bf71bd6e.1be5b" + ] + ] + }, + { + "id": "a56383b.496c48", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 756, + "y": 134, + "z": "6df02477.0463cc", + "wires": [] + }, + { + "id": "cfda30b5.5e166", + "type": "comment", + "name": "request-method = reqExecCommand, req-action = \"execute multiple SLS commands\"", + "info": "Here we basically test if minion1 is active by pinging to it, then install vim package to it. \n", + "comments": "", + "x": 773, + "y": 217, + "z": "6df02477.0463cc", + "wires": [] + }, + { + "id": "a8efb922.f23ce8", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 459, + "y": 751, + "z": "6df02477.0463cc", + "wires": [ + [ + "3ff32215.20cd0e" + ] + ] + }, + { + "id": "df0c0907.d17838", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 836, + "y": 638, + "z": "6df02477.0463cc", + "wires": [ + [ + "1e5bbe2e.9cbb82", + "a8efb922.f23ce8" + ] + ] + }, + { + "id": "1e5bbe2e.9cbb82", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 1054, + "y": 644, + "z": "6df02477.0463cc", + "wires": [ + [ + "40ce8a6.5f7d174" + ] + ] + }, + { + "id": "3ff32215.20cd0e", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 647, + "y": 745, + "z": "6df02477.0463cc", + "wires": [ + [ + "8e2c712b.784b4", + "3d74cfe5.d41f5" + ] + ] + }, + { + "id": "8e2c712b.784b4", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 830, + "y": 823, + "z": "6df02477.0463cc", + "wires": [ + [ + "40ce8a6.5f7d174" + ] + ] + }, + { + "id": "3d74cfe5.d41f5", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 829, + "y": 758, + "z": "6df02477.0463cc", + "wires": [ + [ + "8313564b.004798" + ] + ] + }, + { + "id": "2dda30fc.8747", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 586, + "y": 549, + "z": "6df02477.0463cc", + "wires": [ + [ + "e0133af5.2ca028", + "7f28f521.cf47cc" + ] + ] + }, + { + "id": "7f28f521.cf47cc", + "type": "other", + "name": "outcome", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 656, + "y": 640, + "z": "6df02477.0463cc", + "wires": [ + [ + "df0c0907.d17838" + ] + ] + }, + { + "id": "e0133af5.2ca028", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 780, + "y": 549, + "z": "6df02477.0463cc", + "wires": [ + [ + "40ce8a6.5f7d174" + ] + ] + }, + { + "id": "8313564b.004798", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 986, + "y": 752, + "z": "6df02477.0463cc", + "wires": [ + [ + "13d18d2d.71fbf3", + "2e940add.522a36" + ] + ] + }, + { + "id": "13d18d2d.71fbf3", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 1165, + "y": 825, + "z": "6df02477.0463cc", + "wires": [ + [ + "40ce8a6.5f7d174" + ] + ] + }, + { + "id": "2e940add.522a36", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 1156, + "y": 754, + "z": "6df02477.0463cc", + "wires": [ + [ + "e45accfe.91615" + ] + ] + }, + { + "id": "6d6678d2.6a9bd8", + "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 controlls minion1 and minion2. ", + "comments": "", + "x": 756, + "y": 173, + "z": "6df02477.0463cc", + "wires": [] + } +] \ No newline at end of file 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 new file mode 100644 index 000000000..0e5e17c42 --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-multi-sls.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 new file mode 100644 index 000000000..a8535d00e --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.json @@ -0,0 +1,203 @@ +[ + { + "id": "bd0f1105.ff214", + "type": "method", + "name": "saltstack-adapter-1.0", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 526, + "y": 238, + "z": "c053ae12.4067b", + "wires": [ + [ + "f4e59dd0.ee45f" + ] + ] + }, + { + "id": "26f2a2b8.90f58e", + "type": "service-logic", + "name": "APPC 2.0.1", + "module": "APPC", + "version": "2.0.1", + "comments": "", + "xml": "", + "outputs": 1, + "x": 317, + "y": 316, + "z": "c053ae12.4067b", + "wires": [ + [ + "bd0f1105.ff214" + ] + ] + }, + { + "id": "55a7736.2789e8c", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 1064, + "y": 453, + "z": "c053ae12.4067b", + "wires": [] + }, + { + "id": "f4e59dd0.ee45f", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 735, + "y": 240, + "z": "c053ae12.4067b", + "wires": [ + [ + "93fca622.05ad58", + "7ce4a659.44c828" + ] + ] + }, + { + "id": "2ceb37d9.a8ba18", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 522, + "y": 398, + "z": "c053ae12.4067b", + "wires": [ + [ + "cd89356c.279678", + "781026e2.01d498" + ] + ] + }, + { + "id": "cd89356c.279678", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 708, + "y": 456, + "z": "c053ae12.4067b", + "wires": [ + [ + "55a7736.2789e8c" + ] + ] + }, + { + "id": "93fca622.05ad58", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 985, + "y": 237, + "z": "c053ae12.4067b", + "wires": [ + [ + "55a7736.2789e8c" + ] + ] + }, + { + "id": "7ce4a659.44c828", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 332, + "y": 405, + "z": "c053ae12.4067b", + "wires": [ + [ + "2ceb37d9.a8ba18" + ] + ] + }, + { + "id": "781026e2.01d498", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 711, + "y": 398, + "z": "c053ae12.4067b", + "wires": [ + [ + "ce510062.8dcc7" + ] + ] + }, + { + "id": "ce510062.8dcc7", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\n", + "comments": "", + "x": 893, + "y": 399, + "z": "c053ae12.4067b", + "wires": [] + }, + { + "id": "593bd7fb.675368", + "type": "dgstart", + "name": "DGSTART", + "outputs": 1, + "x": 295, + "y": 216, + "z": "c053ae12.4067b", + "wires": [ + [ + "26f2a2b8.90f58e" + ] + ] + }, + { + "id": "901c8408.5fecb8", + "type": "comment", + "name": "SaltStack Adaptor DG", + "info": "", + "comments": "", + "x": 673, + "y": 103, + "z": "c053ae12.4067b", + "wires": [] + }, + { + "id": "cc449713.a1be88", + "type": "comment", + "name": "request-method = reqExecCommand, req-action = \"execute a single SLS command\"", + "info": "Here we just ping to all the minions, and we dont even check if the minions are active. ", + "comments": "", + "x": 684, + "y": 188, + "z": "c053ae12.4067b", + "wires": [] + }, + { + "id": "c07fa80e.7f3ac8", + "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 controlls minion1 and minion2. ", + "comments": "", + "x": 676, + "y": 144, + "z": "c053ae12.4067b", + "wires": [] + } +] \ No newline at end of file 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 new file mode 100644 index 000000000..57620f58a --- /dev/null +++ b/saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand/APPC_saltstack-adapter-1.0-exec-single-SLSComm.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From f8ebec657389d40a88442b5a9be1a18254bbdbfd Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Wed, 18 Jul 2018 15:27:52 +0900 Subject: saltstack to take env and file param Issue-ID: CCSDK-383 Change-Id: Id069d77d8f11203a2f604470c116bcf3cc618c2f Signed-off-by: Ganesh Chandrasekaran --- saltstack-adapter/README.md | 32 +- saltstack-adapter/pom.xml | 8 +- .../saltstack-adapter-features/.gitignore | 6 +- .../saltstack-adapter-features/pom.xml | 9 +- .../src/main/resources/features.xml | 8 +- .../saltstack-adapter-installer/pom.xml | 8 +- .../src/assembly/assemble_installer_zip.xml | 8 +- .../src/assembly/assemble_mvnrepo_zip.xml | 8 +- .../src/main/resources/scripts/install-feature.sh | 6 +- .../saltstack-adapter-provider/.gitignore | 6 +- .../saltstack-adapter-provider/pom.xml | 9 +- .../sli/adaptors/saltstack/SaltstackAdapter.java | 8 +- .../adaptors/saltstack/impl/ConnectionBuilder.java | 8 +- .../saltstack/impl/SaltstackAdapterImpl.java | 84 +++-- .../sli/adaptors/saltstack/impl/SshConnection.java | 13 +- .../sli/adaptors/saltstack/model/JsonParser.java | 2 +- .../saltstack/model/SaltstackMessageParser.java | 110 +++++- .../adaptors/saltstack/model/SaltstackResult.java | 8 +- .../saltstack/model/SaltstackResultCodes.java | 8 +- .../saltstack/model/SaltstackServerEmulator.java | 8 +- .../blueprint/saltstack-adapter-blueprint.xml | 2 +- .../main/resources/saltstack-adapter.properties | 8 +- .../ccsdk/adapter/impl/TestConnectionBuilder.java | 8 +- .../adapter/impl/TestSaltstackAdapterImpl.java | 309 ++++++++++++----- ...TestSaltstackAdapterPropertiesProviderImpl.java | 8 +- .../onap/ccsdk/adapter/model/TestJsonParser.java | 2 +- .../resources/org/onap/ccsdk/default.properties | 8 +- .../APPC_saltstack-adapter-1.0-exe-nonSLS.json | 6 +- .../APPC_saltstack-adapter-1.0-exe-nonSLS.xml | 8 +- .../APPC_saltstack-adapter-1.0-exec-SLSFile.json | 4 +- .../APPC_saltstack-adapter-1.0-exec-SLSFile.xml | 16 +- .../APPC_saltstack-adapter-1.0-exec-multi-sls.json | 4 +- .../APPC_saltstack-adapter-1.0-exec-multi-sls.xml | 32 +- ..._saltstack-adapter-1.0-exec-single-SLSComm.json | 2 +- ...C_saltstack-adapter-1.0-exec-single-SLSComm.xml | 8 +- .../APPC_saltstack-adapter-1.0 IDEAL.json | 215 +++++++++++- .../APPC_saltstack-adapter-1.0 IDEAL.xml | 78 +++-- ...PPC_saltstack-adapter-1.0-exec-SLS-applyTo.json | 373 ++++++++++++++++++++- ...APPC_saltstack-adapter-1.0-exec-SLS-applyTo.xml | 169 ++++++---- .../APPC_saltstack-adapter-1.0-SLSFILE.json | 215 +++++++++++- .../APPC_saltstack-adapter-1.0-SLSFILE.xml | 74 ++-- ...saltstack-adapter-1.0-exec-SLSFile-applyTo.json | 373 ++++++++++++++++++++- ..._saltstack-adapter-1.0-exec-SLSFile-applyTo.xml | 169 ++++++---- .../staltstack-example-server/README.md | 206 ++++++++++-- .../saltstack_sample_sls-2.yml | 8 +- .../saltstact_sample_sls.yml | 8 +- 46 files changed, 2204 insertions(+), 466 deletions(-) (limited to 'saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand') diff --git a/saltstack-adapter/README.md b/saltstack-adapter/README.md index 87c43f986..6d40af7a6 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. 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 --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 --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 c8c1db26b..34688deec 100644 --- a/saltstack-adapter/pom.xml +++ b/saltstack-adapter/pom.xml @@ -1,11 +1,11 @@ diff --git a/saltstack-adapter/saltstack-adapter-features/.gitignore b/saltstack-adapter/saltstack-adapter-features/.gitignore index 8820cee57..e1ca0dee0 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 3b94b2fd4..6f765c8fb 100644 --- a/saltstack-adapter/saltstack-adapter-features/pom.xml +++ b/saltstack-adapter/saltstack-adapter-features/pom.xml @@ -1,16 +1,15 @@ + language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> 4.0.0 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 5359d8088..6eef6d27c 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 @@ diff --git a/saltstack-adapter/saltstack-adapter-installer/pom.xml b/saltstack-adapter/saltstack-adapter-installer/pom.xml index 0853179f9..b600aed6a 100644 --- a/saltstack-adapter/saltstack-adapter-installer/pom.xml +++ b/saltstack-adapter/saltstack-adapter-installer/pom.xml @@ -1,11 +1,11 @@ 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 322fa76eb..7d212cbb5 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 @@ 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 ec65e79e1..93df6602b 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 @@ 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 c8214c520..38782cabb 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 255b54097..4e1ad823a 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 41bf7c679..c93558e8f 100644 --- a/saltstack-adapter/saltstack-adapter-provider/pom.xml +++ b/saltstack-adapter/saltstack-adapter-provider/pom.xml @@ -1,17 +1,16 @@ + language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> 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 cdfe4ff7b..346910a39 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 bd811fffb..f6b3b70cb 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 acd3db20d..5373c227a 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 d8616920b..62724c364 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 be1fa5747..0eb1fc0e8 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 f7c513c92..3095fca9b 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 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 params) { @@ -208,6 +215,77 @@ public class SaltstackMessageParser { return Long.parseLong(params.get(SaltstackMessageParser.EXEC_TIMEOUT_TO_APPLY)); } + /** + * Method that validates that the Map has enough information + * to query Saltstack server for a result. If so, it returns + * the appropriate EnvParameters to execute the SLS file. + */ + public JSONObject reqEnvParameters(Map 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 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 params, String[] optionalTestParams, JSONObject jsonPayload) + throws JSONException { + + Set 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 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 @@ -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 f6ea0b427..b29dd8e80 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 32871ff06..92a611683 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 1b62e4bdb..55beb2294 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 df5c46d37..2c3b7b04e 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 ccaea20c6..0b077524d 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 933f3fcf7..266147aad 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 50bf75826..a0d36046c 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", ""); + 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", ""); + 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", ""); + 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", ""); + 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", ""); + 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 d5699c4c9..deb46534f 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 74e7ed0c4..ed1e02c4e 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 2f8fb4585..3e7e2bcc4 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 3a287e341..562c24ad3 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": "\n\n\n\n", + "xml": "\n\n\n\n", "comments": "", "x": 1007, "y": 373, @@ -48,7 +48,7 @@ "id": "38662e01.1d3c22", "type": "execute", "name": "execute", - "xml": "\n \n \n \n \n \n \n \n \n", + "xml": "\n \n \n \n \n \n \n \n \n", "comments": "", "outputs": 1, "x": 700, @@ -146,7 +146,7 @@ "id": "1f81a3db.54cd1c", "type": "returnSuccess", "name": "return success", - "xml": "\n\n\n\n", + "xml": "\n\n\n\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 eadf33619..e28bbc2a1 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'> - - - - + + + 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 95178ac26..deefddf34 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": "\n \n \n \n \n \n \n \n \n", + "xml": "\n \n \n \n \n \n \n \n \n", "comments": "", "outputs": 1, "x": 761, @@ -209,7 +209,7 @@ "id": "770411a5.18825", "type": "execute", "name": "execute", - "xml": "\n \n \n \n \n \n \n \n \n", + "xml": "\n \n \n \n \n \n \n \n \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 c112723c3..9861351d7 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'> - - - - + + @@ -47,7 +47,7 @@ @@ -56,10 +56,10 @@ - - - + 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 852545879..1b891a20c 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": "\n \n \n \n \n \n \n \n \n", + "xml": "\n \n \n \n \n \n \n \n \n", "comments": "", "outputs": 1, "x": 824, @@ -209,7 +209,7 @@ "id": "df0c0907.d17838", "type": "execute", "name": "execute", - "xml": "\n \n \n \n \n \n \n \n \n", + "xml": "\n \n \n \n \n \n \n \n \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 0e5e17c42..404ac7acf 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'> - - - - + + + value='`$org.openecomp.appc.adapter.saltstack.message`'/> + value='`$org.openecomp.appc.adapter.saltstack.results`'/> @@ -29,9 +29,9 @@ + value='`$org.openecomp.appc.adapter.saltstack.message`'/> + value='`$org.openecomp.appc.adapter.saltstack.results`'/> @@ -40,14 +40,14 @@ + value='`$org.openecomp.appc.adapter.saltstack.message`'/> + value='`$org.openecomp.appc.adapter.saltstack.results`'/> @@ -56,20 +56,20 @@ - - - + + value='`$org.openecomp.appc.adapter.saltstack.message`'/> + value='`$org.openecomp.appc.adapter.saltstack.results`'/> 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 a8535d00e..920e1145a 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": "\n \n \n \n \n \n \n \n \n", + "xml": "\n \n \n \n \n \n \n \n \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 57620f58a..dfc4691dd 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'> - - - - + + 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 875c6faaf..7fe88f063 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":"\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":"","outputs":1,"x":366,"y":220,"z":"8c500c8b.91561","wires":[["b9234075.7e20b"]]},{"id":"f809843e.12d3b8","type":"returnSuccess","name":"return success","xml":"\n\n\n\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":"\n \n \n \n \n \n \n","comments":"","outputs":1,"x":279,"y":350,"z":"8c500c8b.91561","wires":[["953d6f9.633bc9","2b0177ad.6a0c88"]]},{"id":"953d6f9.633bc9","type":"failure","name":"failure","xml":"\n","comments":"","outputs":1,"x":472,"y":311,"z":"8c500c8b.91561","wires":[["56ac40b9.ab7d9"]]},{"id":"2b0177ad.6a0c88","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":470,"y":383,"z":"8c500c8b.91561","wires":[["245f2c0b.5f8894"]]},{"id":"245f2c0b.5f8894","type":"switchNode","name":"switch","xml":"\n","comments":"","outputs":1,"x":622,"y":371,"z":"8c500c8b.91561","wires":[["9cb78c41.7c1fc","a2c5d59b.172848"]]},{"id":"a2c5d59b.172848","type":"success","name":"success","xml":"\n","comments":"","outputs":1,"x":785,"y":317,"z":"8c500c8b.91561","wires":[["f809843e.12d3b8"]]},{"id":"9cb78c41.7c1fc","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":782,"y":386,"z":"8c500c8b.91561","wires":[["2ca5c925.6ee136"]]},{"id":"56ac40b9.ab7d9","type":"returnFailure","name":"return failure","xml":"\n\n\n\n","comments":"","x":632,"y":295,"z":"8c500c8b.91561","wires":[]},{"id":"2ca5c925.6ee136","type":"returnFailure","name":"return failure","xml":"\n\n\n\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": "\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": "", + "outputs": 1, + "x": 453, + "y": 276, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "80b83851.e527b8" + ] + ] + }, + { + "id": "1f4a794d.fb3be7", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\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": "\n \n \n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 366, + "y": 406, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "b83f5a23.33f938", + "3354190.eb450e8" + ] + ] + }, + { + "id": "b83f5a23.33f938", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 559, + "y": 367, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "efc02e73.0cf1d" + ] + ] + }, + { + "id": "3354190.eb450e8", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 557, + "y": 439, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "88b53985.e42758" + ] + ] + }, + { + "id": "88b53985.e42758", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 709, + "y": 427, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "195a294e.61efb7", + "bc1bfd78.146bc" + ] + ] + }, + { + "id": "bc1bfd78.146bc", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 872, + "y": 373, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "1f4a794d.fb3be7" + ] + ] + }, + { + "id": "195a294e.61efb7", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 869, + "y": 442, + "z": "1f6661d7.1ebd2e", + "wires": [ + [ + "81ddc2e0.dce24" + ] + ] + }, + { + "id": "efc02e73.0cf1d", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 719, + "y": 351, + "z": "1f6661d7.1ebd2e", + "wires": [] + }, + { + "id": "81ddc2e0.dce24", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\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 8a237f3f8..23ec7856b 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 f8c6a015d..b276f3815 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":"\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":"","outputs":1,"x":267,"y":323,"z":"671ca899.284f68","wires":[["edb39979.b1ccd8"]]},{"id":"1591f92e.029ca7","type":"returnFailure","name":"return failure","xml":"\n\n\n\n","comments":"","x":1191,"y":315,"z":"671ca899.284f68","wires":[]},{"id":"95c9ba42.6e4aa8","type":"execute","name":"execute","xml":"\n \n \n \n \n \n \n \n \n","comments":"","outputs":1,"x":684,"y":251,"z":"671ca899.284f68","wires":[["cd0c458a.2430b8","69e531e3.4efc3"]]},{"id":"38b44d70.9c85d2","type":"switchNode","name":"switch","xml":"\n","comments":"","outputs":1,"x":472,"y":405,"z":"671ca899.284f68","wires":[["505df598.069b9c","5d7292e.22ec06c"]]},{"id":"505df598.069b9c","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":658,"y":463,"z":"671ca899.284f68","wires":[["1591f92e.029ca7"]]},{"id":"cd0c458a.2430b8","type":"failure","name":"failure","xml":"\n","comments":"","outputs":1,"x":935,"y":244,"z":"671ca899.284f68","wires":[["1591f92e.029ca7"]]},{"id":"69e531e3.4efc3","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":282,"y":412,"z":"671ca899.284f68","wires":[["38b44d70.9c85d2"]]},{"id":"5d7292e.22ec06c","type":"success","name":"success","xml":"\n","comments":"","outputs":1,"x":661,"y":405,"z":"671ca899.284f68","wires":[["c9df0cea.f2361"]]},{"id":"e4f7eb59.0abb58","type":"returnSuccess","name":"return success","xml":"\n\n\n\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":"\n","comments":"","outputs":1,"x":825,"y":405,"z":"671ca899.284f68","wires":[["d83d6024.2454d","f4d70bbc.f0bc38"]]},{"id":"d83d6024.2454d","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":991,"y":459,"z":"671ca899.284f68","wires":[["1591f92e.029ca7"]]},{"id":"f4d70bbc.f0bc38","type":"other","name":"outcome","xml":"\n","comments":"","outputs":1,"x":994,"y":401,"z":"671ca899.284f68","wires":[["e86d9995.b65c58"]]},{"id":"e86d9995.b65c58","type":"execute","name":"execute","xml":"\n \n \n \n \n \n \n \n \n","comments":"","outputs":1,"x":398,"y":593,"z":"671ca899.284f68","wires":[["89ff1c2a.08f52","e20c4c85.43d3c"]]},{"id":"89ff1c2a.08f52","type":"failure","name":"failure","xml":"\n","comments":"","outputs":1,"x":583,"y":562,"z":"671ca899.284f68","wires":[["6032e33e.5b044c"]]},{"id":"e20c4c85.43d3c","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":581,"y":634,"z":"671ca899.284f68","wires":[["8bb4c177.499c8"]]},{"id":"8bb4c177.499c8","type":"switchNode","name":"switch","xml":"\n","comments":"","outputs":1,"x":733,"y":622,"z":"671ca899.284f68","wires":[["905334fe.934d68","9c217c10.9d539"]]},{"id":"9c217c10.9d539","type":"success","name":"success","xml":"\n","comments":"","outputs":1,"x":896,"y":568,"z":"671ca899.284f68","wires":[["e4f7eb59.0abb58"]]},{"id":"905334fe.934d68","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":893,"y":637,"z":"671ca899.284f68","wires":[["7026a88c.5bffd8"]]},{"id":"6032e33e.5b044c","type":"returnFailure","name":"return failure","xml":"\n\n\n\n","comments":"","x":735,"y":559,"z":"671ca899.284f68","wires":[]},{"id":"7026a88c.5bffd8","type":"returnFailure","name":"return failure","xml":"\n\n\n\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": "\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": "", + "outputs": 1, + "x": 267, + "y": 323, + "z": "671ca899.284f68", + "wires": [ + [ + "edb39979.b1ccd8" + ] + ] + }, + { + "id": "1591f92e.029ca7", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 1191, + "y": 315, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "95c9ba42.6e4aa8", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 684, + "y": 251, + "z": "671ca899.284f68", + "wires": [ + [ + "cd0c458a.2430b8", + "69e531e3.4efc3" + ] + ] + }, + { + "id": "38b44d70.9c85d2", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 472, + "y": 405, + "z": "671ca899.284f68", + "wires": [ + [ + "505df598.069b9c", + "5d7292e.22ec06c" + ] + ] + }, + { + "id": "505df598.069b9c", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 658, + "y": 463, + "z": "671ca899.284f68", + "wires": [ + [ + "1591f92e.029ca7" + ] + ] + }, + { + "id": "cd0c458a.2430b8", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 935, + "y": 244, + "z": "671ca899.284f68", + "wires": [ + [ + "1591f92e.029ca7" + ] + ] + }, + { + "id": "69e531e3.4efc3", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 282, + "y": 412, + "z": "671ca899.284f68", + "wires": [ + [ + "38b44d70.9c85d2" + ] + ] + }, + { + "id": "5d7292e.22ec06c", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 661, + "y": 405, + "z": "671ca899.284f68", + "wires": [ + [ + "c9df0cea.f2361" + ] + ] + }, + { + "id": "e4f7eb59.0abb58", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\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": "\n", + "comments": "", + "outputs": 1, + "x": 825, + "y": 405, + "z": "671ca899.284f68", + "wires": [ + [ + "d83d6024.2454d", + "f4d70bbc.f0bc38" + ] + ] + }, + { + "id": "d83d6024.2454d", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 991, + "y": 459, + "z": "671ca899.284f68", + "wires": [ + [ + "1591f92e.029ca7" + ] + ] + }, + { + "id": "f4d70bbc.f0bc38", + "type": "other", + "name": "outcome", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 994, + "y": 401, + "z": "671ca899.284f68", + "wires": [ + [ + "e86d9995.b65c58" + ] + ] + }, + { + "id": "e86d9995.b65c58", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 398, + "y": 593, + "z": "671ca899.284f68", + "wires": [ + [ + "89ff1c2a.08f52", + "e20c4c85.43d3c" + ] + ] + }, + { + "id": "89ff1c2a.08f52", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 583, + "y": 562, + "z": "671ca899.284f68", + "wires": [ + [ + "6032e33e.5b044c" + ] + ] + }, + { + "id": "e20c4c85.43d3c", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 581, + "y": 634, + "z": "671ca899.284f68", + "wires": [ + [ + "8bb4c177.499c8" + ] + ] + }, + { + "id": "8bb4c177.499c8", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 733, + "y": 622, + "z": "671ca899.284f68", + "wires": [ + [ + "905334fe.934d68", + "9c217c10.9d539" + ] + ] + }, + { + "id": "9c217c10.9d539", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 896, + "y": 568, + "z": "671ca899.284f68", + "wires": [ + [ + "e4f7eb59.0abb58" + ] + ] + }, + { + "id": "905334fe.934d68", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 893, + "y": 637, + "z": "671ca899.284f68", + "wires": [ + [ + "7026a88c.5bffd8" + ] + ] + }, + { + "id": "6032e33e.5b044c", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 735, + "y": 559, + "z": "671ca899.284f68", + "wires": [] + }, + { + "id": "7026a88c.5bffd8", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\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 a82628855..cc4538cac 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 a4ec6f1b7..b20e7e8da 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":"\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":"","outputs":1,"x":456,"y":281,"z":"6d4f912d.f07bc","wires":[["3228200a.5dc1a"]]},{"id":"49109fbc.a7a14","type":"returnSuccess","name":"return success","xml":"\n\n\n\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":"\n \n \n \n \n \n \n","comments":"","outputs":1,"x":369,"y":411,"z":"6d4f912d.f07bc","wires":[["71746570.35f0dc","3e4f7a4a.ae0dc6"]]},{"id":"71746570.35f0dc","type":"failure","name":"failure","xml":"\n","comments":"","outputs":1,"x":562,"y":372,"z":"6d4f912d.f07bc","wires":[["e59a1a81.112a08"]]},{"id":"3e4f7a4a.ae0dc6","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":560,"y":444,"z":"6d4f912d.f07bc","wires":[["59e320fa.12908"]]},{"id":"59e320fa.12908","type":"switchNode","name":"switch","xml":"\n","comments":"","outputs":1,"x":712,"y":432,"z":"6d4f912d.f07bc","wires":[["f81ed07.2135c3","eb55b5a9.f0d2f8"]]},{"id":"eb55b5a9.f0d2f8","type":"success","name":"success","xml":"\n","comments":"","outputs":1,"x":875,"y":378,"z":"6d4f912d.f07bc","wires":[["49109fbc.a7a14"]]},{"id":"f81ed07.2135c3","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":872,"y":447,"z":"6d4f912d.f07bc","wires":[["6549631f.8e516c"]]},{"id":"e59a1a81.112a08","type":"returnFailure","name":"return failure","xml":"\n\n\n\n","comments":"","x":722,"y":356,"z":"6d4f912d.f07bc","wires":[]},{"id":"6549631f.8e516c","type":"returnFailure","name":"return failure","xml":"\n\n\n\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": "\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": "", + "outputs": 1, + "x": 456, + "y": 281, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "3228200a.5dc1a" + ] + ] + }, + { + "id": "49109fbc.a7a14", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\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": "\n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 369, + "y": 411, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "71746570.35f0dc", + "3e4f7a4a.ae0dc6" + ] + ] + }, + { + "id": "71746570.35f0dc", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 562, + "y": 372, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "e59a1a81.112a08" + ] + ] + }, + { + "id": "3e4f7a4a.ae0dc6", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 560, + "y": 444, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "59e320fa.12908" + ] + ] + }, + { + "id": "59e320fa.12908", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 712, + "y": 432, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "f81ed07.2135c3", + "eb55b5a9.f0d2f8" + ] + ] + }, + { + "id": "eb55b5a9.f0d2f8", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 875, + "y": 378, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "49109fbc.a7a14" + ] + ] + }, + { + "id": "f81ed07.2135c3", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 872, + "y": 447, + "z": "6d4f912d.f07bc", + "wires": [ + [ + "6549631f.8e516c" + ] + ] + }, + { + "id": "e59a1a81.112a08", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 722, + "y": 356, + "z": "6d4f912d.f07bc", + "wires": [] + }, + { + "id": "6549631f.8e516c", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\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 bd3325b3f..2c5e600fc 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 de4f0fbb9..264950d5e 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":"\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":"","outputs":1,"x":289,"y":318,"z":"723548c7.652d78","wires":[["9a6bf94f.d969f8"]]},{"id":"6c593992.106038","type":"returnFailure","name":"return failure","xml":"\n\n\n\n","comments":"","x":1202,"y":280,"z":"723548c7.652d78","wires":[]},{"id":"138ad7ed.403248","type":"execute","name":"execute","xml":"\n \n \n \n \n \n \n \n \n","comments":"","outputs":1,"x":706,"y":246,"z":"723548c7.652d78","wires":[["167273ed.f0577c","954a34ea.701368"]]},{"id":"d5841e65.537ba","type":"switchNode","name":"switch","xml":"\n","comments":"","outputs":1,"x":494,"y":400,"z":"723548c7.652d78","wires":[["ede42371.2f52b","d306d7a0.c830e8"]]},{"id":"ede42371.2f52b","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":680,"y":458,"z":"723548c7.652d78","wires":[["6c593992.106038"]]},{"id":"167273ed.f0577c","type":"failure","name":"failure","xml":"\n","comments":"","outputs":1,"x":957,"y":239,"z":"723548c7.652d78","wires":[["6c593992.106038"]]},{"id":"954a34ea.701368","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":304,"y":407,"z":"723548c7.652d78","wires":[["d5841e65.537ba"]]},{"id":"d306d7a0.c830e8","type":"success","name":"success","xml":"\n","comments":"","outputs":1,"x":683,"y":400,"z":"723548c7.652d78","wires":[["5b12ba31.94b3b4"]]},{"id":"9ef7fcc3.69279","type":"returnSuccess","name":"return success","xml":"\n\n\n\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":"\n","comments":"","outputs":1,"x":847,"y":400,"z":"723548c7.652d78","wires":[["9bf0915.96f217","f6e533d.95d99d"]]},{"id":"9bf0915.96f217","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":1013,"y":454,"z":"723548c7.652d78","wires":[["6c593992.106038"]]},{"id":"f6e533d.95d99d","type":"other","name":"outcome","xml":"\n","comments":"","outputs":1,"x":1016,"y":396,"z":"723548c7.652d78","wires":[["eb57ba41.1d7328"]]},{"id":"eb57ba41.1d7328","type":"execute","name":"execute","xml":"\n \n \n \n \n \n \n \n \n","comments":"","outputs":1,"x":420,"y":588,"z":"723548c7.652d78","wires":[["892a8f1d.7d77f","74be8a6e.975f24"]]},{"id":"892a8f1d.7d77f","type":"failure","name":"failure","xml":"\n","comments":"","outputs":1,"x":605,"y":557,"z":"723548c7.652d78","wires":[["8c091fe.c6cbfe"]]},{"id":"74be8a6e.975f24","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":603,"y":629,"z":"723548c7.652d78","wires":[["3875d695.fd37ca"]]},{"id":"3875d695.fd37ca","type":"switchNode","name":"switch","xml":"\n","comments":"","outputs":1,"x":755,"y":617,"z":"723548c7.652d78","wires":[["2e60af80.ea3a6","24ed6dd2.6624c2"]]},{"id":"24ed6dd2.6624c2","type":"success","name":"success","xml":"\n","comments":"","outputs":1,"x":918,"y":563,"z":"723548c7.652d78","wires":[["9ef7fcc3.69279"]]},{"id":"2e60af80.ea3a6","type":"other","name":"other","xml":"\n","comments":"","outputs":1,"x":915,"y":632,"z":"723548c7.652d78","wires":[["2e4414a7.ba6d4c"]]},{"id":"8c091fe.c6cbfe","type":"returnFailure","name":"return failure","xml":"\n\n\n\n","comments":"","x":757,"y":554,"z":"723548c7.652d78","wires":[]},{"id":"2e4414a7.ba6d4c","type":"returnFailure","name":"return failure","xml":"\n\n\n\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": "\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": "", + "outputs": 1, + "x": 289, + "y": 318, + "z": "723548c7.652d78", + "wires": [ + [ + "9a6bf94f.d969f8" + ] + ] + }, + { + "id": "6c593992.106038", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 1202, + "y": 280, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "138ad7ed.403248", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 706, + "y": 246, + "z": "723548c7.652d78", + "wires": [ + [ + "167273ed.f0577c", + "954a34ea.701368" + ] + ] + }, + { + "id": "d5841e65.537ba", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 494, + "y": 400, + "z": "723548c7.652d78", + "wires": [ + [ + "ede42371.2f52b", + "d306d7a0.c830e8" + ] + ] + }, + { + "id": "ede42371.2f52b", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 680, + "y": 458, + "z": "723548c7.652d78", + "wires": [ + [ + "6c593992.106038" + ] + ] + }, + { + "id": "167273ed.f0577c", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 957, + "y": 239, + "z": "723548c7.652d78", + "wires": [ + [ + "6c593992.106038" + ] + ] + }, + { + "id": "954a34ea.701368", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 304, + "y": 407, + "z": "723548c7.652d78", + "wires": [ + [ + "d5841e65.537ba" + ] + ] + }, + { + "id": "d306d7a0.c830e8", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 683, + "y": 400, + "z": "723548c7.652d78", + "wires": [ + [ + "5b12ba31.94b3b4" + ] + ] + }, + { + "id": "9ef7fcc3.69279", + "type": "returnSuccess", + "name": "return success", + "xml": "\n\n\n\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": "\n", + "comments": "", + "outputs": 1, + "x": 847, + "y": 400, + "z": "723548c7.652d78", + "wires": [ + [ + "9bf0915.96f217", + "f6e533d.95d99d" + ] + ] + }, + { + "id": "9bf0915.96f217", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 1013, + "y": 454, + "z": "723548c7.652d78", + "wires": [ + [ + "6c593992.106038" + ] + ] + }, + { + "id": "f6e533d.95d99d", + "type": "other", + "name": "outcome", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 1016, + "y": 396, + "z": "723548c7.652d78", + "wires": [ + [ + "eb57ba41.1d7328" + ] + ] + }, + { + "id": "eb57ba41.1d7328", + "type": "execute", + "name": "execute", + "xml": "\n \n \n \n \n \n \n \n \n", + "comments": "", + "outputs": 1, + "x": 420, + "y": 588, + "z": "723548c7.652d78", + "wires": [ + [ + "892a8f1d.7d77f", + "74be8a6e.975f24" + ] + ] + }, + { + "id": "892a8f1d.7d77f", + "type": "failure", + "name": "failure", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 605, + "y": 557, + "z": "723548c7.652d78", + "wires": [ + [ + "8c091fe.c6cbfe" + ] + ] + }, + { + "id": "74be8a6e.975f24", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 603, + "y": 629, + "z": "723548c7.652d78", + "wires": [ + [ + "3875d695.fd37ca" + ] + ] + }, + { + "id": "3875d695.fd37ca", + "type": "switchNode", + "name": "switch", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 755, + "y": 617, + "z": "723548c7.652d78", + "wires": [ + [ + "2e60af80.ea3a6", + "24ed6dd2.6624c2" + ] + ] + }, + { + "id": "24ed6dd2.6624c2", + "type": "success", + "name": "success", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 918, + "y": 563, + "z": "723548c7.652d78", + "wires": [ + [ + "9ef7fcc3.69279" + ] + ] + }, + { + "id": "2e60af80.ea3a6", + "type": "other", + "name": "other", + "xml": "\n", + "comments": "", + "outputs": 1, + "x": 915, + "y": 632, + "z": "723548c7.652d78", + "wires": [ + [ + "2e4414a7.ba6d4c" + ] + ] + }, + { + "id": "8c091fe.c6cbfe", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\n", + "comments": "", + "x": 757, + "y": 554, + "z": "723548c7.652d78", + "wires": [] + }, + { + "id": "2e4414a7.ba6d4c", + "type": "returnFailure", + "name": "return failure", + "xml": "\n\n\n\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 314cd345c..16c573add 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 beaf32f42..7d9442239 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", ""); + 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", ""); + params.put("HostName", ""); 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", ""); 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", ""); 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", ""); + 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", ""); + 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", ""); + 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", ""); 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", ""); + 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 468d2a24b..b96773e1c 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 bcc7fda9a..84cc917b6 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========================================================= # */ -- cgit 1.2.3-korg From e70da25135855b88571b19c108089b74181996a6 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Fri, 20 Jul 2018 17:53:04 +0900 Subject: Saltstack port not mandatory Issue-ID: CCSDK-390 Change-Id: Ie9448d3a3fbbc7e52e8103ca5da1e2a3e080d58c Signed-off-by: Ganesh Chandrasekaran --- .../saltstack/impl/SaltstackAdapterImpl.java | 16 ++++--- .../sli/adaptors/saltstack/model/JsonParser.java | 2 +- .../saltstack/model/SaltstackMessageParser.java | 51 ++++------------------ .../blueprint/saltstack-adapter-blueprint.xml | 2 +- ...TestSaltstackAdapterPropertiesProviderImpl.java | 6 +-- .../onap/ccsdk/adapter/model/TestJsonParser.java | 2 +- .../APPC_saltstack-adapter-1.0-exe-nonSLS.xml | 16 +++---- .../APPC_saltstack-adapter-1.0-exec-SLSFile.json | 8 ++-- .../APPC_saltstack-adapter-1.0-exec-SLSFile.xml | 30 ++++++------- .../APPC_saltstack-adapter-1.0-exec-multi-sls.json | 8 ++-- .../APPC_saltstack-adapter-1.0-exec-multi-sls.xml | 14 +++--- ..._saltstack-adapter-1.0-exec-single-SLSComm.json | 6 +-- ...C_saltstack-adapter-1.0-exec-single-SLSComm.xml | 16 +++---- 13 files changed, 75 insertions(+), 102 deletions(-) (limited to 'saltstack-adapter/saltstack-directed-graphs-sample/reqExecCommand') 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 5373c227a..5e0cc77eb 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterImpl.java @@ -176,7 +176,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter { logger.info("Creating ssh client connection"); // set path to keystore file String sshHost = props.getProperty(SS_SERVER_HOSTNAME); - String sshPort = props.getProperty(SS_SERVER_PORT); + String sshPort = reqServerPort(props) ; String sshUserName = props.getProperty(SS_SERVER_USERNAME); String sshPassword = props.getProperty(SS_SERVER_PASSWD); sshClient = new ConnectionBuilder(sshHost, sshPort, sshUserName, sshPassword); @@ -184,7 +184,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter { // set path to keystore file String sshKey = props.getProperty(SS_SERVER_SSH_KEY); String sshHost = props.getProperty(SS_SERVER_HOSTNAME); - String sshPort = props.getProperty(SS_SERVER_PORT); + String sshPort = reqServerPort(props); logger.info("Creating ssh client with ssh KEY from " + sshKey); sshClient = new ConnectionBuilder(sshHost, sshPort, sshKey); } else if ("BOTH".equalsIgnoreCase(clientType)) { @@ -193,7 +193,7 @@ public class SaltstackAdapterImpl implements SaltstackAdapter { String sshHost = props.getProperty(SS_SERVER_HOSTNAME); String sshUserName = props.getProperty(SS_SERVER_USERNAME); String sshPassword = props.getProperty(SS_SERVER_PASSWD); - String sshPort = props.getProperty(SS_SERVER_PORT); + String sshPort = reqServerPort(props); logger.info("Creating ssh client with ssh KEY from " + sshKey); sshClient = new ConnectionBuilder(sshHost, sshPort, sshUserName, sshPassword, sshKey); } else { @@ -204,13 +204,19 @@ public class SaltstackAdapterImpl implements SaltstackAdapter { logger.error("Error Initializing Saltstack Adapter due to Unknown Exception", e); throw new SvcLogicException("Saltstack Adapter Property file parsing Error = port in property file has to be an integer."); } catch (Exception e) { - logger.error("Error Initializing Saltstack Adapter due to Unknown Exception", e); + logger.error("Error Initializing Saltstack Adapter due to Exception", e); throw new SvcLogicException("Saltstack Adapter Property file parsing Error = " + e.getMessage()); } - logger.info("Initialized Saltstack Adapter"); } + private String reqServerPort(Properties props) { + // use default port if null + if (props.getProperty(SS_SERVER_PORT) == null) + return "22"; + return props.getProperty(SS_SERVER_PORT); + } + private void setSSHClient(Map params) throws SvcLogicException { if (sshClient == null) { logger.info("saltstack-adapter.properties not defined so reading saltstack host and " + diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java index 0eb1fc0e8..3eb353a17 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/JsonParser.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * openECOMP : SDN-C + * ONAP : CCSDK * ================================================================================ * Copyright (C) 2018 Samsung Electronics. All rights * reserved. diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java index 3095fca9b..8548efc06 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SaltstackMessageParser.java @@ -78,13 +78,9 @@ public class SaltstackMessageParser { * the appropriate PORT number. */ public String reqPortResult(Map params) throws SvcLogicException { - - final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY, - PASS_KEY}; - - for (String key : mandatoryTestParams) { - throwIfMissingMandatoryParam(params, key); - } + // use default port if null + if (params.get(SS_AGENT_PORT_KEY) == null) + return "22"; return params.get(SS_AGENT_PORT_KEY); } @@ -95,12 +91,7 @@ public class SaltstackMessageParser { */ public String reqHostNameResult(Map params) throws SvcLogicException { - final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY, - PASS_KEY}; - - for (String key : mandatoryTestParams) { - throwIfMissingMandatoryParam(params, key); - } + throwIfMissingMandatoryParam(params, SS_AGENT_HOSTNAME_KEY); return params.get(SS_AGENT_HOSTNAME_KEY); } @@ -126,12 +117,7 @@ public class SaltstackMessageParser { */ public String reqCmd(Map params) throws SvcLogicException { - final String[] mandatoryTestParams = {CMD_EXEC, IS_SLS_EXEC}; - - for (String key : mandatoryTestParams) { - throwIfMissingMandatoryParam(params, key); - } - + throwIfMissingMandatoryParam(params, CMD_EXEC); return params.get(SaltstackMessageParser.CMD_EXEC); } @@ -142,12 +128,7 @@ public class SaltstackMessageParser { */ public String reqSlsFile(Map params) throws SvcLogicException { - final String[] mandatoryTestParams = {SLS_FILE_LOCATION}; - - for (String key : mandatoryTestParams) { - throwIfMissingMandatoryParam(params, key); - } - + throwIfMissingMandatoryParam(params, SLS_FILE_LOCATION); return params.get(SaltstackMessageParser.SLS_FILE_LOCATION); } @@ -158,11 +139,7 @@ public class SaltstackMessageParser { */ public String reqSlsName(Map params) throws SvcLogicException { - final String[] mandatoryTestParams = {SLS_NAME}; - - for (String key : mandatoryTestParams) { - throwIfMissingMandatoryParam(params, key); - } + throwIfMissingMandatoryParam(params, SLS_NAME); String slsName = params.get(SaltstackMessageParser.SLS_NAME); try { if (slsName.substring(slsName.lastIndexOf("."), slsName.length()).equalsIgnoreCase(".sls")) { @@ -309,12 +286,7 @@ public class SaltstackMessageParser { */ public String reqUserNameResult(Map params) throws SvcLogicException { - final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY, - PASS_KEY}; - - for (String key : mandatoryTestParams) { - throwIfMissingMandatoryParam(params, key); - } + throwIfMissingMandatoryParam(params, USER_KEY); return params.get(USER_KEY); } @@ -325,12 +297,7 @@ public class SaltstackMessageParser { */ public String reqPasswordResult(Map params) throws SvcLogicException { - final String[] mandatoryTestParams = {SS_AGENT_HOSTNAME_KEY, SS_AGENT_PORT_KEY, USER_KEY, - PASS_KEY}; - - for (String key : mandatoryTestParams) { - throwIfMissingMandatoryParam(params, key); - } + throwIfMissingMandatoryParam(params, PASS_KEY); return params.get(PASS_KEY); } diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml b/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml index 2c3b7b04e..446ab3e44 100755 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/resources/org/opendaylight/blueprint/saltstack-adapter-blueprint.xml @@ -1,7 +1,7 @@