本文整理汇总了Python中devops.models.Environment.create_environment方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.create_environment方法的具体用法?Python Environment.create_environment怎么用?Python Environment.create_environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类devops.models.Environment
的用法示例。
在下文中一共展示了Environment.create_environment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create_environment [as 别名]
def setUp(self):
super(TestLibvirtTemplate, self).setUp()
# speed up retry
self.sleep_mock = self.patch('time.sleep')
# mock open
self.open_mock = mock.mock_open(read_data='image_data')
self.patch('devops.driver.libvirt.libvirt_driver.open',
self.open_mock, create=True)
self.os_mock = self.patch('devops.helpers.helpers.os')
self.os_mock.urandom = os.urandom
# noinspection PyPep8Naming
Size = collections.namedtuple('Size', ['st_size'])
self.file_sizes = {
'/tmp/admin.iso': Size(st_size=500),
}
self.os_mock.stat.side_effect = self.file_sizes.get
# Create Environment
self.full_conf = yaml.load(ENV_TMPLT)
self.env = Environment.create_environment(self.full_conf)
self.d = self.env.get_group(name='rack-01').driver
示例2: _create_env_from_config
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create_environment [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: d_env
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create_environment [as 别名]
def d_env(self):
if self._virt_env is None:
if not self._config:
try:
return Environment.get(name=settings.ENV_NAME)
except Exception:
self._virt_env = Environment.describe_environment(boot_from=settings.ADMIN_BOOT_DEVICE)
self._virt_env.define()
else:
try:
return Environment.get(name=self._config["template"]["devops_settings"]["env_name"])
except Exception:
self._virt_env = Environment.create_environment(full_config=self._config)
self._virt_env.define()
return self._virt_env
示例4: setUp
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create_environment [as 别名]
def setUp(self):
super(TestIPMITemplate, self).setUp()
# Create Environment
self.full_conf = yaml.load(ENV_TMPLT)
self.env = Environment.create_environment(self.full_conf)
self.ipmiclient_mock = self.patch(
'devops.driver.baremetal.ipmi_client.IpmiClient')
self.wait_mock = self.patch(
'devops.helpers.helpers.wait')
self.ipmiclient1 = mock.Mock(spec=IpmiClient)
self.ipmiclient2 = mock.Mock(spec=IpmiClient)
def get_client(*args):
"""Tricky way to return necessary node """
if args and args[6] == 'slave-01':
return self.ipmiclient1
elif args and args[6] == 'slave-02':
return self.ipmiclient2
self.ipmiclient_mock.side_effect = get_client
示例5: define_from_config
# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import create_environment [as 别名]
def define_from_config(conf):
env = Environment.create_environment(conf)
env.define()
env.start()
print get_ips(env)