* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2019 Amdocs
-* =============================================================================
+* ================================================================================
+* Copyright (C) 2019 Orange
+* ================================================================================
* 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
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()
+ failed_flag = line.split(':')[1].strip().split('=')[4].split('skipped')[0].strip()
retval[ip_address]=[ok_flag, changed_flag, unreachable_flag, failed_flag]
if "PLAY RECAP" in line:
ParseFlag = True
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2019 Amdocs
-* =============================================================================
+* ================================================================================
+* Copyright (C) 2019 Orange
+* ================================================================================
* 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
output_file.write ("\n[%svip]\n" % Type )
if inventory_type == "None":
output_file.write ("%s\n" % (FloatingIP) )
- elif inventory_type == "VNFC":
+ elif inventory_type == "VNFC" or inventory_type == "VM":
output_file.write ("%s ansible_host=%s\n" % (NE_ID_VIP, FloatingIP) )
- elif inventory_type == "VM":
- output_file.write ("%s ansible_host=%s\n" % (NE_ID_VIP[0:13], FloatingIP) )
output_file.write ("\n[%s]\n" % Type )
Site = NodeList['site']
#print ("vm: " + Name + ": " + IpAddr)
if inventory_type == "None":
output_file.write ("%s\n" % (IpAddr) )
- elif inventory_type == "VNFC":
+ elif inventory_type == "VNFC" or inventory_type == "VM":
output_file.write ("%s ansible_host=%s\n" % (Name, IpAddr) )
- elif inventory_type == "VM":
- output_file.write ("%s ansible_host=%s\n" % (Name[0:13], IpAddr) )
# print site list
output_file.write ("\n[%s:children]\n" % Site )
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
-* =============================================================================
+* ================================================================================
+* Copyright (C) 2019 Orange
+* ================================================================================
* 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
* 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=========================================================
*/
'''
else:
cherrypy.log("Successfully created the directory %s " % path)
+
# location of host file - Default
- HostFile = PlaybookDir + "/inventory/" + VNF_instance + "hosts"
- cherrypy.log("HostFile: " + HostFile)
+ HostFile = "inventory/" + VNF_instance + "hosts"
+ HostFilePath = PlaybookDir + "/" + HostFile
+ cherrypy.log("HostFile: " + HostFilePath)
+
+ # buildInventorySysCall(ANSIBLE_PATH, ANSIBLE_INV, NodeList, PlaybookDir, HostFile, hostgrouplist, hostnamelist)
# if NodeList and InventoryNames need to build host file
if HaveInventoryNames and HaveNodeList:
"StatusMessage": "NodeList: Missing vnfc-type field"}
# Having been built now copy new file to correct file
- shutil.copy(PlaybookDir + "/host_file.txt", HostFile)
- cherrypy.log("Copying Generated host file to: " + HostFile)
+ shutil.copy(PlaybookDir + "/host_file.txt", HostFilePath)
+ cherrypy.log("Copying Generated host file to: " + HostFilePath)
if 'Timeout' in input_json:
timeout = int(input_json['Timeout'])
f.close()
# Check that HostFile exists
- if not os.path.isfile(HostFile):
- cherrypy.log("Inventory file Not Found: " + HostFile)
+ if not os.path.isfile(HostFilePath):
+ cherrypy.log("Inventory file Not Found: " + HostFilePath)
return {"StatusCode": 101, "StatusMessage": "PLAYBOOK INVENTORY FILE NOT FOUND"}
# 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, HostFile, PlaybookDir + '/' + PlayBookFile,
+ args=(callback, Id, "../" + HostFile, "site.yml",
NodeList, TestRecord, PlaybookDir + "/" + PlayBookFunction, ArchiveFlag))
p.start()
ActiveProcess[Id] = p