本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.delete_floating_ip方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.delete_floating_ip方法的具体用法?Python CloudProvider.delete_floating_ip怎么用?Python CloudProvider.delete_floating_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.delete_floating_ip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_floating_ip
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_floating_ip [as 别名]
def delete_floating_ip(cls, cloudname, floating_ip_or_id):
"""
Method to delete a floating ip address
:param cloudname:
:param floating_ip_or_id:
:return:
"""
try:
cloud_provider = CloudProvider(cloudname).provider
floating_ip_dict = None
# check if argument is ip or uuid
if cls.isIPAddr(ip_or_id=floating_ip_or_id):
# get floating ip list
floating_ips = cls.get_floating_ip_list(cloudname)
for floating_ip in list(floating_ips):
ip_addr = floating_ip["ip"]
# if argument ip matches floating ip addr
if ip_addr == floating_ip_or_id:
floating_ip_dict = floating_ip
break
else:
# find by floating ip uuid
floating_ip_dict = cloud_provider.get_floating_ip(floating_ip_id=floating_ip_or_id)
# Could not find floating IP from given args
if floating_ip_dict is None:
return None
# Delete the floating ip; returns None if success
result = cloud_provider.delete_floating_ip(floating_ip_dict["id"])
if not result:
return "Floating IP [{}] deleted successfully!" \
.format(floating_ip_dict["ip"])
except Exception as ex:
Console.error(ex.message)
return