本文整理汇总了Python中devops.models.Environment.list_all方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.list_all方法的具体用法?Python Environment.list_all怎么用?Python Environment.list_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类devops.models.Environment
的用法示例。
在下文中一共展示了Environment.list_all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list_all [as 别名]
def update():
from os import environ
from devops.models import Environment
environ.setdefault("DJANGO_SETTINGS_MODULE", "devops.settings")
with open("hosts.pp", "w") as pp:
for e in Environment.list_all():
ip = e.nodes().admin.get_ip_address_by_network_name(e.admin_net)
pp.write("host {{ '{}': ip => '{}' }}\n".format(e.name, ip))
local("sudo puppet apply hosts.pp")
示例2: _create_env_from_config
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list_all [as 别名]
def _create_env_from_config(self, config):
env_name = config['template']['devops_settings']['env_name']
for env in Environment.list_all():
if env.name == env_name:
print("Please, set another environment name")
raise SystemExit()
self.env = Environment.create_environment(config)
self.env.define()
# Start all l2 network devices
for group in self.env.get_groups():
for net in group.get_l2_network_devices():
net.start()
示例3: do_list
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list_all [as 别名]
def do_list(self):
env_list = Environment.list_all().values("name", "created")
columns = []
for env in env_list:
column = collections.OrderedDict({"NAME": env["name"]})
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")
column["ADMIN IP"] = admin_ip
if self.params.timestamps:
column["CREATED"] = env["created"].strftime("%Y-%m-%d_%H:%M:%S")
columns.append(column)
self.print_table(headers="keys", columns=columns)
示例4: do_create
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list_all [as 别名]
def do_create(self):
env_name = self.params.name
for env in Environment.list_all():
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()
示例5: do_list
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list_all [as 别名]
def do_list(self):
env_list = Environment.list_all().values('name', 'created')
columns = []
for env in env_list:
column = collections.OrderedDict({'NAME': env['name']})
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'))
column['ADMIN IP'] = admin_ip
if self.params.timestamps:
column['CREATED'] = env['created'].strftime(
'%Y-%m-%d_%H:%M:%S')
columns.append(column)
self.print_table(headers="keys", columns=columns)
示例6: tearDown
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import list_all [as 别名]
def tearDown(self):
for environment in Environment.list_all():
environment.erase()