当前位置: 首页>>代码示例>>Python>>正文


Python environment.global_env函数代码示例

本文整理汇总了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)
开发者ID:KongJustin,项目名称:senlin,代码行数:7,代码来源:test_profile_types.py

示例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)
开发者ID:KongJustin,项目名称:senlin,代码行数:7,代码来源:test_triggers.py

示例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)
开发者ID:tengqm,项目名称:senlin,代码行数:7,代码来源:test_policy_types.py

示例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
            }
        }
开发者ID:jonnary,项目名称:senlin,代码行数:15,代码来源:test_policies.py

示例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]))
开发者ID:MountainWei,项目名称:senlin,代码行数:29,代码来源:test_nodes.py

示例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)
开发者ID:KongJustin,项目名称:senlin,代码行数:26,代码来源:test_clusters.py

示例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)
开发者ID:KongJustin,项目名称:senlin,代码行数:26,代码来源:test_environment.py

示例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'},
            }
        }
开发者ID:KongJustin,项目名称:senlin,代码行数:18,代码来源:test_profiles.py

示例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)
开发者ID:tengqm,项目名称:senlin,代码行数:9,代码来源:base.py

示例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'},
            }
        }
开发者ID:paperandsoap,项目名称:senlin,代码行数:18,代码来源:test_profiles.py

示例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)
开发者ID:KongJustin,项目名称:senlin,代码行数:11,代码来源:test_driver.py

示例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)
开发者ID:KongJustin,项目名称:senlin,代码行数:12,代码来源:test_driver.py

示例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
开发者ID:KongJustin,项目名称:senlin,代码行数:21,代码来源:test_environment.py

示例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")
开发者ID:KongJustin,项目名称:senlin,代码行数:13,代码来源:test_nodes.py

示例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])
开发者ID:tengqm,项目名称:senlin,代码行数:14,代码来源:test_clusters.py


注:本文中的senlin.engine.environment.global_env函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。