summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dt5972@att.com>2018-03-29 12:31:45 -0400
committerTimoney, Dan (dt5972) <dt5972@att.com>2018-03-29 12:31:45 -0400
commit99fe1a5e5cd8348d6a7e501691d4b78eca97393b (patch)
tree4d4008770a74459ae11a47ac7d35024b6571c239
parentf3a007533b141852f1c6b5acc5d8bfb2b07ed502 (diff)
Add ansible adapter to CCSDK
Copy APP-C Ansible adaptor to CCSDK Change-Id: Ie7f0662befd5cff446f2b2351a233bcfa7d6f4c0 Issue-ID: CCSDK-172 Signed-off-by: Timoney, Dan (dt5972) <dt5972@att.com>
-rw-r--r--ansible-adapter/ansible-adapter-bundle/.gitignore25
-rw-r--r--ansible-adapter/ansible-adapter-bundle/debug-logs/EELF/debug.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/application.log432
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/audit.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/error.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/metrics.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/performance.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/policy.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/security.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/logs/EELF/server.log0
-rw-r--r--ansible-adapter/ansible-adapter-bundle/pom.xml142
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapter.java52
-rwxr-xr-xansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapterPropertiesProvider.java28
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java425
-rwxr-xr-xansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java186
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java199
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java311
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResult.java81
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResultCodes.java93
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleServerEmulator.java137
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/main/resources/ansible-adaptor.properties48
-rwxr-xr-xansible-adapter/ansible-adapter-bundle/src/main/resources/org/opendaylight/blueprint/ansible-adapter-blueprint.xml39
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java130
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/model/TestAnsibleAdapter.java81
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java182
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java454
-rw-r--r--ansible-adapter/ansible-adapter-bundle/src/test/resources/org/onap/appc/default.properties111
-rw-r--r--ansible-adapter/ansible-adapter-features/.gitignore26
-rw-r--r--ansible-adapter/ansible-adapter-features/ccsdk-ansible-adapter/pom.xml47
-rwxr-xr-xansible-adapter/ansible-adapter-features/features-ansible-adapter/pom.xml29
-rw-r--r--ansible-adapter/ansible-adapter-features/pom.xml31
-rw-r--r--ansible-adapter/ansible-adapter-features/src/main/resources/features.xml40
-rw-r--r--ansible-adapter/ansible-adapter-installer/pom.xml152
-rw-r--r--ansible-adapter/ansible-adapter-installer/src/assembly/assemble_installer_zip.xml62
-rw-r--r--ansible-adapter/ansible-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml50
-rw-r--r--ansible-adapter/ansible-adapter-installer/src/main/resources/scripts/install-feature.sh43
-rw-r--r--ansible-adapter/ansible-example-server/AnsibleModule.py170
-rw-r--r--ansible-adapter/ansible-example-server/AnsibleSql.py322
-rw-r--r--ansible-adapter/ansible-example-server/Ansible_inventory27
-rw-r--r--ansible-adapter/ansible-example-server/LoadAnsibleMySql.py207
-rw-r--r--ansible-adapter/ansible-example-server/README103
-rw-r--r--ansible-adapter/ansible-example-server/RestServer.py948
-rw-r--r--ansible-adapter/ansible-example-server/RestServer_config55
-rw-r--r--ansible-adapter/ansible-example-server/ansible_sleep@0.00.yml42
-rw-r--r--ansible-adapter/pom.xml196
-rwxr-xr-xpom.xml1
46 files changed, 5707 insertions, 0 deletions
diff --git a/ansible-adapter/ansible-adapter-bundle/.gitignore b/ansible-adapter/ansible-adapter-bundle/.gitignore
new file mode 100644
index 00000000..255b5409
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/.gitignore
@@ -0,0 +1,25 @@
+# ============LICENSE_START==========================================
+# ONAP : APPC
+# ===================================================================
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the License);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END============================================
+/bin/
+/target/
+/target-ide/
+/.settings/
diff --git a/ansible-adapter/ansible-adapter-bundle/debug-logs/EELF/debug.log b/ansible-adapter/ansible-adapter-bundle/debug-logs/EELF/debug.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/debug-logs/EELF/debug.log
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/application.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/application.log
new file mode 100644
index 00000000..ba4ab0bd
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/application.log
@@ -0,0 +1,432 @@
+2018-03-28 22:52:42,565|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-28 22:52:42,568|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-28 22:52:42,586|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-28 22:52:42,586|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-28 22:52:42,596|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-28 22:52:42,599|||main||||INFO||||||| Got uri
+2018-03-28 22:52:42,601|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-28 22:52:42,602|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-28 22:52:42,606|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-28 22:52:42,606|||main||||INFO||||||| Processing results in response
+2018-03-28 22:52:42,607|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-28 22:52:42,607|||main||||INFO||||||| Iterating through hosts
+2018-03-28 22:52:42,607|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-28 22:52:42,607|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-28 22:52:42,607|||main||||INFO||||||| Request response = FINISHED
+2018-03-28 22:52:42,608|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-28 22:52:42,661|||main||||INFO||||||| Updated Payload = {"Id":"0fd0d6db-30cc-4f6a-9a11-a15a5813bb28","PlaybookName":"test_playbook.yaml"}
+2018-03-28 22:52:42,661|||main||||INFO||||||| Posting request = {"Id":"0fd0d6db-30cc-4f6a-9a11-a15a5813bb28","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-28 22:52:42,661|||main||||INFO||||||| Submission of Test successful.
+2018-03-28 22:52:42,720|||main||||INFO||||||| ------------------------------------------------------------------------------
+2018-03-28 22:52:42,733|||main||||INFO||||||| APPC0001I ECOMP Application Controller (APP-C) initialization started at March 28, 2018 6:52:42 PM EDT
+2018-03-28 22:52:42,733|||main||||INFO||||||| APPC0002I All prior configuration has been cleared
+2018-03-28 22:52:42,734|||main||||INFO||||||| APPC0004I Configuration defaults loaded from resource file "org/onap/appc/default.properties"
+2018-03-28 22:52:42,736|||main||||INFO||||||| APPC0006I Property "org.onap.appc.resources" ="org/onap/appc/i18n/MessageResources"
+2018-03-28 22:52:42,736|||main||||INFO||||||| APPC0006I Property "test.expected-endpoints" ="1"
+2018-03-28 22:52:42,736|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.file" ="appc.properties"
+2018-03-28 22:52:42,737|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.min.pool" ="1"
+2018-03-28 22:52:42,737|||main||||INFO||||||| APPC0006I Property "test.expected-regions" ="1"
+2018-03-28 22:52:42,737|||main||||INFO||||||| APPC0006I Property "org.onap.appc.security.logger" ="org.onap.appc.security"
+2018-03-28 22:52:42,737|||main||||INFO||||||| APPC0006I Property "appc.application.name" ="APPC"
+2018-03-28 22:52:42,737|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.max.pool" ="0"
+2018-03-28 22:52:42,738|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.limit" ="10"
+2018-03-28 22:52:42,738|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.path" ="/Users/dt5972;etc;../etc"
+2018-03-28 22:52:42,738|||main||||INFO||||||| APPC0006I Property "org.onap.appc.openstack.poll.interval" ="20"
+2018-03-28 22:52:42,738|||main||||INFO||||||| APPC0006I Property "provider.trusted.hosts" ="*"
+2018-03-28 22:52:42,739|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.delay" ="30"
+2018-03-28 22:52:42,739|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logger" ="org.onap.appc"
+2018-03-28 22:52:42,739|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.adaptor.name" ="org.onap.appc.appc_provider_adapter"
+2018-03-28 22:52:42,739|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.path" ="/opt/onap/appc/data/properties,/Users/dt5972,."
+2018-03-28 22:52:42,740|||main||||INFO||||||| APPC0006I Property "org.onap.appc.server.state.change.timeout" ="300"
+2018-03-28 22:52:42,740|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.file" ="org/onap/appc/logback.xml"
+2018-03-28 22:52:42,741|||main||||INFO||||||| APPC0008I Searching path "/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc" for configuration settings "appc.properties"
+2018-03-28 22:52:42,742|||main||||WARN||||||| APPC0007E No configuration file named [appc.properties] was found on the configuration search path [/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc]. If a configuration file should have been loaded, check the file name and search path specified. APPC will proceed using the default values and command-line overrides (if any).
+2018-03-28 22:52:42,742|||main||||INFO||||||| APPC0010I No application-specific override properties were provided!
+2018-03-28 22:52:42,742|||main||||INFO||||||| APPC0011I Merging system properties into configuration
+2018-03-28 22:52:42,743|||main||||INFO||||||| APPC0013I Loading resource bundle "org/onap/appc/i18n/MessageResources"
+2018-03-28 22:52:42,999|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-28 22:52:42,999|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-28 22:52:42,999|||main||||INFO||||||| Ansible http client type set to null
+2018-03-28 22:52:42,999|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-28 22:52:43,231|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-28 22:52:43,231|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-28 22:52:43,233|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-28 22:52:43,233|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-28 22:52:43,234|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-28 22:52:43,234|||main||||INFO||||||| Ansible http client type set to null
+2018-03-28 22:52:43,234|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-28 22:52:43,236|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-28 22:52:43,237|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-28 22:52:43,245|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-28 22:52:43,245|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-28 22:52:43,245|||main||||INFO||||||| Ansible http client type set to null
+2018-03-28 22:52:43,245|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-28 22:52:43,247|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-28 22:52:43,247|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-28 22:52:43,247|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-28 22:52:43,249|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-28 22:52:43,249|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-28 22:52:43,249|||main||||INFO||||||| Ansible http client type set to null
+2018-03-28 22:52:43,249|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-28 22:52:43,251|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-28 22:52:43,251|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-28 22:52:43,251|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-28 22:52:43,251|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-28 22:52:43,251|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-28 22:52:43,251|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-28 22:52:43,252|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-28 22:52:43,256|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-28 22:52:43,256|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-28 22:52:43,256|||main||||INFO||||||| Ansible http client type set to null
+2018-03-28 22:52:43,256|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-28 22:52:43,258|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-28 22:52:43,258|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-28 22:52:43,259|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-28 22:52:43,259|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-28 22:52:43,259|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-28 22:52:43,259|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-28 22:52:43,259|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-28 22:52:43,259|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:16:38,923|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-29 00:16:38,925|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-29 00:16:38,941|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 00:16:38,941|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 00:16:38,950|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 00:16:38,952|||main||||INFO||||||| Got uri
+2018-03-29 00:16:38,955|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-29 00:16:38,955|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 00:16:38,960|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-29 00:16:38,960|||main||||INFO||||||| Processing results in response
+2018-03-29 00:16:38,960|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-29 00:16:38,960|||main||||INFO||||||| Iterating through hosts
+2018-03-29 00:16:38,960|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-29 00:16:38,960|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-29 00:16:38,960|||main||||INFO||||||| Request response = FINISHED
+2018-03-29 00:16:38,961|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-29 00:16:39,015|||main||||INFO||||||| Updated Payload = {"Id":"a7b29574-f604-4ac7-ad99-d7755cbb72ce","PlaybookName":"test_playbook.yaml"}
+2018-03-29 00:16:39,015|||main||||INFO||||||| Posting request = {"Id":"a7b29574-f604-4ac7-ad99-d7755cbb72ce","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-29 00:16:39,015|||main||||INFO||||||| Submission of Test successful.
+2018-03-29 00:16:39,073|||main||||INFO||||||| ------------------------------------------------------------------------------
+2018-03-29 00:16:39,083|||main||||INFO||||||| APPC0001I ECOMP Application Controller (APP-C) initialization started at March 28, 2018 8:16:39 PM EDT
+2018-03-29 00:16:39,083|||main||||INFO||||||| APPC0002I All prior configuration has been cleared
+2018-03-29 00:16:39,084|||main||||INFO||||||| APPC0004I Configuration defaults loaded from resource file "org/onap/appc/default.properties"
+2018-03-29 00:16:39,085|||main||||INFO||||||| APPC0006I Property "org.onap.appc.resources" ="org/onap/appc/i18n/MessageResources"
+2018-03-29 00:16:39,085|||main||||INFO||||||| APPC0006I Property "test.expected-endpoints" ="1"
+2018-03-29 00:16:39,086|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.file" ="appc.properties"
+2018-03-29 00:16:39,086|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.min.pool" ="1"
+2018-03-29 00:16:39,086|||main||||INFO||||||| APPC0006I Property "test.expected-regions" ="1"
+2018-03-29 00:16:39,086|||main||||INFO||||||| APPC0006I Property "org.onap.appc.security.logger" ="org.onap.appc.security"
+2018-03-29 00:16:39,086|||main||||INFO||||||| APPC0006I Property "appc.application.name" ="APPC"
+2018-03-29 00:16:39,087|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.max.pool" ="0"
+2018-03-29 00:16:39,087|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.limit" ="10"
+2018-03-29 00:16:39,087|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.path" ="/Users/dt5972;etc;../etc"
+2018-03-29 00:16:39,087|||main||||INFO||||||| APPC0006I Property "org.onap.appc.openstack.poll.interval" ="20"
+2018-03-29 00:16:39,087|||main||||INFO||||||| APPC0006I Property "provider.trusted.hosts" ="*"
+2018-03-29 00:16:39,088|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.delay" ="30"
+2018-03-29 00:16:39,088|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logger" ="org.onap.appc"
+2018-03-29 00:16:39,088|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.adaptor.name" ="org.onap.appc.appc_provider_adapter"
+2018-03-29 00:16:39,088|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.path" ="/opt/onap/appc/data/properties,/Users/dt5972,."
+2018-03-29 00:16:39,088|||main||||INFO||||||| APPC0006I Property "org.onap.appc.server.state.change.timeout" ="300"
+2018-03-29 00:16:39,089|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.file" ="org/onap/appc/logback.xml"
+2018-03-29 00:16:39,090|||main||||INFO||||||| APPC0008I Searching path "/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc" for configuration settings "appc.properties"
+2018-03-29 00:16:39,090|||main||||WARN||||||| APPC0007E No configuration file named [appc.properties] was found on the configuration search path [/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc]. If a configuration file should have been loaded, check the file name and search path specified. APPC will proceed using the default values and command-line overrides (if any).
+2018-03-29 00:16:39,091|||main||||INFO||||||| APPC0010I No application-specific override properties were provided!
+2018-03-29 00:16:39,091|||main||||INFO||||||| APPC0011I Merging system properties into configuration
+2018-03-29 00:16:39,091|||main||||INFO||||||| APPC0013I Loading resource bundle "org/onap/appc/i18n/MessageResources"
+2018-03-29 00:16:39,317|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:16:39,317|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:16:39,318|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:16:39,318|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:16:39,551|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:16:39,551|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:16:39,553|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:16:39,554|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:16:39,554|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:16:39,554|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:16:39,554|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:16:39,559|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:16:39,560|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:16:39,567|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:16:39,568|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:16:39,568|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:16:39,568|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:16:39,572|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:16:39,572|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:16:39,572|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:16:39,574|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:16:39,574|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:16:39,574|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:16:39,574|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:16:39,577|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:16:39,577|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:16:39,578|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:16:39,578|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:16:39,578|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-29 00:16:39,578|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-29 00:16:39,578|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-29 00:16:39,583|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:16:39,583|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:16:39,583|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:16:39,583|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:16:39,586|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:16:39,587|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:16:39,587|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:16:39,587|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:16:39,587|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-29 00:16:39,587|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-29 00:16:39,588|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-29 00:16:39,588|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:19:31,739|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-29 00:19:31,743|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-29 00:19:31,763|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 00:19:31,763|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 00:19:31,775|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 00:19:31,780|||main||||INFO||||||| Got uri
+2018-03-29 00:19:31,783|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-29 00:19:31,783|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 00:19:31,788|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-29 00:19:31,788|||main||||INFO||||||| Processing results in response
+2018-03-29 00:19:31,789|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-29 00:19:31,789|||main||||INFO||||||| Iterating through hosts
+2018-03-29 00:19:31,789|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-29 00:19:31,789|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-29 00:19:31,789|||main||||INFO||||||| Request response = FINISHED
+2018-03-29 00:19:31,789|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-29 00:19:31,845|||main||||INFO||||||| Updated Payload = {"Id":"7ec4b740-c114-45a0-afcf-3f3ed17a7417","PlaybookName":"test_playbook.yaml"}
+2018-03-29 00:19:31,845|||main||||INFO||||||| Posting request = {"Id":"7ec4b740-c114-45a0-afcf-3f3ed17a7417","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-29 00:19:31,845|||main||||INFO||||||| Submission of Test successful.
+2018-03-29 00:19:31,911|||main||||INFO||||||| ------------------------------------------------------------------------------
+2018-03-29 00:19:31,919|||main||||INFO||||||| APPC0001I ECOMP Application Controller (APP-C) initialization started at March 28, 2018 8:19:31 PM EDT
+2018-03-29 00:19:31,919|||main||||INFO||||||| APPC0002I All prior configuration has been cleared
+2018-03-29 00:19:31,920|||main||||INFO||||||| APPC0004I Configuration defaults loaded from resource file "org/onap/appc/default.properties"
+2018-03-29 00:19:31,921|||main||||INFO||||||| APPC0006I Property "org.onap.appc.resources" ="org/onap/appc/i18n/MessageResources"
+2018-03-29 00:19:31,921|||main||||INFO||||||| APPC0006I Property "test.expected-endpoints" ="1"
+2018-03-29 00:19:31,921|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.file" ="appc.properties"
+2018-03-29 00:19:31,921|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.min.pool" ="1"
+2018-03-29 00:19:31,921|||main||||INFO||||||| APPC0006I Property "test.expected-regions" ="1"
+2018-03-29 00:19:31,922|||main||||INFO||||||| APPC0006I Property "org.onap.appc.security.logger" ="org.onap.appc.security"
+2018-03-29 00:19:31,922|||main||||INFO||||||| APPC0006I Property "appc.application.name" ="APPC"
+2018-03-29 00:19:31,922|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.max.pool" ="0"
+2018-03-29 00:19:31,922|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.limit" ="10"
+2018-03-29 00:19:31,922|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.path" ="/Users/dt5972;etc;../etc"
+2018-03-29 00:19:31,923|||main||||INFO||||||| APPC0006I Property "org.onap.appc.openstack.poll.interval" ="20"
+2018-03-29 00:19:31,923|||main||||INFO||||||| APPC0006I Property "provider.trusted.hosts" ="*"
+2018-03-29 00:19:31,923|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.delay" ="30"
+2018-03-29 00:19:31,923|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logger" ="org.onap.appc"
+2018-03-29 00:19:31,923|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.adaptor.name" ="org.onap.appc.appc_provider_adapter"
+2018-03-29 00:19:31,923|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.path" ="/opt/onap/appc/data/properties,/Users/dt5972,."
+2018-03-29 00:19:31,924|||main||||INFO||||||| APPC0006I Property "org.onap.appc.server.state.change.timeout" ="300"
+2018-03-29 00:19:31,924|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.file" ="org/onap/appc/logback.xml"
+2018-03-29 00:19:31,925|||main||||INFO||||||| APPC0008I Searching path "/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc" for configuration settings "appc.properties"
+2018-03-29 00:19:31,926|||main||||WARN||||||| APPC0007E No configuration file named [appc.properties] was found on the configuration search path [/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc]. If a configuration file should have been loaded, check the file name and search path specified. APPC will proceed using the default values and command-line overrides (if any).
+2018-03-29 00:19:31,926|||main||||INFO||||||| APPC0010I No application-specific override properties were provided!
+2018-03-29 00:19:31,926|||main||||INFO||||||| APPC0011I Merging system properties into configuration
+2018-03-29 00:19:31,927|||main||||INFO||||||| APPC0013I Loading resource bundle "org/onap/appc/i18n/MessageResources"
+2018-03-29 00:19:32,164|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:19:32,164|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:19:32,165|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:19:32,165|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:19:32,349|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:19:32,349|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:19:32,353|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:19:32,353|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:19:32,353|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:19:32,353|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:19:32,353|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:19:32,357|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:19:32,357|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:19:32,364|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:19:32,364|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:19:32,364|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:19:32,364|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:19:32,367|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:19:32,367|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:19:32,368|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:19:32,368|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:19:32,368|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:19:32,369|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:19:32,369|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:19:32,371|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:19:32,372|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:19:32,372|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:19:32,372|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:19:32,372|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-29 00:19:32,372|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-29 00:19:32,373|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-29 00:19:32,377|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:19:32,378|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:19:32,378|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:19:32,378|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:19:32,380|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:19:32,380|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:19:32,380|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:19:32,380|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:19:32,381|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-29 00:19:32,381|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-29 00:19:32,381|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-29 00:19:32,381|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:26:41,423|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-29 00:26:41,427|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-29 00:26:41,445|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 00:26:41,445|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 00:26:41,458|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 00:26:41,463|||main||||INFO||||||| Got uri
+2018-03-29 00:26:41,466|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-29 00:26:41,467|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 00:26:41,472|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-29 00:26:41,472|||main||||INFO||||||| Processing results in response
+2018-03-29 00:26:41,473|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-29 00:26:41,473|||main||||INFO||||||| Iterating through hosts
+2018-03-29 00:26:41,473|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-29 00:26:41,473|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-29 00:26:41,473|||main||||INFO||||||| Request response = FINISHED
+2018-03-29 00:26:41,473|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-29 00:26:41,529|||main||||INFO||||||| Updated Payload = {"Id":"c0ef1a98-f53d-4a3d-b685-0ab7e4b80653","PlaybookName":"test_playbook.yaml"}
+2018-03-29 00:26:41,529|||main||||INFO||||||| Posting request = {"Id":"c0ef1a98-f53d-4a3d-b685-0ab7e4b80653","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-29 00:26:41,529|||main||||INFO||||||| Submission of Test successful.
+2018-03-29 00:26:41,594|||main||||INFO||||||| ------------------------------------------------------------------------------
+2018-03-29 00:26:41,604|||main||||INFO||||||| APPC0001I ECOMP Application Controller (APP-C) initialization started at March 28, 2018 8:26:41 PM EDT
+2018-03-29 00:26:41,604|||main||||INFO||||||| APPC0002I All prior configuration has been cleared
+2018-03-29 00:26:41,604|||main||||INFO||||||| APPC0004I Configuration defaults loaded from resource file "org/onap/appc/default.properties"
+2018-03-29 00:26:41,605|||main||||INFO||||||| APPC0006I Property "org.onap.appc.resources" ="org/onap/appc/i18n/MessageResources"
+2018-03-29 00:26:41,606|||main||||INFO||||||| APPC0006I Property "test.expected-endpoints" ="1"
+2018-03-29 00:26:41,606|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.file" ="appc.properties"
+2018-03-29 00:26:41,606|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.min.pool" ="1"
+2018-03-29 00:26:41,606|||main||||INFO||||||| APPC0006I Property "test.expected-regions" ="1"
+2018-03-29 00:26:41,607|||main||||INFO||||||| APPC0006I Property "org.onap.appc.security.logger" ="org.onap.appc.security"
+2018-03-29 00:26:41,607|||main||||INFO||||||| APPC0006I Property "appc.application.name" ="APPC"
+2018-03-29 00:26:41,607|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.max.pool" ="0"
+2018-03-29 00:26:41,607|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.limit" ="10"
+2018-03-29 00:26:41,607|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.path" ="/Users/dt5972;etc;../etc"
+2018-03-29 00:26:41,608|||main||||INFO||||||| APPC0006I Property "org.onap.appc.openstack.poll.interval" ="20"
+2018-03-29 00:26:41,608|||main||||INFO||||||| APPC0006I Property "provider.trusted.hosts" ="*"
+2018-03-29 00:26:41,608|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.retry.delay" ="30"
+2018-03-29 00:26:41,608|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logger" ="org.onap.appc"
+2018-03-29 00:26:41,608|||main||||INFO||||||| APPC0006I Property "org.onap.appc.provider.adaptor.name" ="org.onap.appc.appc_provider_adapter"
+2018-03-29 00:26:41,608|||main||||INFO||||||| APPC0006I Property "org.onap.appc.bootstrap.path" ="/opt/onap/appc/data/properties,/Users/dt5972,."
+2018-03-29 00:26:41,609|||main||||INFO||||||| APPC0006I Property "org.onap.appc.server.state.change.timeout" ="300"
+2018-03-29 00:26:41,609|||main||||INFO||||||| APPC0006I Property "org.onap.appc.logging.file" ="org/onap/appc/logback.xml"
+2018-03-29 00:26:41,610|||main||||INFO||||||| APPC0008I Searching path "/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc" for configuration settings "appc.properties"
+2018-03-29 00:26:41,610|||main||||WARN||||||| APPC0007E No configuration file named [appc.properties] was found on the configuration search path [/opt/onap/appc/data/properties,/Users/dt5972,etc,../etc]. If a configuration file should have been loaded, check the file name and search path specified. APPC will proceed using the default values and command-line overrides (if any).
+2018-03-29 00:26:41,610|||main||||INFO||||||| APPC0010I No application-specific override properties were provided!
+2018-03-29 00:26:41,610|||main||||INFO||||||| APPC0011I Merging system properties into configuration
+2018-03-29 00:26:41,611|||main||||INFO||||||| APPC0013I Loading resource bundle "org/onap/appc/i18n/MessageResources"
+2018-03-29 00:26:41,889|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:26:41,892|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:26:41,892|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:26:41,892|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:26:42,102|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:26:42,102|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:26:42,104|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:26:42,104|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:26:42,105|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:26:42,105|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:26:42,105|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:26:42,109|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:26:42,109|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:26:42,120|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:26:42,121|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:26:42,121|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:26:42,121|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:26:42,124|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:26:42,125|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:26:42,125|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:26:42,126|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:26:42,127|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:26:42,127|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:26:42,127|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:26:42,130|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:26:42,130|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:26:42,130|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:26:42,130|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:26:42,131|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-29 00:26:42,131|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-29 00:26:42,131|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-29 00:26:42,136|||main||||INFO||||||| Starting bundle APPC Ansible Adapter
+2018-03-29 00:26:42,137|||main||||INFO||||||| APPC0024I APPC: component Ansible Adapter is being initialized...
+2018-03-29 00:26:42,137|||main||||INFO||||||| Ansible http client type set to null
+2018-03-29 00:26:42,137|||main||||INFO||||||| Creating http client with default behaviour
+2018-03-29 00:26:42,140|||main||||INFO||||||| Initialized Ansible Adapter
+2018-03-29 00:26:42,140|||main||||INFO||||||| APPC0036I APPC: registering service Ansible Adapter using class AnsibleAdapter
+2018-03-29 00:26:42,140|||main||||INFO||||||| APPC0025I APPC: component Ansible Adapter has completed initialization
+2018-03-29 00:26:42,141|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 00:26:42,141|||main||||INFO||||||| APPC0026I APPC component Ansible Adapter is terminating...
+2018-03-29 00:26:42,141|||main||||INFO||||||| APPC0037I APPC unregistering service Ansible Adapter
+2018-03-29 00:26:42,142|||main||||INFO||||||| APPC0027I APPC component Ansible Adapter has terminated
+2018-03-29 00:26:42,142|||main||||INFO||||||| Stopping bundle APPC Ansible Adapter
+2018-03-29 15:02:43,144|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-29 15:02:43,146|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-29 15:02:43,163|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:02:43,163|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:02:43,175|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:02:43,178|||main||||INFO||||||| Got uri
+2018-03-29 15:02:43,181|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-29 15:02:43,182|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:02:43,186|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-29 15:02:43,187|||main||||INFO||||||| Processing results in response
+2018-03-29 15:02:43,187|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-29 15:02:43,187|||main||||INFO||||||| Iterating through hosts
+2018-03-29 15:02:43,187|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-29 15:02:43,187|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-29 15:02:43,187|||main||||INFO||||||| Request response = FINISHED
+2018-03-29 15:02:43,187|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-29 15:02:43,250|||main||||INFO||||||| Updated Payload = {"Id":"f7bef643-2fd6-4971-a11d-df3f3e6f7239","PlaybookName":"test_playbook.yaml"}
+2018-03-29 15:02:43,250|||main||||INFO||||||| Posting request = {"Id":"f7bef643-2fd6-4971-a11d-df3f3e6f7239","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-29 15:02:43,251|||main||||INFO||||||| Submission of Test successful.
+2018-03-29 15:11:07,494|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-29 15:11:07,496|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-29 15:11:07,509|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:11:07,510|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:11:07,519|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:11:07,522|||main||||INFO||||||| Got uri
+2018-03-29 15:11:07,525|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-29 15:11:07,526|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:11:07,530|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-29 15:11:07,530|||main||||INFO||||||| Processing results in response
+2018-03-29 15:11:07,530|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-29 15:11:07,530|||main||||INFO||||||| Iterating through hosts
+2018-03-29 15:11:07,530|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-29 15:11:07,531|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-29 15:11:07,531|||main||||INFO||||||| Request response = FINISHED
+2018-03-29 15:11:07,531|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-29 15:11:07,584|||main||||INFO||||||| Updated Payload = {"Id":"0ef396f6-c282-4d1e-b4ca-4b4de5a74d9e","PlaybookName":"test_playbook.yaml"}
+2018-03-29 15:11:07,584|||main||||INFO||||||| Posting request = {"Id":"0ef396f6-c282-4d1e-b4ca-4b4de5a74d9e","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-29 15:11:07,584|||main||||INFO||||||| Submission of Test successful.
+2018-03-29 15:23:27,898|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-29 15:23:27,900|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-29 15:23:27,915|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:23:27,915|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:23:27,924|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:23:27,927|||main||||INFO||||||| Got uri
+2018-03-29 15:23:27,930|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-29 15:23:27,930|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:23:27,935|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-29 15:23:27,935|||main||||INFO||||||| Processing results in response
+2018-03-29 15:23:27,935|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-29 15:23:27,935|||main||||INFO||||||| Iterating through hosts
+2018-03-29 15:23:27,935|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-29 15:23:27,935|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-29 15:23:27,935|||main||||INFO||||||| Request response = FINISHED
+2018-03-29 15:23:27,936|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-29 15:23:27,990|||main||||INFO||||||| Updated Payload = {"Id":"42a25cdb-b4a1-4037-8547-a50c98152d78","PlaybookName":"test_playbook.yaml"}
+2018-03-29 15:23:27,990|||main||||INFO||||||| Posting request = {"Id":"42a25cdb-b4a1-4037-8547-a50c98152d78","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-29 15:23:27,991|||main||||INFO||||||| Submission of Test successful.
+2018-03-29 15:51:24,894|||main||||INFO||||||| EELF0005I Searching path "${user.home};etc;../etc" for log configuration file "logback-test.xml"
+2018-03-29 15:51:24,897|||main||||INFO||||||| EELF0001I Loading default logging configuration from system resource file "com/att/eelf/logback.xml"
+2018-03-29 15:51:24,914|||main||||INFO||||||| Retrieving results from https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:51:24,915|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=101&Type=GetLog
+2018-03-29 15:51:24,926|||main||||INFO||||||| Request output = {"Results":{"192.168.1.10":{"Id":"101","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:51:24,931|||main||||INFO||||||| Got uri
+2018-03-29 15:51:24,936|||main||||INFO||||||| Querying url = https://192.168.1.1?Id=100&Type=GetResult
+2018-03-29 15:51:24,936|||main||||INFO||||||| Parsing response from Server = {"Results":{"192.168.1.10":{"Id":"100","StatusCode":200,"StatusMessage":"SUCCESS"}},"StatusCode":200,"StatusMessage":"FINISHED"}
+2018-03-29 15:51:24,942|||main||||INFO||||||| Received response with code = 200, Message = FINISHED
+2018-03-29 15:51:24,942|||main||||INFO||||||| Processing results in response
+2018-03-29 15:51:24,942|||main||||INFO||||||| Get JSON dictionary from Results ..
+2018-03-29 15:51:24,942|||main||||INFO||||||| Iterating through hosts
+2018-03-29 15:51:24,943|||main||||INFO||||||| Processing host = 192.168.1.10
+2018-03-29 15:51:24,943|||main||||INFO||||||| Code = 200, Message = SUCCESS
+2018-03-29 15:51:24,943|||main||||INFO||||||| Request response = FINISHED
+2018-03-29 15:51:24,943|||main||||INFO||||||| Ansible Request 100 finished with Result = success, Message = FINISHED
+2018-03-29 15:51:25,000|||main||||INFO||||||| Updated Payload = {"Id":"414194e1-a472-4cc4-baa1-d6f7b2aaa7fd","PlaybookName":"test_playbook.yaml"}
+2018-03-29 15:51:25,000|||main||||INFO||||||| Posting request = {"Id":"414194e1-a472-4cc4-baa1-d6f7b2aaa7fd","PlaybookName":"test_playbook.yaml"} to url = https://192.168.1.1
+2018-03-29 15:51:25,000|||main||||INFO||||||| Submission of Test successful.
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/audit.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/audit.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/audit.log
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/error.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/error.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/error.log
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/metrics.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/metrics.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/metrics.log
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/performance.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/performance.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/performance.log
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/policy.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/policy.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/policy.log
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/security.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/security.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/security.log
diff --git a/ansible-adapter/ansible-adapter-bundle/logs/EELF/server.log b/ansible-adapter/ansible-adapter-bundle/logs/EELF/server.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/logs/EELF/server.log
diff --git a/ansible-adapter/ansible-adapter-bundle/pom.xml b/ansible-adapter/ansible-adapter-bundle/pom.xml
new file mode 100644
index 00000000..2d6a50bf
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/pom.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ============LICENSE_START=======================================================
+ ONAP : APPC ================================================================================
+ Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs =============================================================================
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. ECOMP is
+ a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END========================================================= -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>ansible-adapter-bundle</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <name>ccsdk-sli-adaptors :: ansible-adapter :: ${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${apache.httpcomponents.client.version}</version>
+ </dependency>
+
+ <!-- http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
+
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ </dependency>
+
+
+ <!-- Needed to run test cases -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>1.9.13</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <!-- <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId>
+ <version>2.8.0</version> </dependency> -->
+
+ </dependencies>
+
+
+<!-- <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-ansible-adapter</Bundle-SymbolicName>
+ <Bundle-Activator>org.onap.appc.adapter.ansible.AnsibleActivator</Bundle-Activator>
+ <Export-Package>org.onap.appc.adapter.ansible</Export-Package>
+ <Import-Package>org.onap.ccsdk.sli.core.sli.*,org.osgi.framework.*,org.slf4j.*,
+ javax.net.*,javax.net.ssl.*,org.xml.sax.*,javax.xml.bind.*,javax.naming.*,
+ javax.security.*</Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mariadb-java-client|xml-apis</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build> -->
+</project>
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapter.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapter.java
new file mode 100644
index 00000000..a2d537e5
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapter.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible;
+
+import java.util.Map;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+
+/**
+ * This interface defines the operations that the Ansible adapter exposes.
+ *
+ */
+public interface AnsibleAdapter extends SvcLogicJavaPlugin {
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ */
+ String getAdapterName();
+
+ /* Method to post request for execution of Playbook */
+ void reqExec(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
+
+ /* Method to get result of a playbook execution request */
+ void reqExecResult(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
+
+ /* Method to get log of a playbook execution request */
+ void reqExecLog(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException;
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapterPropertiesProvider.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapterPropertiesProvider.java
new file mode 100755
index 00000000..6d9f4f12
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/AnsibleAdapterPropertiesProvider.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * onap
+ * ================================================================================
+ * Copyright (C) 2016 - 2017 ONAP
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible;
+
+import java.util.Properties;
+
+public interface AnsibleAdapterPropertiesProvider {
+
+ public Properties getProperties();
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java
new file mode 100644
index 00000000..3d14a71c
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterImpl.java
@@ -0,0 +1,425 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible.impl;
+
+import java.util.Map;
+import java.util.Properties;
+import org.apache.commons.lang.StringUtils;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.ccsdk.sli.adaptors.ansible.AnsibleAdapter;
+import org.onap.ccsdk.sli.adaptors.ansible.AnsibleAdapterPropertiesProvider;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleMessageParser;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleResult;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleResultCodes;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleServerEmulator;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+/**
+ * This class implements the {@link AnsibleAdapter} interface. This interface defines the behaviors
+ * that our service provides.
+ */
+public class AnsibleAdapterImpl implements AnsibleAdapter {
+
+
+ /**
+ * The constant used to define the service name in the mapped diagnostic context
+ */
+ @SuppressWarnings("nls")
+ public static final String MDC_SERVICE = "service";
+
+ /**
+ * The constant for the status code for a failed outcome
+ */
+ @SuppressWarnings("nls")
+ public static final String OUTCOME_FAILURE = "failure";
+
+ /**
+ * The constant for the status code for a successful outcome
+ */
+ @SuppressWarnings("nls")
+ public static final String OUTCOME_SUCCESS = "success";
+
+ /**
+ * Adapter Name
+ */
+ private static final String ADAPTER_NAME = "Ansible Adapter";
+ private static final String APPC_EXCEPTION_CAUGHT = "APPCException caught";
+
+ private static final String RESULT_CODE_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.result.code";
+ private static final String MESSAGE_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.message";
+ private static final String RESULTS_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.results";
+ private static final String ID_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.Id";
+ private static final String LOG_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.log";
+
+ private static final String CLIENT_TYPE_PROPERTY_NAME = "org.onap.appc.adapter.ansible.clientType";
+ private static final String TRUSTSTORE_PROPERTY_NAME = "org.onap.appc.adapter.ansible.trustStore";
+ private static final String TRUSTPASSWD_PROPERTY_NAME = "org.onap.appc.adapter.ansible.trustStore.trustPasswd";
+
+ private static final String PASSWORD = "Password";
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(AnsibleAdapterImpl.class);
+
+
+ /**
+ * Connection object
+ **/
+ private ConnectionBuilder httpClient;
+
+ /**
+ * Ansible API Message Handlers
+ **/
+ private AnsibleMessageParser messageProcessor;
+
+ /**
+ * indicator whether in test mode
+ **/
+ private boolean testMode = false;
+
+ /**
+ * server emulator object to be used if in test mode
+ **/
+ private AnsibleServerEmulator testServer;
+
+ /**
+ * This default constructor is used as a work around because the activator wasn't getting called
+ */
+ public AnsibleAdapterImpl() {
+ initialize(new AnsibleAdapterPropertiesProviderImpl());
+ }
+ public AnsibleAdapterImpl(AnsibleAdapterPropertiesProvider propProvider) {
+ initialize(propProvider);
+ }
+
+ /**
+ * Used for jUnit test and testing interface
+ */
+ public AnsibleAdapterImpl(boolean mode) {
+ testMode = mode;
+ testServer = new AnsibleServerEmulator();
+ messageProcessor = new AnsibleMessageParser();
+ }
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ * @see org.onap.appc.adapter.rest.AnsibleAdapter#getAdapterName()
+ */
+ @Override
+ public String getAdapterName() {
+ return ADAPTER_NAME;
+ }
+
+ /**
+ * @param rc Method posts info to Context memory in case of an error and throws a
+ * SvcLogicException causing SLI to register this as a failure
+ */
+ @SuppressWarnings("static-method")
+ private void doFailure(SvcLogicContext svcLogic, int code, String message) throws SvcLogicException {
+
+ svcLogic.setStatus(OUTCOME_FAILURE);
+ svcLogic.setAttribute(RESULT_CODE_ATTRIBUTE_NAME, Integer.toString(code));
+ svcLogic.setAttribute(MESSAGE_ATTRIBUTE_NAME, message);
+
+ throw new SvcLogicException("Ansible Adapter Error = " + message);
+ }
+
+ /**
+ * initialize the Ansible adapter based on default and over-ride configuration data
+ */
+ private void initialize(AnsibleAdapterPropertiesProvider propProvider) {
+
+
+ Properties props = propProvider.getProperties();
+
+ // Create the message processor instance
+ messageProcessor = new AnsibleMessageParser();
+
+ // Create the http client instance
+ // type of client is extracted from the property file parameter
+ // org.onap.appc.adapter.ansible.clientType
+ // It can be :
+ // 1. TRUST_ALL (trust all SSL certs). To be used ONLY in dev
+ // 2. TRUST_CERT (trust only those whose certificates have been stored in the trustStore file)
+ // 3. DEFAULT (trust only well known certificates). This is standard behavior to which it will
+ // revert. To be used in PROD
+
+ try {
+ String clientType = props.getProperty(CLIENT_TYPE_PROPERTY_NAME);
+ logger.info("Ansible http client type set to " + clientType);
+
+ if ("TRUST_ALL".equals(clientType)) {
+ logger.info(
+ "Creating http client to trust ALL ssl certificates. WARNING. This should be done only in dev environments");
+ httpClient = new ConnectionBuilder(1);
+ } else if ("TRUST_CERT".equals(clientType)) {
+ // set path to keystore file
+ String trustStoreFile = props.getProperty(TRUSTSTORE_PROPERTY_NAME);
+ String key = props.getProperty(TRUSTPASSWD_PROPERTY_NAME);
+ char[] trustStorePasswd = key.toCharArray();
+ logger.info("Creating http client with trustmanager from " + trustStoreFile);
+ httpClient = new ConnectionBuilder(trustStoreFile, trustStorePasswd);
+ } else {
+ logger.info("Creating http client with default behaviour");
+ httpClient = new ConnectionBuilder(0);
+ }
+ } catch (Exception e) {
+ logger.error("Error Initializing Ansible Adapter due to Unknown Exception", e);
+ }
+
+ logger.info("Initialized Ansible Adapter");
+ }
+
+ // Public Method to post request to execute playbook. Posts the following back
+ // to Svc context memory
+ // org.onap.appc.adapter.ansible.req.code : 100 if successful
+ // org.onap.appc.adapter.ansible.req.messge : any message
+ // org.onap.appc.adapter.ansible.req.Id : a unique uuid to reference the request
+ @Override
+ public void reqExec(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
+
+ String playbookName = StringUtils.EMPTY;
+ String payload = StringUtils.EMPTY;
+ String agentUrl = StringUtils.EMPTY;
+ String user = StringUtils.EMPTY;
+ String password = StringUtils.EMPTY;
+ String id = StringUtils.EMPTY;
+
+ JSONObject jsonPayload;
+
+ try {
+ // create json object to send request
+ jsonPayload = messageProcessor.reqMessage(params);
+
+ agentUrl = (String) jsonPayload.remove("AgentUrl");
+ user = (String) jsonPayload.remove("User");
+ password = (String) jsonPayload.remove(PASSWORD);
+ id = jsonPayload.getString("Id");
+ payload = jsonPayload.toString();
+ logger.info("Updated Payload = " + payload);
+ } catch (SvcLogicException e) {
+ logger.error(APPC_EXCEPTION_CAUGHT, e);
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
+ "Error constructing request for execution of playbook due to missing mandatory parameters. Reason = "
+ + e.getMessage());
+ } catch (JSONException e) {
+ logger.error("JSONException caught", e);
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
+ "Error constructing request for execution of playbook due to invalid JSON block. Reason = "
+ + e.getMessage());
+ } catch (NumberFormatException e) {
+ logger.error("NumberFormatException caught", e);
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
+ "Error constructing request for execution of playbook due to invalid parameter values. Reason = "
+ + e.getMessage());
+ }
+
+ int code = -1;
+ String message = StringUtils.EMPTY;
+
+ try {
+ // post the test request
+ logger.info("Posting request = " + payload + " to url = " + agentUrl);
+ AnsibleResult testResult = postExecRequest(agentUrl, payload, user, password);
+
+ // Process if HTTP was successful
+ if (testResult.getStatusCode() == 200) {
+ testResult = messageProcessor.parsePostResponse(testResult.getStatusMessage());
+ } else {
+ doFailure(ctx, testResult.getStatusCode(),
+ "Error posting request. Reason = " + testResult.getStatusMessage());
+ }
+
+ code = testResult.getStatusCode();
+ message = testResult.getStatusMessage();
+
+ // Check status of test request returned by Agent
+ if (code == AnsibleResultCodes.PENDING.getValue()) {
+ logger.info(String.format("Submission of Test %s successful.", playbookName));
+ // test request accepted. We are in asynchronous case
+ } else {
+ doFailure(ctx, code, "Request for execution of playbook rejected. Reason = " + message);
+ }
+ } catch (SvcLogicException e) {
+ logger.error(APPC_EXCEPTION_CAUGHT, e);
+ doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(),
+ "Exception encountered when posting request for execution of playbook. Reason = " + e.getMessage());
+ }
+
+ ctx.setAttribute(RESULT_CODE_ATTRIBUTE_NAME, Integer.toString(code));
+ ctx.setAttribute(MESSAGE_ATTRIBUTE_NAME, message);
+ ctx.setAttribute(ID_ATTRIBUTE_NAME, id);
+ }
+
+ /**
+ * Public method to query status of a specific request It blocks till the Ansible Server
+ * responds or the session times out (non-Javadoc)
+ *
+ * @see org.onap.ccsdk.sli.adaptors.ansible.AnsibleAdapter#reqExecResult(java.util.Map,
+ * org.onap.ccsdk.sli.core.sli.SvcLogicContext)
+ */
+ @Override
+ public void reqExecResult(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
+
+ // Get URI
+ String reqUri = StringUtils.EMPTY;
+
+ try {
+ reqUri = messageProcessor.reqUriResult(params);
+ logger.info("Got uri ", reqUri );
+ } catch (SvcLogicException e) {
+ logger.error(APPC_EXCEPTION_CAUGHT, e);
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
+ "Error constructing request to retrieve result due to missing parameters. Reason = "
+ + e.getMessage());
+ return;
+ } catch (NumberFormatException e) {
+ logger.error("NumberFormatException caught", e);
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
+ "Error constructing request to retrieve result due to invalid parameters value. Reason = "
+ + e.getMessage());
+ return;
+ }
+
+ int code = -1;
+ String message = StringUtils.EMPTY;
+ String results = StringUtils.EMPTY;
+
+ try {
+ // Try to retrieve the test results (modify the URL for that)
+ AnsibleResult testResult = queryServer(reqUri, params.get("User"), params.get(PASSWORD));
+ code = testResult.getStatusCode();
+ message = testResult.getStatusMessage();
+
+ if (code == 200) {
+ logger.info("Parsing response from Server = " + message);
+ // Valid HTTP. process the Ansible message
+ testResult = messageProcessor.parseGetResponse(message);
+ code = testResult.getStatusCode();
+ message = testResult.getStatusMessage();
+ results = testResult.getResults();
+ }
+
+ logger.info("Request response = " + message);
+ } catch (SvcLogicException e) {
+ doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(),
+ "Exception encountered retrieving result : " + e.getMessage());
+ return;
+ }
+
+ // We were able to get and process the results. Determine if playbook succeeded
+
+ if (code == AnsibleResultCodes.FINAL_SUCCESS.getValue()) {
+ message = String.format("Ansible Request %s finished with Result = %s, Message = %s", params.get("Id"),
+ OUTCOME_SUCCESS, message);
+ logger.info(message);
+ } else {
+ logger.info(String.format("Ansible Request %s finished with Result %s, Message = %s", params.get("Id"),
+ OUTCOME_FAILURE, message));
+ ctx.setAttribute(RESULTS_ATTRIBUTE_NAME, results);
+ doFailure(ctx, code, message);
+ return;
+ }
+
+ ctx.setAttribute(RESULT_CODE_ATTRIBUTE_NAME, Integer.toString(400));
+ ctx.setAttribute(MESSAGE_ATTRIBUTE_NAME, message);
+ ctx.setAttribute(RESULTS_ATTRIBUTE_NAME, results);
+ ctx.setStatus(OUTCOME_SUCCESS);
+ }
+
+ /**
+ * Public method to get logs from playbook execution for a specific request
+ *
+ * It blocks till the Ansible Server responds or the session times out very similar to
+ * reqExecResult logs are returned in the DG context variable org.onap.appc.adapter.ansible.log
+ */
+ @Override
+ public void reqExecLog(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
+
+ String reqUri = StringUtils.EMPTY;
+ try {
+ reqUri = messageProcessor.reqUriLog(params);
+ logger.info("Retrieving results from " + reqUri);
+ } catch (Exception e) {
+ logger.error("Exception caught", e);
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), e.getMessage());
+ }
+
+ String message = StringUtils.EMPTY;
+ try {
+ // Try to retrieve the test results (modify the url for that)
+ AnsibleResult testResult = queryServer(reqUri, params.get("User"), params.get(PASSWORD));
+ message = testResult.getStatusMessage();
+ logger.info("Request output = " + message);
+ ctx.setAttribute(LOG_ATTRIBUTE_NAME, message);
+ ctx.setStatus(OUTCOME_SUCCESS);
+ } catch (Exception e) {
+ logger.error("Exception caught", e);
+ doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(),
+ "Exception encountered retreiving output : " + e.getMessage());
+ }
+ }
+
+ /**
+ * Method that posts the request
+ */
+ private AnsibleResult postExecRequest(String agentUrl, String payload, String user, String password) {
+
+ AnsibleResult testResult;
+
+ if (!testMode) {
+ httpClient.setHttpContext(user, password);
+ testResult = httpClient.post(agentUrl, payload);
+ } else {
+ testResult = testServer.Post(agentUrl, payload);
+ }
+ return testResult;
+ }
+
+ /**
+ * Method to query Ansible server
+ */
+ private AnsibleResult queryServer(String agentUrl, String user, String password) {
+
+ AnsibleResult testResult;
+
+ logger.info("Querying url = " + agentUrl);
+
+ if (!testMode) {
+ testResult = httpClient.get(agentUrl);
+ } else {
+ testResult = testServer.Get(agentUrl);
+ }
+
+ return testResult;
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java
new file mode 100755
index 00000000..bffb494f
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java
@@ -0,0 +1,186 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * onap
+ * ================================================================================
+ * Copyright (C) 2016 - 2017 ONAP
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Vector;
+import org.onap.ccsdk.sli.adaptors.ansible.AnsibleAdapterPropertiesProvider;
+import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.utils.JREFileResolver;
+import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver;
+import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver;
+import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver;
+import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Responsible for determining the properties file to use and instantiating the
+ * <code>SqlResource</code> Service. The priority for properties file
+ * resolution is as follows:
+ *
+ * <ol>
+ * <li>A directory identified by the system environment variable
+ * <code>SDNC_CONFIG_DIR</code></li>
+ * <li>The default directory <code>DEFAULT_DBLIB_PROP_DIR</code></li>
+ * <li>A directory identified by the JRE argument
+ * <code>sql-resource.properties</code></li>
+ * <li>A <code>sql-resource.properties</code> file located in the karaf root
+ * directory</li>
+ * </ol>
+ */
+public class AnsibleAdapterPropertiesProviderImpl implements AnsibleAdapterPropertiesProvider {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AnsibleAdapterPropertiesProviderImpl.class);
+
+ /**
+ * The name of the properties file for database configuration
+ */
+ private static final String ANSIBLEADAPTER_PROP_FILE_NAME = "ansible-adapter.properties";
+
+ /**
+ * A prioritized list of strategies for resolving sql-resource properties files.
+ */
+ private Vector<PropertiesFileResolver> ansibleAdapterPropertiesFileResolvers = new Vector<>();
+
+ /**
+ * The configuration properties for the db connection.
+ */
+ private Properties properties;
+
+ /**
+ * Set up the prioritized list of strategies for resolving dblib properties
+ * files.
+ */
+ public AnsibleAdapterPropertiesProviderImpl() {
+ ansibleAdapterPropertiesFileResolvers
+ .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable"));
+ ansibleAdapterPropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory"));
+
+ ansibleAdapterPropertiesFileResolvers.add(
+ new JREFileResolver("Using property file (3) from JRE argument", AnsibleAdapterPropertiesProviderImpl.class));
+ ansibleAdapterPropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this));
+
+ // determines properties file as according to the priority described in the
+ // class header comment
+ final File propertiesFile = determinePropertiesFile(this);
+ if (propertiesFile != null) {
+ try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) {
+ properties = new Properties();
+ properties.load(fileInputStream);
+ } catch (final IOException e) {
+ LOG.error("Failed to load properties for file: {}", propertiesFile.toString(),
+ new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(),
+ e));
+ }
+ } else {
+ // Try to read properties as resource
+
+ InputStream propStr = getClass().getResourceAsStream("/" + ANSIBLEADAPTER_PROP_FILE_NAME);
+ if (propStr != null) {
+ properties = new Properties();
+ try {
+ properties.load(propStr);
+ propStr.close();
+ } catch (IOException e) {
+ properties = null;
+ }
+ }
+
+ }
+
+ if (properties == null) {
+ reportFailure("Missing configuration properties resource(3)", new ConfigurationException(
+ "Missing configuration properties resource(3): " + ANSIBLEADAPTER_PROP_FILE_NAME));
+ }
+ }
+
+ /**
+ * Extract svclogic config properties.
+ *
+ * @return the svclogic config properties
+ */
+ public Properties getProperties() {
+ return properties;
+ }
+
+ /**
+ * Reports the method chosen for properties resolution to the
+ * <code>Logger</code>.
+ *
+ * @param message
+ * Some user friendly message
+ * @param fileOptional
+ * The file location of the chosen properties file
+ * @return the file location of the chosen properties file
+ */
+ private static File reportSuccess(final String message, final Optional<File> fileOptional) {
+ if (fileOptional.isPresent()) {
+ final File file = fileOptional.get();
+ LOG.info("{} {}", message, file.getPath());
+ return file;
+ }
+ return null;
+ }
+
+ /**
+ * Reports fatal errors. This is the case in which no properties file could be
+ * found.
+ *
+ * @param message
+ * An appropriate fatal error message
+ * @param configurationException
+ * An exception describing what went wrong during resolution
+ */
+ private static void reportFailure(final String message, final ConfigurationException configurationException) {
+
+ LOG.error("{}", message, configurationException);
+ }
+
+ /**
+ * Determines the sql-resource properties file to use based on the following priority:
+ * <ol>
+ * <li>A directory identified by the system environment variable
+ * <code>SDNC_CONFIG_DIR</code></li>
+ * <li>The default directory <code>DEFAULT_DBLIB_PROP_DIR</code></li>
+ * <li>A directory identified by the JRE argument
+ * <code>sql-resource.properties</code></li>
+ * <li>A <code>sql-resource.properties</code> file located in the karaf root
+ * directory</li>
+ * </ol>
+ */
+ File determinePropertiesFile(final AnsibleAdapterPropertiesProviderImpl resourceProvider) {
+
+ for (final PropertiesFileResolver sliPropertiesFileResolver : ansibleAdapterPropertiesFileResolvers) {
+ final Optional<File> fileOptional = sliPropertiesFileResolver.resolveFile(ANSIBLEADAPTER_PROP_FILE_NAME);
+ if (fileOptional.isPresent()) {
+ return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional);
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
new file mode 100644
index 00000000..fbc77346
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/ConnectionBuilder.java
@@ -0,0 +1,199 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible.impl;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleResult;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleResultCodes;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+/**
+ * Returns a custom http client
+ * - based on options
+ * - can create one with ssl using an X509 certificate that does NOT have a known CA
+ * - create one which trusts ALL SSL certificates
+ * - return default httpclient (which only trusts known CAs from default cacerts file for process) this is the default
+ * option
+ **/
+
+public class ConnectionBuilder {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(ConnectionBuilder.class);
+
+ private CloseableHttpClient httpClient = null;
+ private HttpClientContext httpContext = new HttpClientContext();
+
+ /**
+ * Constructor that initializes an http client based on certificate
+ **/
+ public ConnectionBuilder(String certFile) throws KeyStoreException, CertificateException, IOException,
+ KeyManagementException, NoSuchAlgorithmException, SvcLogicException {
+
+ /* Point to the certificate */
+ FileInputStream fs = new FileInputStream(certFile);
+
+ /* Generate a certificate from the X509 */
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate) cf.generateCertificate(fs);
+
+ /* Create a keystore object and load the certificate there */
+ KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
+ keystore.load(null, null);
+ keystore.setCertificateEntry("cacert", cert);
+
+ SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext,
+ SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+
+ httpClient = HttpClients.custom().setSSLSocketFactory(factory).build();
+ }
+
+ /**
+ * Constructor which trusts all certificates in a specific java keystore file (assumes a JKS
+ * file)
+ **/
+ public ConnectionBuilder(String trustStoreFile, char[] trustStorePasswd) throws KeyStoreException, IOException,
+ KeyManagementException, NoSuchAlgorithmException, CertificateException {
+
+ /* Load the specified trustStore */
+ KeyStore keystore = KeyStore.getInstance("JKS");
+ FileInputStream readStream = new FileInputStream(trustStoreFile);
+ keystore.load(readStream, trustStorePasswd);
+
+ SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext,
+ SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+
+ httpClient = HttpClients.custom().setSSLSocketFactory(factory).build();
+ }
+
+ /**
+ * Constructor that trusts ALL SSl certificates (NOTE : ONLY FOR DEV TESTING) if Mode == 1 or
+ * Default if Mode == 0
+ */
+ public ConnectionBuilder(int mode)
+ throws SSLException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
+ if (mode == 1) {
+ SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build();
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext,
+ SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+
+ httpClient = HttpClients.custom().setSSLSocketFactory(factory).build();
+ } else {
+ httpClient = HttpClients.createDefault();
+ }
+ }
+
+ // Use to create an http context with auth headers
+ public void setHttpContext(String user, String myPassword) {
+
+ // Are credential provided ? If so, set the context to be used
+ if (user != null && !user.isEmpty() && myPassword != null && !myPassword.isEmpty()) {
+ UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, myPassword);
+ AuthScope authscope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
+ BasicCredentialsProvider credsprovider = new BasicCredentialsProvider();
+ credsprovider.setCredentials(authscope, credentials);
+ httpContext.setCredentialsProvider(credsprovider);
+ }
+ }
+
+ // Method posts to the ansible server and writes out response to
+ // Ansible result object
+ public AnsibleResult post(String agentUrl, String payload) {
+
+ AnsibleResult result = new AnsibleResult();
+ try {
+
+ HttpPost postObj = new HttpPost(agentUrl);
+ StringEntity bodyParams = new StringEntity(payload, "UTF-8");
+ postObj.setEntity(bodyParams);
+ postObj.addHeader("Content-type", "application/json");
+
+ HttpResponse response = httpClient.execute(postObj, httpContext);
+
+ HttpEntity entity = response.getEntity();
+ String responseOutput = entity != null ? EntityUtils.toString(entity) : null;
+ int responseCode = response.getStatusLine().getStatusCode();
+ result.setStatusCode(responseCode);
+ result.setStatusMessage(responseOutput);
+ } catch (IOException io) {
+ logger.error("Caught IOException", io);
+ result.setStatusCode(AnsibleResultCodes.IO_EXCEPTION.getValue());
+ result.setStatusMessage(io.getMessage());
+ }
+ return result;
+ }
+
+ // Method gets information from an Ansible server and writes out response to
+ // Ansible result object
+
+ public AnsibleResult get(String agentUrl) {
+
+ AnsibleResult result = new AnsibleResult();
+
+ try {
+ HttpGet getObj = new HttpGet(agentUrl);
+ HttpResponse response = httpClient.execute(getObj, httpContext);
+
+ HttpEntity entity = response.getEntity();
+ String responseOutput = entity != null ? EntityUtils.toString(entity) : null;
+ int responseCode = response.getStatusLine().getStatusCode();
+ result.setStatusCode(responseCode);
+ result.setStatusMessage(responseOutput);
+ } catch (IOException io) {
+ result.setStatusCode(AnsibleResultCodes.IO_EXCEPTION.getValue());
+ result.setStatusMessage(io.getMessage());
+ logger.error("Caught IOException", io);
+ }
+ return result;
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java
new file mode 100644
index 00000000..0f286257
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java
@@ -0,0 +1,311 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible.model;
+
+/**
+ * This module implements the APP-C/Ansible Server interface
+ * based on the REST API specifications
+ */
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import com.google.common.base.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class that validates and constructs requests sent/received from
+ * Ansible Server
+ */
+public class AnsibleMessageParser {
+
+ private static final String STATUS_MESSAGE_KEY = "StatusMessage";
+ private static final String STATUS_CODE_KEY = "StatusCode";
+
+ private static final String PLAYBOOK_NAME_KEY = "PlaybookName";
+ private static final String AGENT_URL_KEY = "AgentUrl";
+ private static final String PASS_KEY = "Password";
+ private static final String USER_KEY = "User";
+ private static final String ID_KEY = "Id";
+
+ private static final String LOCAL_PARAMETERS_OPT_KEY = "LocalParameters";
+ private static final String FILE_PARAMETERS_OPT_KEY = "FileParameters";
+ private static final String ENV_PARAMETERS_OPT_KEY = "EnvParameters";
+ private static final String NODE_LIST_OPT_KEY = "NodeList";
+ private static final String TIMEOUT_OPT_KEY = "Timeout";
+ private static final String VERSION_OPT_KEY = "Version";
+ private static final String ACTION_OPT_KEY = "Action";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AnsibleMessageParser.class);
+
+ /**
+ * Accepts a map of strings and
+ * a) validates if all parameters are appropriate (else, throws an exception) and
+ * b) if correct returns a JSON object with appropriate key-value pairs to send to the server.
+ *
+ * Mandatory parameters, that must be in the supplied information to the Ansible Adapter
+ * 1. URL to connect to
+ * 2. credentials for URL (assume username password for now)
+ * 3. Playbook name
+ *
+ */
+ public JSONObject reqMessage(Map<String, String> params) throws SvcLogicException {
+ final String[] mandatoryTestParams = {AGENT_URL_KEY, PLAYBOOK_NAME_KEY, USER_KEY, PASS_KEY};
+ final String[] optionalTestParams = {ENV_PARAMETERS_OPT_KEY, NODE_LIST_OPT_KEY, LOCAL_PARAMETERS_OPT_KEY,
+ TIMEOUT_OPT_KEY, VERSION_OPT_KEY, FILE_PARAMETERS_OPT_KEY, ACTION_OPT_KEY};
+
+ JSONObject jsonPayload = new JSONObject();
+
+ for (String key : mandatoryTestParams) {
+ throwIfMissingMandatoryParam(params, key);
+ jsonPayload.put(key, params.get(key));
+ }
+
+ parseOptionalParams(params, optionalTestParams, jsonPayload);
+
+ // Generate a unique uuid for the test
+ String reqId = UUID.randomUUID().toString();
+ jsonPayload.put(ID_KEY, reqId);
+
+ return jsonPayload;
+ }
+
+ /**
+ * Method that validates that the Map has enough information
+ * to query Ansible server for a result. If so, it returns
+ * the appropriate url, else an empty string.
+ */
+ public String reqUriResult(Map<String, String> params) throws SvcLogicException {
+
+ final String[] mandatoryTestParams = {AGENT_URL_KEY, ID_KEY, USER_KEY, PASS_KEY};
+
+ for (String key : mandatoryTestParams) {
+ throwIfMissingMandatoryParam(params, key);
+ }
+ return params.get(AGENT_URL_KEY) + "?Id=" + params.get(ID_KEY) + "&Type=GetResult";
+ }
+
+ /**
+ * Method that validates that the Map has enough information
+ * to query Ansible server for logs. If so, it populates the appropriate
+ * returns the appropriate url, else an empty string.
+ */
+ public String reqUriLog(Map<String, String> params) throws SvcLogicException {
+
+ final String[] mandatoryTestParams = {AGENT_URL_KEY, ID_KEY, USER_KEY, PASS_KEY};
+
+ for (String mandatoryParam : mandatoryTestParams) {
+ throwIfMissingMandatoryParam(params, mandatoryParam);
+ }
+ return params.get(AGENT_URL_KEY) + "?Id=" + params.get(ID_KEY) + "&Type=GetLog";
+ }
+
+ /**
+ * This method parses response from the Ansible Server when we do a post
+ * and returns an AnsibleResult object.
+ */
+ public AnsibleResult parsePostResponse(String input) throws SvcLogicException {
+ AnsibleResult ansibleResult;
+ try {
+ JSONObject postResponse = new JSONObject(input);
+
+ int code = postResponse.getInt(STATUS_CODE_KEY);
+ String msg = postResponse.getString(STATUS_MESSAGE_KEY);
+
+ int initResponseValue = AnsibleResultCodes.INITRESPONSE.getValue();
+ boolean validCode = AnsibleResultCodes.CODE.checkValidCode(initResponseValue, code);
+ if (!validCode) {
+ throw new SvcLogicException("Invalid InitResponse code = " + code + " received. MUST be one of "
+ + AnsibleResultCodes.CODE.getValidCodes(initResponseValue));
+ }
+
+ ansibleResult = new AnsibleResult(code, msg);
+
+ } catch (JSONException e) {
+ ansibleResult = new AnsibleResult(600, "Error parsing response = " + input + ". Error = " + e.getMessage());
+ }
+ return ansibleResult;
+ }
+
+ /**
+ * This method parses response from an Ansible server when we do a GET for a result
+ * and returns an AnsibleResult object.
+ **/
+ public AnsibleResult parseGetResponse(String input) throws SvcLogicException {
+
+ AnsibleResult ansibleResult = new AnsibleResult();
+
+ try {
+ JSONObject postResponse = new JSONObject(input);
+ ansibleResult = parseGetResponseNested(ansibleResult, postResponse);
+ } catch (JSONException e) {
+ ansibleResult = new AnsibleResult(AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
+ "Error parsing response = " + input + ". Error = " + e.getMessage(), "");
+ }
+ return ansibleResult;
+ }
+
+ private AnsibleResult parseGetResponseNested(AnsibleResult ansibleResult, JSONObject postRsp) throws SvcLogicException {
+
+ int codeStatus = postRsp.getInt(STATUS_CODE_KEY);
+ String messageStatus = postRsp.getString(STATUS_MESSAGE_KEY);
+ int finalCode = AnsibleResultCodes.FINAL_SUCCESS.getValue();
+
+ boolean valCode =
+ AnsibleResultCodes.CODE.checkValidCode(AnsibleResultCodes.FINALRESPONSE.getValue(), codeStatus);
+
+ if (!valCode) {
+ throw new SvcLogicException("Invalid FinalResponse code = " + codeStatus + " received. MUST be one of "
+ + AnsibleResultCodes.CODE.getValidCodes(AnsibleResultCodes.FINALRESPONSE.getValue()));
+ }
+
+ ansibleResult.setStatusCode(codeStatus);
+ ansibleResult.setStatusMessage(messageStatus);
+ LOGGER.info("Received response with code = {}, Message = {}", codeStatus, messageStatus);
+
+ if (!postRsp.isNull("Results")) {
+
+ // Results are available. process them
+ // Results is a dictionary of the form
+ // {host :{status:s, group:g, message:m, hostname:h}, ...}
+ LOGGER.info("Processing results in response");
+ JSONObject results = postRsp.getJSONObject("Results");
+ LOGGER.info("Get JSON dictionary from Results ..");
+ Iterator<String> hosts = results.keys();
+ LOGGER.info("Iterating through hosts");
+
+ while (hosts.hasNext()) {
+ String host = hosts.next();
+ LOGGER.info("Processing host = {}", host);
+
+ try {
+ JSONObject hostResponse = results.getJSONObject(host);
+ int subCode = hostResponse.getInt(STATUS_CODE_KEY);
+ String message = hostResponse.getString(STATUS_MESSAGE_KEY);
+
+ LOGGER.info("Code = {}, Message = {}", subCode, message);
+
+ if (subCode != 200 || !message.equals("SUCCESS")) {
+ finalCode = AnsibleResultCodes.REQ_FAILURE.getValue();
+ }
+ } catch (JSONException e) {
+ ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
+ ansibleResult.setStatusMessage(String.format(
+ "Error processing response message = %s from host %s", results.getString(host), host));
+ break;
+ }
+ }
+
+ ansibleResult.setStatusCode(finalCode);
+
+ // We return entire Results object as message
+ ansibleResult.setResults(results.toString());
+
+ } else {
+ ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
+ ansibleResult.setStatusMessage("Results not found in GET for response");
+ }
+ return ansibleResult;
+ }
+
+ private void parseOptionalParams(Map<String, String> params, String[] optionalTestParams, JSONObject jsonPayload) {
+
+ Set<String> optionalParamsSet = new HashSet<>();
+ Collections.addAll(optionalParamsSet, optionalTestParams);
+
+ //@formatter:off
+ params.entrySet()
+ .stream()
+ .filter(entry -> optionalParamsSet.contains(entry.getKey()))
+ .filter(entry -> !Strings.isNullOrEmpty(entry.getValue()))
+ .forEach(entry -> parseOptionalParam(entry, jsonPayload));
+ //@formatter:on
+ }
+
+ private void parseOptionalParam(Map.Entry<String, String> params, JSONObject jsonPayload) {
+ String key = params.getKey();
+ String payload = params.getValue();
+
+ switch (key) {
+ case TIMEOUT_OPT_KEY:
+ int timeout = Integer.parseInt(payload);
+ if (timeout < 0) {
+ throw new NumberFormatException(" : specified negative integer for timeout = " + payload);
+ }
+ jsonPayload.put(key, payload);
+ break;
+
+ case VERSION_OPT_KEY:
+ jsonPayload.put(key, payload);
+ break;
+
+ case LOCAL_PARAMETERS_OPT_KEY:
+ case ENV_PARAMETERS_OPT_KEY:
+ JSONObject paramsJson = new JSONObject(payload);
+ jsonPayload.put(key, paramsJson);
+ break;
+
+ case NODE_LIST_OPT_KEY:
+ JSONArray paramsArray = new JSONArray(payload);
+ jsonPayload.put(key, paramsArray);
+ 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);
+ }
+
+ private void throwIfMissingMandatoryParam(Map<String, String> params, String key) throws SvcLogicException {
+ if (!params.containsKey(key)) {
+ throw new SvcLogicException(String.format(
+ "Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !",
+ key));
+ }
+ if (Strings.isNullOrEmpty(params.get(key))) {
+ throw new SvcLogicException(String.format(
+ "Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !",
+ key));
+ }
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResult.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResult.java
new file mode 100644
index 00000000..3d1b3cfa
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResult.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible.model;
+
+/**
+ * Simple class to store code and message returned by POST/GET to an Ansible Server
+ */
+public class AnsibleResult {
+
+ private static final String EMPTY_VALUE = "UNKNOWN";
+
+ private int statusCode;
+ private String statusMessage;
+ private String results;
+
+ public AnsibleResult() {
+ this(-1, EMPTY_VALUE, EMPTY_VALUE);
+ }
+
+ public AnsibleResult(int code, String message) {
+ this(code, message, EMPTY_VALUE);
+ }
+
+ public AnsibleResult(int code, String message, String result) {
+ statusCode = code;
+ statusMessage = message;
+ results = result;
+ }
+
+ public void setStatusCode(int code) {
+ this.statusCode = code;
+ }
+
+ public void setStatusMessage(String message) {
+ this.statusMessage = message;
+ }
+
+ public void setResults(String results) {
+ this.results = results;
+ }
+
+ void set(int code, String message, String results) {
+ this.statusCode = code;
+ this.statusMessage = message;
+ this.results = results;
+ }
+
+ public int getStatusCode() {
+ return this.statusCode;
+ }
+
+ public String getStatusMessage() {
+ return this.statusMessage;
+ }
+
+ public String getResults() {
+ return this.results;
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResultCodes.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResultCodes.java
new file mode 100644
index 00000000..a529e4a0
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleResultCodes.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * enum of the various codes that APP-C uses to resolve different
+ * status of response from Ansible Server
+ **/
+
+public enum AnsibleResultCodes {
+
+ // @formatter:off
+ SUCCESS(400),
+ KEYSTORE_EXCEPTION(622),
+ CERTIFICATE_ERROR(610),
+ IO_EXCEPTION(611),
+ HOST_UNKNOWN(625),
+ USER_UNAUTHORIZED(613),
+ UNKNOWN_EXCEPTION(699),
+ SSL_EXCEPTION(697),
+ INVALID_PAYLOAD(698),
+ INVALID_RESPONSE(601),
+ PENDING(100),
+ REJECTED(101),
+ FINAL_SUCCESS(200),
+ REQ_FAILURE(401),
+ MESSAGE(1),
+ CODE(0),
+ INITRESPONSE(0),
+ FINALRESPONSE(1);
+ // @formatter:on
+
+ private final Set<Integer> initCodes = new HashSet<>(Arrays.asList(100, 101));
+ private final Set<Integer> finalCodes = new HashSet<>(Arrays.asList(200, 500));
+ private final ArrayList<Set<Integer>> codeSets = new ArrayList<>(Arrays.asList(initCodes, finalCodes));
+ private final Set<String> messageSet = new HashSet<>(Arrays.asList("PENDING", "FINISHED", "TERMINATED"));
+ private final int value;
+
+ AnsibleResultCodes(int value) {
+ this.value = value;
+ };
+
+ public int getValue() {
+ return value;
+ }
+
+ public boolean checkValidCode(int type, int code) {
+ return codeSets.get(type).contains(code);
+ }
+
+ public String getValidCodes(int type) {
+ StringBuilder sb = new StringBuilder("[ ");
+ codeSets.get(type).stream().forEach(s -> sb.append(s).append(","));
+ return sb.append("]").toString();
+ }
+
+ public boolean checkValidMessage(String message) {
+ return messageSet.contains(message);
+ }
+
+ public String getValidMessages() {
+ StringBuilder sb = new StringBuilder("[ ");
+ messageSet.stream().forEach(s -> sb.append(s).append(","));
+ return sb.append("]").toString();
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleServerEmulator.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleServerEmulator.java
new file mode 100644
index 00000000..993c7006
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleServerEmulator.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+/*
+ * Class to emulate responses from the Ansible Server that is compliant with the APP-C Ansible Server
+ * Interface. Used for jUnit tests to verify code is working. In tests it can be used
+ * as a replacement for methods from ConnectionBuilder class
+ */
+
+package org.onap.ccsdk.sli.adaptors.ansible.model;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
+import org.json.JSONException;
+import org.json.JSONObject;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class AnsibleServerEmulator {
+
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(AnsibleServerEmulator.class);
+
+ private static final String PLAYBOOK_NAME = "PlaybookName";
+ private static final String STATUS_CODE = "StatusCode";
+ private static final String STATUS_MESSAGE = "StatusMessage";
+
+ private String playbookName = "test_playbook.yaml";
+
+ /**
+ * Method that emulates the response from an Ansible Server
+ * when presented with a request to execute a playbook
+ * Returns an ansible object result. The response code is always the http code 200 (i.e connection successful)
+ * payload is json string as would be sent back by Ansible Server
+ **/
+ public AnsibleResult Post(String agentUrl, String payload) {
+ AnsibleResult result = new AnsibleResult();
+
+ try {
+ // Request must be a JSON object
+
+ JSONObject message = new JSONObject(payload);
+ if (message.isNull("Id")) {
+ rejectRequest(result, "Must provide a valid Id");
+ } else if (message.isNull(PLAYBOOK_NAME)) {
+ rejectRequest(result, "Must provide a playbook Name");
+ } else if (!message.getString(PLAYBOOK_NAME).equals(playbookName)) {
+ rejectRequest(result, "Playbook " + message.getString(PLAYBOOK_NAME) + " not found in catalog");
+ } else {
+ acceptRequest(result);
+ }
+ } catch (JSONException e) {
+ logger.error("JSONException caught", e);
+ rejectRequest(result, e.getMessage());
+ }
+ return result;
+ }
+
+ /**
+ * Method to emulate response from an Ansible
+ * Server when presented with a GET request
+ * Returns an ansibl object result. The response code is always the http code 200 (i.e connection successful)
+ * payload is json string as would be sent back by Ansible Server
+ *
+ **/
+ public AnsibleResult Get(String agentUrl) {
+
+ Pattern pattern = Pattern.compile(".*?\\?Id=(.*?)&Type.*");
+ Matcher matcher = pattern.matcher(agentUrl);
+ String id = StringUtils.EMPTY;
+ String vmAddress = "192.168.1.10";
+
+ if (matcher.find()) {
+ id = matcher.group(1);
+ }
+
+ AnsibleResult getResult = new AnsibleResult();
+
+ JSONObject response = new JSONObject();
+ response.put(STATUS_CODE, 200);
+ response.put(STATUS_MESSAGE, "FINISHED");
+
+ JSONObject results = new JSONObject();
+
+ JSONObject vmResults = new JSONObject();
+ vmResults.put(STATUS_CODE, 200);
+ vmResults.put(STATUS_MESSAGE, "SUCCESS");
+ vmResults.put("Id", id);
+ results.put(vmAddress, vmResults);
+
+ response.put("Results", results);
+
+ getResult.setStatusCode(200);
+ getResult.setStatusMessage(response.toString());
+
+ return getResult;
+ }
+
+ private void rejectRequest(AnsibleResult result, String Message) {
+ result.setStatusCode(200);
+ JSONObject response = new JSONObject();
+ response.put(STATUS_CODE, AnsibleResultCodes.REJECTED.getValue());
+ response.put(STATUS_MESSAGE, Message);
+ result.setStatusMessage(response.toString());
+ }
+
+ private void acceptRequest(AnsibleResult result) {
+ result.setStatusCode(200);
+ JSONObject response = new JSONObject();
+ response.put(STATUS_CODE, AnsibleResultCodes.PENDING.getValue());
+ response.put(STATUS_MESSAGE, "PENDING");
+ result.setStatusMessage(response.toString());
+ }
+} \ No newline at end of file
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/resources/ansible-adaptor.properties b/ansible-adapter/ansible-adapter-bundle/src/main/resources/ansible-adaptor.properties
new file mode 100644
index 00000000..d49c0396
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/resources/ansible-adaptor.properties
@@ -0,0 +1,48 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+#
+# Default properties for the APP-C TestService Adapter
+#
+# -------------------------------------------------------------------------------------------------
+#
+# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
+# to supply configuration options
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=${user.home},/opt/opendaylight/current/properties
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.onap.appc.resources=org.onap/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.onap.appc.provider.adaptor.name=org.onap.appc.appc_ansible_adapter
+
+
+# Default truststore path and password
+org.onap.appc.adapter.ansible.trustStore=/opt/opendaylight/tls-client/mykeystore.js
+org.onap.appc.adapter.ansible.trustStore.trustPasswd=changeit
+org.onap.appc.adapter.ansible.clientType=DEFAULT
diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/resources/org/opendaylight/blueprint/ansible-adapter-blueprint.xml b/ansible-adapter/ansible-adapter-bundle/src/main/resources/org/opendaylight/blueprint/ansible-adapter-blueprint.xml
new file mode 100755
index 00000000..d7be01e9
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/main/resources/org/opendaylight/blueprint/ansible-adapter-blueprint.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <bean id="propProvider" class="org.onap.ccsdk.sli.adaptors.ansible.impl.AnsibleAdapterPropertiesProviderImpl" />
+
+ <bean id="ansibleAdapterInstance" class="org.onap.ccsdk.sli.adaptors.ansible.impl.AnsibleAdapterImpl">
+ <argument ref="propProvider"/>
+ </bean>
+
+ <service ref="ansibleAdapterInstance">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.adaptors.ansible.AnsibleAdapter</value>
+ </interfaces>
+ </service>
+
+</blueprint>
diff --git a/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
new file mode 100644
index 00000000..d96a709c
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.ansible.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.adaptors.ansible.impl.AnsibleAdapterImpl;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+
+public class TestAnsibleAdapterImpl {
+
+ private final String PENDING = "100";
+ private final String SUCCESS = "400";
+ private String message = "{\"Results\":{\"192.168.1.10\":{\"Id\":\"101\",\"StatusCode\":200,\"StatusMessage\":\"SUCCESS\"}},\"StatusCode\":200,\"StatusMessage\":\"FINISHED\"}";
+
+ private AnsibleAdapterImpl adapter;
+ private String TestId;
+ private boolean testMode = true;
+ private Map<String, String> params;
+ private SvcLogicContext svcContext;
+
+
+ @Before
+ public void setup() throws IllegalArgumentException {
+ testMode = true;
+ svcContext = new SvcLogicContext();
+ adapter = new AnsibleAdapterImpl(testMode);
+
+ params = new HashMap<>();
+ params.put("AgentUrl", "https://192.168.1.1");
+ params.put("User", "test");
+ params.put("Password", "test");
+ }
+
+ @After
+ public void tearDown() {
+ testMode = false;
+ adapter = null;
+ params = null;
+ svcContext = null;
+ }
+
+ @Test
+ public void reqExec_shouldSetPending() throws IllegalStateException, IllegalArgumentException {
+
+ params.put("PlaybookName", "test_playbook.yaml");
+
+ try {
+ adapter.reqExec(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.ansible.result.Id");
+ System.out.println("Comparing " + PENDING + " and " + status);
+ assertEquals(PENDING, status);
+ } catch (SvcLogicException e) {
+ String status = svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ fail(e.getMessage() + " Code = " + status);
+ } catch (Exception e) {
+ fail(e.getMessage() + " Unknown exception encountered ");
+ }
+ }
+
+ @Test
+ public void reqExecResult_shouldSetSuccess() throws IllegalStateException, IllegalArgumentException {
+
+ params.put("Id", "100");
+
+ for (String ukey : params.keySet()) {
+ System.out.println(String.format("Ansible Parameter %s = %s", ukey, params.get(ukey)));
+ }
+
+ try {
+ adapter.reqExecResult(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ assertEquals(SUCCESS, status);
+ } catch (SvcLogicException e) {
+ String status = svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ fail(e.getMessage() + " Code = " + status);
+ } catch (Exception e) {
+ fail(e.getMessage() + " Unknown exception encountered ");
+ }
+ }
+
+ @Test
+ public void reqExecLog_shouldSetMessage() throws IllegalStateException, IllegalArgumentException {
+
+ params.put("Id", "101");
+
+ try {
+ adapter.reqExecLog(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.ansible.log");
+ assertEquals(message, status);
+ } catch (SvcLogicException e) {
+ String status = svcContext.getAttribute("org.onap.appc.adapter.ansible.log");
+ fail(e.getMessage() + " Code = " + status);
+ } catch (Exception e) {
+ fail(e.getMessage() + " Unknown exception encountered ");
+ }
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/model/TestAnsibleAdapter.java b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/model/TestAnsibleAdapter.java
new file mode 100644
index 00000000..aebc1c0d
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/model/TestAnsibleAdapter.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.appc.adapter.ansible.model;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.lang.reflect.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleMessageParser;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleResult;
+import org.onap.ccsdk.sli.adaptors.ansible.model.AnsibleServerEmulator;
+
+public class TestAnsibleAdapter {
+
+ private Class[] parameterTypes;
+ private AnsibleMessageParser ansibleMessageParser;
+ private Method m;
+ private String name;
+
+ @Test
+ public void callPrivateConstructorsMethodsForCodeCoverage() throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ /* test constructors */
+ Class<?>[] classesOne = {AnsibleMessageParser.class};
+ for(Class<?> clazz : classesOne) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ name = constructor.getName();
+ constructor.setAccessible(true);
+ assertNotNull(constructor.newInstance());
+ }
+ Class<?>[] classesTwo = {AnsibleServerEmulator.class};
+ for(Class<?> clazz : classesTwo) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ name = constructor.getName();
+ constructor.setAccessible(true);
+ assertNotNull(constructor.newInstance());
+ }
+ Class<?>[] classesThree = {AnsibleResult.class};
+ for(Class<?> clazz : classesThree) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ name = constructor.getName();
+ constructor.setAccessible(true);
+ assertNotNull(constructor.newInstance());
+ }
+
+ /* test methods */
+ ansibleMessageParser = new AnsibleMessageParser();
+ parameterTypes = new Class[1];
+ parameterTypes[0] = java.lang.String.class;
+
+ m = ansibleMessageParser.getClass().getDeclaredMethod("getFilePayload", parameterTypes);
+ m.setAccessible(true);
+ assertNotNull(m.invoke(ansibleMessageParser,"{\"test\": test}"));
+
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
new file mode 100644
index 00000000..13b5fdfb
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
@@ -0,0 +1,182 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.appc.test;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.appc.test.InterceptLogger;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+
+/**
+ * This class is used as a test harness to wrap the call to an executor node.
+ */
+
+public class ExecutorHarness {
+
+ /**
+ * The executor to be tested
+ */
+ private SvcLogicJavaPlugin executor;
+
+ /**
+ * The collection of all exec methods found on the class
+ */
+ private Map<String, Method> methods;
+
+ /**
+ * The field of the class being tested that contains the reference to the logger to be used. This is modified to
+ * point to our interception logger for the test.
+ */
+ private Field contextLogger;
+
+ /**
+ * The interception logger that buffers all messages logged and allows us to look at them as part of the test case.
+ */
+ private InterceptLogger logger;
+
+ /**
+ * Create the harness and initialize it
+ *
+ * @throws SecurityException
+ * If a security manager, s, is present and any of the following conditions is met:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>the caller's class loader is not the same as or an ancestor of the class loader for the current
+ * class and invocation of s.checkPackageAccess() denies access to the package of this class</li>
+ * </ul>
+ * @throws NoSuchFieldException
+ * if a field with the specified name is not found.
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is either
+ * inaccessible or final.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+ */
+ @SuppressWarnings("nls")
+ public ExecutorHarness() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
+ IllegalAccessException {
+ methods = new HashMap<>();
+ new SvcLogicContext();
+
+ Class<?> contextClass = SvcLogicContext.class;
+ contextLogger = contextClass.getDeclaredField("LOG");
+ contextLogger.setAccessible(true);
+ logger = new InterceptLogger();
+ contextLogger.set(null, logger);
+ }
+
+ /**
+ * Convenience constructor
+ *
+ * @param executor
+ * The executor to be tested by the harness
+ * @throws SecurityException
+ * If a security manager, s, is present and any of the following conditions is met:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>the caller's class loader is not the same as or an ancestor of the class loader for the current
+ * class and invocation of s.checkPackageAccess() denies access to the package of this class</li>
+ * </ul>
+ * @throws NoSuchFieldException
+ * if a field with the specified name is not found.
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is either
+ * inaccessible or final.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+ */
+ public ExecutorHarness(SvcLogicJavaPlugin executor) throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+ this();
+ setExecutor(executor);
+ }
+
+ /**
+ * @param executor
+ * The java plugin class to be executed
+ */
+ public void setExecutor(SvcLogicJavaPlugin executor) {
+ this.executor = executor;
+ scanExecutor();
+ }
+
+ /**
+ * @return The java plugin class to be executed
+ */
+ public SvcLogicJavaPlugin getExecutor() {
+ return executor;
+ }
+
+ /**
+ * @return The set of all methods that meet the signature requirements
+ */
+ public List<String> getExecMethodNames() {
+ List<String> names = new ArrayList<>();
+ names.addAll(methods.keySet());
+ return names;
+ }
+
+ /**
+ * Returns an indication if the named method is a valid executor method that could be called from a DG execute node
+ *
+ * @param methodName
+ * The method name to be validated
+ * @return True if the method name meets the signature requirements, false if the method either does not exist or
+ * does not meet the requirements.
+ */
+ public boolean isExecMethod(String methodName) {
+ return methods.containsKey(methodName);
+ }
+
+ /**
+ * This method scans the executor class hierarchy to locate all methods that match the required signature of the
+ * executor and records these methods in a map.
+ */
+ private void scanExecutor() {
+ methods.clear();
+ Class<?> executorClass = executor.getClass();
+ Method[] publicMethods = executorClass.getMethods();
+ for (Method method : publicMethods) {
+ if (method.getReturnType().equals(Void.class)) {
+ Class<?>[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length == 2) {
+ if (Map.class.isAssignableFrom(paramTypes[0])
+ && SvcLogicContext.class.isAssignableFrom(paramTypes[1])) {
+ methods.put(method.getName(), method);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
new file mode 100644
index 00000000..b101ecee
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
@@ -0,0 +1,454 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.appc.test;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Marker;
+
+import ch.qos.logback.classic.Level;
+
+/**
+ * This class is used as an intercept logger that can be used in testing to intercept and record all messages that are
+ * logged, thus allowing a junit test case to examine the log output and make assertions.
+ */
+public class InterceptLogger implements org.slf4j.Logger {
+
+ /**
+ * This inner class represents an intercepted log event
+ */
+ public class LogRecord {
+ private Level level;
+ private String message;
+ private long timestamp;
+ private Throwable t;
+
+ public LogRecord(Level level, String message) {
+ setLevel(level);
+ setTimestamp(System.currentTimeMillis());
+ setMessage(message);
+ }
+
+ public LogRecord(Level level, String message, Throwable t) {
+ this(level, message);
+ setThrowable(t);
+ }
+
+ /**
+ * @return the value of level
+ */
+ public Level getLevel() {
+ return level;
+ }
+
+ /**
+ * @return the value of message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * @return the value of timestamp
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * @param level
+ * the value for level
+ */
+ public void setLevel(Level level) {
+ this.level = level;
+ }
+
+ /**
+ * @param message
+ * the value for message
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * @param timestamp
+ * the value for timestamp
+ */
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * @return the value of t
+ */
+ public Throwable getThrowable() {
+ return t;
+ }
+
+ /**
+ * @param t
+ * the value for t
+ */
+ public void setThrowable(Throwable t) {
+ this.t = t;
+ }
+
+ }
+
+ /**
+ * The list of all intercepted log events
+ */
+ private List<LogRecord> events;
+
+ /**
+ * Create the intercept logger
+ */
+ public InterceptLogger() {
+ events = new ArrayList<LogRecord>(1000);
+ }
+
+ /**
+ * @return Returns all intercepted log events
+ */
+ public List<LogRecord> getLogRecords() {
+ return events;
+ }
+
+ /**
+ * Clears all log events
+ */
+ public void clear() {
+ events.clear();
+ }
+
+ @Override
+ public void debug(Marker marker, String msg) {
+ debug(msg);
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg) {
+ debug(MessageFormat.format(format, arg));
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object... arguments) {
+ debug(MessageFormat.format(format, arguments));
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg1, Object arg2) {
+ debug(MessageFormat.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void debug(Marker marker, String msg, Throwable t) {
+ debug(msg, t);
+ }
+
+ @Override
+ public void debug(String msg) {
+ events.add(new LogRecord(Level.DEBUG, msg));
+ }
+
+ @Override
+ public void debug(String format, Object arg) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void debug(String format, Object... arguments) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void debug(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void debug(String msg, Throwable t) {
+ events.add(new LogRecord(Level.DEBUG, msg, t));
+ }
+
+ @Override
+ public void error(Marker marker, String msg) {
+ error(msg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg) {
+ error(format, arg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object... arguments) {
+ error(format, arguments);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg1, Object arg2) {
+ error(format, arg1, arg2);
+ }
+
+ @Override
+ public void error(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.ERROR, msg, t));
+ }
+
+ @Override
+ public void error(String msg) {
+ events.add(new LogRecord(Level.ERROR, msg));
+ }
+
+ @Override
+ public void error(String format, Object arg) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void error(String format, Object... arguments) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void error(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void error(String msg, Throwable t) {
+ events.add(new LogRecord(Level.ERROR, msg, t));
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public void info(Marker marker, String msg) {
+ info(msg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg) {
+ info(format, arg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object... arguments) {
+ info(format, arguments);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg1, Object arg2) {
+ info(format, arg1, arg2);
+ }
+
+ @Override
+ public void info(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.INFO, msg, t));
+ }
+
+ @Override
+ public void info(String msg) {
+ events.add(new LogRecord(Level.INFO, msg));
+ }
+
+ @Override
+ public void info(String format, Object arg) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void info(String format, Object... arguments) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void info(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void info(String msg, Throwable t) {
+ events.add(new LogRecord(Level.INFO, msg, t));
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isDebugEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isInfoEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isTraceEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isWarnEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public void trace(Marker marker, String msg) {
+ trace(msg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg) {
+ trace(format, arg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object... argArray) {
+ trace(format, argArray);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg1, Object arg2) {
+ trace(format, arg1, arg2);
+ }
+
+ @Override
+ public void trace(Marker marker, String msg, Throwable t) {
+ trace(msg, t);
+ }
+
+ @Override
+ public void trace(String msg) {
+ events.add(new LogRecord(Level.TRACE, msg));
+ }
+
+ @Override
+ public void trace(String format, Object arg) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void trace(String format, Object... arguments) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void trace(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void trace(String msg, Throwable t) {
+ events.add(new LogRecord(Level.TRACE, msg, t));
+ }
+
+ @Override
+ public void warn(Marker marker, String msg) {
+ warn(msg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg) {
+ warn(format, arg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object... arguments) {
+ warn(format, arguments);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg1, Object arg2) {
+ warn(format, arg1, arg2);
+ }
+
+ @Override
+ public void warn(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.WARN, msg, t));
+ }
+
+ @Override
+ public void warn(String msg) {
+ events.add(new LogRecord(Level.WARN, msg));
+ }
+
+ @Override
+ public void warn(String format, Object arg) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void warn(String format, Object... arguments) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void warn(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void warn(String msg, Throwable t) {
+ events.add(new LogRecord(Level.WARN, msg, t));
+ }
+}
diff --git a/ansible-adapter/ansible-adapter-bundle/src/test/resources/org/onap/appc/default.properties b/ansible-adapter/ansible-adapter-bundle/src/test/resources/org/onap/appc/default.properties
new file mode 100644
index 00000000..2f8fb458
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-bundle/src/test/resources/org/onap/appc/default.properties
@@ -0,0 +1,111 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+#
+# Default properties for the APP-C Provider Adapter
+#
+# -------------------------------------------------------------------------------------------------
+#
+# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
+# to supply configuration options
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/onap/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.onap.appc.resources=org/onap/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.onap.appc.provider.adaptor.name=org.onap.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.onap.appc.logging.file=org/onap/appc/logback.xml
+org.onap.appc.logging.path=${user.home};etc;../etc
+org.onap.appc.logger=org.onap.appc
+org.onap.appc.security.logger=org.onap.appc.security
+#
+# The minimum and maximum provider/tenant context pool sizes. Min=1 means that as soon
+# as the provider/tenant is referenced a Context is opened and added to the pool. Max=0
+# means that the upper bound on the pool is unbounded.
+org.onap.appc.provider.min.pool=1
+org.onap.appc.provider.max.pool=0
+
+#
+# The following properties are used to configure the retry logic for connection to the
+# IaaS provider(s). The retry delay property is the amount of time, in seconds, the
+# application waits between retry attempts. The retry limit is the number of retries
+# that are allowed before the request is failed.
+org.onap.appc.provider.retry.delay = 30
+org.onap.appc.provider.retry.limit = 10
+
+#
+# The trusted hosts list for SSL access when a certificate is not provided.
+#
+provider.trusted.hosts=*
+#
+# The amount of time, in seconds, to wait for a server state change (start->stop, stop->start, etc).
+# If the server does not change state to a valid state within the alloted time, the operation
+# fails.
+org.onap.appc.server.state.change.timeout=300
+#
+# The amount of time to wait, in seconds, between subsequent polls to the OpenStack provider
+# to refresh the status of a resource we are waiting on.
+#
+org.onap.appc.openstack.poll.interval=20
+#
+# The connection information to connect to the provider we are using. These properties
+# are "structured" properties, in that the name is a compound name, where the nodes
+# of the name can be ordered (1, 2, 3, ...). All of the properties with the same ordinal
+# position are defining the same entity. For example, provider1.type and provider1.name
+# are defining the same provider, whereas provider2.name and provider2.type are defining
+# the values for a different provider. Any number of providers can be defined in this
+# way.
+#
+
+# Don't change these 2 right now since they are hard coded in the DG
+#provider1.type=appc
+#provider1.name=appc
+
+#These you can change
+#provider1.identity=appc
+#provider1.tenant1.name=appc
+#provider1.tenant1.userid=appc
+#provider1.tenant1.password=appc
+
+# After a change to the provider make sure to recheck these values with an api call to provider1.identity/tokens
+test.expected-regions=1
+test.expected-endpoints=1
+
+#Your OpenStack IP
+#test.ip=192.168.1.2
+# Your OpenStack Platform's Keystone Port (default is 5000)
+#test.port=5000
+#test.tenantid=abcde12345fghijk6789lmnopq123rst
+#test.vmid=abc12345-1234-5678-890a-abcdefg12345
+# Port 8774 below is default port for OpenStack's Nova API Service
+#test.url=http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345
+
diff --git a/ansible-adapter/ansible-adapter-features/.gitignore b/ansible-adapter/ansible-adapter-features/.gitignore
new file mode 100644
index 00000000..8820cee5
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-features/.gitignore
@@ -0,0 +1,26 @@
+# ============LICENSE_START==========================================
+# ONAP : APPC
+# ===================================================================
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the License);
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END============================================
+/target/
+/target-ide/
+/bin/
+/classes/
+/.settings/
diff --git a/ansible-adapter/ansible-adapter-features/ccsdk-ansible-adapter/pom.xml b/ansible-adapter/ansible-adapter-features/ccsdk-ansible-adapter/pom.xml
new file mode 100644
index 00000000..d847dc78
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-features/ccsdk-ansible-adapter/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>single-feature-parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>ccsdk-ansible-adapter</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>ccsdk-sli-adaptors :: ansible-adapter:: ${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>odl-mdsal-broker</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>ccsdk-sli</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ansible-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/ansible-adapter/ansible-adapter-features/features-ansible-adapter/pom.xml b/ansible-adapter/ansible-adapter-features/features-ansible-adapter/pom.xml
new file mode 100755
index 00000000..3bb94421
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-features/features-ansible-adapter/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>feature-repo-parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>features-ansible-adapter</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>ccsdk-sli-adaptors :: ansible-adapter :: ${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ccsdk-ansible-adapter</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/ansible-adapter/ansible-adapter-features/pom.xml b/ansible-adapter/ansible-adapter-features/pom.xml
new file mode 100644
index 00000000..036cc075
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-features/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ============LICENSE_START=======================================================
+ ONAP : APPC ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. ================================================================================
+ Copyright (C) 2017 Amdocs =============================================================================
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. ECOMP is
+ a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END========================================================= -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>odlparent-lite</artifactId>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>ansible-adapter-features</artifactId>
+ <name>ccsdk-sli-adaptors :: ansible-adapter :: ${project.artifactId}</name>
+
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>ccsdk-ansible-adapter</module>
+ <module>features-ansible-adapter</module>
+ </modules>
+</project>
diff --git a/ansible-adapter/ansible-adapter-features/src/main/resources/features.xml b/ansible-adapter/ansible-adapter-features/src/main/resources/features.xml
new file mode 100644
index 00000000..69d3b9b0
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-features/src/main/resources/features.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-ansible-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+ <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features</repository>
+
+ <feature name='appc-ansible-adapter' description="appc-ansible-adapter" version='${project.version}'>
+ <feature version="${odl.mdsal.version}">odl-mdsal-broker</feature>
+ <feature>sdnc-sli</feature>
+ <bundle dependency="true">mvn:org.onap.appc/appc-common/${project.version}</bundle>
+ <bundle>mvn:org.onap.appc/appc-ansible-adapter-bundle/${project.version}</bundle>
+ </feature>
+
+</features>
diff --git a/ansible-adapter/ansible-adapter-installer/pom.xml b/ansible-adapter/ansible-adapter-installer/pom.xml
new file mode 100644
index 00000000..7aa18ba5
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-installer/pom.xml
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>ansible-adapter-installer</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <name>ccsdk-sli-adaptors :: ansible-adapter :: ${project.artifactId}</name>
+ <packaging>pom</packaging>
+ <properties>
+ <application.name>ccsdk-ansible-adapter</application.name>
+ <features.boot>${application.name}</features.boot>
+ <features.repositories>mvn:org.onap.ccsdk.sli.adaptors/${features.boot}/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>${application.name}</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>ansible-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <excludeGroupIds>org.opendaylight</excludeGroupIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/ansible-adapter/ansible-adapter-installer/src/assembly/assemble_installer_zip.xml b/ansible-adapter/ansible-adapter-installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 00000000..322fa76e
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,62 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/ansible-adapter/ansible-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml b/ansible-adapter/ansible-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 00000000..615ee37d
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,50 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/ansible-adapter/ansible-adapter-installer/src/main/resources/scripts/install-feature.sh b/ansible-adapter/ansible-adapter-installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 00000000..05b4ae37
--- /dev/null
+++ b/ansible-adapter/ansible-adapter-installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,43 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+#!/bin/bash
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -n -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot}
diff --git a/ansible-adapter/ansible-example-server/AnsibleModule.py b/ansible-adapter/ansible-example-server/AnsibleModule.py
new file mode 100644
index 00000000..3458c28b
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/AnsibleModule.py
@@ -0,0 +1,170 @@
+'''
+/*-
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Copyright (C) 2017 Amdocs
+* =============================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+* ============LICENSE_END=========================================================
+*/
+'''
+
+import os, subprocess
+import sys
+from collections import namedtuple
+import json
+
+import uuid
+
+def ansibleSysCall (inventory_path, playbook_path, nodelist, mandatory,
+ envparameters, localparameters, lcm, timeout):
+
+ print "***> in AnsibleModule.ansibleSysCall"
+ print " EnvParameters: ", envparameters
+ print " LocalParameters:", localparameters
+ print " Inventory: ", inventory_path
+ print " Playbook: ", playbook_path
+ print " NodeList: ", nodelist
+ print " Mandatory: ", mandatory
+ print " Timeout: ", timeout
+ log = []
+
+ str_parameters = ''
+
+ if not envparameters == {}:
+ for key in envparameters:
+ if str_parameters == '':
+ str_parameters = '"' + str(key) + '=\'' + str(envparameters[key]) + '\''
+ else:
+ str_parameters += ' ' + str(key) + '=\'' + str(envparameters[key]) + '\''
+ str_parameters += '"'
+
+ if len(str_parameters) > 0:
+ cmd = 'timeout --signal=KILL ' + str(timeout) + \
+ ' ansible-playbook -v --extra-vars ' + str_parameters + ' -i ' + \
+ inventory_path + ' ' + playbook_path
+ else:
+ cmd = 'timeout --signal=KILL ' + str(timeout) + \
+ ' ansible-playbook -v -i ' + inventory_path + ' ' + playbook_path
+
+ print " CMD: ", cmd
+
+ print "\n =================ANSIBLE STDOUT BEGIN============================================\n"
+ p = subprocess.Popen(cmd, shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ # p.wait()
+ (stdout_value, err) = p.communicate()
+
+ stdout_value_cleanup = ''
+ for line in stdout_value:
+ stdout_value_cleanup += line.replace(' ', ' ')
+ stdout_value = stdout_value_cleanup.splitlines()
+
+ ParseFlag = False
+ retval = {}
+ returncode = p.returncode
+
+ if returncode == 137:
+
+ print " ansible-playbook system call timed out"
+ # ansible-playbook system call timed out
+ for line in stdout_value: # p.stdout.readlines():
+ log.append (line)
+
+
+ elif 'ping' in lcm:
+
+ targetnode = envparameters['TargetNode'].split(' ')
+ str_json = None
+ for line in stdout_value: # p.stdout.readlines():
+ print line # line,
+ if "PLAY RECAP" in line:
+ ParseFlag = False
+ if ParseFlag and len(line.strip())>0:
+ str_json += line.strip()
+ if "TASK [debug]" in line:
+ ParseFlag = True
+ str_json = ''
+ log.append (line)
+
+ if str_json:
+ if '=>' in str_json:
+ out_json =eval(str_json.split('=>')[1].replace('true','True').replace('false','False'))
+
+ if 'ping.stdout_lines' in out_json:
+ for node in targetnode:
+ ip_address = node
+ ok_flag = '0'
+ changed_flag = '0'
+ unreachable_flag = '0'
+ failed_flag = '1'
+ for rec in out_json['ping.stdout_lines']:
+ if node in rec and "is alive" in rec:
+ ok_flag = '1'
+ changed_flag = '1'
+ unreachable_flag = '0'
+ failed_flag = '0'
+ for rec in out_json['ping.stdout_lines']:
+ if node in rec and "address not found" in rec:
+ ok_flag = '0'
+ changed_flag = '0'
+ unreachable_flag = '1'
+ failed_flag = '0'
+ retval[ip_address]=[ok_flag, changed_flag, unreachable_flag,
+ failed_flag]
+ else:
+
+ for line in stdout_value: # p.stdout.readlines():
+ print line # line,
+ if ParseFlag and len(line.strip())>0:
+ ip_address = line.split(':')[0].strip()
+ ok_flag = line.split(':')[1].strip().split('=')[1].split('changed')[0].strip()
+ changed_flag = line.split(':')[1].strip().split('=')[2].split('unreachable')[0].strip()
+ unreachable_flag = line.split(':')[1].strip().split('=')[3].split('failed')[0].strip()
+ failed_flag = line.split(':')[1].strip().split('=')[4].strip()
+ retval[ip_address]=[ok_flag, changed_flag, unreachable_flag, failed_flag]
+ if "PLAY RECAP" in line:
+ ParseFlag = True
+ log.append (line)
+
+ # retval['p'] = p.wait()
+
+ print " =================ANSIBLE STDOUT END==============================================\n"
+
+ return retval, log, returncode
+
+if __name__ == '__main__':
+
+ from multiprocessing import Process, Value, Array, Manager
+ import time
+
+ nodelist = 'host'
+
+ playbook_file = 'ansible_sleep@0.00.yml'
+
+
+ d = Manager().dict()
+
+ p = Process(nodelist=ansible_call, args=('ansible_module_config', playbook_file, nodelist,d, ))
+ p.start()
+
+ print "Process running"
+ print d
+ p.join()
+ print d
diff --git a/ansible-adapter/ansible-example-server/AnsibleSql.py b/ansible-adapter/ansible-example-server/AnsibleSql.py
new file mode 100644
index 00000000..ab58a96c
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/AnsibleSql.py
@@ -0,0 +1,322 @@
+'''
+/*-
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Copyright (C) 2017 Amdocs
+* =============================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+* ============LICENSE_END=========================================================
+*/
+'''
+
+import pymysql, sys
+from os import listdir
+from os.path import isfile, join
+
+class mySql():
+
+ def __init__(self, myhost, myuser, mypasswd, mydb):
+ self.con = True
+ self.error = ''
+ self.db = None
+ try:
+ self.db = pymysql.connect(host=myhost,
+ user=myuser,
+ passwd=mypasswd,
+ db=mydb)
+ self.cur = self.db.cursor()
+ except Exception as e:
+ self.error = e[1]
+ self.con = False
+
+ def Query (self, myquery, val = None):
+ results = None
+ try:
+ if val:
+ self.cur.execute(myquery, val)
+ else:
+ self.cur.execute(myquery)
+ self.db.commit()
+ results = self.cur.fetchall()
+ except Exception, e:
+ results = repr(e)
+ return results
+
+ def Close (self):
+ if self.db:
+ self.db.close()
+
+def loadPlaybook (sqlintf, value, version, ext = '.yml'):
+
+ errorCode = 0
+ diag = ''
+
+ # Test if primary key already defined
+ query = "SELECT name FROM playbook WHERE name='" + value +"'"
+ results = sqlintf.Query (query)
+ if len(results) > 0:
+ pass
+ else:
+ query = "INSERT INTO playbook (name) VALUES ('" + value + "')"
+ results = sqlintf.Query (query)
+ if len(results) > 0:
+ errorCode = 1
+ diag = results
+
+ # Load playbook
+ file = open(playbook_path + value + ext, 'r')
+ load_file = file.read()
+
+ if not errorCode:
+ sql = "UPDATE playbook SET value=%s, version=%s, type=%s WHERE name=%s"
+
+ results = sqlintf.Query(sql, (load_file, version, ext, value))
+
+ if len (results) > 0:
+ # Error loading playbook
+ errorCode = 1
+ diag = results
+
+ return errorCode, diag
+
+def loadCredentials (sqlintf, hostgroup, hostname, cred):
+ errorCode = 0
+ diag = ''
+
+ # Load credentials
+
+ query = "SELECT hostname,hostgroup FROM inventory WHERE hostname='" + hostname +"'"
+ results = sqlintf.Query (query)
+
+ if hostname in str (results):
+
+ results_hostgroups = results[0][1]
+
+ if hostgroup in results_hostgroups.split(','):
+ query = "UPDATE inventory SET hostname='" + hostname + "',credentials='" +\
+ cred +\
+ "' WHERE hostname='" + hostname + "'"
+ else:
+
+ results_hostgroups = results_hostgroups + ',' + hostgroup
+
+ query = "UPDATE inventory SET hostname='" + hostname + "',credentials='" +\
+ cred + "',hostgroup='" + results_hostgroups + \
+ "' WHERE hostname='" + hostname + "'"
+
+ results = sqlintf.Query (query)
+
+ else:
+
+ query = "INSERT INTO inventory (hostgroup, hostname, credentials) VALUES ('" + \
+ hostgroup + "','" + hostname + "','" + cred + "')"
+ results = sqlintf.Query (query)
+
+ if len (results) > 0:
+ # Error loading playbook
+ errorCode = 1
+ diag = results
+
+ return errorCode, diag
+
+
+def readPlaybook (sqlintf, value, version=None):
+
+ errorCode = 0
+ diag = ''
+
+ print "***> in AnsibleSql.readPlaybook"
+
+ if not version:
+ query = "SELECT MAX(version) FROM playbook WHERE name like'" + value + "%'"
+ print " Query:", query
+ results = sqlintf.Query (query)
+ version = results[0][0]
+
+ print " Provided playbook name:", value
+ print " Used version:", version
+
+ results = []
+ if version:
+ query = "SELECT value,type FROM playbook WHERE name='" + value + "@" + version + "'"
+ results = sqlintf.Query (query)
+
+ print "Query:", query
+ print "Results:", results
+
+ if len(results) == 0:
+ errorCode = 1
+ else:
+ if len(results[0]) == 0:
+ errorCode = 1
+ diag = results[0]
+ else:
+ diag = results[0]
+
+ return value, version, errorCode, diag
+
+def readCredentials (sqlintf, tag):
+ errorCode = []
+ diag = []
+
+ print "***> in AnsibleSql.readCredential"
+
+ # Load credentials
+
+ for rec in tag:
+
+ # Try hostgroup
+ query = "SELECT hostgroup, hostname, credentials FROM inventory WHERE hostgroup LIKE '%" + \
+ rec +"%'"
+ query_results = sqlintf.Query (query)
+
+ results = ()
+ for q in query_results:
+ if rec in q[0].split(','):
+ l = list(q)
+ l[0] = rec
+ q = tuple(l)
+ results = (q,) + results
+
+ if len(results) == 0:
+ # Try hostname
+ query = "SELECT hostgroup, hostname, credentials FROM inventory WHERE hostname='" + \
+ rec +"'"
+ results = sqlintf.Query (query)
+
+ print " Query:", query
+ print " Results:", len(results), results
+
+ if len(results) == 0:
+ errorCode = 1
+ hostgroup = rec
+ hostname = rec
+ credentials = 'ansible_connection=ssh ansible_ssh_user=na ansible_ssh_private_key_file=na\n'
+ diag.append([hostgroup, hostname, credentials])
+ else:
+ errorCode = 0
+ for i in range(len (results)):
+ for h in results[i][0].split(','):
+ hostgroup = h
+ hostname = results[i][1]
+ credentials = results[i][2]
+ diag.append([hostgroup, hostname, credentials])
+
+ return errorCode, diag
+
+
+if __name__ == '__main__':
+
+ ################################################################
+ # Change below
+ ################################################################
+ host="localhost" # your host, usually localhost
+ user="mysql_user_id" # your username
+ passwd="password_4_mysql_user_id" # your password
+ db="ansible" # name of the data base
+
+ playbook_path = "/home/ubuntu/RestServerOpenSource/"
+ inventory = "/home/ubuntu/RestServerOpenSource/Ansible_inventory"
+ ################################################################
+
+ onlyfiles = [f for f in listdir(playbook_path)
+ if isfile(join(playbook_path, f))]
+
+ sqlintf = mySql (host, user, passwd, db)
+
+ # Load playbooks
+
+ print "Loading playbooks"
+ for file in onlyfiles:
+ if "yml" in file:
+
+ name = file.split (".yml")[0]
+ print " Loading:", name
+ version = name.split("@")[1]
+ errorCode, diag = loadPlaybook (sqlintf, name, version, '.yml')
+ if errorCode:
+ print " Results: Failed - ", diag
+ else:
+ print " Results: Success"
+
+ print "\nLoading inventory"
+
+ # Load inventory
+
+ hostgroup = None
+ inv = {}
+ file = open(inventory, 'r')
+
+ for line in file:
+
+ if '[' in line and ']' in line:
+ hostgroup = line.strip().replace('[','').replace(']','')
+ inv[hostgroup] = {}
+ elif hostgroup and len(line.strip())>0:
+ host = line.strip().split(" ")[0]
+ credentials = line.replace(host,"")
+ inv[hostgroup][host] = credentials
+
+ file.close()
+
+ for hostgroup in inv:
+ print " Loading:", hostgroup
+ hostfqdn = ''
+ cred = ''
+ for hostname in inv[hostgroup]:
+ cred = inv[hostgroup][hostname]
+ errorCode, diag = loadCredentials (sqlintf, hostgroup, hostname, cred)
+ if errorCode:
+ print " Results: Failed - ", diag
+ else:
+ print " Results: Success"
+
+ print "\nReading playbook"
+
+ # Read playbook
+
+ if not sqlintf.con:
+ print "Cannot connect to MySql:", sqlintf.error
+ sys.exit()
+
+ name = "ansible_sleep"
+ print "Reading playbook:", name
+ value, version, errorCode, diag = readPlaybook (sqlintf, name)
+ if errorCode:
+ print "Results: Failed - ", diag
+ else:
+ print "Results: Success"
+ print value
+ print version
+ print diag
+
+ print "\nReading inventory"
+
+ # Read inventory
+
+ tag = ["your_inventory_test_group_name"]
+ print "Reading inventory tag:", tag
+ errorCode, diag = readCredentials (sqlintf, tag)
+ if errorCode:
+ print "Results: Failed - ", diag
+ else:
+ print "Results: Success"
+ print diag
+
+ sqlintf.Close()
+
diff --git a/ansible-adapter/ansible-example-server/Ansible_inventory b/ansible-adapter/ansible-example-server/Ansible_inventory
new file mode 100644
index 00000000..69df84ff
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/Ansible_inventory
@@ -0,0 +1,27 @@
+# /*-
+# * ============LICENSE_START=======================================================
+# * ONAP : APPC
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# * ================================================================================
+# * Copyright (C) 2017 Amdocs
+# * =============================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# * ============LICENSE_END=========================================================
+# */
+
+[host]
+localhost ansible_connection=local
+
diff --git a/ansible-adapter/ansible-example-server/LoadAnsibleMySql.py b/ansible-adapter/ansible-example-server/LoadAnsibleMySql.py
new file mode 100644
index 00000000..0a1c78a6
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/LoadAnsibleMySql.py
@@ -0,0 +1,207 @@
+'''
+/*-
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Copyright (C) 2017 Amdocs
+* =============================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+* ============LICENSE_END=========================================================
+*/
+'''
+
+#!/usr/bin/python
+import pymysql
+from os import listdir
+from os.path import isfile, join
+
+class mySql():
+
+ def __init__(self, myhost, myuser, mypasswd, mydb):
+ self.db = pymysql.connect(host=myhost,
+ user=myuser,
+ passwd=mypasswd,
+ db=mydb)
+ self.cur = self.db.cursor()
+
+ def Query (self, myquery, val = None):
+ results = None
+ error = None
+ try:
+ if val:
+ self.cur.execute(myquery, val)
+ else:
+ self.cur.execute(myquery)
+ self.db.commit()
+ results = self.cur.fetchall()
+ except Exception, e:
+ error = str (e)
+ return results, error
+
+ def Close (self):
+ self.db.close()
+
+def loadPlaybook (value, version, ext = '.yml'):
+
+ errorCode = 0
+ diag = ''
+
+ # Test if primary key already defined
+ query = "SELECT name FROM playbook WHERE name='" + value +"'"
+ results, error = sqlintf.Query (query)
+ if results:
+ # print "Primary key already defined: Updating playbook"
+ pass
+ else:
+ # print "Primary key not defined: Insert new playbook"
+ query = "INSERT INTO playbook (name) VALUES ('" + value + "')"
+ results, error = sqlintf.Query (query)
+ if error:
+ errorCode = 1
+ diag = error
+
+ # Load playbook
+ file = open(playbook_path + value + ext, 'r')
+ load_file = file.read()
+
+ # Load playbook
+
+ if not errorCode:
+ sql = "UPDATE playbook SET value=%s, version=%s, type=%s WHERE name=%s"
+
+ results, error = sqlintf.Query(sql, (load_file, version, ext, value))
+
+ if error:
+ # Error loading playbook
+ errorCode = 1
+ diag = error
+
+ return errorCode, diag
+
+def loadCredentials (hostgroup, hostname, cred):
+ errorCode = 0
+ diag = ''
+
+ # Load credentials
+
+ query = "SELECT hostname,hostgroup FROM inventory WHERE hostname='" + hostname +"'"
+ results = sqlintf.Query (query)
+
+ print '==>', results
+
+ if hostname in str(results):
+
+ results_hostgroups = results[0][0][1]
+
+ # print "Record already defined: Updating inventory"
+ if hostgroup in results_hostgroups.split(','):
+ query = "UPDATE inventory SET hostname='" + hostname + "',credentials='" +\
+ cred +\
+ "' WHERE hostname='" + hostname + "'"
+ else:
+
+ results_hostgroups = results_hostgroups + ',' + hostgroup
+
+ query = "UPDATE inventory SET hostname='" + hostname + "',credentials='" +\
+ cred + "',hostgroup='" + results_hostgroups + \
+ "' WHERE hostname='" + hostname + "'"
+
+ results, error = sqlintf.Query (query)
+
+ else:
+
+ query = "INSERT INTO inventory (hostgroup, hostname, credentials) VALUES ('" + \
+ hostgroup + "','" + hostname + "','" + cred + "')"
+ results, error = sqlintf.Query (query)
+
+ if error:
+ # Error loading credentials
+ errorCode = 1
+ diag = results
+
+ return errorCode, diag
+
+
+if __name__ == '__main__':
+
+ ################################################################
+ # Change below
+ ################################################################
+ host="localhost" # your host, usually localhost
+ user="mysql_user_id" # your username
+ passwd="password_4_mysql_user_id" # your password
+ db="ansible" # name of the data base
+
+ playbook_path = "/home/ubuntu/RestServerOpenSource/"
+ inventory = "/home/ubuntu/RestServerOpenSource/Ansible_inventory"
+ ################################################################
+
+ onlyfiles = [f for f in listdir(playbook_path)
+ if isfile(join(playbook_path, f))]
+
+ sqlintf = mySql (host, user, passwd, db)
+
+ # Load playbooks
+ print "Loading playbooks"
+ for file in onlyfiles:
+ if "yml" in file:
+ name = file.split (".yml")[0]
+ print " Loading:", name
+ version = name.split("@")[1]
+ errorCode, diag = loadPlaybook (name, version)
+ if errorCode:
+ print " Results: Failed - ", diag
+ else:
+ print " Results: Success"
+ if "tar.gz" in file:
+ name = file.split (".tar.gz")[0]
+ print " Loading:", name
+ version = name.split("@")[1]
+ errorCode, diag = loadPlaybook (name, version, ".tar.gz")
+
+ print "\nLoading inventory"
+
+ # Load inventory
+ hostgroup = None
+ inv = {}
+ file = open(inventory, 'r')
+
+ for line in file:
+
+ if '[' in line and ']' in line:
+ hostgroup = line.strip().replace('[','').replace(']','')
+ inv[hostgroup] = {}
+ elif hostgroup and len(line.strip())>0:
+ host = line.strip().split(" ")[0]
+ credentials = line.replace(host,"")
+ inv[hostgroup][host] = credentials
+
+ file.close()
+
+ for hostgroup in inv:
+ print " Loading:", hostgroup
+ hostfqdn = ''
+ cred = ''
+ for hostname in inv[hostgroup]:
+ cred = inv[hostgroup][hostname]
+ errorCode, diag = loadCredentials (hostgroup, hostname, cred)
+ if errorCode:
+ print " Results: Failed - ", diag
+ else:
+ print " Results: Success"
+
+ sqlintf.Close()
diff --git a/ansible-adapter/ansible-example-server/README b/ansible-adapter/ansible-example-server/README
new file mode 100644
index 00000000..c858361e
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/README
@@ -0,0 +1,103 @@
+'''
+/*-
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Copyright (C) 2017 Amdocs
+* =============================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+* ============LICENSE_END=========================================================
+*/
+'''
+
+============
+INSTALLATION:
+============
+
+Python:
+-------
+sudo apt-get install python2.7
+sudo apt-get install python-pip
+pip install PyMySQL
+pip install requests
+
+Ansible:
+--------
+sudo apt-get install software-properties-common
+sudo apt-add-repository ppa:ansible/ansible
+sudo apt-get update
+sudo apt-get install ansible
+
+SQL db:
+-------
+
+sudo apt-get install mysql-server
+
+Set root passwd during installation (i.e. password_4_mysql_user_id)
+
+sudo service mysql restart
+
+Setup mysql:
+------------
+
+mysql -u [username]-p
+mysql -uroot -p
+
+Create user (i.e. id=mysql_user_id psswd=password_4_mysql_user_id)
+ CREATE USER 'appc'@'%' IDENTIFIED BY 'password_4_mysql_user_id';
+ GRANT ALL PRIVILEGES ON *.* TO 'mysql_user_id'@'%';
+ SET PASSWORD FOR 'mysql_user_id'@'%'=PASSWORD('password_4_mysql_user_id');
+
+Create schema
+ CREATE SCHEMA ansible;
+ show databases;
+ use ansible;
+ CREATE TABLE playbook (name VARCHAR(45) NOT NULL, value BLOB, type VARCHAR(60), version VARCHAR(60), PRIMARY KEY (name));
+ show tables;
+ CREATE TABLE inventory (hostname VARCHAR(45) NOT NULL, hostgroup VARCHAR(45), credentials VARCHAR(500), PRIMARY KEY (hostname));
+ SHOW COLUMNS FROM playbook;
+ SHOW COLUMNS FROM inventory;
+ GRANT ALL PRIVILEGES ON *.* TO 'mysql_user_id'@'%' IDENTIFIED BY 'password_4_mysql_user_id' WITH GRANT OPTION;
+ GRANT ALL PRIVILEGES ON *.* TO 'ansible'@'%' IDENTIFIED BY 'ansible_agent' WITH GRANT OPTION;
+ FLUSH PRIVILEGES;
+
+Load db:
+--------
+
+python LoadAnsibleMySql.py
+
+=============
+CODE TESTING:
+=============
+1. Start RestServer: python RestServer.py
+
+2. Try curl commands (case no secured REST: http & no authentication):
+
+- Request to execute playbook:
+curl -H "Content-type: application/json" -X POST -d '{"Id": "10", "PlaybookName": "ansible_sleep", "NodeList": ["host"], "Timeout": "60", "EnvParameters": {"Sleep": "10"}}' http://0.0.0.0:8000/Dispatch
+
+response: {"ExpectedDuration": "60sec", "StatusMessage": "PENDING", "StatusCode": 100}
+
+- Get results (blocked until test finished):
+curl --cacert ~/SshKey/fusion_eric-vm_cert.pem --user "appc:abc123" -H "Content-type: application/json" -X GET "http://0.0.0.0:8000/Dispatch/?Id=10&Type=GetResult"
+
+response: {"Results": {"localhost": {"GroupName": "host", "StatusMessage": "SUCCESS", "StatusCode": 200}}, "PlaybookName": "ansible_sleep", "Version": "0.00", "Duration": "11.261794", "StatusMessage": "FINISHED", "StatusCode": 200}
+
+- Delete playbook execution information
+curl --cacert ~/SshKey/fusion_eric-vm_cert.pem --user "appc:abc123" -H "Content-type: application/json" -X DELETE http://0.0.0.0:8000/Dispatch/?Id=10
+
+response: {"StatusMessage": "PLAYBOOK EXECUTION RECORDS DELETED", "StatusCode": 200}
diff --git a/ansible-adapter/ansible-example-server/RestServer.py b/ansible-adapter/ansible-example-server/RestServer.py
new file mode 100644
index 00000000..4758a9b9
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/RestServer.py
@@ -0,0 +1,948 @@
+'''
+/*-
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* Copyright (C) 2017 Amdocs
+* =============================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+* ============LICENSE_END=========================================================
+*/
+'''
+
+import time, datetime, json, os, sys, subprocess, re
+import uuid
+import tarfile
+import shutil
+
+import requests
+
+import cherrypy
+from cherrypy.lib.httputil import parse_query_string
+from cherrypy.lib import auth_basic
+
+from multiprocessing import Process, Manager
+
+from AnsibleModule import ansibleSysCall
+
+import AnsibleSql
+from AnsibleSql import readPlaybook, readCredentials
+
+from os import listdir
+from os.path import isfile, join
+
+TestRecord = Manager().dict()
+ActiveProcess = {}
+
+def sys_call (cmd):
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ output = p.stdout.readlines()
+ retval = p.wait()
+ if len (output) > 0:
+ for i in range(len(output)):
+ output[i] = output[i].strip()
+ return retval, output
+
+def callback (Id, Result, Output, Log, returncode):
+
+ print "***> in RestServer.callback"
+
+ if Id in TestRecord:
+ time_now = datetime.datetime.utcnow()
+ delta_time = (time_now - TestRecord[Id]['Time']).total_seconds()
+ Result['PlaybookName'] = TestRecord[Id]['PlaybookName']
+ Result['Version'] = TestRecord[Id]['Version']
+ if returncode == 137:
+ Result['StatusCode'] = 500
+ Result['StatusMessage'] = "TERMINATED"
+ else:
+ Result['StatusCode'] = 200
+ Result['StatusMessage'] = "FINISHED"
+
+ # Need to update the whole data structure for key=Id otherwise Manager is not updated
+ TestRecord[Id] = {'PlaybookName': TestRecord[Id]['PlaybookName'],
+ 'LCM': TestRecord[Id]['LCM'],
+ 'Version': TestRecord[Id]['Version'],
+ 'NodeList': TestRecord[Id]['NodeList'],
+ 'HostGroupList': TestRecord[Id]['HostGroupList'],
+ 'HostNameList': TestRecord[Id]['HostNameList'],
+ 'Time': TestRecord[Id]['Time'],
+ 'Timeout': TestRecord[Id]['Timeout'],
+ 'Duration': str(delta_time),
+ 'EnvParameters': TestRecord[Id]['EnvParameters'],
+ 'LocalParameters': TestRecord[Id]['LocalParameters'],
+ 'FileParameters': TestRecord[Id]['FileParameters'],
+ 'CallBack': TestRecord[Id]['CallBack'],
+ 'Result': Result,
+ 'Log': Log,
+ 'Output': Output,
+ 'Path': TestRecord[Id]['Path'],
+ 'Mandatory': TestRecord[Id]['Path']}
+
+ if not TestRecord[Id]['CallBack'] == None:
+
+ # Posting results to callback server
+
+ data = {"StatusCode": 200,
+ "StatusMessage": "FINISHED",
+ "PlaybookName": TestRecord[Id]["PlaybookName"],
+ "Version": TestRecord[Id]["Version"],
+ "Duration": TestRecord[Id]["Duration"],
+ "Results": TestRecord[Id]['Result']['Results']}
+
+ if not TestRecord[Id]['Output']['Output'] == {}:
+ for key in data["Results"]:
+ if key in TestRecord[Id]['Output']['Output']:
+ data["Results"][key]["Output"] = TestRecord[Id]['Output']['Output'][key]
+
+ print " Posting to", TestRecord[Id]['CallBack']
+
+ s = requests.Session()
+ r = s.post(TestRecord[Id]['CallBack'], data = json.dumps(data),
+ headers = {'content-type': 'application/json'})
+ print " Response", r.status_code, r.text
+
+def RunAnsible_Playbook (callback, Id, Inventory, Playbook, NodeList, TestRecord,
+ Path, ArchiveFlag):
+
+ print "***> in RestServer.RunAnsible_Playbook"
+
+ # Run test in playbook for given target
+ Result = ''
+
+ retval, log, returncode = ansibleSysCall (Inventory, Playbook, NodeList,
+ TestRecord[Id]['Mandatory'],
+ TestRecord[Id]['EnvParameters'],
+ TestRecord[Id]['LocalParameters'],
+ TestRecord[Id]['LCM'],
+ TestRecord[Id]['Timeout'])
+
+
+ print " returncode:", returncode
+ print " retval: ", retval
+ print " log: ", log
+
+ Log = ''.join(log)
+ Output = {'Output': {}}
+
+ onlyfiles = [f for f in listdir(Path)
+ if isfile(join(Path, f))]
+
+ for file in onlyfiles:
+ if "results.txt" in file:
+ f = open(Path + "/" + file, "r")
+ key = file.split("_")[0]
+ Output['Output'][key] = f.read()
+ f.close()
+
+ Result = {'Results': {}}
+ if 'could not be found' in Log:
+ Result['Results'] = {"StatusCode": 101,
+ "StatusMessage": "PLAYBOOK NOT FOUND"}
+ if returncode == 137:
+ Result['Results'] = {"StatusCode": 500,
+ "StatusMessage": "TERMINATED"}
+
+ elif TestRecord[Id]['NodeList'] == []:
+
+ host_index = None
+
+ if 'TargetNode' in TestRecord[Id]['EnvParameters']:
+ targetlist = TestRecord[Id]['EnvParameters']['TargetNode'].split(' ')
+ else:
+ targetlist = ["localhost"]
+
+ for key in retval:
+ for i in range (len(targetlist)):
+ if key in targetlist[i]:
+ host_index = i
+
+ if int(retval[key][0]) > 0 and int(retval[key][2]) == 0 and \
+ int(retval[key][3]) == 0:
+
+ if host_index:
+ Result['Results'][targetlist[host_index]] = \
+ {"GroupName": 'na', "StatusCode": 200, \
+ "StatusMessage": "SUCCESS"}
+ else:
+ Result['Results'][key] = \
+ {"GroupName": 'na', "StatusCode": 200, \
+ "StatusMessage": "SUCCESS"}
+ elif int(retval[key][2]) > 0:
+ if host_index:
+ Result['Results'][targetlist[host_index]] = \
+ {"GroupName": 'na', "StatusCode": 400, \
+ "StatusMessage": "NOT REACHABLE"}
+ else:
+ Result['Results'][key] = \
+ {"GroupName": 'na', "StatusCode": 400, \
+ "StatusMessage": "NOT REACHABLE"}
+ elif int(retval[key][3]) > 0:
+ if host_index:
+ Result['Results'][targetlist[host_index]] = \
+ {"GroupName": 'na', "StatusCode": 400, \
+ "StatusMessage": "FAILURE"}
+ else:
+ Result['Results'][key] = \
+ {"GroupName": 'na', "StatusCode": 400, \
+ "StatusMessage": "FAILURE"}
+ else:
+
+ for key in retval:
+
+ if len(TestRecord[Id]['HostNameList']) > 0:
+
+ host_index = []
+ for i in range (len(TestRecord[Id]['HostNameList'])):
+ if key in TestRecord[Id]['HostNameList'][i]:
+ host_index.append(i)
+
+ if int(retval[key][0]) > 0 and int(retval[key][2]) == 0 and \
+ int(retval[key][3]) == 0:
+
+ if len(host_index) > 0:
+ Result['Results'][TestRecord[Id]['HostNameList'][host_index[0]]] = \
+ {"GroupName": TestRecord[Id]['HostGroupList'][host_index[0]],
+ "StatusCode": 200, "StatusMessage": "SUCCESS"}
+
+ for i in range (1, len(host_index)):
+ Result['Results'][TestRecord[Id]['HostNameList'][host_index[i]]]["GroupName"]+=\
+ "," + TestRecord[Id]['HostGroupList'][host_index[i]]
+ else:
+ Result['Results'][key] = \
+ {"GroupName": key,
+ "StatusCode": 200, "StatusMessage": "SUCCESS"}
+
+ elif int(retval[key][2]) > 0:
+
+ if len(host_index) > 0:
+ Result['Results'][TestRecord[Id]['HostNameList'][host_index[0]]] = \
+ {"GroupName": TestRecord[Id]['HostGroupList'][host_index[0]],
+ "StatusCode": 400, "StatusMessage": "NOT REACHABLE"}
+
+ for i in range (1, len(host_index)):
+ Result['Results'][TestRecord[Id]['HostNameList'][host_index[i]]]["GroupName"]+=\
+ "," + TestRecord[Id]['HostGroupList'][host_index[i]]
+ else:
+ Result['Results'][key] = \
+ {"GroupName": key,
+ "StatusCode": 200, "StatusMessage": "NOT REACHABLE"}
+
+ elif int(retval[key][3]) > 0:
+
+ if len(host_index) > 0:
+ Result['Results'][TestRecord[Id]['HostNameList'][host_index[0]]] = \
+ {"GroupName": TestRecord[Id]['HostGroupList'][host_index[0]],
+ "StatusCode": 400, "StatusMessage": "FAILURE"}
+
+ for i in range (1, len(host_index)):
+ Result['Results'][TestRecord[Id]['HostNameList'][host_index[i]]]["GroupName"]+=\
+ "," + TestRecord[Id]['HostGroupList'][host_index[i]]
+ else:
+ Result['Results'][key] = \
+ {"GroupName": key,
+ "StatusCode": 200, "StatusMessage": "FAILURE"}
+ else:
+ host_index = None
+ for i in range (len(TestRecord[Id]['NodeList'])):
+ if key in TestRecord[Id]['NodeList'][i]:
+ host_index = i
+
+ if int(retval[key][0]) > 0 and int(retval[key][2]) == 0 and \
+ int(retval[key][3]) == 0:
+ Result['Results'][TestRecord[Id]['NodeList'][host_index]] = \
+ {"GroupName": 'na', "StatusCode": 200, \
+ "StatusMessage": "SUCCESS"}
+ elif int(retval[key][2]) > 0:
+ Result['Results'][TestRecord[Id]['NodeList'][host_index]] = \
+ {"GroupName": 'na', "StatusCode": 400, "StatusMessage": "NOT REACHABLE"}
+ elif int(retval[key][3]) > 0:
+ Result['Results'][TestRecord[Id]['NodeList'][host_index]] = \
+ {"GroupName": 'na', "StatusCode": 400, "StatusMessage": "FAILURE"}
+
+ callback (Id, Result, Output, Log, returncode)
+
+class TestManager (object):
+
+ @cherrypy.expose
+ @cherrypy.tools.json_out()
+ @cherrypy.tools.json_in()
+ @cherrypy.tools.allow(methods=['POST', 'GET', 'DELETE'])
+
+ def Dispatch(self, **kwargs):
+
+ # Let cherrypy error handler deal with malformed requests
+ # No need for explicit error handler, we use default ones
+
+ time_now = datetime.datetime.utcnow()
+
+ # Erase old test results (2x timeout)
+ if TestRecord:
+ for key in TestRecord.copy():
+ delta_time = (time_now - TestRecord[key]['Time']).seconds
+ if delta_time > 2*TestRecord[key]['Timeout']:
+ print "Deleted history for test", key
+ if os.path.exists(TestRecord[key]['Path']):
+ shutil.rmtree (TestRecord[key]['Path'])
+ del TestRecord[key]
+
+ print "***> in RestServer.Dispatch:", cherrypy.request.method
+
+ HomeDir = os.path.dirname(os.path.realpath("~/"))
+
+ if 'POST' in cherrypy.request.method:
+
+ input_json = cherrypy.request.json
+ print " Payload: ", input_json
+
+ if 'Id' in input_json and 'PlaybookName' in input_json:
+
+ if True:
+
+ if not input_json['Id'] in TestRecord:
+
+ Id = input_json['Id']
+ PlaybookName = input_json['PlaybookName']
+
+ version = None
+ if 'Version' in input_json:
+ version = input_json['Version']
+
+ AnsibleInvFail = True
+ AnsiblePlaybookFail = True
+
+ MySqlConFail = True
+ MySqlCause = ''
+
+ LocalNodeList = None
+
+ str_uuid = str (uuid.uuid4())
+
+ LCM = PlaybookName.split(".")[0].split('_')[-1]
+ PlaybookDir = HomeDir + "/" + ansible_temp + "/" + \
+ PlaybookName.split(".")[0] + "_" + str_uuid
+ AnsibleInv = LCM + "_" + "inventory"
+ ArchiveFlag = False
+
+ print " LCM: ", LCM
+ print " PlaybookDir: ", ansible_temp + PlaybookDir.split(ansible_temp)[1]
+ print " AnsibleInv: ", AnsibleInv
+ print " ansible_temp: ", ansible_temp
+
+ if not os.path.exists(HomeDir + "/" + ansible_temp):
+ os.makedirs(HomeDir + "/" + ansible_temp)
+
+ os.mkdir(PlaybookDir)
+
+ # Process inventory file for target
+
+ hostgrouplist = []
+ hostnamelist = []
+
+ NodeList = []
+ if 'NodeList' in input_json:
+ NodeList = input_json['NodeList']
+
+ print " NodeList: ", NodeList
+
+ if NodeList == []:
+ # By default set to local host
+ AnsibleInvFail = False
+
+ LocalNodeList = "host"
+ LocalCredentials = "localhost ansible_connection=local"
+ f = open(PlaybookDir + "/" + AnsibleInv, "w")
+ f.write("[" + LocalNodeList + "]\n")
+ f.write(LocalCredentials)
+ f.close()
+
+ else:
+
+ if from_files:
+
+ # Get credentials from file
+
+ data_inventory_orig = {}
+ data_inventory_target = {}
+ curr_group = None
+
+ print "***>", ansible_path + "/" + ansible_inv
+ f = open(ansible_path + "/" + ansible_inv, "r")
+ for line in f:
+ line = line.rstrip()
+
+ if len(line)> 0:
+ if '#' not in line:
+ if "[" in line and "]" in line:
+ data_inventory_orig[line] = []
+ curr_group = line
+ else:
+ data_inventory_orig[curr_group].append(line)
+ f.close()
+
+ for node in NodeList:
+ Fail = True
+ if "[" + node + "]" in data_inventory_orig:
+ if not "[" + node + "]" in data_inventory_target:
+
+ print "RESET", "[" + node + "]"
+ data_inventory_target["[" + node + "]"] = []
+ else:
+ print "OK", "[" + node + "]"
+ Fail = False
+ for cred in data_inventory_orig["[" + node + "]"]:
+ data_inventory_target["[" + node + "]"].append(cred)
+
+ else:
+ for key in data_inventory_orig:
+ if node in " ".join(data_inventory_orig[key]):
+ if not key in data_inventory_target:
+ data_inventory_target[key] = []
+ for cred in data_inventory_orig[key]:
+ if node in cred:
+ data_inventory_target[key].append(cred)
+ Fail = False
+
+ if Fail:
+ data_inventory_target["["+node+"]"] = \
+ [node + " ansible_connection=ssh ansible_ssh_user=na ansible_ssh_private_key_file=na"]
+
+ AnsibleInvFail = False
+
+ f = open(PlaybookDir + "/" + AnsibleInv, "w")
+ for key in data_inventory_target:
+ f.write(key + "\n")
+ for rec in data_inventory_target[key]:
+ hostgrouplist.append(key.replace("[", '').replace("]", ''))
+ hostnamelist.append(rec.split(' ')[0])
+ f.write(rec + "\n")
+ f.close()
+
+ else:
+
+ # Get credentials from mySQL
+
+ sqlintf = AnsibleSql.mySql (host, user, passwd,
+ db)
+ if sqlintf.con:
+ MySqlConFail = False
+ errorCode, diag = readCredentials (sqlintf,
+ NodeList)
+
+ print errorCode, diag
+ if len (diag) > 0:
+ f = open(PlaybookDir + "/" + AnsibleInv,
+ "w")
+ AnsibleInvFail = False
+ # [hostgroup, hostname, credentials]
+ for i in range(len(diag)):
+ f.write('[' + diag[i][0] + ']' + "\n")
+ f.write(diag[i][1]+ " " + diag[i][2] + "\n\n")
+ hostgrouplist.append(diag[i][0])
+ hostnamelist.append(diag[i][1])
+ f.close()
+ else:
+ MySqlConFailCause = sqlintf.error
+ sqlintf.Close()
+
+ timeout = timeout_seconds
+ if 'Timeout' in input_json:
+ timeout = int (input_json['Timeout'])
+
+ EnvParam = {}
+ if 'EnvParameters' in input_json:
+ EnvParam = input_json['EnvParameters']
+
+ LocalParam = {}
+ if 'LocalParameters' in input_json:
+ LocalParam = input_json['LocalParameters']
+
+ FileParam = {}
+ if 'FileParameters' in input_json:
+ FileParam = input_json['FileParameters']
+
+ callback_flag = None
+ if 'CallBack' in input_json:
+ callback_flag = input_json['CallBack']
+
+ TestRecord[Id] = {'PlaybookName': PlaybookName,
+ 'LCM': LCM,
+ 'Version': version,
+ 'NodeList': NodeList,
+ 'HostGroupList': hostgrouplist,
+ 'HostNameList': hostnamelist,
+ 'Time': time_now,
+ 'Duration': timeout,
+ 'Timeout': timeout,
+ 'EnvParameters': EnvParam,
+ 'LocalParameters': LocalParam,
+ 'FileParameters': FileParam,
+ 'CallBack': callback_flag,
+ 'Result': {"StatusCode": 100,
+ "StatusMessage": 'PENDING',
+ "ExpectedDuration": str(timeout) + "sec"},
+ 'Log': '',
+ 'Output': {},
+ 'Path': PlaybookDir,
+ 'Mandatory': None}
+
+ # Write files
+
+ if not TestRecord[Id]['FileParameters'] == {}:
+ for key in TestRecord[Id]['FileParameters']:
+ filename = key
+ filecontent = TestRecord[Id]['FileParameters'][key]
+ f = open(PlaybookDir + "/" + filename, "w")
+ f.write(filecontent)
+ f.close()
+
+
+ # Process playbook
+
+ if from_files:
+
+ # Get playbooks from files
+
+ MySqlConFail = False
+
+ version = None
+ target_PlaybookName = None
+
+ if '@' in PlaybookName:
+ version = PlaybookName.split("@")[1]
+ version = version.replace('.yml','')
+ version = version.replace('.tar.gz','')
+
+ onlyfiles = [f for f in listdir(ansible_path)
+ if isfile(join(ansible_path, f))]
+
+ version_max = '0.00'
+ version_target = ''
+
+ for file in onlyfiles:
+ if LCM in file:
+ temp_version = file.split("@")[1]
+ temp_version = temp_version.replace('.yml','')
+ temp_version = temp_version.replace('.tar.gz','')
+ if version_max < temp_version:
+ version_max = temp_version
+
+ if not version == None:
+ if version in PlaybookName:
+ version_target = version
+ target_PlaybookName = file
+
+ if target_PlaybookName == None:
+ for file in onlyfiles:
+ if LCM in file and version_max in file:
+ target_PlaybookName = file
+ version_target = version_max
+
+ if target_PlaybookName:
+ AnsiblePlaybookFail = False
+ readversion = version_target
+ src = ansible_path + "/" + target_PlaybookName
+ if ".tar.gz" in target_PlaybookName:
+ dest = PlaybookDir + "/" + LCM + ".tar.gz"
+ shutil.copy2(src, dest)
+ retcode = subprocess.call(['tar', '-xvzf',
+ dest, "-C", PlaybookDir])
+ ArchiveFlag = True
+ else:
+ dest = PlaybookDir + "/" + LCM + ".yml"
+ shutil.copy2(src, dest)
+
+ else:
+ # Get playbooks from mySQL
+
+ sqlintf = AnsibleSql.mySql (host, user, passwd, db)
+ if sqlintf.con:
+ MySqlConFail = False
+
+ name, readversion, AnsiblePlaybookFail, diag = \
+ readPlaybook (sqlintf, PlaybookName.split(".")[0],
+ version)
+
+ if not AnsiblePlaybookFail:
+
+ f = open(PlaybookDir + "/" + LCM + diag[1], "w")
+ f.write(diag[0])
+ f.close()
+
+ if ".tar.gz" in diag[1]:
+ retcode = subprocess.call(['tar', '-xvzf',
+ PlaybookDir + "/" + LCM + diag[1], "-C", PlaybookDir])
+ f.close()
+ ArchiveFlag = True
+ else:
+ MySqlConFailCause = sqlintf.error
+ sqlintf.Close()
+
+ if MySqlConFail:
+ if os.path.exists(PlaybookDir):
+ shutil.rmtree (PlaybookDir)
+ del TestRecord[Id]
+ return {"StatusCode": 101,
+ "StatusMessage": "CANNOT CONNECT TO MYSQL: " \
+ + MySqlConFailCause}
+ elif AnsiblePlaybookFail:
+ if os.path.exists(PlaybookDir):
+ shutil.rmtree (PlaybookDir)
+ del TestRecord[Id]
+ return {"StatusCode": 101,
+ "StatusMessage": "PLAYBOOK NOT FOUND"}
+ elif AnsibleInvFail:
+ if os.path.exists(PlaybookDir):
+ shutil.rmtree (PlaybookDir)
+ del TestRecord[Id]
+ return {"StatusCode": 101,
+ "StatusMessage": "NODE LIST CREDENTIALS NOT FOUND"}
+ else:
+
+ # Test EnvParameters
+ playbook_path = None
+ if ArchiveFlag:
+ for dName, sdName, fList in os.walk(PlaybookDir):
+ if LCM+".yml" in fList:
+ playbook_path = dName
+ else:
+ playbook_path = PlaybookDir
+
+ # Store local vars
+ if not os.path.exists(playbook_path + "/vars"):
+ os.mkdir(playbook_path + "/vars")
+ if not os.path.isfile(playbook_path + "/vars/defaults.yml"):
+ os.mknod(playbook_path + "/vars/defaults.yml")
+
+ for key in TestRecord[Id]['LocalParameters']:
+ host_index = []
+ for i in range(len(TestRecord[Id]['HostNameList'])):
+ if key in TestRecord[Id]['HostNameList'][i]:
+ host_index.append(i)
+ if len(host_index) == 0:
+ for i in range(len(TestRecord[Id]['HostGroupList'])):
+ if key in TestRecord[Id]['HostGroupList'][i]:
+ host_index.append(i)
+ if len(host_index) > 0:
+ for i in range(len(host_index)):
+ f = open(playbook_path + "/vars/" +
+ TestRecord[Id]['HostNameList'][host_index[i]] +
+ ".yml", "a")
+ for param in TestRecord[Id]['LocalParameters'][key]:
+ f.write(param + ": " +
+ str (TestRecord[Id]['LocalParameters'][key][param]) +
+ "\n")
+ f.close()
+
+ # Get mandatory parameters from playbook
+ Mandatory = []
+ with open(playbook_path + "/" + LCM + ".yml") as origin_file:
+ for line in origin_file:
+ if "Mandatory" in line:
+ temp = line.split(":")[1].strip().replace(' ', '')
+ if len(temp) > 0:
+ Mandatory = temp.split(",")
+
+ TestRecord[Id] = {'PlaybookName': TestRecord[Id]['PlaybookName'],
+ 'LCM': TestRecord[Id]['LCM'],
+ 'Version': readversion,
+ 'NodeList': TestRecord[Id]['NodeList'],
+ 'HostGroupList': TestRecord[Id]['HostGroupList'],
+ 'HostNameList': TestRecord[Id]['HostNameList'],
+ 'Time': TestRecord[Id]['Time'],
+ 'Timeout': TestRecord[Id]['Timeout'],
+ 'Duration': TestRecord[Id]['Duration'],
+ 'EnvParameters': TestRecord[Id]['EnvParameters'],
+ 'LocalParameters': TestRecord[Id]['LocalParameters'],
+ 'FileParameters': TestRecord[Id]['FileParameters'],
+ 'CallBack': TestRecord[Id]['CallBack'],
+ 'Result': TestRecord[Id]['Result'],
+ 'Log': TestRecord[Id]['Log'],
+ 'Output': TestRecord[Id]['Output'],
+ 'Path': TestRecord[Id]['Path'],
+ 'Mandatory': Mandatory}
+
+ TestKey = False
+
+ if Mandatory:
+ for val in Mandatory:
+ if EnvParam:
+ if val in EnvParam:
+ TestKey = True
+ else:
+ if LocalParam:
+ for key in TestRecord[Id]['NodeList']:
+ if key in LocalParam:
+ if val in LocalParam[key]:
+ TestKey = True
+ else:
+ if LocalParam:
+ for key in TestRecord[Id]['NodeList']:
+ if key in LocalParam:
+ if val in LocalParam[key]:
+ TestKey = True
+
+ if not TestKey:
+ if os.path.exists(PlaybookDir):
+ shutil.rmtree (PlaybookDir)
+ del TestRecord[Id]
+ return {"StatusCode": 101,
+ "StatusMessage": "MISSING MANDATORY PARAMETER: " + \
+ " ".join(str(x) for x in Mandatory)}
+
+
+ # Cannot use thread because ansible module uses
+ # signals which are only supported in main thread.
+ # So use multiprocess with shared object
+
+ p = Process(target = RunAnsible_Playbook,
+ args = (callback, Id, PlaybookDir + "/" + AnsibleInv,
+ playbook_path + "/" + LCM + ".yml",
+ NodeList, TestRecord, PlaybookDir,
+ ArchiveFlag))
+ p.start()
+ ActiveProcess[Id] = p
+ return TestRecord[Id]['Result']
+ else:
+ return {"StatusCode": 101, "StatusMessage": "TEST ID ALREADY DEFINED"}
+
+ else:
+ return {"StatusCode": 500, "StatusMessage": "REQUEST MUST INCLUDE: NODELIST"}
+
+ else:
+ return {"StatusCode": 500, "StatusMessage": "JSON OBJECT MUST INCLUDE: ID, PLAYBOOKNAME"}
+
+ elif 'GET' in cherrypy.request.method:
+
+ input_data = parse_query_string(cherrypy.request.query_string)
+
+ print "***> in RestServer.GET"
+ print " Payload: ", input_data, input_data['Type']
+
+ if 'Id' in input_data and 'Type' in input_data:
+ if not ('GetResult' in input_data['Type'] or 'GetOutput' in input_data['Type'] or 'GetLog' in input_data['Type']):
+ return {"StatusCode": 500, "StatusMessage": "RESULTS TYPE UNDEFINED"}
+ if input_data['Id'] in TestRecord:
+
+ if 'GetResult' in input_data['Type']:
+
+ print "Result:", TestRecord[input_data['Id']]['Result']
+
+ if 'StatusMessage' in TestRecord[input_data['Id']]['Result'] and getresults_block:
+
+ print "*** Request blocked", input_data['Id']
+
+ while ActiveProcess[input_data['Id']].is_alive():
+ time.sleep(5)
+
+ print "*** Request released ", input_data['Id']
+
+ print TestRecord[input_data['Id']]['Result']
+ if TestRecord[input_data['Id']]['Result']['StatusCode'] == 500:
+ out_obj = TestRecord[input_data['Id']]['Result']['Results']
+ else:
+ out_obj = {"StatusCode": 200,
+ "StatusMessage": "FINISHED",
+ "PlaybookName": TestRecord[input_data['Id']]["PlaybookName"],
+ "Version": TestRecord[input_data['Id']]["Version"],
+ "Duration": TestRecord[input_data['Id']]["Duration"],
+ "Results": TestRecord[input_data['Id']]['Result']['Results']}
+ if not TestRecord[input_data['Id']]['Output']['Output'] == {}:
+ for key in out_obj["Results"]:
+ if key in TestRecord[input_data['Id']]['Output']['Output']:
+ out_obj["Results"][key]["Output"] = TestRecord[input_data['Id']]['Output']['Output'][key]
+
+ return out_obj
+
+ elif 'GetOutput' in input_data['Type']:
+
+ if TestRecord[input_data['Id']]['Output'] == {} and \
+ getresults_block:
+
+ print "*** Request blocked", input_data['Id']
+
+ while TestRecord[input_data['Id']]['Output'] == {} \
+ or 'StatusMessage' in TestRecord[input_data['Id']]['Result']:
+ time.sleep(5)
+
+ print "*** Request released ", input_data['Id']
+
+ print "Output:", TestRecord[input_data['Id']]['Output']
+ return {"Output": TestRecord[input_data['Id']]['Output']['Output']}
+ else:
+ # GetLog
+
+ if TestRecord[input_data['Id']]['Log'] == '' and \
+ getresults_block:
+
+ print "*** Request blocked", input_data['Id']
+
+ while TestRecord[input_data['Id']]['Log'] == '' \
+ or 'StatusMessage' in TestRecord[input_data['Id']]['Result']:
+ time.sleep(5)
+
+ print "*** Request released ", input_data['Id']
+
+ print "Log:", TestRecord[input_data['Id']]['Log']
+ return {"Log": TestRecord[input_data['Id']]['Log']}
+ else:
+ return {"StatusCode": 500, "StatusMessage": "TEST ID UNDEFINED"}
+ else:
+ return {"StatusCode": 500, "StatusMessage": "MALFORMED REQUEST"}
+ elif 'DELETE' in cherrypy.request.method:
+ input_data = parse_query_string(cherrypy.request.query_string)
+
+ print "***> in RestServer.DELETE"
+ print " Payload: ", input_data
+
+ if input_data['Id'] in TestRecord:
+ if not 'PENDING' in TestRecord[input_data['Id']]['Result']:
+ print " Path:", TestRecord[input_data['Id']]['Path']
+ if os.path.exists(TestRecord[input_data['Id']]['Path']):
+ shutil.rmtree (TestRecord[input_data['Id']]['Path'])
+ TestRecord.pop (input_data['Id'])
+ if input_data['Id'] in ActiveProcess:
+ ActiveProcess.pop (input_data['Id'])
+
+ return {"StatusCode": 200, "StatusMessage": "PLAYBOOK EXECUTION RECORDS DELETED"}
+ else:
+ return {"StatusCode": 200, "StatusMessage": "PENDING"}
+ else:
+ return {"StatusCode": 500, "StatusMessage": "TEST ID UNDEFINED"}
+
+
+if __name__ == '__main__':
+
+ # Read configuration
+
+ config_file_path = "RestServer_config"
+
+ if not os.path.exists(config_file_path):
+ print '[INFO] The config file does not exist'
+ sys.exit(0)
+
+ ip = 'na'
+ port = 'na'
+ tls = False
+ auth = False
+ pub = 'na'
+ id = 'na'
+ priv = 'na'
+ psswd = 'na'
+ timeout_seconds = 'na'
+ ansible_path = 'na'
+ ansible_inv = 'na'
+ ansible_temp = 'na'
+ host = 'na'
+ user = 'na'
+ passwd = 'na'
+ db = 'na'
+ getresults_block = False
+ from_files = False
+
+ file = open(config_file_path, 'r')
+ for line in file.readlines():
+ if '#' not in line:
+ if 'ip:' in line:
+ ip = line.split(':')[1].strip()
+ elif 'port:' in line:
+ port = line.split(':')[1].strip()
+ elif 'tls:' in line:
+ tls = 'YES' in line.split(':')[1].strip().upper()
+ elif 'auth:' in line:
+ auth = 'YES' in line.split(':')[1].strip().upper()
+ if tls and 'priv:' in line:
+ priv = line.split(':')[1].strip()
+ if tls and 'pub:' in line:
+ pub = line.split(':')[1].strip()
+ if auth and 'id:' in line:
+ id = line.split(':')[1].strip()
+ if auth and 'psswd:' in line:
+ psswd = line.split(':')[1].strip()
+ if 'timeout_seconds' in line:
+ timeout_seconds = int (line.split(':')[1].strip())
+ if 'ansible_path' in line:
+ ansible_path = line.split(':')[1].strip()
+ if 'ansible_inv' in line:
+ ansible_inv = line.split(':')[1].strip()
+ if not os.path.exists(ansible_path + "/" + ansible_inv):
+ print '[INFO] The ansible_inv file does not exist'
+ sys.exit(0)
+ if 'ansible_temp' in line:
+ ansible_temp = line.split(':')[1].strip()
+ if 'host' in line:
+ host = line.split(':')[1].strip()
+ if 'user' in line:
+ user = line.split(':')[1].strip()
+ if 'passwd' in line:
+ passwd = line.split(':')[1].strip()
+ if 'db' in line:
+ db = line.split(':')[1].strip()
+ if 'getresults_block' in line:
+ getresults_block = 'YES' in line.split(':')[1].strip().upper()
+ if 'from_files' in line:
+ from_files = 'YES' in line.split(':')[1].strip().upper()
+ file.close()
+
+ # Initialization
+
+ global_conf = {
+ 'global': {
+ 'server.socket_host': ip,
+ 'server.socket_port': int(port),
+ 'server.protocol_version': 'HTTP/1.1'
+ }
+ }
+
+ if tls:
+ # Use pythons built-in SSL
+ cherrypy.server.ssl_module = 'builtin'
+
+ # Point to certificate files
+
+ if not os.path.exists(pub):
+ print '[INFO] The public certificate does not exist'
+ sys.exit(0)
+
+ if not os.path.exists(priv):
+ print '[INFO] The private key does not exist'
+ sys.exit(0)
+
+ cherrypy.server.ssl_certificate = pub
+ cherrypy.server.ssl_private_key = priv
+
+ if auth:
+ userpassdict = {id: psswd}
+ checkpassword = cherrypy.lib.auth_basic.checkpassword_dict(userpassdict)
+
+ app_conf = {'/':
+ {'tools.auth_basic.on': True,
+ 'tools.auth_basic.realm': 'earth',
+ 'tools.auth_basic.checkpassword': checkpassword,
+ }
+ }
+
+ cherrypy.tree.mount(TestManager(), '/', app_conf)
+ else:
+ cherrypy.tree.mount(TestManager(), '/')
+
+ cherrypy.config.update(global_conf)
+
+ # Start server
+
+ cherrypy.engine.start()
+ cherrypy.engine.block()
diff --git a/ansible-adapter/ansible-example-server/RestServer_config b/ansible-adapter/ansible-example-server/RestServer_config
new file mode 100644
index 00000000..dc28581c
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/RestServer_config
@@ -0,0 +1,55 @@
+# /*-
+# * ============LICENSE_START=======================================================
+# * ONAP : APPC
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# * ================================================================================
+# * Copyright (C) 2017 Amdocs
+# * =============================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# * ============LICENSE_END=========================================================
+# */
+
+# Host definition
+ip: 0.0.0.0
+port: 8000
+
+# Security (controls use of TLS encrypton and RestServer authentication)
+tls: no
+auth: no
+
+# TLS certificates (must be built on application host)
+priv: provide_privated_key.pem
+pub: provide_public_key.pem
+
+# RestServer authentication
+id: provide_RestServer_id
+psswd: provide_password_4_RestServer_id
+
+# Mysql
+host: localhost
+user: mysql_user_id
+passwd: password_4_mysql_user_id
+db: ansible
+
+# Playbooks
+from_files: yes
+ansible_path: /home/ubuntu/RestServerOpenSource
+ansible_inv: Ansible_inventory
+ansible_temp: PlaybooksTemp
+timeout_seconds: 60
+
+# Blocking on GetResults
+getresults_block: yes
diff --git a/ansible-adapter/ansible-example-server/ansible_sleep@0.00.yml b/ansible-adapter/ansible-example-server/ansible_sleep@0.00.yml
new file mode 100644
index 00000000..aba2919e
--- /dev/null
+++ b/ansible-adapter/ansible-example-server/ansible_sleep@0.00.yml
@@ -0,0 +1,42 @@
+# /*-
+# * ============LICENSE_START=======================================================
+# * ONAP : APPC
+# * ================================================================================
+# * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# * ================================================================================
+# * Copyright (C) 2017 Amdocs
+# * =============================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# * ============LICENSE_END=========================================================
+# */
+
+- hosts: all
+
+ # Mandatory:
+ vars:
+ sleep_time: "{{Sleep|default(10)}}"
+
+ tasks:
+
+ - debug:
+ msg: "Sleep time: {{ sleep_time }}"
+
+ - name: sleep
+ shell: sleep {{ sleep_time }}
+
+
+ - debug:
+ msg: "Done"
+
diff --git a/ansible-adapter/pom.xml b/ansible-adapter/pom.xml
new file mode 100644
index 00000000..ede91592
--- /dev/null
+++ b/ansible-adapter/pom.xml
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>ansible-adaptor</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <name>ccsdk-sli-adaptors :: ansible-adapter</name>
+ <description>Abstractions to interact with Ansible server via REST</description>
+ <packaging>pom</packaging>
+
+ <build>
+ <plugins>
+
+ <!-- Black duck plugin Not required for regular builds
+ <plugin> <groupId>com.blackducksoftware.integration</groupId> <artifactId>hub-maven-plugin</artifactId>
+ <version>1.4.0</version> <inherited>false</inherited> <configuration> <hubProjectName>${project.name}</hubProjectName>
+ <outputDirectory>${project.basedir}</outputDirectory> <deployHubBdio>false</deployHubBdio>
+ </configuration> <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>create-bdio-file</id>
+ <phase>package</phase>
+ <goals>
+ <goal>createHubOutput</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
+ -->
+
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalDependencies>
+ <additionalDependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${antlr.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.3</version>
+ </additionalDependency>
+ </additionalDependencies>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc-no-fork</report>
+ <report>test-javadoc-no-fork</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>dual-report</id>
+ <configuration>
+ <type>range</type>
+ <range>30</range>
+ </configuration>
+ <reports>
+ <report>changelog</report>
+ <report>file-activity</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+
+ </reporting>
+
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.onap.appc</groupId>
+ <artifactId>ansible-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.appc</groupId>
+ <artifactId>ansible-adapter-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+
+
+ </dependencyManagement>
+
+ <pluginRepositories>
+ <!-- Black Duck plugin dependencies -->
+ <pluginRepository>
+ <id>JCenter</id>
+ <name>JCenter Repository</name>
+ <url>http://jcenter.bintray.com</url>
+ </pluginRepository>
+
+ </pluginRepositories>
+
+ <modules>
+ <module>ansible-adapter-bundle</module>
+ <module>ansible-adapter-features</module>
+ <module>ansible-adapter-installer</module>
+ </modules>
+</project>
diff --git a/pom.xml b/pom.xml
index bdeefe8e..ecb52e7b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -107,6 +107,7 @@
</build>
<modules>
<module>aai-service</module>
+ <module>ansible-adapter</module>
<module>mdsal-resource</module>
<module>resource-assignment</module>
<module>sql-resource</module>