def cleanuptoken(session): try: cancel_active_requests(session) print("Cancelled Active Requests") delete_deployments(session) print("Deployments Removed") except: print(f'Found {len(Deployment.list(session))} Deployments to Remove') for i in Deployment.list(session): Deployment.force_delete(session, i['id']) print("All Deployments Force Deleted") data = deletion_block(session) return data
def delete_org(): req = request.get_json() _account = req['account'] u = get_user_org(table, _account) session = Session.login(u['apikey']) org = u['spcorg'] try: User.remove(session=session, id=u['orgid'], username=_account) print("User Removed") except: print("User not found in org or error has occurred...moving on") delete_item(table, u['spcorg'], u['apikey']) create_item(table, spc_org=u['spcorg'], org_id=u['orgid'], api_key=u['apikey'], aws_access_key=u['aws_access_key'], aws_secret_key=u['aws_secret_key'], azure_application_id=u['azure_application_id'], azure_application_key=u['azure_application_key'], azure_tenant_id=u['azure_tenant_id'], azure_subscription_id=u['azure_subscription_id'], in_use='False', username='******') delete_item(table, u['spcorg'], 'True') create_item(table, spc_org=u['spcorg'], org_id=u['orgid'], api_key=u['apikey'], aws_access_key=u['aws_access_key'], aws_secret_key=u['aws_secret_key'], azure_application_id=u['azure_application_id'], azure_application_key=u['azure_application_key'], azure_tenant_id=u['azure_tenant_id'], azure_subscription_id=u['azure_subscription_id'], in_use='False', username='******') try: cancel_active_requests(session) print("Cancelled Active Requests") delete_deployments(session) print("Deployments Removed") except: print(f'Found {len(Deployment.list(session))} Deployments to Remove') for i in Deployment.list(session): Deployment.force_delete(session, i['id']) print("All Deployments Force Deleted") x = deletion_block(session) return jsonify(x)
def orgstats(token): session = Session.login(token) orgStats = {} orgStats['blueprints'] = len(Blueprint.list(session)) orgStats['cloudaccounts'] = len(CloudAccount.list(session)) orgStats['cloudzones'] = len(CloudZone.list(session)) orgStats['deployments'] = len(Deployment.list(session)) return orgStats
def getorginfo(session): cloudaccounts = len(CloudAccount.list(session)) projects = len(Project.list(session)) bps = len(Blueprint.list(session)) deployments = len(Deployment.list(session)) serialData = {} serialData['cloudaccounts'] = cloudaccounts serialData['projects'] = projects serialData['bps'] = bps serialData['deployments'] = deployments return serialData
def deletion_block(session): try: bps = len(Blueprint.list(session)) delete_blueprints(session) print("Deleting Source Content") source_cleanup(session) print("Deleting Subscriptions") sub_cleanup(session) print("Deleting Actions") action_cleanup(session) print("Deleting GitHub Integrations") delete_integrations_github(session) print("Deleting My VMware Integration") delete_integrations_myvmware(session) print("Deleting Ansible Integration") delete_integrations_ansible(session) print(f"{bps} Blueprints Deleted") delete_image_mappings(session) print("Image Mappings Deleted") delete_flavor_mapping(session) print("Flavor Mappings Deleted") delete_network_profile(session) print("Network Profiles Deleted") delete_storage_profile(session) print("Storage Profile Deleted") delete_project(session) print("Projects Removed") zones = len(CloudZone.list(session)) delete_cloudzones(session) print(f"{zones} Cloud Zones Cleaned") delete_cloudaccounts(session) print(f" Removed {zones} Cloud Zones") data = {} data['Deployments Removed'] = len(Deployment.list(session)) data['Blueprints Removed'] = len(Blueprint.list(session)) data['Image Mappings Removed'] = len(ImageMapping.list(session)) data['Flavor Mappings Removed'] = len(FlavorMapping.list(session)) data['Storage Profile Removed'] = len(StorageProfile.list(session)) data['Projects Removed'] = len(Project.list(session)) data['Cloud Zones Cleaned'] = len(CloudZone.list(session)) data['Cloud Accounts Removed'] = len(CloudAccount.list(session)) except: data = {"status":"failed"} return data
def delete_deployments(session): if len(Deployment.list(session)) > 0: for i in Deployment.list(session): Deployment.delete(session, i['id']) return