本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.list_job方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.list_job方法的具体用法?Python CloudProvider.list_job怎么用?Python CloudProvider.list_job使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.list_job方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list_job [as 别名]
#.........这里部分代码省略.........
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()
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 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
else:
Console.error("refresh not supported for this kind: {}".format(kind))
except Exception as ex:
Console.error(ex.message)
return False
示例2: refresh
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list_job [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
示例3: refresh
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list_job [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