本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.create_floating_ip方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.create_floating_ip方法的具体用法?Python CloudProvider.create_floating_ip怎么用?Python CloudProvider.create_floating_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.create_floating_ip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_floating_ip
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import create_floating_ip [as 别名]
def create_floating_ip(cls, cloudname, floating_pool=None):
"""
Method to create a floating ip address under a pool
:param cloudname:
:param floating_pool:
:return: floating ip addr
"""
try:
cloud_provider = CloudProvider(cloudname).provider
# If floating pool is not given,
# get first from list
if floating_pool is None:
floating_pool = cloud_provider.provider.floating_ip_pools.list()[0].name
Console.ok("Floating pool not provided, selected [{}] as the pool.".format(floating_pool))
floating_ip = cloud_provider.create_floating_ip(float_pool=floating_pool)
return floating_ip
except Exception as ex:
Console.error(ex.message, ex)
return