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


Python policy.refresh函数代码示例

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


在下文中一共展示了refresh函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reset_service

def reset_service():
    # Reset worker in case SIGHUP is called.
    # Note that this is called only in case a service is running in
    # daemon mode.
    setup_logging()
    set_config_defaults()
    policy.refresh()
开发者ID:21atlas,项目名称:neutron,代码行数:7,代码来源:config.py

示例2: setUp

    def setUp(self):
        super(NeutronPolicyTestCase, self).setUp()
        policy.refresh()
        # Add Fake resources to RESOURCE_ATTRIBUTE_MAP
        attributes.RESOURCE_ATTRIBUTE_MAP.update(FAKE_RESOURCES)
        self.rules = dict((k, common_policy.parse_rule(v)) for k, v in {
            "context_is_admin": "role:admin",
            "context_is_advsvc": "role:advsvc",
            "admin_or_network_owner": "rule:context_is_admin or "
                                      "tenant_id:%(network:tenant_id)s",
            "admin_or_owner": ("rule:context_is_admin or "
                               "tenant_id:%(tenant_id)s"),
            "admin_only": "rule:context_is_admin",
            "regular_user": "role:user",
            "shared": "field:networks:shared=True",
            "external": "field:networks:router:external=True",
            "default": '@',

            "create_network": "rule:admin_or_owner",
            "create_network:shared": "rule:admin_only",
            "update_network": '@',
            "update_network:shared": "rule:admin_only",
            "get_network": "rule:admin_or_owner or rule:shared or "
                           "rule:external or rule:context_is_advsvc",
            "create_subnet": "rule:admin_or_network_owner",
            "create_port:mac": "rule:admin_or_network_owner or "
                               "rule:context_is_advsvc",
            "update_port": "rule:admin_or_owner or rule:context_is_advsvc",
            "get_port": "rule:admin_or_owner or rule:context_is_advsvc",
            "delete_port": "rule:admin_or_owner or rule:context_is_advsvc",
            "create_fake_resource": "rule:admin_or_owner",
            "create_fake_resource:attr": "rule:admin_or_owner",
            "create_fake_resource:attr:sub_attr_1": "rule:admin_or_owner",
            "create_fake_resource:attr:sub_attr_2": "rule:admin_only",

            "create_fake_policy:": "rule:admin_or_owner",
            "get_firewall_policy": "rule:admin_or_owner or "
                            "rule:shared",
            "get_firewall_rule": "rule:admin_or_owner or "
                            "rule:shared",

            "insert_rule": "rule:admin_or_owner",
            "remove_rule": "rule:admin_or_owner",
        }.items())

        def remove_fake_resource():
            del attributes.RESOURCE_ATTRIBUTE_MAP["%ss" % FAKE_RESOURCE_NAME]

        self.patcher = mock.patch.object(neutron.policy,
                                         'init',
                                         new=self.fakepolicyinit)
        self.patcher.start()
        self.addCleanup(remove_fake_resource)
        self.context = context.Context('fake', 'fake', roles=['user'])
        plugin_klass = importutils.import_class(
            "neutron.db.db_base_plugin_v2.NeutronDbPluginV2")
        self.manager_patcher = mock.patch('neutron.manager.NeutronManager')
        fake_manager = self.manager_patcher.start()
        fake_manager_instance = fake_manager.return_value
        fake_manager_instance.plugin = plugin_klass()
开发者ID:Intellifora,项目名称:neutron,代码行数:60,代码来源:test_policy.py

示例3: setUp

    def setUp(self):
        super(DefaultPolicyTestCase, self).setUp()
        tmpfilename = self.get_temp_file_path("policy.json")
        self.rules = {"default": "", "example:exist": "!"}
        with open(tmpfilename, "w") as policyfile:
            jsonutils.dump(self.rules, policyfile)
        cfg.CONF.set_override("policy_file", tmpfilename)
        policy.refresh()
        self.addCleanup(policy.reset)

        self.context = context.Context("fake", "fake")
开发者ID:noironetworks,项目名称:neutron2,代码行数:11,代码来源:test_policy.py

示例4: setUp

    def setUp(self):
        super(DefaultPolicyTestCase, self).setUp()
        tmpfilename = self.get_temp_file_path('policy.json')
        self.rules = {
            "default": '',
            "example:exist": '!',
        }
        with open(tmpfilename, "w") as policyfile:
            jsonutils.dump(self.rules, policyfile)
        policy.refresh(policy_file=tmpfilename)

        self.context = context.Context('fake', 'fake')
开发者ID:21atlas,项目名称:neutron,代码行数:12,代码来源:test_policy.py

示例5: test_modified_policy_reloads

 def test_modified_policy_reloads(self):
     tmpfilename = self.get_temp_file_path("policy")
     action = "example:test"
     with open(tmpfilename, "w") as policyfile:
         policyfile.write("""{"example:test": ""}""")
     cfg.CONF.set_override("policy_file", tmpfilename)
     policy.refresh()
     policy.enforce(self.context, action, self.target)
     with open(tmpfilename, "w") as policyfile:
         policyfile.write("""{"example:test": "!"}""")
     policy.refresh()
     self.target = {"tenant_id": "fake_tenant"}
     self.assertRaises(common_policy.PolicyNotAuthorized, policy.enforce, self.context, action, self.target)
开发者ID:noironetworks,项目名称:neutron2,代码行数:13,代码来源:test_policy.py

示例6: setUp

    def setUp(self):
        super(DefaultPolicyTestCase, self).setUp()
        self.tempdir = self.useFixture(fixtures.TempDir())
        tmpfilename = self.tempdir.join('policy.json')
        self.rules = {
            "default": '',
            "example:exist": '!',
        }
        with open(tmpfilename, "w") as policyfile:
            jsonutils.dump(self.rules, policyfile)
        cfg.CONF.set_override('policy_file', tmpfilename)
        policy.refresh()
        self.addCleanup(policy.reset)

        self.context = context.Context('fake', 'fake')
开发者ID:asadoughi,项目名称:neutron,代码行数:15,代码来源:test_policy.py

示例7: test_modified_policy_reloads

 def test_modified_policy_reloads(self):
     tmpfilename = self.get_temp_file_path('policy')
     action = "example:test"
     with open(tmpfilename, "w") as policyfile:
         policyfile.write("""{"example:test": ""}""")
     policy.refresh(policy_file=tmpfilename)
     policy.enforce(self.context, action, self.target)
     with open(tmpfilename, "w") as policyfile:
         policyfile.write("""{"example:test": "!"}""")
     policy.refresh(policy_file=tmpfilename)
     self.target = {'tenant_id': 'fake_tenant'}
     self.assertRaises(oslo_policy.PolicyNotAuthorized,
                       policy.enforce,
                       self.context,
                       action,
                       self.target)
开发者ID:21atlas,项目名称:neutron,代码行数:16,代码来源:test_policy.py

示例8: setUp

    def setUp(self):
        super(NeutronPolicyTestCase, self).setUp()
        # Add Fake resources to RESOURCE_ATTRIBUTE_MAP
        attributes.RESOURCES.update(FAKE_RESOURCES)
        self._set_rules()

        self.patcher = mock.patch.object(neutron.policy,
                                         'init',
                                         new=self.fakepolicyinit)
        self.patcher.start()
        policy.refresh()
        self.addCleanup(policy.refresh)
        self.context = context.Context('fake', 'fake', roles=['user'])
        plugin_klass = importutils.import_class(
            "neutron.db.db_base_plugin_v2.NeutronDbPluginV2")
        directory.add_plugin(plugin_constants.CORE, plugin_klass())
开发者ID:cubeek,项目名称:neutron,代码行数:16,代码来源:test_policy.py

示例9: reset

 def reset(self):
     config.setup_logging()
     policy.refresh()
开发者ID:Intellifora,项目名称:neutron,代码行数:3,代码来源:service.py


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