本文整理汇总了Python中cloudmesh_client.common.ConfigDict.ConfigDict.keys方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigDict.keys方法的具体用法?Python ConfigDict.keys怎么用?Python ConfigDict.keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.common.ConfigDict.ConfigDict
的用法示例。
在下文中一共展示了ConfigDict.keys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cloudmesh_client.common.ConfigDict import ConfigDict [as 别名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import keys [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)
示例2: __init__
# 需要导入模块: from cloudmesh_client.common.ConfigDict import ConfigDict [as 别名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import keys [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)
示例3: __init__
# 需要导入模块: from cloudmesh_client.common.ConfigDict import ConfigDict [as 别名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import keys [as 别名]
def __init__(self, context):
cmd.Cmd.__init__(self)
self.variables = {}
self.command_topics = {}
self.register_topics()
self.context = context
# TODO get loglevel from DB or yaml file, if not defined set to ERROR
self.loglevel = "DEBUG"
self._hist = []
if self.context.debug:
print("init CloudmeshConsole")
self.prompt = 'cm> '
self.doc_header = "Documented commands (type help <command>):"
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)
# Initialize Logging
# LogUtil.initialize_logging()
# sys,exit(1)
value = Default.get('cloud', category='general')
if value is None:
clouds = ConfigDict(filename=filename)["cloudmesh"]["clouds"]
cloud = clouds.keys()[0]
Default.set('cloud', cloud, category='general')
value = Default.get('default', category='general')
if value is None:
Default.set('default', 'default', category='general')
cluster = 'kilo' # hardcode a value if not defined
value = Default.get('cluster', category='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, category='general')
group = Default.get_group()
if group is None:
Default.set_group("default")
Default.load("cloudmesh.yaml")
on = Default.timer()
group = Default.get_group()
if group is None:
Default.set_group("default")
r = Default.get_refresh()
if r is None:
Default.set_refresh("on")
"""
try:
sshm = SSHKeyManager()
m = sshm.get_from_yaml(
load_order="~/.cloudmesh/cloudmesh.yaml")
d = dict(m.__keys__)
sshdb = SSHKeyDBManager()
for keyname in m.__keys__:
filename = m[keyname]["path"]
try:
sshdb.add(filename,
keyname,
source="yaml",
uri="file://" + filename)
except Exception as e:
pass
except Exception as e:
Console.error("Problem adding keys from yaml file")
#.........这里部分代码省略.........