本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.boot_vm方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.boot_vm方法的具体用法?Python CloudProvider.boot_vm怎么用?Python CloudProvider.boot_vm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.boot_vm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: boot
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import boot_vm [as 别名]
def boot(cls, **kwargs):
cloud_provider = CloudProvider(kwargs["cloud"]).provider
if kwargs["cloud"] == 'kilo':
# For kilo, we use a different network interface
net_id = None
# Get list of networks in kilo
network_list = cloud_provider.provider.networks.list()
# Validate each interface
for network in network_list:
# Check if interface name is fg478-net,
# Get the interface id
if network.label == "fg478-net":
net_id = network.id
nics = [{"net-id": net_id}]
# TODO: BUG: nics seems unexpected argument
vm_id = cloud_provider.boot_vm(kwargs["name"],
kwargs["image"],
kwargs["flavor"],
key=kwargs["key_name"],
secgroup=kwargs["secgroup_list"],
nics=nics)
else:
vm_id = cloud_provider.boot_vm(kwargs["name"], kwargs["image"], kwargs["flavor"], key=kwargs["key_name"],
secgroup=kwargs["secgroup_list"])
print("Machine {:} is being booted on {:} Cloud...".format(kwargs["name"], cloud_provider.cloud))
# Explicit refresh called after VM boot, to update db.
# cls.refresh(cloud=kwargs["cloud"])
return vm_id
示例2: boot
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import boot_vm [as 别名]
def boot(cls, **kwargs):
key_name = kwargs["key_name"]
cloud_name = kwargs["cloud"]
conf = ConfigDict("cloudmesh.yaml")
username = conf["cloudmesh"]["profile"]["username"]
keycloudmap = cls.cm.get_key_cloud_mapping(username, key_name, cloud_name)
if keycloudmap is None or len(keycloudmap) == 0:
Console.error("No key cloud mapping found for user {:}, key name {:} and cloud {:} in database."
.format(username, key_name, cloud_name))
return
# print("Keycloudmap = {:}".format(keycloudmap))
key_name_on_cloud = keycloudmap["key_name_on_cloud"]
# print("Booting with key_name_on_cloud as " + key_name_on_cloud)
cloud_provider = CloudProvider(cloud_name).provider
if "nics" in kwargs:
vm = cloud_provider.boot_vm(kwargs["name"],
kwargs["image"],
kwargs["flavor"],
key=key_name_on_cloud,
secgroup=kwargs["secgroup_list"],
nics=nics)
else:
vm = cloud_provider.boot_vm(kwargs["name"],
kwargs["image"],
kwargs["flavor"],
key=key_name_on_cloud,
secgroup=kwargs["secgroup_list"],
nics=None)
print("Machine {:} is being booted on {:} Cloud...".format(kwargs["name"], cloud_provider.cloud))
return vm
示例3: boot
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import boot_vm [as 别名]
def boot(cls, **kwargs):
arg = dotdict(kwargs)
for a in ["key", "name", "image", "flavor"]:
if a not in kwargs:
raise ValueError(a + " not in arguments to vm boot")
conf = ConfigDict("cloudmesh.yaml")
arg.username = conf["cloudmesh"]["profile"]["user"]
arg.group = arg.group or Default.group
cloud_provider = CloudProvider(arg.cloud).provider
if "nics" in arg:
nics = arg.nics
else:
nics = None
basic_dict = {
"cloud": arg.cloud,
"name": arg.name,
"image": arg.image,
"flavor": arg.flavor,
"key": arg.key,
"secgroup": [arg.secgroup],
"nics": nics,
"meta": {'kind': 'cloudmesh',
'group': arg.group,
'image': arg.image,
'flavor': arg.flavor,
'key': arg.key,
'category': arg.cloud
}
}
# Special case for Azure where certificate details needs to be added
if arg.cloud == "azure":
kwargs = dict()
kwargs['kind'] = "key_azure"
db_result = cls.cm.find(**kwargs)
# pprint("Key DB results")
key_result = None
try:
for key in db_result:
if key['name'] == arg.key:
pprint("Found the key")
key_result = key
break
if key_result is not None:
new_dict_items = dict()
new_dict_items['cert_thumbprint'] = key_result['fingerprint']
new_dict_items['pub_key_path'] = key_result['key_path']
new_dict_items['cert_path'] = key_result['certificate']
new_dict_items['pfx_path'] = key_result['pfx_path']
basic_dict.update(new_dict_items)
else:
pprint("None found in DB")
except:
traceback.print_exc()
pprint("Exception while processing azure boot arguments")
d = dotdict(basic_dict)
Console.ok("Machine {name} is being booted on cloud {cloud} ...".format(**arg))
print(Printer.attribute(d))
vm = cloud_provider.boot_vm(**d)
if vm is not None:
cls.refresh(cloud=arg.cloud)
cls.cm.set(d.name, "key", d.key, scope="first", kind="vm")
cls.cm.set(d.name, "image", d.image, scope="first", kind="vm")
cls.cm.set(d.name, "flavor", d.flavor, scope="first", kind="vm")
cls.cm.set(d.name, "group", arg.group, scope="first", kind="vm")
cls.cm.set(d.name, "user", arg.user, scope="first", kind="vm")
# update group and key
#
# cls.cm.update("vm", name=data.name)
return vm