本文整理匯總了Python中cloudmesh_client.cloud.default.Default.refresh方法的典型用法代碼示例。如果您正苦於以下問題:Python Default.refresh方法的具體用法?Python Default.refresh怎麽用?Python Default.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cloudmesh_client.cloud.default.Default
的用法示例。
在下文中一共展示了Default.refresh方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: do_image
# 需要導入模塊: from cloudmesh_client.cloud.default import Default [as 別名]
# 或者: from cloudmesh_client.cloud.default.Default import refresh [as 別名]
def do_image(self, args, arguments):
"""
::
Usage:
image refresh [--cloud=CLOUD]
image list [ID] [--cloud=CLOUD] [--format=FORMAT] [--refresh]
This lists out the images present for a cloud
Options:
--format=FORMAT the output format [default: table]
--cloud=CLOUD the cloud name
--refresh live data taken from the cloud
Examples:
cm image refresh
cm image list
cm image list --format=csv
cm image list 58c9552c-8d93-42c0-9dea-5f48d90a3188 --refresh
"""
cloud = arguments["--cloud"] or Default.get_cloud()
if cloud is None:
Console.error("Default cloud doesn't exist")
return
if arguments["refresh"] or Default.refresh():
msg = "Refresh image for cloud {:}.".format(cloud)
if Image.refresh(cloud):
Console.ok("{:} ok.".format(msg))
else:
Console.error("{:} failed.".format(msg))
return ""
if arguments["list"]:
id = arguments['ID']
live = arguments['--refresh']
output_format = arguments["--format"]
if id is None:
result = Image.list(cloud, output_format)
else:
result = Image.details(cloud, id, live, output_format)
if result is None:
Console.error("No image(s) found. Failed.")
# Todo:
# if database size = 0:
# Console.error("No images in the database, please refresh.")
print(result)
return ""
示例2: do_flavor
# 需要導入模塊: from cloudmesh_client.cloud.default import Default [as 別名]
# 或者: from cloudmesh_client.cloud.default.Default import refresh [as 別名]
def do_flavor(self, args, arguments):
"""
::
Usage:
flavor refresh [--cloud=CLOUD] [-v]
flavor list [ID] [--cloud=CLOUD] [--format=FORMAT] [--refresh] [-v]
This lists out the flavors present for a cloud
Options:
--format=FORMAT the output format [default: table]
--cloud=CLOUD the cloud name
--refresh refreshes the data before displaying it
from the cloud
Examples:
cm flavor refresh
cm flavor list
cm flavor list --format=csv
cm flavor show 58c9552c-8d93-42c0-9dea-5f48d90a3188 --refresh
"""
cloud = arguments["--cloud"] or Default.get_cloud()
if cloud is None:
Console.error("Default cloud doesn't exist")
return
if arguments["-v"]:
print ("Cloud: {}".format(cloud))
if arguments["refresh"] or Default.refresh():
msg = "Refresh flavor for cloud {:}.".format(cloud)
if Flavor.refresh(cloud):
Console.ok("{:} ok".format(msg))
else:
Console.error("{:} failed".format(msg))
return ""
if arguments["list"]:
cluster_id = arguments['ID']
refresh = arguments['--refresh']
output_format = arguments["--format"]
if cluster_id is None:
result = Flavor.list(cloud, output_format)
else:
result = Flavor.details(cloud, cluster_id, refresh, output_format)
if result is None:
#
# auto refresh
#
Console.error("No flavor(s) found. Failed")
# Flavor.refresh(cloud)
# Console.ok("Refreshing flavor(s). ok.")
else:
print(result)
return ""
示例3: do_secgroup
# 需要導入模塊: from cloudmesh_client.cloud.default import Default [as 別名]
# 或者: from cloudmesh_client.cloud.default.Default import refresh [as 別名]
def do_secgroup(self, args, arguments):
"""
::
Usage:
secgroup list [--cloud=CLOUD] [--tenant=TENANT]
secgroup create [--cloud=CLOUD] [--tenant=TENANT] LABEL
secgroup delete [--cloud=CLOUD] [--tenant=TENANT] LABEL
secgroup rules-list [--cloud=CLOUD] [--tenant=TENANT] LABEL
secgroup rules-add [--cloud=CLOUD] [--tenant=TENANT] LABEL FROMPORT TOPORT PROTOCOL CIDR
secgroup rules-delete [--cloud=CLOUD] [--tenant=TENANT] LABEL FROMPORT TOPORT PROTOCOL CIDR
secgroup refresh [--cloud=CLOUD]
secgroup -h | --help
secgroup --version
Options:
-h help message
--cloud=CLOUD Name of the IaaS cloud e.g. india_openstack_grizzly.
--tenant=TENANT Name of the tenant, e.g. fg82.
Arguments:
LABEL The label/name of the security group
FROMPORT Staring port of the rule, e.g. 22
TOPORT Ending port of the rule, e.g. 22
PROTOCOL Protocol applied, e.g. TCP,UDP,ICMP
CIDR IP address range in CIDR format, e.g., 129.79.0.0/16
Description:
security_group command provides list/add/delete
security_groups for a tenant of a cloud, as well as
list/add/delete of rules for a security group from a
specified cloud and tenant.
Examples:
$ secgroup list --cloud india --tenant fg82
$ secgroup rules-list --cloud india --tenant fg82 default
$ secgroup create --cloud india --tenant fg82 webservice
$ secgroup rules-add --cloud india --tenant fg82 webservice 8080 8088 TCP "129.79.0.0/16"
"""
# pprint(arguments)
cloud = arguments["--cloud"] or Default.get_cloud()
if arguments["refresh"] or Default.refresh():
msg = "Refresh secgroup for cloud {:}.".format(cloud)
if SecGroup.refresh(cloud):
Console.ok("{:} ok".format(msg))
else:
Console.error("{:} failed".format(msg))
return ""
elif arguments["list"]:
# if no arguments read default
tenant = arguments["--tenant"] or Default.get("tenant")
# If default not set, terminate
if not cloud:
Console.error("Default cloud not set!")
return
if not tenant:
Console.error("Default tenant not set!")
return ""
result = SecGroup.list(project=tenant, cloudname=cloud)
if result:
print(result)
else:
Console.error("No Security Groups found in the cloudmesh database!")
return ""
elif arguments["create"]:
# if no arguments read default
tenant = arguments["--tenant"] or Default.get("tenant", cloud)
label = arguments["LABEL"]
# If default not set, terminate
if not cloud:
Console.error("Default cloud not set!")
return
if not tenant:
Console.error("Default tenant not set!")
return ""
# Create returns uuid of created sec-group
uuid = SecGroup.create(label, cloud, tenant)
if uuid:
Console.ok("Created a new security group [{}] with UUID [{}]".format(label, uuid))
else:
Console.error("Exiting!")
return ""
elif arguments["delete"]:
# if no arguments read default
tenant = arguments["--tenant"] or Default.get("tenant", cloud)
label = arguments["LABEL"]
# If default not set, terminate
#.........這裏部分代碼省略.........
示例4: print
# 需要導入模塊: from cloudmesh_client.cloud.default import Default [as 別名]
# 或者: from cloudmesh_client.cloud.default.Default import refresh [as 別名]
if commands is not None:
sshcommand += " \"{:}\"".format(commands)
# print(sshcommand)
os.system(sshcommand)
elif arguments["list"]:
if arguments["--all"]:
try:
_format = arguments["--format"] or "table"
d = ConfigDict("cloudmesh.yaml")
for cloud in d["cloudmesh"]["clouds"]:
if arguments["--refresh"] or Default.refresh():
_refresh()
print("Listing VMs on Cloud: {:}".format(cloud))
result = Vm.list(cloud=cloud, output_format=_format)
if result is not None:
print(result)
else:
print("Sorry. No data found with requested parameters in DB.")
msg = "info. OK."
Console.ok(msg)
except Exception, e:
import traceback
print(traceback.format_exc())
print(e)
Console.error("Problem listing all instances")