本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.rename_vm方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.rename_vm方法的具体用法?Python CloudProvider.rename_vm怎么用?Python CloudProvider.rename_vm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.rename_vm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rename
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import rename_vm [as 别名]
def rename(cls, **kwargs):
cloud_provider = CloudProvider(kwargs["cloud"]).provider
new_name = kwargs["new_name"]
for server in kwargs["servers"]:
cloud_provider.rename_vm(server, new_name)
print("Machine {:} renamed to {:} on {:} Cloud...".format(server, new_name, cloud_provider.cloud))
# Explicit refresh called after VM delete, to update db.
cls.refresh(cloud=kwargs["cloud"])
示例2: rename
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import rename_vm [as 别名]
def rename(cls, **kwargs):
arg = dotdict(kwargs)
cloud_provider = CloudProvider(kwargs["cloud"]).provider
# Check for vms with duplicate names in DB.
vms = cls.get_vms_by_name(name=arg.oldname, cloud=arg.cloud)
if len(vms) > 1:
users_choice = "y"
if not arg.force:
print("More than 1 vms found with the same name as {}."
.format(server))
users_choice = input(
"Would you like to auto-order the new names? (y/n): ")
if users_choice.strip() == "y":
count = 1
for index in vms:
count_new_name = "{0}{1}".format(arg.newname, count)
# print(vms[index])
cloud_provider.rename_vm(vms[index]["uuid"],
count_new_name)
print(
"Machine {0} with UUID {1} renamed to {2} on {3} cloud"
.format(vms[index]["name"],
vms[index]["uuid"],
count_new_name,
cloud_provider.cloud))
count += 1
elif users_choice.strip() == "n":
cloud_provider.rename_vm(arg.oldname, arg.newname)
print(
"Machine {0} renamed to {1} on {2} Cloud..."
.format(arg.oldname, arg.newname, cloud_provider.cloud))
else:
Console.error("Invalid Choice.")
return
else:
cloud_provider.rename_vm(arg.oldname, arg.newname)
print("Machine {0} renamed to {1} on {2} Cloud..."
.format(arg.oldname, arg.newname, cloud_provider.cloud))
# Explicit refresh called after VM rename, to update db.
cls.refresh(cloud=arg.cloud)