本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.list方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.list方法的具体用法?Python CloudProvider.list怎么用?Python CloudProvider.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_002
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list [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: test_001
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list [as 别名]
def test_001(self):
"""test image list :return: """
HEADING()
from pprint import pprint
cloud = "chameleon-ec2"
provider = CloudProvider(cloud).provider
print(provider, type(provider))
# pprint (provider.__dict__)
# pprint (dir(provider))
# r = provider.list_flavor(cloud)
# pprint(r)
for kind in ["image"]: # ["image", "vm", "flavor", "key"]: # , "flavor", "vm", "limits", "quota"]:
r = provider.list(kind, cloud)
pprint(r)
assert True
示例3: refresh
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list [as 别名]
def refresh(cls, 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 = cls.user
purge = kwargs.get("purge", True)
if kind in ["flavor", "image", "vm"]:
# get provider for specific cloud
provider = CloudProvider(name).provider
elements = cls.find(category=name, kind=kind, output='dict')
current_elements = {}
if elements:
for element in elements:
current_elements[element["name"]] = element
# pprint(current_elements)
# if purge:
# cls.clear(kind=kind, category=name)
elements = provider.list(kind, name)
for element in list(elements.values()):
element["uuid"] = element['id']
element['type'] = 'string'
element["category"] = name
# element["user"] = user
element["kind"] = kind
element["provider"] = provider.cloud_type
if current_elements is not None:
for index in current_elements:
current = current_elements[index]
for attribute in ["username", "image", "flavor", "group"]:
if attribute in current and current[attribute] is not None:
element[attribute] = current[attribute]
# print ("CCC", index, element["name"], element["flavor"])
cls.add(element)
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 job in list(vms.values()):
job[u'uuid'] = job['id']
job[u'type'] = 'string'
job[u'category'] = name
# job[u'user'] = user
cls.add(job)
cls.save()
return True
elif kind not in ["secgroup"]:
Console.error("refresh not supported for this kind: {}".format(kind))
except Exception as ex:
Console.error("Problem with secgroup")
return False