本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.list_flavor方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.list_flavor方法的具体用法?Python CloudProvider.list_flavor怎么用?Python CloudProvider.list_flavor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.list_flavor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_002
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list_flavor [as 别名]
def test_002(self):
""" test flavor list :return: """
HEADING()
from pprint import pprint
cloud = "chameleon-ec2"
provider = CloudProvider(cloud).provider
# print (provider, type(provider))
# r = provider.list_flavor(cloud)
# pprint(r)
kind = 'flavor'
r = provider.list(kind, cloud)
pprint(r)
assert 't2.small' in str(r)
r = provider.list_flavor(cloud)
pprint(r)
assert 't2.small' in str(r)
r = provider.provider.list_sizes(cloud)
pprint(r)
assert 't2.small' in str(r)
示例2: refresh
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list_flavor [as 别名]
def refresh(self, kind, name, **kwargs):
"""
This method refreshes the local database
with the live cloud details
:param kind:
:param name:
:param kwargs:
:return:
"""
try:
# print(cloudname)
# get the user
# TODO: Confirm user
user = self.user
if kind in ["flavor", "image", "vm", "secgroup"]:
# get provider for specific cloud
provider = CloudProvider(name).provider
# clear local db records for kind
self.clear(kind, name)
# for secgroup, clear rules as well
if kind == "secgroup":
self.clear("secgrouprule", name)
if kind == "flavor":
flavors = provider.list_flavor(name)
for flavor in list(flavors.values()):
flavor["uuid"] = flavor['id']
flavor['type'] = 'string'
flavor["category"] = name
flavor["user"] = user
db_obj = {0: {kind: flavor}}
self.add_obj(db_obj)
self.save()
return True
elif kind == "image":
images = provider.list_image(name)
for image in list(images.values()):
image['uuid'] = image['id']
image['type'] = 'string'
image['category'] = name
image['user'] = user
db_obj = {0: {kind: image}}
self.add_obj(db_obj)
self.save()
return True
elif kind == "vm":
vms = provider.list_vm(name)
for vm in list(vms.values()):
vm['uuid'] = vm['id']
vm['type'] = 'string'
vm['category'] = name
vm['user'] = user
db_obj = {0: {kind: vm}}
self.add_obj(db_obj)
self.save()
return True
elif kind == "secgroup":
secgroups = provider.list_secgroup(name)
# pprint(secgroups)
for secgroup in list(secgroups.values()):
secgroup_db_obj = self.db_obj_dict("secgroup",
name=secgroup['name'],
uuid=secgroup['id'],
category=name,
project=secgroup['tenant_id'],
user=user
)
for rule in secgroup['rules']:
rule_db_obj = self.db_obj_dict("secgrouprule",
uuid=rule['id'],
name=secgroup['name'],
groupid=rule['parent_group_id'],
category=name,
user=user,
project=secgroup['tenant_id'],
fromPort=rule['from_port'],
toPort=rule['to_port'],
protocol=rule['ip_protocol'])
if bool(rule['ip_range']) is not False:
rule_db_obj[0]['secgrouprule']['cidr'] = rule['ip_range']['cidr']
self.add_obj(rule_db_obj)
self.save()
# rule-for-loop ends
self.add_obj(secgroup_db_obj)
self.save()
#.........这里部分代码省略.........
示例3: refresh
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list_flavor [as 别名]
def refresh(self, kind, name, **kwargs):
"""
This method refreshes the local database
with the live cloud details
:param kind:
:param name:
:param kwargs:
:return:
"""
try:
# print(cloudname)
# get the user
# TODO: Confirm user
user = self.user
if kind in ["flavor", "image", "vm"]:
# get provider for specific cloud
provider = CloudProvider(name).provider
# clear local db records for kind
self.clear(kind, name)
if kind == "flavor":
flavors = provider.list_flavor(name)
for flavor in flavors.values():
flavor["uuid"] = flavor["id"]
flavor["type"] = "string"
flavor["cloud"] = name
flavor["user"] = user
db_obj = {0: {kind: flavor}}
self.add_obj(db_obj)
self.save()
return True
elif kind == "image":
images = provider.list_image(name)
for image in images.values():
image["uuid"] = image["id"]
image["type"] = "string"
image["cloud"] = name
image["user"] = user
db_obj = {0: {kind: image}}
self.add_obj(db_obj)
self.save()
return True
elif kind == "vm":
vms = provider.list_vm(name)
for vm in vms.values():
vm["uuid"] = vm["id"]
vm["type"] = "string"
vm["cloud"] = name
vm["user"] = user
db_obj = {0: {kind: vm}}
self.add_obj(db_obj)
self.save()
return True
elif kind in ["batchjob"]:
# provider = BatchProvider(name).provider
# provider = BatchProvider(name)
from cloudmesh_client.cloud.hpc.BatchProvider import BatchProvider
provider = BatchProvider(name)
vms = provider.list_job(name)
for vm in vms.values():
vm["uuid"] = vm["id"]
vm["type"] = "string"
vm["cloud"] = name
vm["user"] = user
db_obj = {0: {kind: vm}}
self.add_obj(db_obj)
self.save()
return True
else:
Console.error("refresh not supported for this kind: {}".format(kind))
except Exception as ex:
Console.error(ex.message)
return False