diff options
-rwxr-xr-x | ansible-server/src/main/ansible-server/AnsibleModule.py | 22 | ||||
-rw-r--r-- | ansible-server/src/main/ansible-server/BuildPlaybookParams.py | 43 | ||||
-rwxr-xr-x | ansible-server/src/main/ansible-server/RestServer.py | 13 | ||||
-rw-r--r-- | odlsli/odlsli-alpine/pom.xml | 19 | ||||
-rw-r--r-- | odlsli/odlsli-ubuntu/pom.xml | 16 |
5 files changed, 80 insertions, 33 deletions
diff --git a/ansible-server/src/main/ansible-server/AnsibleModule.py b/ansible-server/src/main/ansible-server/AnsibleModule.py index d0af0cf2..71d0c059 100755 --- a/ansible-server/src/main/ansible-server/AnsibleModule.py +++ b/ansible-server/src/main/ansible-server/AnsibleModule.py @@ -33,15 +33,13 @@ import cherrypy from cherrypy.lib.httputil import parse_query_string from cherrypy.lib import auth_basic -def ansibleSysCall (inventory_path, playbook_path, nodelist, mandatory, - envparameters, localparameters, timeout, playbookdir): - +def ansibleSysCall (inventory_path, playbook_path, nodelist, mandatory, envparameters, localparameters, timeout, playbookdir): cherrypy.log( "***> in AnsibleModule.ansibleSysCall") log = [] str_parameters = '' - if not envparameters == '': + if envparameters: for key in envparameters: if str_parameters == '': str_parameters = '"' + str(key) + '=\'' + str(envparameters[key]) + '\'' @@ -51,22 +49,20 @@ def ansibleSysCall (inventory_path, playbook_path, nodelist, mandatory, str_parameters += '"' if len(str_parameters) > 0: - cmd = 'export HOME=/home/ansible; env; cd ' + playbookdir + ';' +'timeout -s KILL -t ' + str(timeout) + \ + cmd = 'cd ' + playbookdir + ';' + 'timeout -s KILL -t ' + str(timeout) + \ ' ansible-playbook -v --timeout ' + str(timeout) + ' --extra-vars ' + str_parameters + ' -i ' + \ inventory_path + ' ' + playbook_path + ' | tee log.file' else: - cmd = 'export HOME=/home/ansible; env; cd ' + playbookdir + ';' +'timeout -s KILL -t ' + str(timeout) + \ - ' ansible-playbook -v --timeout ' + str(timeout) + ' -i ' + inventory_path + ' ' + playbook_path +' | tee log.file' + cmd = 'cd ' + playbookdir + ';' + 'timeout -s KILL -t ' + str(timeout) + \ + ' ansible-playbook -v --timeout ' + str(timeout) + ' -i ' + inventory_path + ' ' + playbook_path + ' | tee log.file' cherrypy.log("CMD: " + cmd) cherrypy.log("PlayBook Start: " + playbookdir ) - p = subprocess.Popen(cmd, shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) #PAP #p.wait() - (stdout_value, err) = p.communicate() + stdout_value, err = p.communicate() stdout_value_cleanup = '' for line in stdout_value: @@ -78,15 +74,11 @@ def ansibleSysCall (inventory_path, playbook_path, nodelist, mandatory, returncode = p.returncode if returncode == 137: - cherrypy.log(" ansible-playbook system call timed out") # ansible-playbook system call timed out for line in stdout_value: # p.stdout.readlines(): log.append (line) - - else: - for line in stdout_value: # p.stdout.readlines(): print line # line, if ParseFlag and len(line.strip())>0: diff --git a/ansible-server/src/main/ansible-server/BuildPlaybookParams.py b/ansible-server/src/main/ansible-server/BuildPlaybookParams.py index 1593592d..e3a0b4b5 100644 --- a/ansible-server/src/main/ansible-server/BuildPlaybookParams.py +++ b/ansible-server/src/main/ansible-server/BuildPlaybookParams.py @@ -1,3 +1,27 @@ +''' +/*- +* ============LICENSE_START======================================================= +* ONAP : APPC +* ================================================================================ +* Copyright (C) 2017-2019 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. +* +* ============LICENSE_END========================================================= +*/ +''' from os import listdir from os.path import isfile, join @@ -10,11 +34,12 @@ import cherrypy def buildInventorySysCall(ansible_path, ansible_inv, node_list, playbook_dir, target_inv, hostgrouplist, hostnamelist): if not node_list: - LocalNodeList = "host" - LocalCredentials = "localhost ansible_connection=local" + local_node_list = "host" + local_credentials = "localhost ansible_connection=local" + f = open(playbook_dir + "/" + target_inv, "w") - f.write("[" + LocalNodeList + "]\n") - f.write(LocalCredentials) + f.write("[" + local_node_list + "]\n") + f.write(local_credentials) f.close() else: # Get credentials from file @@ -37,14 +62,14 @@ def buildInventorySysCall(ansible_path, ansible_inv, node_list, playbook_dir, ta f.close() for node in node_list: - Fail = True + fail_flag = True if "[" + node + "]" in data_inventory_orig: - if not "[" + node + "]" in data_inventory_target: + if "[" + node + "]" not in data_inventory_target: cherrypy.log("RESET", "[" + node + "]") data_inventory_target["[" + node + "]"] = [] else: cherrypy.log("OK", "[" + node + "]") - Fail = False + fail_flag = False for cred in data_inventory_orig["[" + node + "]"]: data_inventory_target["[" + node + "]"].append(cred) else: @@ -55,9 +80,9 @@ def buildInventorySysCall(ansible_path, ansible_inv, node_list, playbook_dir, ta for cred in data_inventory_orig[key]: if node + " " in cred: data_inventory_target[key].append(cred) - Fail = False + fail_flag = False - if Fail: + if fail_flag: data_inventory_target["[" + node + "]"] = \ [node + " ansible_connection=ssh ansible_ssh_user=na ansible_ssh_private_key_file=na"] diff --git a/ansible-server/src/main/ansible-server/RestServer.py b/ansible-server/src/main/ansible-server/RestServer.py index f24eae0a..2b4da335 100755 --- a/ansible-server/src/main/ansible-server/RestServer.py +++ b/ansible-server/src/main/ansible-server/RestServer.py @@ -1,4 +1,4 @@ -""" +''' /*- * ============LICENSE_START======================================================= * ONAP : APPC @@ -21,7 +21,7 @@ * * ============LICENSE_END========================================================= */ -""" +''' import time, datetime, json, os, sys, subprocess import uuid @@ -559,7 +559,7 @@ def process_vnf_playbook(input_json, Id, EnvParameters, time_now): cherrypy.log("HostFile: " + HostFile) # if NodeList and InventoryNames need to build host file - if HaveInventoryNames & HaveNodeList: + if HaveInventoryNames and HaveNodeList: cherrypy.log("Build host file from NodeList") ret = buildHostsSysCall(input_json, PlaybookDir, inventory_names) if ret < 0: @@ -785,9 +785,10 @@ def handle_get_method(input_data): if TestRecord[input_data['Id']]['Output'] == {} and getresults_block: cherrypy.log("*** Request blocked " + input_data['Id']) - while TestRecord[input_data['Id']]['Output'] == {} \ - or 'StatusMessage' in TestRecord[input_data['Id']]['Result']: - time.sleep(5) + # while TestRecord[input_data['Id']]['Output'] == {} \ + # or 'StatusMessage' in TestRecord[input_data['Id']]['Result']: + while ActiveProcess[input_data['Id']].is_alive(): + time.sleep(3) cherrypy.log("*** Request released " + input_data['Id']) diff --git a/odlsli/odlsli-alpine/pom.xml b/odlsli/odlsli-alpine/pom.xml index 72132796..708324a0 100644 --- a/odlsli/odlsli-alpine/pom.xml +++ b/odlsli/odlsli-alpine/pom.xml @@ -25,7 +25,7 @@ <image.name>onap/ccsdk-odlsli-alpine-image</image.name> <ccsdk.project.version>${project.version}</ccsdk.project.version> <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> - <ccsdk.features.version>0.4.2</ccsdk.features.version> + <ccsdk.features.version>0.5.0-SNAPSHOT</ccsdk.features.version> <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> <opendaylight.root>opt/opendaylight</opendaylight.root> @@ -36,7 +36,7 @@ <ccsdk.odl.features>ccsdk-sli-core-all,ccsdk-sli-adaptors-all,ccsdk-sli-northbound-all,ccsdk-sli-plugins-all,ccsdk-features-all</ccsdk.odl.features> <odl.boot.features.extra>${odl.features.extra},${ccsdk.odl.features}</odl.boot.features.extra> </properties> - + <dependencies> <dependency> <groupId>${project.groupId}</groupId> @@ -264,6 +264,21 @@ <classifier>repo</classifier> <type>zip</type> </dependency> + <dependency> + <groupId>org.onap.ccsdk.features.sdnr.northbound</groupId> + <artifactId>sdnr-northbound-features-installer</artifactId> + <version>${ccsdk.features.version}</version> + <classifier>repo</classifier> + <type>zip</type> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.features.sdnr.northbound</groupId> + <artifactId>oofpcipoc-installer</artifactId> + <version>${ccsdk.features.version}</version> + <classifier>repo</classifier> + <type>zip</type> + </dependency> + </dependencies> <build> diff --git a/odlsli/odlsli-ubuntu/pom.xml b/odlsli/odlsli-ubuntu/pom.xml index 14752532..3b3adea9 100644 --- a/odlsli/odlsli-ubuntu/pom.xml +++ b/odlsli/odlsli-ubuntu/pom.xml @@ -25,7 +25,7 @@ <image.name>onap/ccsdk-odlsli-image</image.name> <ccsdk.project.version>${project.version}</ccsdk.project.version> <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> - <ccsdk.features.version>0.4.2</ccsdk.features.version> + <ccsdk.features.version>0.5.0-SNAPSHOT</ccsdk.features.version> <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format> <opendaylight.root>opt/opendaylight</opendaylight.root> @@ -263,6 +263,20 @@ <classifier>repo</classifier> <type>zip</type> </dependency> + <dependency> + <groupId>org.onap.ccsdk.features.sdnr.northbound</groupId> + <artifactId>sdnr-northbound-features-installer</artifactId> + <version>${ccsdk.features.version}</version> + <classifier>repo</classifier> + <type>zip</type> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.features.sdnr.northbound</groupId> + <artifactId>oofpcipoc-installer</artifactId> + <version>${ccsdk.features.version}</version> + <classifier>repo</classifier> + <type>zip</type> + </dependency> </dependencies> <build> |