本文整理汇总了Python中senlin.engine.environment.global_env函数的典型用法代码示例。如果您正苦于以下问题:Python global_env函数的具体用法?Python global_env怎么用?Python global_env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了global_env函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
super(ProfileTypeTest, self).setUp()
self.ctx = utils.dummy_context(project='profile_type_test_project')
self.eng = service.EngineService('host-a', 'topic-a')
self.eng.init_tgm()
environment.global_env().register_profile('TestProfile',
fakes.TestProfile)
示例2: setUp
def setUp(self):
super(TriggerTest, self).setUp()
self.ctx = utils.dummy_context(project='trigger_test_project')
self.eng = service.EngineService('host-a', 'topic-a')
self.eng.init_tgm()
environment.global_env().register_trigger('TestTrigger',
fakes.TestTrigger)
示例3: setUp
def setUp(self):
super(PolicyTypeTest, self).setUp()
self.ctx = utils.dummy_context(tenant_id='policy_type_test_tenant')
self.eng = service.EngineService('host-a', 'topic-a')
self.eng.init_tgm()
environment.global_env().register_policy('TestPolicy',
fakes.TestPolicy)
示例4: _setup_fakes
def _setup_fakes(self):
"""Set up fake policy for the purpose of testing.
This method is provided in a standalone function because not all
test cases need such a set up.
"""
environment.global_env().register_policy('TestPolicy-1.0',
fakes.TestPolicy)
self.spec = {
'type': 'TestPolicy',
'version': '1.0',
'properties': {
'KEY2': 6
}
}
示例5: test_node_join_profile_type_not_match
def test_node_join_profile_type_not_match(self, notify):
# prepare a cluster with different profile type
env = environment.global_env()
env.register_profile('OtherProfileType', fakes.TestProfile)
other_spec = {
'type': 'OtherProfileType',
'version': '1.0',
'properties': {
'INT': 20,
'STR': 'okay',
}
}
other_profile = self.eng.profile_create(self.ctx, 'new-profile',
other_spec)
c = self.eng.cluster_create(self.ctx, 'c-1', 0, other_profile['id'])
cluster_id = c['id']
node = self.eng.node_create(self.ctx, 'node1', self.profile['id'])
node_id = node['id']
ex = self.assertRaises(rpc.ExpectedException,
self.eng.node_join,
self.ctx, node_id, cluster_id)
self.assertEqual(exception.ProfileTypeNotMatch, ex.exc_info[0])
self.assertEqual('Node and cluster have different profile type, '
'operation aborted.',
six.text_type(ex.exc_info[1]))
示例6: setUp
def setUp(self):
super(ClusterTest, self).setUp()
self.ctx = utils.dummy_context(project='cluster_test_project')
self.eng = service.EngineService('host-a', 'topic-a')
self.eng.init_tgm()
self.eng.dispatcher = mock.Mock()
env = environment.global_env()
env.register_profile('TestProfile', fakes.TestProfile)
env.register_policy('TestPolicy', fakes.TestPolicy)
spec = {
'type': 'TestProfile',
'version': '1.0',
'properties': {'INT': 10, 'STR': 'string'},
}
self.profile = self.eng.profile_create(self.ctx, 'p-test', spec,
permission='1111')
spec = {
'type': 'TestPolicy',
'version': '1.0',
'properties': {'KEY2': 3}
}
self.policy = self.eng.policy_create(self.ctx, 'policy_1', spec,
cooldown=60, level=50)
示例7: test_create_default
def test_create_default(self):
ge = environment.global_env()
e = environment.Environment()
reg_prof = e.profile_registry
reg_plcy = e.policy_registry
reg_trig = e.trigger_registry
reg_driv = e.driver_registry
self.assertEqual({}, e.params)
self.assertEqual("profiles", reg_prof.registry_name)
self.assertEqual("policies", reg_plcy.registry_name)
self.assertEqual("triggers", reg_trig.registry_name)
self.assertEqual("drivers", reg_driv.registry_name)
self.assertFalse(reg_prof.is_global)
self.assertFalse(reg_plcy.is_global)
self.assertFalse(reg_trig.is_global)
self.assertFalse(reg_driv.is_global)
self.assertEqual("profiles", ge.profile_registry.registry_name)
self.assertEqual("policies", ge.policy_registry.registry_name)
self.assertEqual("triggers", ge.trigger_registry.registry_name)
self.assertEqual("drivers", ge.driver_registry.registry_name)
self.assertEqual(ge.profile_registry, reg_prof.global_registry)
self.assertEqual(ge.policy_registry, reg_plcy.global_registry)
self.assertEqual(ge.trigger_registry, reg_trig.global_registry)
self.assertEqual(ge.driver_registry, reg_driv.global_registry)
示例8: setUp
def setUp(self):
super(ProfileTest, self).setUp()
self.ctx = utils.dummy_context(project='profile_test_project')
self.eng = service.EngineService('host-a', 'topic-a')
self.eng.init_tgm()
environment.global_env().register_profile('TestProfile',
fakes.TestProfile)
self.spec = {
'type': 'TestProfile',
'version': '1.0',
'properties': {
'INT': 1,
'STR': 'str',
'LIST': ['v1', 'v2'],
'MAP': {'KEY1': 1, 'KEY2': 'v2'},
}
}
示例9: __new__
def __new__(cls, type_name, name, **kwargs):
'''Create a new policy of the appropriate class.'''
if cls != Policy:
PolicyClass = cls
else:
PolicyClass = environment.global_env().get_policy(type_name)
return super(Policy, cls).__new__(PolicyClass)
示例10: _setup_fakes
def _setup_fakes(self):
"""Set up fake proflie for the purpose of testing.
This method is provided in a standalone function because not all
test cases need such a set up.
"""
environment.global_env().register_profile('TestProfile-1.0',
fakes.TestProfile)
self.spec = {
'type': 'TestProfile',
'version': '1.0',
'properties': {
'INT': 1,
'STR': 'str',
'LIST': ['v1', 'v2'],
'MAP': {'KEY1': 1, 'KEY2': 'v2'},
}
}
示例11: test_init_using_specified_cloud_backend
def test_init_using_specified_cloud_backend(self):
plugin2 = mock.Mock()
plugin2.compute = 'Compute2'
plugin2.orchestration = 'Orchestration2'
env = environment.global_env()
env.register_driver('cloud_backend_2', plugin2)
# Using specified cloud backend
sd = driver_base.SenlinDriver('cloud_backend_2')
self.assertEqual('Compute2', sd.compute)
self.assertEqual('Orchestration2', sd.orchestration)
示例12: test_init_using_default_cloud_backend
def test_init_using_default_cloud_backend(self):
plugin1 = mock.Mock()
plugin1.compute = 'Compute1'
plugin1.orchestration = 'Orchestration1'
env = environment.global_env()
env.register_driver('cloud_backend_1', plugin1)
# Using default cloud backend defined in configure file
cfg.CONF.set_override('cloud_backend', 'cloud_backend_1')
sd = driver_base.SenlinDriver()
self.assertEqual('Compute1', sd.compute)
self.assertEqual('Orchestration1', sd.orchestration)
示例13: test_global_initialize
def test_global_initialize(self, mock_mapping):
mock_mapping.return_value = [["aaa", mock.Mock()]]
environment._environment = None
environment.initialize()
expected = [
mock.call("senlin.profiles"),
mock.call("senlin.policies"),
mock.call("senlin.triggers"),
mock.call("senlin.drivers"),
]
self.assertIsNotNone(environment._environment)
self.assertEqual(expected, mock_mapping.call_args_list)
self.assertIsNotNone(environment.global_env().get_profile("aaa"))
self.assertIsNotNone(environment.global_env().get_policy("aaa"))
self.assertIsNotNone(environment.global_env().get_trigger("aaa"))
self.assertIsNotNone(environment.global_env().get_driver("aaa"))
environment._environment = None
示例14: setUp
def setUp(self):
super(NodeTest, self).setUp()
self.ctx = utils.dummy_context(project="node_test_project")
self.eng = service.EngineService("host-a", "topic-a")
self.eng.init_tgm()
self.eng.dispatcher = mock.Mock()
env = environment.global_env()
env.register_profile("TestProfile", fakes.TestProfile)
self.spec = {"type": "TestProfile", "version": "1.0", "properties": {"INT": 10, "STR": "string"}}
self.profile = self.eng.profile_create(self.ctx, "p-test", self.spec, permission="1111")
示例15: test_cluster_update_update_to_diff_profile_type
def test_cluster_update_update_to_diff_profile_type(self, notify):
# Register a different profile
env = environment.global_env()
env.register_profile('DiffProfileType', fakes.TestProfile)
new_profile = self.eng.profile_create(
self.ctx, 'p-test', 'DiffProfileType',
spec={'INT': 10, 'STR': 'string'}, perm='1111')
c = self.eng.cluster_create(self.ctx, 'c-1', 0, self.profile['id'])
ex = self.assertRaises(rpc.ExpectedException,
self.eng.cluster_update,
self.ctx, c['id'], profile_id=new_profile['id'])
self.assertEqual(exception.ProfileTypeNotMatch, ex.exc_info[0])