本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.list_console方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.list_console方法的具体用法?Python CloudProvider.list_console怎么用?Python CloudProvider.list_console使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.list_console方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_vm
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import list_console [as 别名]
#.........这里部分代码省略.........
Console.error("Problem listing defaults", traceflag=False)
elif arguments["ping"]:
try:
if arguments["NAME"] is None and arguments["N"] is None:
name = arguments["NAME"] or Default.vm
n = arguments["N"] or 1
elif arguments["NAME"].isdigit():
n = arguments["NAME"]
name = Default.vm
else:
name = arguments["NAME"] or Default.vm
n = arguments["N"] or 1
print("Ping:", name, str(n))
vm = dotdict(Vm.list(name=name, category=cloud, output="dict")["dict"])
ip = vm.floating_ip
result = Shell.ping(host=ip, count=n)
print(result)
except Exception as e:
Console.error(e.message, traceflag=False)
elif arguments["console"]:
try:
name = arguments["NAME"] or Default.vm
vm = dotdict(Vm.list(name=name, category=cloud, output="dict")["dict"])
cloud_provider = CloudProvider(cloud).provider
vm_list = cloud_provider.list_console(vm.uuid)
print(vm_list)
msg = "info. OK."
Console.ok(msg)
except Exception as e:
# Error.traceback(e)
Console.error("Problem retrieving status of the VM", traceflag=False)
elif arguments["status"]:
try:
cloud_provider = CloudProvider(cloud).provider
vm_list = cloud_provider.list_vm(cloud)
vms = [vm_list[i]["name"] for i in vm_list ]
print ("V", vms)
pattern = arguments["NAMES"]
if pattern is not None:
if "*" in pattern:
print ("serach")
names = search(vms, pattern)
else:
names = Parameter.expand()
for i in vm_list:
if vm_list[i]["name"] in names:
print("{} {}".format(vm_list[i]["status"], vm_list[i]["name"]))
else:
print("{} {}".format(vm_list[0]["status"], vm_list[0]["name"]))
except Exception as e:
# Error.traceback(e)
Console.error("Problem retrieving status of the VM", traceflag=True)
elif arguments["wait"]:
interval = arguments["--interval"] or 5