本文整理汇总了Python中dbaas_cloudstack.provider.CloudStackProvider.remove_networkapi_equipment方法的典型用法代码示例。如果您正苦于以下问题:Python CloudStackProvider.remove_networkapi_equipment方法的具体用法?Python CloudStackProvider.remove_networkapi_equipment怎么用?Python CloudStackProvider.remove_networkapi_equipment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbaas_cloudstack.provider.CloudStackProvider
的用法示例。
在下文中一共展示了CloudStackProvider.remove_networkapi_equipment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: undo
# 需要导入模块: from dbaas_cloudstack.provider import CloudStackProvider [as 别名]
# 或者: from dbaas_cloudstack.provider.CloudStackProvider import remove_networkapi_equipment [as 别名]
def undo(self, workflow_dict):
LOG.info("Running undo...")
try:
if 'databaseinfra' not in workflow_dict and 'hosts' not in workflow_dict:
LOG.info("We could not find a databaseinfra inside the workflow_dict")
return False
if len(workflow_dict['hosts']) == 1:
return True
databaseinfraattr = DatabaseInfraAttr.objects.filter(
databaseinfra=workflow_dict['databaseinfra'])
cs_credentials = get_credentials_for(
environment=workflow_dict['environment'],
credential_type=CredentialType.CLOUDSTACK)
networkapi_credentials = get_credentials_for(
environment=workflow_dict['environment'],
credential_type=CredentialType.NETWORKAPI)
cs_provider = CloudStackProvider(credentials=cs_credentials,
networkapi_credentials=networkapi_credentials)
networkapi_equipment_id = workflow_dict.get('networkapi_equipment_id')
for infra_attr in databaseinfraattr:
networkapi_equipment_id = infra_attr.networkapi_equipment_id
networkapi_ip_id = infra_attr.networkapi_ip_id
if networkapi_ip_id:
LOG.info("Removing network api IP for %s" % networkapi_ip_id)
if not cs_provider.remove_networkapi_ip(equipment_id=networkapi_equipment_id,
ip_id=networkapi_ip_id):
return False
LOG.info("Removing secondary_ip for %s" % infra_attr.cs_ip_id)
if not cs_provider.remove_secondary_ips(infra_attr.cs_ip_id):
return False
LOG.info("Secondary ip deleted!")
infra_attr.delete()
LOG.info("Databaseinfraattr deleted!")
if networkapi_equipment_id:
cs_provider.remove_networkapi_equipment(equipment_id=networkapi_equipment_id)
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0010)
workflow_dict['exceptions']['traceback'].append(traceback)
return False