X-Git-Url: https://gerrit.onap.org/r/gitweb?p=ccsdk%2Fdistribution.git;a=blobdiff_plain;f=ansible-server%2Fsrc%2Fmain%2Fansible-server%2FRestServer.py;h=483b83224482d46da1f44f65ed0abcf256ef3c0a;hp=f24eae0aabdda7354ab3a4a798beb81918b189e5;hb=ef127a5f590c092e5020d8ecd6cf10eaa8329ddc;hpb=274830837af67ce2db232bb11dc4d227609ecb89 diff --git a/ansible-server/src/main/ansible-server/RestServer.py b/ansible-server/src/main/ansible-server/RestServer.py index f24eae0a..483b8322 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 @@ -295,7 +295,7 @@ def store_local_vars(playbook_path, Id): cherrypy.log("LocalParameters: " + str(local_parms)) f = open(playbook_path + "/vars/defaults.yml", "a") - for key, value in local_parms.items(): + for key, value in list(local_parms.items()): f.write(key + "=" + value + "\n") f.close() # ################################################## @@ -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: @@ -718,8 +718,8 @@ def handle_get_method(input_data): # Just a debug to dump any records if 'GetStatus' in input_data['Type']: cherrypy.log("******** Dump Records **********") - if TestRecord.items(): - for id, record in TestRecord.items(): + if list(TestRecord.items()): + for id, record in list(TestRecord.items()): cherrypy.log(" Id: " + id) cherrypy.log("Record: " + str(record)) else: @@ -778,16 +778,17 @@ def handle_get_method(input_data): return out_obj elif 'GetStatus' in input_data['Type']: cherrypy.log(" Dump Records") - for id, record in TestRecord.items(): + for id, record in list(TestRecord.items()): cherrypy.log(" id: " + id) cherrypy.log(" Record:" + str(record)) elif 'GetTheOutput' in input_data['Type'] or 'GetOutput' in input_data['Type']: 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']) @@ -1026,7 +1027,7 @@ if __name__ == '__main__': if 'ansible_inv' in config_line: ANSIBLE_INV = config_line.split(':')[1].strip() if not os.path.exists(ANSIBLE_PATH + "/" + ANSIBLE_INV): - print '[INFO] The ansible_inv file does not exist' + print('[INFO] The ansible_inv file does not exist') sys.exit(0) if 'ansible_temp' in config_line: ANSIBLE_TEMP = config_line.split(':')[1].strip()