Verified Commit b86ac60b authored by Nate Childers's avatar Nate Childers 🚴

import .previous file managment from rhel setup

parent 3825ddf7
Pipeline #120302 failed with stages
in 8 seconds
......@@ -241,19 +241,24 @@ def update_library_item(session, args, cl_item_id, changes):
def delete_vm(session, args, vmid):
'''Delets the source VM'''
res = session.delete('https://'+args.vc+'/rest/vcenter/vm/'+vmid)
if res.status_code == 200:
print "VM "+args.vm+" deleted."
return True
return None
keep_vm = os.environ.get('KEEP_SOURCE_VM', False)
if (keep_vm == "True") or (keep_vm is True):
print "Not deleting vm "+args.vm
return None
else:
'''Deletes the source VM'''
res = session.delete('https://'+args.vc+'/rest/vcenter/vm/'+vmid)
if res.status_code == 200:
print "VM "+args.vm+" deleted."
return True
return None
def delete_content_library_item(session, args, cl_item_id):
''' Deletes a content library item '''
res = session.delete('https://'+args.vc+'/rest/com/vmware/content/library/item/id:'+cl_item_id)
if res.status_code == 200:
print "Content Library Item deleted"
print "Content Library Item Id: {} deleted".format(cl_item_id)
return True
return None
......@@ -274,11 +279,17 @@ def deploy_template(session, args, clid, cl_item_id):
to the production template name (e.g. os-version)
'''
old_cl_item_id = get_content_library_item_id(session, args.vc, clid, args.deploy)
previous_cl_item_id = get_content_library_item_id(session, args.vc, clid, args.deploy)
old_previous_cl_item_id = get_content_library_item_id(session, args.vc, clid, args.deploy + '.previous')
print "deploy_template: {} to {}".format(args.cli, args.deploy)
if old_cl_item_id is not None:
# update via 2 renames
rename_previous = rename_content_library_item(session, args, old_cl_item_id, args.deploy + '.previous')
if previous_cl_item_id is not None:
# remove old .previous content library item
if old_previous_cl_item_id is not None:
print "deploy_template: old {} removed".format(args.deploy + '.previous')
delete_old_previous = delete_content_library_item(session, args, old_previous_cl_item_id)
return delete_old_previous
rename_previous = rename_content_library_item(session, args, previous_cl_item_id, args.deploy + '.previous')
if rename_previous is not None:
print "deploy_template: .previous renamed; deploying {} to {}".format(args.cli, args.deploy)
rename_target = rename_content_library_item(session, args, cl_item_id, args.deploy)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment