本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.delete_vm方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.delete_vm方法的具体用法?Python CloudProvider.delete_vm怎么用?Python CloudProvider.delete_vm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.delete_vm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_vm [as 别名]
def delete(cls, **kwargs):
cloud_provider = CloudProvider(kwargs["cloud"]).provider
for server in kwargs["servers"]:
cloud_provider.delete_vm(server)
print("Machine {:} is being deleted on {:} Cloud...".format(server, cloud_provider.cloud))
# Explicit refresh called after VM delete, to update db.
cls.refresh(cloud=kwargs["cloud"])
示例2: delete
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_vm [as 别名]
def delete(cls, **kwargs):
cloud_provider = CloudProvider(kwargs["cloud"]).provider
for server in kwargs["servers"]:
cloud_provider.delete_vm(server)
print("Machine {:} is being deleted on {:} Cloud...".format(server, cloud_provider.cloud))
示例3: delete
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_vm [as 别名]
def delete(cls, **kwargs):
arg = dotdict(kwargs)
force = kwargs.get("force", Default.purge)
if "cloud" in arg:
cloud_provider = CloudProvider(arg.cloud).provider
for server in kwargs["servers"]:
vm = cls.cm.find(name=server, kind="vm", cloud=arg.cloud, scope="first")
if vm:
provider = vm["provider"]
cloud = vm["category"]
# If server has a floating ip associated, release it
server_dict = Network.get_instance_dict(cloudname=arg.cloud,
instance_id=server)
floating_ip = server_dict["floating_ip"]
if floating_ip is not None:
Network.disassociate_floating_ip(cloudname=arg.cloud,
instance_name=server,
floating_ip=floating_ip)
cloud_provider.delete_vm(server)
if force:
cls.cm.delete(kind="vm",
provider=provider,
category=cloud,
name=server) # delete the record from db
Console.ok("VM record {:} is being deleted from the local database..." \
.format(server))
else:
cls.cm.set(server, "status", "deleted", kind="vm", scope="first")
# Console.ok("VM {:} is being deleted on {:} cloud...".format(server, cloud_provider.cloud))
else:
Console.error("VM {:} can not be found.".format(server), traceflag=False)
else:
clouds = set()
for server in arg.servers:
vm = cls.cm.find(kind="vm", name=server, scope="first")
if vm:
cloud = vm["category"]
provider = vm["provider"]
cloud_provider = CloudProvider(cloud).provider
clouds.add(cloud)
cloud_provider.delete_vm(server)
if force:
cls.cm.delete(kind="vm",
provider=provider,
category=cloud,
name=server)
Console.ok("VM record {:} is being deleted from the local database..." \
.format(server))
else:
cls.cm.set(server, "status", "deleted", kind="vm", scope="first")
# Console.ok("VM {:} is being deleted on {:} cloud...".format(server, cloud))
else:
Console.error("VM {:} can not be found.".format(server), traceflag=False)