本文整理匯總了Python中devops.manager.Manager.environment_list方法的典型用法代碼示例。如果您正苦於以下問題:Python Manager.environment_list方法的具體用法?Python Manager.environment_list怎麽用?Python Manager.environment_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類devops.manager.Manager
的用法示例。
在下文中一共展示了Manager.environment_list方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Shell
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import environment_list [as 別名]
class Shell(object):
def __init__(self):
super(Shell, self).__init__()
self.params = self.get_params()
self.manager = Manager()
def execute(self):
self.commands.get(self.params.command)(self)
def do_list(self):
env_list = self.manager.environment_list().values('name')
for env in env_list:
print(env['name'])
return env_list
def node_dict(self, node):
return {'name': node.name,
'vnc': node.get_vnc_port()}
def do_show(self):
environment = self.manager.environment_get(self.params.name)
print('%5s %25s' % ("VNC", "NODE-NAME"))
for item in map(lambda x: self.node_dict(x), environment.nodes):
print ('%5s %25s' % (item['vnc'], item['name']))
def do_erase(self):
self.manager.environment_get(self.params.name).erase()
def do_start(self):
self.manager.environment_get(self.params.name).start()
def do_destroy(self):
self.manager.environment_get(self.params.name).destroy(verbose=False)
def do_suspend(self):
self.manager.environment_get(self.params.name).suspend(verbose=False)
def do_resume(self):
self.manager.environment_get(self.params.name).resume(verbose=False)
def do_revert(self):
self.manager.environment_get(self.params.name).revert(
self.params.snapshot_name)
def do_snapshot(self):
self.manager.environment_get(self.params.name).snapshot(
self.params.snapshot_name)
def do_synchronize(self):
self.manager.synchronize_environments()
def do_snapshot_list(self):
environment = self.manager.environment_get(self.params.name)
snap_nodes = {}
max_len = 0
for node in environment.nodes:
snaps = sorted(node.get_snapshots())
for snap in snaps:
if len(snap) > max_len:
max_len = len(snap)
if snap in snap_nodes:
snap_nodes[snap].append(node.name)
else:
snap_nodes[snap] = [node.name, ]
print("%*s %50s" % (max_len, "SNAPSHOT", "NODES-NAME"))
for snap in snap_nodes:
print("%*s %50s" % (max_len, snap,
', '.join(snap_nodes[snap])))
def do_snapshot_delete(self):
environment = self.manager.environment_get(self.params.name)
for node in environment.nodes:
snaps = sorted(node.get_snapshots())
if self.params.snapshot_name in snaps:
node.erase_snapshot(name=self.params.snapshot_name)
def do_net_list(self):
environment = self.manager.environment_get(self.params.name)
networks = environment.networks
print("%15s %10s" % ("NETWORK NAME", "IP NET"))
for network in networks:
print("%15s %10s" % (network.name, network.ip_network))
def do_timesync(self):
env = self.manager.environment_get(self.params.name)
if not self.params.node_name:
_nodes = {node.name: node.get_vnc_port() for node in env.nodes}
for node_name in sorted(_nodes.keys()):
if _nodes[node_name] != '-1':
sync_node_time(env, node_name)
else:
sync_node_time(env, self.params.node_name)
def do_revert_resume(self):
self.manager.environment_get(self.params.name).revert(
self.params.snapshot_name)
#.........這裏部分代碼省略.........
示例2: Shell
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import environment_list [as 別名]
class Shell(object):
def __init__(self):
super(Shell, self).__init__()
self.params = self.get_params()
self.manager = Manager()
def execute(self):
self.commands.get(self.params.command)(self)
def do_list(self):
env_list = self.manager.environment_list().values('name')
for env in env_list:
print env['name']
return env_list
def node_dict(self, node):
return {'name': node.name,
'vnc': node.get_vnc_port()}
def do_show(self):
environment = self.manager.environment_get(self.params.name)
print '%5s %25s' % ("VNC", "NODE-NAME")
for item in map(lambda x: self.node_dict(x), environment.nodes):
print '%5s %25s' % (item['vnc'], item['name'])
def do_erase(self):
self.manager.environment_get(self.params.name).erase()
def do_start(self):
self.manager.environment_get(self.params.name).start()
def do_destroy(self):
self.manager.environment_get(self.params.name).destroy(verbose=False)
def do_suspend(self):
self.manager.environment_get(self.params.name).suspend(verbose=False)
def do_resume(self):
self.manager.environment_get(self.params.name).resume(verbose=False)
def do_revert(self):
self.manager.environment_get(self.params.name).revert(
self.params.snapshot_name)
def do_snapshot(self):
self.manager.environment_get(self.params.name).snapshot(
self.params.snapshot_name)
def do_synchronize(self):
self.manager.synchronize_environments()
commands = {
'list': do_list,
'show': do_show,
'erase': do_erase,
'start': do_start,
'destroy': do_destroy,
'suspend': do_suspend,
'resume': do_resume,
'revert': do_revert,
'snapshot': do_snapshot,
'sync': do_synchronize
}
def get_params(self):
name_parser = argparse.ArgumentParser(add_help=False)
name_parser.add_argument('name', help='environment name',
default=environ.get('ENV_NAME'))
snapshot_name_parser = argparse.ArgumentParser(add_help=False)
snapshot_name_parser.add_argument('--snapshot-name',
help='snapshot name',
default=environ.get('SNAPSHOT_NAME'))
parser = argparse.ArgumentParser(
description="Manage virtual environments")
subparsers = parser.add_subparsers(help='commands', dest='command')
subparsers.add_parser('list')
subparsers.add_parser('show', parents=[name_parser])
subparsers.add_parser('erase', parents=[name_parser])
subparsers.add_parser('start', parents=[name_parser])
subparsers.add_parser('destroy', parents=[name_parser])
subparsers.add_parser('suspend', parents=[name_parser])
subparsers.add_parser('resume', parents=[name_parser])
subparsers.add_parser('revert',
parents=[name_parser, snapshot_name_parser])
subparsers.add_parser('snapshot',
parents=[name_parser, snapshot_name_parser])
subparsers.add_parser('sync')
return parser.parse_args()
示例3: Shell
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import environment_list [as 別名]
class Shell(object):
def __init__(self):
super(Shell, self).__init__()
self.params = self.get_params()
self.manager = Manager()
def execute(self):
self.commands.get(self.params.command)(self)
def do_list(self):
print self.manager.environment_list().values('name')
def node_dict(self, node):
return {'name': node.name,
'vnc': node.get_vnc_port(),
}
def do_show(self):
environment = self.manager.environment_get(self.params.name)
print {
'name': environment.name,
'nodes': map(lambda x: {'node': self.node_dict(x)},
environment.nodes)
}
def do_erase(self):
self.manager.environment_get(self.params.name).erase()
def do_start(self):
self.manager.environment_get(self.params.name).start()
def do_destroy(self):
self.manager.environment_get(self.params.name).destroy(verbose=False)
def do_suspend(self):
self.manager.environment_get(self.params.name).suspend()
def do_resume(self):
self.manager.environment_get(self.params.name).resume()
def do_revert(self):
self.manager.environment_get(self.params.name).revert(
self.params.snapshot_name)
def do_snapshot(self):
self.manager.environment_get(self.params.name).snapshot(
self.params.snapshot_name)
commands = {
'list': do_list,
'show': do_show,
'erase': do_erase,
'start': do_start,
'destroy': do_destroy,
'suspend': do_suspend,
'resume': do_resume,
'revert': do_revert,
'snapshot': do_snapshot
}
def get_params(self):
name_parser = argparse.ArgumentParser(add_help=False)
name_parser.add_argument('name', help='environment name',
default=os.getenv('ENV_NAME'))
snapshot_name_parser = argparse.ArgumentParser(add_help=False)
snapshot_name_parser.add_argument('--snapshot-name',
help='snapshot name',
default=os.getenv('SNAPSHOT_NAME'))
parser = argparse.ArgumentParser(
description="Manage virtual environments")
subparsers = parser.add_subparsers(help='commands', dest='command')
subparsers.add_parser('list')
subparsers.add_parser('show', parents=[name_parser])
subparsers.add_parser('erase', parents=[name_parser])
subparsers.add_parser('start', parents=[name_parser])
subparsers.add_parser('destroy', parents=[name_parser])
subparsers.add_parser('suspend', parents=[name_parser])
subparsers.add_parser('resume', parents=[name_parser])
subparsers.add_parser('revert',
parents=[name_parser, snapshot_name_parser])
subparsers.add_parser('snapshot',
parents=[name_parser, snapshot_name_parser])
return parser.parse_args()