X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ansible-server%2Fsrc%2Fmain%2Fansible-server%2FRestServer.py;h=3f42bfe4b3bfde798acb739e8b3cf1bceb4a0fe3;hb=e5db019ba1ee8685730f30ca6a819554d8903354;hp=2b4da3357bf86c98d7cc7b53c142dfdac3e8a87b;hpb=a2dbe8b0bd25eaa8ad27ac15f9080c88feb1d308;p=ccsdk%2Fdistribution.git diff --git a/ansible-server/src/main/ansible-server/RestServer.py b/ansible-server/src/main/ansible-server/RestServer.py index 2b4da335..3f42bfe4 100755 --- a/ansible-server/src/main/ansible-server/RestServer.py +++ b/ansible-server/src/main/ansible-server/RestServer.py @@ -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() # ################################################## @@ -329,6 +329,13 @@ def process_pnf_playbook(input_json, Id, EnvParameters, time_now): cherrypy.log("Request Decode: EnvParameters " + json.dumps(EnvParameters)) cherrypy.log("Request Decode: PlaybookName " + PlaybookName) + for key in EnvParameters: + value = EnvParameters[key] + if isinstance(value, (list, dict)): + valueStr = json.dumps(value) + # Need to dump two times to keep the backslash and double quotes, add backslash and single quotes for spaces + EnvParameters[key] = "\\'" + json.dumps(valueStr)[1:-1] + "\\'" + str_uuid = str(uuid.uuid4()) HomeDir = os.path.dirname(os.path.realpath("~/")) @@ -718,8 +725,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,7 +785,7 @@ 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']: @@ -1027,7 +1034,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()