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

Python network_count_check.filter_factory函数代码示例

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

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



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

示例1: test_attach_checking_configured_two_allowed_adding_third

    def test_attach_checking_configured_two_allowed_adding_third(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        m_instance = self.create_patch(self.get_instance_path)
        m_get_nwinfo = self.create_patch(
            'nova.compute.utils.get_nw_info_for_instance')
        vif_id1 = '12345678-1234-1234-1234-123456789012'
        vif_id2 = '12345678-0000-1234-1234-123456789012'
        net_id1 = '12345678-1234-0000-1234-123456789012'
        net_id2 = '12345678-1234-1234-0000-123456789012'
        m_get_nwinfo.return_value = [MockedVIFInfo(vif_id1, net_id1),
                                     MockedVIFInfo(vif_id2, net_id2)]
        conf = {'networks_max': '2', 'enabled': 'true'}
        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(2, result.check_config.networks_max)

        body = '{"virtual_interface": {"network_id": "%s"}}'

        goodurl = '/%s/servers/%s/os-virtual-interfacesv2'
        vif = self.vifuuid
        resp = result.__call__.request(goodurl % (self.tenant_id, vif),
                                       method='POST', body=body % self.adduuid)
        self.assertEqual(1, m_instance.call_count)
        self.assertEqual(1, m_get_nwinfo.call_count)
        self.assertTrue(isinstance(resp, webob.exc.HTTPForbidden))
        self.assertTrue('be attached' in str(resp))
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:26,代码来源:test_network_count_check.py


示例2: test_runtime_overrides

    def test_runtime_overrides(self):
        self.set_reconfigure()
        headers = {'X_WAFFLEHAUS_NETWORKCOUNTCHECK_ENABLED': False}

        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        conf = {'networks_min': '1', 'networks_max': '2',
                'required_nets': self.pubuuid, 'enabled': 'true'}

        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(1, result.check_config.networks_min)

        net1 = '{"uuid": "%s"}' % self.srvuuid
        net2 = '{"uuid": "%s"}' % self.adduuid
        body = '{"server": {"networks":[%s, %s]}}' % (net1, net2)

        goodurl = '/%s/servers'
        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body)
        self.assertTrue(isinstance(resp, webob.exc.HTTPForbidden))
        self.assertTrue('but missing' in str(resp))

        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body, headers=headers)
        self.assertFalse(isinstance(resp, webob.exc.HTTPForbidden))
        self.assertFalse('but missing' in str(resp))
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:26,代码来源:test_network_count_check.py


示例3: test_return_app_on_missing_context

    def test_return_app_on_missing_context(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = None

        result = network_count_check.filter_factory(self.conf)(self.app)
        result.__call__.request('/something', method='POST')
        self.assertEqual(1, m_ctx.call_count)
        self.assertEqual(self.app, result.app)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:8,代码来源:test_network_count_check.py


示例4: test_boot_no_body_returns_app

    def test_boot_no_body_returns_app(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        conf = {'networks_min': '1', 'networks_max': '1',
                'optional_nets': self.pubuuid, 'enabled': 'true'}

        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(1, result.check_config.networks_min)
        body = ''

        goodurl = '/%s/servers'
        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body)
        self.assertEqual(self.app, resp)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:14,代码来源:test_network_count_check.py


示例5: test_boot_less_than_min_networks

    def test_boot_less_than_min_networks(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        conf = {'networks_min': '1', 'networks_max': '2', 'enabled': 'true'}

        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(1, result.check_config.networks_min)
        body = '{"server": {"networks":[]}}'

        goodurl = '/%s/servers'
        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body)
        self.assertTrue(isinstance(resp, webob.exc.HTTPForbidden))
        self.assertTrue('be attached' in str(resp))
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:14,代码来源:test_network_count_check.py


示例6: test_boot_suports_no_networks

    def test_boot_suports_no_networks(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        conf = {'networks_min': '0', 'enabled': 'true'}

        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(0, result.check_config.networks_min)

        body = '{"server": {"networks":[]}}'

        goodurl = '/%s/servers'
        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body)
        self.assertEqual(self.app, resp)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:14,代码来源:test_network_count_check.py


示例7: test_boot_suports_no_network_in_body_with_requires

    def test_boot_suports_no_network_in_body_with_requires(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        conf = {'networks_min': '0', 'networks_max': '2',
                'required_nets': self.pubuuid, 'enabled': 'true'}

        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(0, result.check_config.networks_min)

        body = '{"server": {}}'

        goodurl = '/%s/servers'
        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body)
        self.assertTrue(isinstance(resp, webob.exc.HTTPForbidden))
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:15,代码来源:test_network_count_check.py


示例8: test_run_on_post

    def test_run_on_post(self):
        m_ctx = self.create_patch(self.ctx_path)

        result = network_count_check.filter_factory(self.conf)(self.app)
        result.__call__.request('/something', method='GET')
        self.assertEqual(0, m_ctx.call_count)
        self.assertEqual(self.app, result.app)
        result.__call__.request('/something', method='PUT')
        self.assertEqual(0, m_ctx.call_count)
        self.assertEqual(self.app, result.app)
        result.__call__.request('/something', method='DELETE')
        self.assertEqual(0, m_ctx.call_count)
        self.assertEqual(self.app, result.app)
        result.__call__.request('/something', method='POST')
        self.assertEqual(1, m_ctx.call_count)
        self.assertEqual(self.app, result.app)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:16,代码来源:test_network_count_check.py


示例9: test_attach_no_body_returns_app

    def test_attach_no_body_returns_app(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        m_get_nwinfo = self.create_patch(
            'nova.compute.utils.get_nw_info_for_instance')
        m_get_nwinfo.return_value = []

        result = network_count_check.filter_factory(self.conf)(self.app)

        body = ''

        goodurl = '/%s/servers/%s/os-virtual-interfacesv2'
        vif = self.vifuuid
        resp = result.__call__.request(goodurl % (self.tenant_id, vif),
                                       method='POST', body=body)
        self.assertEqual(self.app, resp)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:16,代码来源:test_network_count_check.py


示例10: test_boot_beyond_max_networks_ok_with_optionals

    def test_boot_beyond_max_networks_ok_with_optionals(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        conf = {'networks_min': '1', 'networks_max': '1',
                'optional_nets': self.pubuuid, 'enabled': 'true'}

        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(1, result.check_config.networks_min)

        net1 = '{"uuid": "%s"}' % self.pubuuid
        net2 = '{"uuid": "%s"}' % self.adduuid
        body = '{"server": {"networks":[%s, %s]}}' % (net1, net2)

        goodurl = '/%s/servers'
        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body)
        self.assertEqual(self.app, resp)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:17,代码来源:test_network_count_check.py


示例11: test_boot_beyond_max_networks_need_required

    def test_boot_beyond_max_networks_need_required(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        conf = {'networks_min': '1', 'networks_max': '2',
                'required_nets': self.pubuuid, 'enabled': 'true'}

        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(1, result.check_config.networks_min)

        net1 = '{"uuid": "%s"}' % self.srvuuid
        net2 = '{"uuid": "%s"}' % self.adduuid
        body = '{"server": {"networks":[%s, %s]}}' % (net1, net2)

        goodurl = '/%s/servers'
        resp = result.__call__.request(goodurl % self.tenant_id, method='POST',
                                       body=body)
        self.assertTrue(isinstance(resp, webob.exc.HTTPForbidden))
        self.assertTrue('but missing' in str(resp))
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:18,代码来源:test_network_count_check.py


示例12: test_attach_checking_default_one_isolated_allowed_from_none

    def test_attach_checking_default_one_isolated_allowed_from_none(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        m_instance = self.create_patch(self.get_instance_path)
        m_get_nwinfo = self.create_patch(
            'nova.compute.utils.get_nw_info_for_instance')
        m_get_nwinfo.return_value = []

        result = network_count_check.filter_factory(self.conf)(self.app)
        self.assertEqual(1, result.check_config.networks_max)

        body = '{"virtual_interface": {"network_id": "%s"}}'

        goodurl = '/%s/servers/%s/os-virtual-interfacesv2'
        vif = self.vifuuid
        resp = result.__call__.request(goodurl % (self.tenant_id, vif),
                                       method='POST', body=body % self.adduuid)
        self.assertEqual(1, m_instance.call_count)
        self.assertEqual(1, m_get_nwinfo.call_count)
        self.assertEqual(self.app, resp)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:20,代码来源:test_network_count_check.py


示例13: test_pathing_properly

    def test_pathing_properly(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        m_attach = self.create_patch(self.attach_path)
        m_boot = self.create_patch(self.boot_path)

        result = network_count_check.filter_factory(self.conf)(self.app)
        self.assertEqual(0, m_attach.call_count)
        self.assertEqual(0, m_boot.call_count)

        result.__call__.request('/%s/derp' % self.tenant_id, method='POST',
                                body=self.boot_body1)
        result.__call__.request('/%s/servers' % '909090', method='POST',
                                body=self.boot_body1)
        result.__call__.request('/%s/servers' % self.tenant_id, method='GET',
                                body=self.boot_body1)
        result.__call__.request('/%s/servers' % self.tenant_id, method='PUT',
                                body=self.boot_body1)
        result.__call__.request('/%s/servers' % self.tenant_id,
                                method='DELETE', body=self.boot_body1)
        goodurl = '/%s/servers/%s/os-virtual-interfacesv2'
        badurl = '/%s/servers/%s/os-virtual-interfaces'
        result.__call__.request(goodurl % ('909090', self.vifuuid),
                                method='POST', body=self.boot_body1)
        result.__call__.request(goodurl % (self.tenant_id, '1234'),
                                method='POST', body=self.boot_body1)
        result.__call__.request(badurl % (self.tenant_id, '1234'),
                                method='POST', body=self.boot_body1)
        self.assertEqual(0, m_attach.call_count)
        self.assertEqual(0, m_boot.call_count)

        result.__call__.request('/%s/servers' % self.tenant_id, method='POST',
                                body=self.boot_body1)
        self.assertEqual(0, m_attach.call_count)
        self.assertEqual(1, m_boot.call_count)

        result.__call__.request(goodurl % (self.tenant_id, self.vifuuid),
                                method='POST', body=self.boot_body1)
        self.assertEqual(1, m_attach.call_count)
        self.assertEqual(1, m_boot.call_count)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:40,代码来源:test_network_count_check.py


示例14: test_attach_with_malformed_body_returns_app

    def test_attach_with_malformed_body_returns_app(self):
        m_ctx = self.create_patch(self.ctx_path)
        m_ctx.return_value = self.context
        m_instance = self.create_patch(self.get_instance_path)
        m_get_nwinfo = self.create_patch(
            'nova.compute.utils.get_nw_info_for_instance')
        m_get_nwinfo.return_value = [MockedVIFInfo(self.vifuuid, self.srvuuid)]
        conf = {'banned_nets': self.pubuuid,
                'networks_max': '2', 'enabled': 'true'}
        result = network_count_check.filter_factory(conf)(self.app)
        self.assertEqual(2, result.check_config.networks_max)
        self.assertEqual(1, len(result.check_config.banned_networks))

        body = '{"virtual_interface": {"network": "%s"}}'

        goodurl = '/%s/servers/%s/os-virtual-interfacesv2'
        vif = self.vifuuid
        resp = result.__call__.request(goodurl % (self.tenant_id, vif),
                                       method='POST', body=body % self.pubuuid)
        self.assertEqual(0, m_instance.call_count)
        self.assertEqual(0, m_get_nwinfo.call_count)
        self.assertEqual(self.app, resp)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:22,代码来源:test_network_count_check.py


示例15: test_initial_instance

 def test_initial_instance(self):
     result = network_count_check.filter_factory(self.conf)(self.app)
     self.assertIsNotNone(result)
开发者ID:csdhome,项目名称:wafflehaus.nova,代码行数:3,代码来源:test_network_count_check.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python context_filter.filter_factory函数代码示例发布时间:2022-05-26
下一篇:
Python utils.keyfmt函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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