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

Python manager.NeutronManager类代码示例

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

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



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

示例1: get_resources

 def get_resources(cls):
     """Returns Ext Resources."""
     parent_resource = dict(member_name="tenant",
                            collection_name="extensions/csco/tenants")
     controller = CredentialController(NeutronManager.get_plugin())
     return [extensions.ResourceExtension('credentials', controller,
                                          parent=parent_resource)]
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:7,代码来源:credential.py


示例2: test_port_vif_details

 def test_port_vif_details(self):
     plugin = NeutronManager.get_plugin()
     with self.port(name='name') as port1:
         ctx = context.get_admin_context()
         port = plugin.get_port(ctx, port1['port']['id'])
         self.assertEqual(port['binding:vif_type'],
                          portbindings.VIF_TYPE_OVS)
开发者ID:Doude,项目名称:neutron,代码行数:7,代码来源:test_nvsd_plugin.py


示例3: test_update_port_security_off_address_pairs

 def test_update_port_security_off_address_pairs(self):
     if self._skip_port_security:
         self.skipTest("Plugin does not implement port-security extension")
     with self.network() as net:
         with self.subnet(network=net):
             address_pairs = [{"mac_address": "00:00:00:00:00:01", "ip_address": "10.0.0.1"}]
             res = self._create_port(
                 self.fmt,
                 net["network"]["id"],
                 arg_list=("port_security_enabled", addr_pair.ADDRESS_PAIRS),
                 port_security_enabled=True,
                 allowed_address_pairs=address_pairs,
             )
             port = self.deserialize(self.fmt, res)
             print port
             update_port = {"port": {psec.PORTSECURITY: False}}
             # If plugin implements security groups we also need to remove
             # the security group on port.
             plugin_obj = NeutronManager.get_plugin()
             if "security-groups" in plugin_obj.supported_extension_aliases:
                 update_port["port"]["security_groups"] = []
             req = self.new_update_request("ports", update_port, port["port"]["id"])
             res = req.get_response(self.api)
             self.assertEqual(res.status_int, 409)
             self._delete("ports", port["port"]["id"])
开发者ID:rafiror,项目名称:neutron,代码行数:25,代码来源:test_extension_allowedaddresspairs.py


示例4: setUp

    def setUp(self, plugin=None):
        super(PortSecurityTestCase, self).setUp()

        # Check if a plugin supports security groups
        plugin_obj = NeutronManager.get_plugin()
        self._skip_security_group = ('security-group' not in
                                     plugin_obj.supported_extension_aliases)
开发者ID:CampHarmony,项目名称:neutron,代码行数:7,代码来源:test_extension_portsecurity.py


示例5: test_network_admin_state

 def test_network_admin_state(self):
     name = "network_test"
     admin_status_up = False
     tenant_id = "tenant_test"
     network = {"network": {"name": name, "admin_state_up": admin_status_up, "tenant_id": tenant_id}}
     plugin = NeutronManager.get_plugin()
     self.assertEqual(plugin._network_admin_state(network), network)
开发者ID:nitinnain,项目名称:neutron,代码行数:7,代码来源:test_plumgrid_plugin.py


示例6: test_update_port_security_off_address_pairs

 def test_update_port_security_off_address_pairs(self):
     if self._skip_port_security:
         self.skipTest("Plugin does not implement port-security extension")
     with self.network() as net:
         with self.subnet(network=net):
             address_pairs = [{'mac_address': '00:00:00:00:00:01',
                               'ip_address': '10.0.0.1'}]
             res = self._create_port(self.fmt, net['network']['id'],
                                     arg_list=('port_security_enabled',
                                               addr_pair.ADDRESS_PAIRS,),
                                     port_security_enabled=True,
                                     allowed_address_pairs=address_pairs)
             port = self.deserialize(self.fmt, res)
             print port
             update_port = {'port': {psec.PORTSECURITY: False}}
             # If plugin implements security groups we also need to remove
             # the security group on port.
             plugin_obj = NeutronManager.get_plugin()
             if 'security-groups' in plugin_obj.supported_extension_aliases:
                 update_port['port']['security_groups'] = []
             req = self.new_update_request('ports', update_port,
                                           port['port']['id'])
             res = req.get_response(self.api)
             self.assertEqual(res.status_int, 409)
             self._delete('ports', port['port']['id'])
开发者ID:CampHarmony,项目名称:neutron,代码行数:25,代码来源:test_extension_allowedaddresspairs.py


示例7: test_update_network

    def test_update_network(self):
        plugin_obj = NeutronManager.get_plugin()
        networks_req = {}
        router_inst = RouterInstance()
        network = {
            'router:external': router_inst,
            u'name': u'network1',
            'admin_state_up': 'True',
            'tenant_id': uuid.uuid4().hex.decode(),
            'vpc:route_table': '',
            'shared': False,
            'port_security_enabled': True,
            u'contrail:policys': [],
        }

        context_obj = Context(network['tenant_id'])
        #create project
        if not GlobalProjects:
            project_name = 'admin'
            GlobalProjects.append(MockProject(name=project_name))

        networks_req[u'network'] = network
        net_dict = plugin_obj.create_network(context_obj, networks_req)
        net_id = net_dict.get('id')
        # change one of the attribute and update the network
        network['admin_state_up'] = 'False'
        new_dict = plugin_obj.update_network(context_obj, net_id,
                                             networks_req)
        self.assertNotEqual(net_dict.get('admin_state_up'),
                            new_dict.get('admin_state_up'))
开发者ID:dsetia,项目名称:neutron,代码行数:30,代码来源:test_contrail_plugin.py


示例8: test_delete_subnet

    def test_delete_subnet(self):
        #First create virtual network without subnet and then
        #create subnet to update given network.
        plugin_obj = NeutronManager.get_plugin()
        networks_req = {}
        router_inst = RouterInstance()
        network = {
            'router:external': router_inst,
            u'name': u'network1',
            'admin_state_up': 'True',
            'tenant_id': uuid.uuid4().hex.decode(),
            'vpc:route_table': '',
            'shared': False,
            'port_security_enabled': True,
            u'contrail:policys': [],
        }

        networks_req[u'network'] = network
        context_obj = Context(network['tenant_id'])
        #create project
        if not GlobalProjects:
            project_name = 'admin'
            GlobalProjects.append(MockProject(name=project_name))

        net = plugin_obj.create_network(context_obj, networks_req)

        subnet_obj[u'subnet']['network_id'] = net['id']
        subnet_dict = plugin_obj.create_subnet(context_obj, subnet_obj)
        subnet_id = subnet_dict['id']
        plugin_obj.delete_subnet(context_obj, subnet_id)
开发者ID:dsetia,项目名称:neutron,代码行数:30,代码来源:test_contrail_plugin.py


示例9: test_delete_network

    def test_delete_network(self):
        # First create the network and request to delete the same
        plugin_obj = NeutronManager.get_plugin()
        networks_req = {}
        router_inst = RouterInstance()
        network = {
            'router:external': router_inst,
            u'name': u'network1',
            'admin_state_up': 'True',
            'tenant_id': uuid.uuid4().hex.decode(),
            'vpc:route_table': '',
            'shared': False,
            'port_security_enabled': True,
            u'contrail:policys': [],
        }

        context_obj = Context(network['tenant_id'])
        #create project
        if not GlobalProjects:
            project_name = 'admin'
            GlobalProjects.append(MockProject(name=project_name))

        networks_req[u'network'] = network
        net_dict = plugin_obj.create_network(context_obj, networks_req)
        net_id = net_dict.get('id')

        plugin_obj.delete_network(context_obj, net_id)
        mock_vnc_api_cls.virtual_network_delete.assert_called_once()
开发者ID:dsetia,项目名称:neutron,代码行数:28,代码来源:test_contrail_plugin.py


示例10: test_create_network

    def test_create_network(self):
        plugin_obj = NeutronManager.get_plugin()
        networks_req = {}
        router_inst = RouterInstance()
        network = {
            'router:external': router_inst,
            u'name': u'network1',
            'admin_state_up': 'True',
            'tenant_id': uuid.uuid4().hex.decode(),
            'vpc:route_table': '',
            'shared': False,
            'port_security_enabled': True,
            u'contrail:policys': [],
        }

        networks_req[u'network'] = network
        context_obj = Context(network['tenant_id'])

        #create project
        if not GlobalProjects:
            project_name = 'admin'
            GlobalProjects.append(MockProject(name=project_name))

        net = plugin_obj.create_network(context_obj, networks_req)
        if 'contrail:fq_name' not in net.keys():
            assert False
        else:
            assert True
开发者ID:dsetia,项目名称:neutron,代码行数:28,代码来源:test_contrail_plugin.py


示例11: setUp

 def setUp(self):
     self.httpPatch = patch('httplib.HTTPConnection', create=True,
                            new=HTTPConnectionMock)
     self.httpPatch.start()
     test_l3_plugin.L3NatDBTestCase.setUp = new_L3_setUp
     super(RouterDBTestCase, self).setUp()
     self.plugin_obj = NeutronManager.get_plugin()
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:7,代码来源:test_router_db.py


示例12: test_create_networks_bulk_emulated_plugin_failure

    def test_create_networks_bulk_emulated_plugin_failure(self):
        real_has_attr = hasattr

        def fakehasattr(item, attr):
            if attr.endswith('__native_bulk_support'):
                return False
            return real_has_attr(item, attr)

        plugin_obj = NeutronManager.get_plugin()
        orig = plugin_obj.create_network
        #ensures the API choose the emulation code path
        with mock.patch('__builtin__.hasattr',
                        new=fakehasattr):
            with mock.patch.object(plugin_obj,
                                   'create_network') as patched_plugin:
                def side_effect(*args, **kwargs):
                    return self._do_side_effect(patched_plugin, orig,
                                                *args, **kwargs)
                patched_plugin.side_effect = side_effect
                res = self._create_network_bulk(self.fmt, 2, 'test', True)
                LOG.debug("response is %s" % res)
                # We expect an internal server error as we injected a fault
                self._validate_behavior_on_bulk_failure(
                    res,
                    'networks',
                    wexc.HTTPInternalServerError.code)
开发者ID:50infivedays,项目名称:neutron,代码行数:26,代码来源:test_cisco_mech.py


示例13: test_create_subnets_bulk_emulated_plugin_failure

    def test_create_subnets_bulk_emulated_plugin_failure(self):
        real_has_attr = hasattr

        #ensures the API choose the emulation code path
        def fakehasattr(item, attr):
            if attr.endswith('__native_bulk_support'):
                return False
            return real_has_attr(item, attr)

        with mock.patch('__builtin__.hasattr',
                        new=fakehasattr):
            plugin_obj = NeutronManager.get_plugin()
            orig = plugin_obj.create_subnet
            with mock.patch.object(plugin_obj,
                                   'create_subnet') as patched_plugin:

                def side_effect(*args, **kwargs):
                    self._do_side_effect(patched_plugin, orig,
                                         *args, **kwargs)

                patched_plugin.side_effect = side_effect
                with self.network() as net:
                    res = self._create_subnet_bulk(self.fmt, 2,
                                                   net['network']['id'],
                                                   'test')
                # We expect an internal server error as we injected a fault
                self._validate_behavior_on_bulk_failure(
                    res,
                    'subnets',
                    wexc.HTTPInternalServerError.code)
开发者ID:50infivedays,项目名称:neutron,代码行数:30,代码来源:test_cisco_mech.py


示例14: setUp

    def setUp(self):
        super(ProvidernetExtensionTestCase, self).setUp()

        plugin = 'neutron.neutron_plugin_base_v2.NeutronPluginBaseV2'

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Update the plugin and extensions path
        self.setup_coreplugin(plugin)
        cfg.CONF.set_override('allow_pagination', True)
        cfg.CONF.set_override('allow_sorting', True)
        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        # Ensure Quota checks never fail because of mock
        instance = self.plugin.return_value
        instance.get_networks_count.return_value = 1
        # Instantiate mock plugin and enable the 'provider' extension
        NeutronManager.get_plugin().supported_extension_aliases = (
            ["provider"])
        ext_mgr = ProviderExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.addCleanup(self._plugin_patcher.stop)
        self.addCleanup(self._restore_attribute_map)
        self.api = webtest.TestApp(router.APIRouter())

        quota.QUOTAS._driver = None
        cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
                              group='QUOTAS')
开发者ID:CingHu,项目名称:neutron-1,代码行数:34,代码来源:test_extension_pnet.py


示例15: setUp

    def setUp(self, plugin=None):
        super(AllowedAddressPairTestCase, self).setUp()

        # Check if a plugin supports security groups
        plugin_obj = NeutronManager.get_plugin()
        self._skip_port_security = ('port-security' not in
                                    plugin_obj.supported_extension_aliases)
开发者ID:CampHarmony,项目名称:neutron,代码行数:7,代码来源:test_extension_allowedaddresspairs.py


示例16: test_consistency_watchdog

 def test_consistency_watchdog(self):
     pl = NeutronManager.get_plugin()
     pl.servers.capabilities = []
     self.watch_p.stop()
     with nested(
         mock.patch('eventlet.sleep'),
         mock.patch(
             SERVERMANAGER + '.ServerPool.rest_call',
             side_effect=servermanager.RemoteRestError(
                 reason='Failure to trigger except clause.'
             )
         ),
         mock.patch(
             SERVERMANAGER + '.LOG.exception',
             side_effect=KeyError('Failure to break loop')
         )
     ) as (smock, rmock, lmock):
         # should return immediately without consistency capability
         pl.servers._consistency_watchdog()
         self.assertFalse(smock.called)
         pl.servers.capabilities = ['consistency']
         self.assertRaises(KeyError,
                           pl.servers._consistency_watchdog)
         rmock.assert_called_with('GET', '/health', '', {}, [], False)
         self.assertEqual(1, len(lmock.mock_calls))
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:25,代码来源:test_servermanager.py


示例17: setUp

    def setUp(self, plugin=None):
        ext_mgr = test_extension_security_group.SecurityGroupTestExtensionManager()
        super(PortSecurityTestCase, self).setUp(plugin=plugin, ext_mgr=ext_mgr)

        # Check if a plugin supports security groups
        plugin_obj = NeutronManager.get_plugin()
        self._skip_security_group = "security-group" not in plugin_obj.supported_extension_aliases
开发者ID:nabilmaad,项目名称:neutron,代码行数:7,代码来源:test_extension_portsecurity.py


示例18: test_conflict_sync_raises_error_without_topology

 def test_conflict_sync_raises_error_without_topology(self):
     pl = NeutronManager.get_plugin()
     pl.servers.get_topo_function = None
     with mock.patch(SERVERMANAGER + ".ServerProxy.rest_call", return_value=(httplib.CONFLICT, 0, 0, 0)):
         # making a call should trigger a conflict sync that will
         # error without the topology function set
         self.assertRaises(cfg.Error, pl.servers.rest_call, *("GET", "/", "", None, []))
开发者ID:dreamhost,项目名称:quantum,代码行数:7,代码来源:test_servermanager.py


示例19: setUp

 def setUp(self):
     self.setup_patches()
     self.setup_config_files()
     ext_mgr = RouterRulesTestExtensionManager()
     super(RouterDBTestBase, self).setUp(plugin=self._plugin_name, ext_mgr=ext_mgr)
     cfg.CONF.set_default("allow_overlapping_ips", False)
     self.plugin_obj = NeutronManager.get_plugin()
     self.startHttpPatch()
开发者ID:dreamhost,项目名称:quantum,代码行数:8,代码来源:test_router_db.py


示例20: test_file_put_contents

 def test_file_put_contents(self):
     pl = NeutronManager.get_plugin()
     with mock.patch(SERVERMANAGER + '.open', create=True) as omock:
         pl.servers._file_put_contents('somepath', 'contents')
         omock.assert_has_calls([mock.call('somepath', 'w')])
         omock.return_value.__enter__.return_value.assert_has_calls([
             mock.call.write('contents')
         ])
开发者ID:50infivedays,项目名称:neutron,代码行数:8,代码来源:test_servermanager.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python api.create_object函数代码示例发布时间:2022-05-27
下一篇:
Python manager.init函数代码示例发布时间: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