• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python environment.global_env函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中senlin.engine.environment.global_env函数的典型用法代码示例。如果您正苦于以下问题:Python global_env函数的具体用法?Python global_env怎么用?Python global_env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了global_env函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: __init__

    def __init__(self, backend_name=None):

        if backend_name is None:
            backend_name = cfg.CONF.cloud_backend

        backend = environment.global_env().get_driver(backend_name)

        # TODO(Yanyan Hu): Use openstack compute driver(nova_v2)
        # as the start point of using senlin generic driver.
        self.compute = backend.compute
        self.loadbalancing = backend.loadbalancing
        self.network = backend.network
        self.orchestration = backend.orchestration
        self.telemetry = backend.telemetry
        self.identity = backend.identity
开发者ID:gongwayne,项目名称:Openstack,代码行数:15,代码来源:base.py


示例17: __new__

    def __new__(cls, name, spec, **kwargs):
        """Create a new profile of the appropriate class.

        :param name: The name for the profile.
        :param spec: A dictionary containing the spec for the profile.
        :param kwargs: Keyword arguments for policy creation.
        :returns: An instance of a specific sub-class of Policy.
        """
        type_name, version = schema.get_spec_version(spec)

        if cls != Profile:
            ProfileClass = cls
        else:
            ProfileClass = environment.global_env().get_profile(type_name)

        return super(Profile, cls).__new__(ProfileClass)
开发者ID:KongJustin,项目名称:senlin,代码行数:16,代码来源:base.py


示例18: _prepare_policy

    def _prepare_policy(self, name, type_name=None, cooldown=None, level=None):
        if type_name is not None:
            env = environment.global_env()
            env.register_policy(type_name, fakes.TestPolicy)
        else:
            type_name = 'TestPolicy'
        spec = {
            'type': type_name,
            'version': '1.0',
            'properties': {'KEY2': 5}
        }
        policy = self.eng.policy_create(self.ctx, name, spec,
                                        cooldown=cooldown or 60,
                                        level=level or 50)

        return policy
开发者ID:KongJustin,项目名称:senlin,代码行数:16,代码来源:test_cluster_policies.py


示例19: test_node_update_with_diff_profile_type

    def test_node_update_with_diff_profile_type(self, notify):
        env = environment.global_env()
        env.register_profile("NewProfileType", fakes.TestProfile)
        new_spec = {"type": "NewProfileType", "version": "1.0", "properties": {"INT": 20}}
        new_profile = self.eng.profile_create(self.ctx, "p-new", new_spec)

        node = self.eng.node_create(self.ctx, "node-1", self.profile["id"])

        ex = self.assertRaises(
            rpc.ExpectedException, self.eng.node_update, self.ctx, node["id"], profile_id=new_profile["id"]
        )

        self.assertEqual(exception.ProfileTypeNotMatch, ex.exc_info[0])
        self.assertEqual(
            "Cannot update a node to a different profile type, " "operation aborted.", six.text_type(ex.exc_info[1])
        )
开发者ID:KongJustin,项目名称:senlin,代码行数:16,代码来源:test_nodes.py


示例20: test_node_create_profile_type_not_match

    def test_node_create_profile_type_not_match(self, notify):
        env = environment.global_env()
        env.register_profile("SecondProfile", fakes.TestProfile)
        new_spec = {"type": "SecondProfile", "version": "1.0", "properties": {"INT": 20, "STR": "string"}}
        cluster_profile = self.eng.profile_create(self.ctx, "cp", new_spec)

        cluster = self.eng.cluster_create(self.ctx, "c-1", 0, cluster_profile["id"])

        ex = self.assertRaises(
            rpc.ExpectedException, self.eng.node_create, self.ctx, "n-1", self.profile["id"], cluster_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:KongJustin,项目名称:senlin,代码行数:16,代码来源:test_nodes.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python parser.simple_parse函数代码示例发布时间:2022-05-27
下一篇:
Python api.cluster_get_all函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap