本文整理汇总了Python中cloudmesh_client.cloud.default.Default.get方法的典型用法代码示例。如果您正苦于以下问题:Python Default.get方法的具体用法?Python Default.get怎么用?Python Default.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.default.Default
的用法示例。
在下文中一共展示了Default.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: boot
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def boot(self, cloud=None, image=None, flavor=None, key=None, arguments=None):
"""
Boots the image on a specified cloud
:param image: The name of the image
:type image: str
:param flavor: The name of the flavor
:type flavor: str
:param key: The name of the key
:type key: str
:param cloud: The name of the cloud
:type cloud: str
:param arguments: An array of arguments
:type arguments: list of str
:return: the id of the vm
:rtype: str
"""
if cloud is None:
cloud = Default.get("cloud", "general")
print("get default cloud: " + str(cloud))
if image is None:
image = Default.get("image", cloud)
print("get default image ", str(image))
if flavor is None:
flavor = Default.get("flavor", cloud)
print("get default flavor ", str(flavor))
if key is None:
key = Default.get("key", str(cloud))
print("get default key ", str(key))
# command_key
print("boot an image", image, flavor, key, cloud, arguments)
pass
示例2: get_info
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def get_info(cls, cloud="kilo", name=None, output="table"):
"""
Method to get info about a group
:param cloud:
:param name:
:param output:
:return:
"""
try:
cloud = cloud or Default.get("cloud")
args = {
"name": name,
"cloud": cloud
}
# group = cls.get(name=name, cloud=cloud)
group = cls.cm.find("group", output="object", **args).first()
if group is not None:
d = cls.to_dict(group)
# Transform the dict to show multiple rows per vm
newdict = Group.transform_dict(d)
else:
return None
return dict_printer(newdict,
order=cls.order,
output=output)
except Exception as ex:
Console.error(ex.message, ex)
示例3: __init__
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def __init__(self, context):
cmd.Cmd.__init__(self)
self.command_topics = {}
self.register_topics()
self.context = context
if self.context.debug:
print("init CloudmeshConsole")
self.prompt = 'ghost> '
self.banner = textwrap.dedent("""
+==========================================================+
. _ .-') ('-. .-') _ .
. ( '.( OO )_ _( OO) ( OO) ) .
. .-----. .-'),-----. ,--. ,--.)(,------./ '._ .
. ' .--./ ( OO' .-. '| `.' | | .---'|'--...__) .
. | |('-. / | | | || | | | '--. .--' .
. /_) |OO )\_) | |\| || |'.'| | (| '--. | | .
. || |`-'| \ | | | || | | | | .--' | | .
. (_' '--'\ `' '-' '| | | | | `---. | | .
. `-----' `-----' `--' `--' `------' `--' .
+==========================================================+
Comet Ghost Shell
""")
# KeyCommands.__init__(self, context)
#
# set default cloud and default group if they do not exist
# use the first cloud in cloudmesh.yaml as default
#
value = Default.get('cloud', 'general')
if value is None:
filename = path_expand("~/.cloudmesh/cloudmesh.yaml")
clouds = ConfigDict(filename=filename)["cloudmesh"]["clouds"]
cloud = clouds.keys()[0]
Default.set('cloud', cloud, 'general')
value = Default.get('default', 'general')
if value is None:
Default.set('default', 'default', 'general')
for c in CloudmeshConsole.__bases__[1:]:
# noinspection PyArgumentList
c.__init__(self, context)
示例4: test_007
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def test_007(self):
"""
set default variable
:return:
"""
HEADING()
name = "myvar"
value = "myvalue"
cloud = "mycloud"
Default.set(name, value, cloud)
assert Default.get(name, cloud) == value
self._check(value)
示例5: do_usage
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_usage(self, args, arguments):
"""
::
Usage:
usage list [--cloud=CLOUD] [--start=START] [--end=END] [--tenant=TENANT] [--format=FORMAT]
Show usage data.
Options:
--format=FORMAT the output format [default: table]
--cloud=CLOUD the cloud name
--tenant=TENANT the tenant name
--start=START Usage range start date ex 2012-01-20, default is: 4 weeks ago
--end=END Usage range end date, ex 2012-01-20, default is: tomorrow
Examples:
cm usage list
"""
if arguments["list"]:
cloud = arguments["--cloud"] or Default.get("cloud")
if not cloud:
Console.error("cloud doesn't exist")
return ""
output_format = arguments["--format"]
start = arguments["--start"]
end = arguments["--end"]
tenant = arguments["--tenant"]
usage = Usage.list(cloud,
start=start,
end=end,
tenant=tenant,
format=output_format)
Console.msg(usage)
return ""
示例6: do_list
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_list(self, args, arguments):
"""
::
Usage:
list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] default
list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] vm
list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] flavor
list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] image
List the items stored in the database
Options:
--cloud=CLOUD the name of the cloud
--format=FORMAT the output format
--tenant=TENANT Name of the tenant, e.g. fg82.
Description:
List command prints the values stored in the database
for [default/vm/flavor/image].
Result can be filtered based on the cloud, user & tenant arguments.
If these arguments are not specified, it reads the default
Examples:
$ list --cloud india default
$ list --cloud india --format table flavor
$ list --cloud india --user albert --tenant fg82 flavor
"""
# pprint(arguments)
# Method to get the kind from args
#
# TODO: the kind are defined in the provider,
# TODO: keep the kind lower case
# why is there a reason to make the gind upper case
def get_kind():
for k in ["vm", "image", "flavor", "default"]:
if arguments[k]:
# kinds are all uppercase in model.py
return k.upper()
return "help"
# Read commandline arguments
output_format = arguments['--format']
cloud = arguments['--cloud'] or Default.get_cloud()
user = arguments['--user']
tenant = arguments['--tenant']
# If format is not specified, read default
if output_format is None:
output_format = Default.get("format") or "table"
# If cloud is not specified, get default
if cloud is None:
cloud = Default.get("cloud") or "india"
# If user is not specified, get default
if user is None:
user = Default.get("user")
# If tenant is not specified, get default
if tenant is None:
tenant = Default.get("tenant")
# Get the kind
kind = get_kind()
header = None
order = None
# print help message
if kind == 'help':
Console.ok("Print help!")
return ""
# Prepare the order & header based on kind
# TODO: use lower case so we have a convention thats easy to follow
# TODO: add quota
# TODO: add limits
# TODO: add usage
if kind == 'FLAVOR':
order = [
'cm_cloud',
'disk',
'ephemeral_disk',
'id',
'name',
'ram',
'vcpus'
]
elif kind == 'DEFAULT':
order = ['user',
'cloud',
'name',
'value',
'created_at',
'updated_at'
]
elif kind == 'IMAGE':
order = [
'cm_cloud',
#.........这里部分代码省略.........
示例7: do_sync
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_sync(self, args, arguments):
"""
::
Usage:
sync put [--cloud=CLOUD] [--group=GROUP] LOCALDIR [REMOTEDIR]
sync get [--cloud=CLOUD] [--group=GROUP] REMOTEDIR LOCALDIR
sync put [--server=SERVER] [--group=GROUP] LOCALDIR [REMOTEDIR]
sync get [--server=SERVER] [--group=GROUP] REMOTEDIR LOCALDIR
A simple wrapper for the openstack nova command
Arguments:
LOCALDIR A directory on local machine
REMOTEDIR A directory on remote machine
Options:
--cloud=CLOUD Sync with cloud
"""
cloudname = arguments["--cloud"] or Default.get_cloud()
if cloudname is None:
Console.error("Default cloud has not been set!"
"Please use the following to set it:\n"
"cm default cloud=CLOUDNAME\n"
"or provide it via the --cloud=CLOUDNAME argument.")
return
# Get the arguments
group = arguments["--group"] or Default.get("group", cloudname)
localdir = arguments["LOCALDIR"]
remotedir = arguments["REMOTEDIR"]
if arguments["put"]:
# validate local directory exists
if localdir is None:
Console.error("Please provide the [LOCALDIR] argument.")
return ""
result = Sync.sync(cloudname=cloudname,
localdir=localdir,
remotedir=remotedir,
operation="put")
if result is not None:
Console.ok("Successuly synced local and remote directories.")
elif arguments["get"]:
# validate local directory exists
if localdir is None:
Console.error("Please provide the [LOCALDIR] argument.")
return ""
result = Sync.sync(cloudname=cloudname,
localdir=localdir,
remotedir=remotedir,
operation="get")
if result is not None:
Console.ok("Successuly synced local and remote directories.")
return ""
示例8: __init__
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def __init__(self, context):
cmd.Cmd.__init__(self)
self.command_topics = {}
self.register_topics()
self.context = context
if self.context.debug:
print("init CloudmeshConsole")
self.prompt = 'cm> '
self.banner = textwrap.dedent("""
+=======================================================+
. ____ _ _ _ .
. / ___| | ___ _ _ __| |_ __ ___ ___ ___| |__ .
. | | | |/ _ \| | | |/ _` | '_ ` _ \ / _ \/ __| '_ \ .
. | |___| | (_) | |_| | (_| | | | | | | __/\__ \ | | | .
. \____|_|\___/ \__,_|\__,_|_| |_| |_|\___||___/_| |_| .
+=======================================================+
Cloudmesh Shell
""")
# KeyCommands.__init__(self, context)
#
# set default cloud and default group if they do not exist
# use the first cloud in cloudmesh.yaml as default
#
filename = path_expand("~/.cloudmesh/cloudmesh.yaml")
create_cloudmesh_yaml(filename)
# sys,exit(1)
value = Default.get('cloud', cloud='general')
if value is None:
clouds = ConfigDict(filename=filename)["cloudmesh"]["clouds"]
cloud = clouds.keys()[0]
Default.set('cloud', cloud, cloud='general')
value = Default.get('default', cloud='general')
if value is None:
Default.set('default', 'default', cloud='general')
cluster = 'india' # hardcode a value if not defined
value = Default.get('cluster', cloud='general')
if value is None:
try:
hosts = ssh_config().names()
if hosts is not None:
cluster = hosts[0]
except:
pass # use the hardcoded cluster
else:
cluster = value
Default.set('cluster', cluster, cloud='general')
#
# Read cloud details from yaml file
#
filename = 'cloudmesh.yaml'
config = ConfigDict(filename=filename)["cloudmesh"]
clouds = config["clouds"]
defaults = {'clouds': {},
'key': {}}
for cloud in clouds:
if "default" in config['clouds'][cloud]:
defaults['clouds'][cloud] = config["clouds"][cloud]['default']
if "default" in config["keys"]:
defaults["keys"] = config["keys"]["default"]
else:
defaults['key'] = None
for cloud in defaults["clouds"]:
for default, value in defaults["clouds"][cloud].iteritems():
Default.set(default, value, cloud=cloud)
for c in CloudmeshConsole.__bases__[1:]:
# noinspection PyArgumentList
c.__init__(self, context)
示例9: do_secgroup
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [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 -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["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(tenant, 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
if not cloud:
Console.error("Default cloud not set!")
return ""
if not tenant:
Console.error("Default tenant not set!")
return ""
#.........这里部分代码省略.........
示例10: Username
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
Console.error("Problem booting instance {:}".format(name))
elif arguments["default"]:
try:
count = Counter.get()
prefix = Username()
if prefix is None or count is None:
Console.error("Prefix and Count could not be retrieved correctly.")
return
vm_name = prefix + "-" + str(count).zfill(3)
data = {"name": vm_name,
"cloud": arguments["--cloud"] or Default.get_cloud()}
for attribute in ["image", "flavor", "key", "login_key", "group", "secgroup"]:
data[attribute] = Default.get(attribute, cloud=cloud)
output_format = arguments["--format"] or "table"
print (attribute_printer(data, output=output_format))
msg = "info. OK."
Console.ok(msg)
ValueError("default command not implemented properly. Upon "
"first install the defaults should be read from yaml.")
except Exception, e:
import traceback
print(traceback.format_exc())
print(e)
Console.error("Problem listing defaults")
elif arguments["status"]:
try:
cloud_provider = CloudProvider(cloud).provider
示例11: do_nova
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_nova(self, args, arguments):
"""
::
Usage:
nova set CLOUD
nova info [CLOUD] [--password]
nova help
nova [--group=GROUP] ARGUMENTS...
A simple wrapper for the openstack nova command
Arguments:
GROUP The group to add vms to
ARGUMENTS The arguments passed to nova
help Prints the nova manual
set reads the information from the current cloud
and updates the environment variables if
the cloud is an openstack cloud
info the environment values for OS
Options:
--group=GROUP Add VM to GROUP group
--password Prints the password
-v verbose mode
"""
# pprint(arguments)
cloud = arguments['CLOUD'] or Default.get_cloud()
if not cloud:
Console.error("Default cloud not set!")
return ""
group = arguments["--group"] or Default.get("group", cloud=cloud)
if not group:
Console.error("Default group not set!")
return ""
if arguments["help"]:
os.system("nova help")
return ""
elif arguments["info"]:
set_os_environ(cloud)
d = {}
#
# TODO: this naturally does not work as clouds will have
# different parameters. ALos it does not unset previous
# parameters from other clouds. See register
#
for attribute in ['OS_USERNAME',
'OS_TENANT_NAME',
'OS_AUTH_URL',
'OS_CACERT',
'OS_PASSWORD',
'OS_REGION']:
try:
d[attribute] = os.environ[attribute]
except:
Console.warning("OS environment variable {:} not found"
.format(attribute))
d[attribute] = None
if not arguments["--password"]:
d['OS_PASSWORD'] = "********"
print(row_table(d, order=None, labels=["Variable", "Value"]))
msg = "info. OK."
Console.ok(msg)
return ""
elif arguments["set"]:
if cloud:
set_os_environ(cloud)
msg = "{0} is set".format(cloud)
Console.ok(msg)
else:
Console.error("CLOUD is required")
else: # nova ARGUMENTS...
print("Cloud = {0}".format(cloud))
try:
set_os_environ(cloud)
args = arguments["ARGUMENTS"]
# arguments may contain multiple optional arguments
if len(args) == 1:
args = args[0].split()
result = Shell.execute("nova", args)
print(Nova.remove_subjectAltName_warning(result))
"""
If request for nova boot,
add the vm to group specified,
or else add to default group
"""
if "boot" in args:
# Logic to find ID of VM in the result
fields = []
#.........这里部分代码省略.........
示例12: do_default
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_default(self, args, arguments):
"""
::
Usage:
default list [--cloud=CLOUD] [--format=FORMAT] [--all]
default delete KEY [--cloud=CLOUD]
default KEY [--cloud=CLOUD]
default KEY=VALUE [--cloud=CLOUD]
Arguments:
KEY the name of the default
VALUE the value to set the key to
Options:
--cloud=CLOUD the name of the cloud
--format=FORMAT the output format [default: table]
--all lists all the default values
Description:
Cloudmesh has the ability to manage easily multiple
clouds. One of the key concepts to make the list of such
clouds easier is the introduction of defaults for each
cloud or globally. Hence it is possible to set default
images, flavors for each cloud, and also the default
cloud. The default command is used to set and list the
default values. These defaults are used in other commands
if they are not overwritten by a command parameter.
The current default values can by listed with --all option:(
if you have a default cloud specified. You can also add a
cloud parameter to apply the command to a specific cloud)
default list
A default can be set with
default KEY=VALUE
To look up a default value you can say
default KEY
A default can be deleted with
default delete KEY
Examples:
default list --all
default list --cloud=general
default image=xyz
default image=abc --cloud=kilo
default image
default image --cloud=kilo
default delete image
default delete image --cloud=kilo
"""
# pprint(arguments)
"""
For these keys, the 'cloud' column in db
will always be 'general'.
"""
general_keys = ["cloud", "cluster", "queue"]
"""
If the default cloud has been set (eg. default cloud=xxx),
then subsequent defaults for any key (eg. default image=yyy),
will have 'cloud' column in db as the default cloud that was set.
(eg. image=yyy for cloud=xxx).
"""
if arguments["KEY"] in general_keys:
cloud = "general"
else:
cloud = arguments["--cloud"] or Default.get("cloud", "general") or "general"
if arguments["list"]:
output_format = arguments["--format"]
if arguments['--all'] or arguments["--cloud"] is None:
cloud = None
result = Default.list(cloud=cloud, format=output_format)
if result is None:
Console.error("No default values found")
else:
print(result)
return ""
elif arguments["delete"]:
key = arguments["KEY"]
result = Default.delete(key, cloud)
#.........这里部分代码省略.........
示例13: do_default
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_default(self, args, arguments):
"""
::
Usage:
default
default list [--cloud=CLOUD] [--format=FORMAT] [--all]
default delete KEY [--cloud=CLOUD]
default KEY [--cloud=CLOUD]
default KEY=VALUE [--cloud=CLOUD]
Arguments:
KEY the name of the default
VALUE the value to set the key to
Options:
--cloud=CLOUD the name of the cloud
--format=FORMAT the output format. Values include
table, json, csv, yaml. [default: table]
--all lists all the default values
Description:
Cloudmesh has the ability to manage easily multiple
clouds. One of the key concepts to manage multiple clouds
is to use defaults for the cloud, the images, flavors,
and other values. The default command is used to manage
such default values. These defaults are used in other commands
if they are not overwritten by a command parameter.
The current default values can by listed with
default list --all
Via the default command you can list, set, get and delete
default values. You can list the defaults with
default list
A default can be set with
default KEY=VALUE
To look up a default value you can say
default KEY
A default can be deleted with
default delete KEY
To be specific to a cloud you can specify the name of the
cloud with the --cloud=CLOUD option. The list command can
print the information in various formats iv specified.
Examples:
default
lists the default for the current default cloud
default list --all
lists all default values
default list --cloud=kilo
lists the defaults for the cloud with the name kilo
default image=xyz
sets the default image for the default cloud to xyz
default image=abc --cloud=kilo
sets the default image for the cloud kilo to xyz
default image
list the default image of the default cloud
default image --cloud=kilo
list the default image of the cloud kilo
default delete image
deletes the value for the default image in the
default cloud
default delete image --cloud=kilo
deletes the value for the default image in the
cloud kilo
"""
# pprint(arguments)
"""
For these keys, the 'cloud' column in db
will always be 'general'.
"""
general_keys = ["cloud", "cluster", "queue"]
"""
If the default cloud has been set (eg. default cloud=xxx),
then subsequent defaults for any key (eg. default image=yyy),
will have 'cloud' column in db as the default cloud that was set.
(eg. image=yyy for cloud=xxx).
"""
#.........这里部分代码省略.........
示例14: do_network
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_network(self, args, arguments):
"""
::
Usage:
network get fixed [ip] [--cloud=CLOUD] FIXED_IP
network get floating [ip] [--cloud=CLOUD] FLOATING_IP_ID
network reserve fixed [ip] [--cloud=CLOUD] FIXED_IP
network unreserve fixed [ip] [--cloud=CLOUD] FIXED_IP
network associate floating [ip] [--cloud=CLOUD] [--group=GROUP] [--instance=INS_ID_OR_NAME] [FLOATING_IP]
network disassociate floating [ip] [--cloud=CLOUD] [--group=GROUP] [--instance=INS_ID_OR_NAME] [FLOATING_IP]
network create floating [ip] [--cloud=CLOUD] [--pool=FLOATING_IP_POOL]
network delete floating [ip] [--cloud=CLOUD] FLOATING_IP...
network list floating pool [--cloud=CLOUD]
network list floating [ip] [--cloud=CLOUD] [--instance=INS_ID_OR_NAME] [IP_OR_ID]
network create cluster --group=demo_group
network -h | --help
Options:
-h help message
--cloud=CLOUD Name of the IaaS cloud e.g. india_openstack_grizzly.
--group=GROUP Name of the group in Cloudmesh
--pool=FLOATING_IP_POOL Name of Floating IP Pool
--instance=INS_ID_OR_NAME ID or Name of the vm instance
Arguments:
IP_OR_ID IP Address or ID of IP Address
FIXED_IP Fixed IP Address, e.g. 10.1.5.2
FLOATING_IP Floating IP Address, e.g. 192.1.66.8
FLOATING_IP_ID ID associated with Floating IP, e.g. 185c5195-e824-4e7b-8581-703abec4bc01
Examples:
$ network get fixed ip --cloud=india 10.1.2.5
$ network get fixed --cloud=india 10.1.2.5
$ network get floating ip --cloud=india 185c5195-e824-4e7b-8581-703abec4bc01
$ network get floating --cloud=india 185c5195-e824-4e7b-8581-703abec4bc01
$ network reserve fixed ip --cloud=india 10.1.2.5
$ network reserve fixed --cloud=india 10.1.2.5
$ network unreserve fixed ip --cloud=india 10.1.2.5
$ network unreserve fixed --cloud=india 10.1.2.5
$ network associate floating ip --cloud=india --instance=albert-001 192.1.66.8
$ network associate floating --cloud=india --instance=albert-001
$ network associate floating --cloud=india --group=albert_group
$ network disassociate floating ip --cloud=india --instance=albert-001 192.1.66.8
$ network disassociate floating --cloud=india --instance=albert-001 192.1.66.8
$ network create floating ip --cloud=india --pool=albert-f01
$ network create floating --cloud=india --pool=albert-f01
$ network delete floating ip --cloud=india 192.1.66.8 192.1.66.9
$ network delete floating --cloud=india 192.1.66.8 192.1.66.9
$ network list floating ip --cloud=india
$ network list floating --cloud=india
$ network list floating --cloud=india 192.1.66.8
$ network list floating --cloud=india --instance=323c5195-7yy34-4e7b-8581-703abec4b
$ network list floating pool --cloud=india
$ network create cluster --group=demo_group
"""
# pprint(arguments)
# Get the cloud parameter OR read default
cloudname = arguments["--cloud"] or Default.get_cloud()
if cloudname is None:
Console.error("Default cloud has not been set!"
"Please use the following to set it:\n"
"cm default cloud=CLOUDNAME\n"
"or provide it via the --cloud=CLOUDNAME argument.")
return ""
# Fixed IP info
if arguments["get"] \
and arguments["fixed"]:
fixed_ip = arguments["FIXED_IP"]
result = Network.get_fixed_ip(cloudname,
fixed_ip_addr=fixed_ip)
Console.msg(result)
# Floating IP info
elif arguments["get"] \
and arguments["floating"]:
floating_ip_id = arguments["FLOATING_IP_ID"]
result = Network.get_floating_ip(cloudname,
floating_ip_or_id=floating_ip_id)
Console.msg(result)
# Reserve a fixed ip
elif arguments["reserve"] \
and arguments["fixed"]:
fixed_ip = arguments["FIXED_IP"]
result = Network.reserve_fixed_ip(cloudname=cloudname,
fixed_ip_addr=fixed_ip)
if result is not None:
Console.ok("Reserve fixed ip address [{}] complete.".format(fixed_ip))
# Un-Reserve a fixed ip
elif arguments["unreserve"] \
and arguments["fixed"]:
fixed_ip = arguments["FIXED_IP"]
result = Network.unreserve_fixed_ip(cloudname=cloudname,
fixed_ip_addr=fixed_ip)
if result is not None:
#.........这里部分代码省略.........
示例15: do_hpc
# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get [as 别名]
def do_hpc(self, args, arguments):
# noinspection PyPep8
"""
::
Usage:
hpc queue [--job=NAME][--cluster=CLUSTER][--format=FORMAT]
hpc info [--cluster=CLUSTER][--format=FORMAT]
hpc run SCRIPT [--queue=QUEUE] [--t=TIME] [--N=nodes] [--name=NAME] [--cluster=CLUSTER][--dir=DIR][--group=GROUP][--format=FORMAT]
hpc delete --job=NAME [--cluster=CLUSTER][--group=GROUP]
hpc delete all [--cluster=CLUSTER][--group=GROUP][--format=FORMAT]
hpc status [--job=name] [--cluster=CLUSTER] [--group=GROUP]
hpc test --cluster=CLUSTER [--time=SECONDS]
Options:
--format=FORMAT the output format [default: table]
Examples:
Special notes
if the group is specified only jobs from that group are
considered. Otherwise the default group is used. If the
group is set to None, all groups are used.
cm hpc queue
lists the details of the queues of the hpc cluster
cm hpc queue --name=NAME
lists the details of the job in the queue of the hpc cluster
cm hpc info
lists the details of the hpc cluster
cm hpc run SCRIPT
submits the script to the cluster. The script will be
copied prior to execution into the home directory on the
remote machine. If a DIR is specified it will be copied
into that dir.
The name of the script is either specified in the script
itself, or if not the default nameing scheme of
cloudmesh is used using the same index incremented name
as in vms fro clouds: cloudmeshusername-index
cm hpc delete all
kills all jobs on the default hpc cluster
cm hpc delete all -cluster=all
kills all jobs on all clusters
cm hpc delete --job=NAME
kills a job with a given name or job id
cm hpc default cluster=NAME
sets the default hpc cluster
cm hpc status
returns the status of all jobs
cm hpc status job=ID
returns the status of the named job
cm hpc test --cluster=CLUSTER --time=SECONDS
submits a simple test job to the named cluster and returns
if the job could be successfully executed. This is a
blocking call and may take a long time to complete
dependent on if the queuing system of that cluster is
busy. It will only use one node/core and print the message
#CLOUDMESH: Test ok
in that is being looked for to identify if the test is
successful. If time is used, the job is terminated
after the time is elapsed.
Examples:
cm hpc queue
cm hpc queue --job=xxx
cm hpc info
cm hpc delete --job=6
cm hpc run uname
"""
format = arguments['--format']
cluster = arguments['--cluster'] or Default.get_cluster()
print ("CCC", cluster)
if cluster is None:
Console.error("Default cluster doesn't exist")
return
batch = BatchProvider(cluster)
if arguments["queue"]:
name = arguments['--job']
result = batch.queue(cluster, format=format, job=name)
Console.msg(result)
elif arguments["info"]:
#.........这里部分代码省略.........