本文整理汇总了Python中devops.models.Environment.list方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.list方法的具体用法?Python Environment.list怎么用?Python Environment.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类devops.models.Environment
的用法示例。
在下文中一共展示了Environment.list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_list
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list [as 别名]
def do_list(self):
env_list = Environment.list().values('name', 'created')
for env in env_list:
if self.params.list_ips:
cur_env = Environment.get(name=env['name'])
admin_ip = ''
if 'admin' in [node.name for node in cur_env.get_nodes()]:
admin_ip = (cur_env.get_node(name='admin').
get_ip_address_by_network_name('admin'))
print('{0}\t{1}'.format(env['name'], admin_ip))
elif self.params.timestamps:
created_text = env['created'].strftime('%Y-%m-%d_%H:%M:%S')
print('{0} {1}'.format(env['name'], created_text))
else:
print(env['name'])
return env_list
示例2: do_create
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list [as 别名]
def do_create(self):
env_name = self.params.name
for env in Environment.list():
if env.name == env_name:
print("Please, set another environment name")
raise SystemExit()
self.env = Environment.create(env_name)
networks, prefix = self.params.net_pool.split(':')
Network.default_pool = Network.create_network_pool(
networks=[ipaddr.IPNetwork(networks)],
prefix=int(prefix))
networks = Network.create_networks(environment=self.env)
admin_node = self.admin_add(networks=networks)
self.do_slave_add(force_define=False)
self.env.define()
admin_node.disk_devices.get(device='cdrom').volume.upload(
self.params.iso_path)
for net in self.env.get_networks():
net.start()
示例3: tearDown
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list [as 别名]
def tearDown(self):
for environment in Environment.list():
environment.erase()