コード例 #1
0
    def __init__(self):
        super(BGPVPNPlugin, self).__init__()

        # Need to look into /etc/neutron/networking_bgpvpn.conf for
        # service_provider definitions:
        service_type_manager = st_db.ServiceTypeManager.get_instance()
        service_type_manager.add_provider_configuration(
            bgpvpn_def.LABEL, pconf.ProviderConfiguration('networking_bgpvpn'))

        # Load the default driver
        drivers, default_provider = service_base.load_drivers(
            bgpvpn_def.LABEL, self)
        LOG.info("BGP VPN Service Plugin using Service Driver: %s",
                 default_provider)
        self.driver = drivers[default_provider]

        if len(drivers) > 1:
            LOG.warning("Multiple drivers configured for BGPVPN, although"
                        "running multiple drivers in parallel is not yet"
                        "supported")
        registry.subscribe(self._notify_adding_interface_to_router,
                           resources.ROUTER_INTERFACE, events.BEFORE_CREATE)
        registry.subscribe(self._notify_host_updated, n_resources.HOST,
                           events.AFTER_UPDATE)
        registry.subscribe(self._notify_agent_updated, resources.AGENT,
                           events.AFTER_UPDATE)
        registry.subscribe(self._notify_removing_vpn_from_speaker,
                           dr_resources.BGP_SPEAKER_VPN_ASSOC,
                           events.AFTER_DELETE)
コード例 #2
0
    def __init__(self):
        super(FirewallPluginV2, self).__init__()
        """Do the initialization for the firewall service plugin here."""
        # Initialize the Firewall v2 service plugin
        service_type_manager = st_db.ServiceTypeManager.get_instance()
        service_type_manager.add_provider_configuration(
            fwaas_constants.FIREWALL_V2,
            provider_conf.ProviderConfiguration('neutron_fwaas'))

        # Load the default driver
        drivers, default_provider = service_base.load_drivers(
            fwaas_constants.FIREWALL_V2, self)
        LOG.info("Firewall v2 Service Plugin using Service Driver: %s",
                 default_provider)

        if len(drivers) > 1:
            LOG.warning("Multiple drivers configured for Firewall v2, "
                        "although running multiple drivers in parallel is "
                        "not yet supported")

        self.driver = drivers[default_provider]

        # start rpc listener if driver required
        if isinstance(self.driver, driver_api.FirewallDriverRPCMixin):
            rpc_worker = service.RpcWorker([self], worker_process_count=0)
            self.add_worker(rpc_worker)
コード例 #3
0
 def test_get_service_providers(self):
     self._set_override([
         constants.LOADBALANCER + ':name:path',
         constants.LOADBALANCER + ':name2:path2', 'st2:name:driver:default',
         'st3:name2:driver2:default'
     ])
     provs = [{
         'service_type': constants.LOADBALANCER,
         'name': 'name',
         'driver': 'path',
         'default': False
     }, {
         'service_type': constants.LOADBALANCER,
         'name': 'name2',
         'driver': 'path2',
         'default': False
     }, {
         'service_type': 'st2',
         'name': 'name',
         'driver': 'driver',
         'default': True
     }, {
         'service_type': 'st3',
         'name': 'name2',
         'driver': 'driver2',
         'default': True
     }]
     pconf = provconf.ProviderConfiguration()
     for prov in provs:
         p = pconf.get_service_providers(
             filters={
                 'name': [prov['name']],
                 'service_type': prov['service_type']
             })
         self.assertEqual([prov], p)
コード例 #4
0
 def _set_override(self, service_providers):
     self.service_providers.return_value = service_providers
     st_db.ServiceTypeManager._instance = None
     self.manager = st_db.ServiceTypeManager.get_instance()
     for provider in service_providers:
         self.manager.add_provider_configuration(
             provider.split(':')[0], provconf.ProviderConfiguration())
コード例 #5
0
 def test_get_service_providers_with_fields(self):
     self._set_override([
         constants.LOADBALANCER + ":name:path",
         constants.LOADBALANCER + ":name2:path2"
     ])
     provs = [{
         'service_type': constants.LOADBALANCER,
         'name': 'name',
         'driver': 'path',
         'default': False
     }, {
         'service_type': constants.LOADBALANCER,
         'name': 'name2',
         'driver': 'path2',
         'default': False
     }]
     pconf = provconf.ProviderConfiguration()
     for prov in provs:
         p = pconf.get_service_providers(filters={
             'name': [prov['name']],
             'service_type':
             prov['service_type']
         },
                                         fields=['name'])
         self.assertEqual([{'name': prov['name']}], p)
コード例 #6
0
 def test_ensure_driver_unique(self):
     pconf = provconf.ProviderConfiguration()
     pconf.providers[('svctype', 'name')] = {'driver': 'driver',
                                             'default': True}
     self.assertRaises(n_exc.Invalid,
                       pconf._ensure_driver_unique, 'driver')
     self.assertIsNone(pconf._ensure_driver_unique('another_driver1'))
コード例 #7
0
 def test_get_service_providers(self):
     provs = [{
         'service_type': constants.LOADBALANCER,
         'name': 'name',
         'driver': 'path',
         'default': False
     }, {
         'service_type': constants.LOADBALANCER,
         'name': 'name2',
         'driver': 'path2',
         'default': False
     }, {
         'service_type': 'st2',
         'name': 'name',
         'driver': 'driver',
         'default': True
     }, {
         'service_type': 'st3',
         'name': 'name2',
         'driver': 'driver2',
         'default': True
     }]
     pconf = provconf.ProviderConfiguration(provs)
     for prov in provs:
         p = pconf.get_service_providers(
             filters={
                 'name': [prov['name']],
                 'service_type': prov['service_type']
             })
         self.assertEqual(p, [prov])
コード例 #8
0
ファイル: test_flavors.py プロジェクト: zjtheone/neutron
    def setUp(self):
        super(FlavorPluginTestCase, self).setUp()

        self.config_parse()
        cfg.CONF.set_override(
            'core_plugin',
            'neutron.tests.unit.extensions.test_flavors.DummyCorePlugin')
        cfg.CONF.set_override(
            'service_plugins',
            ['neutron.tests.unit.extensions.test_flavors.DummyServicePlugin'])

        self.useFixture(
            fixtures.MonkeyPatch('neutron.manager.NeutronManager._instance'))

        self.plugin = flavors_plugin.FlavorsPlugin()
        self.ctx = context.get_admin_context()

        providers = [DummyServiceDriver.get_service_type() +
                     ":" + _provider + ":" + _driver]
        self.service_manager = servicetype_db.ServiceTypeManager.get_instance()
        self.service_providers = mock.patch.object(
            provconf.NeutronModule, 'service_providers').start()
        self.service_providers.return_value = providers
        for provider in providers:
            self.service_manager.add_provider_configuration(
                provider.split(':')[0], provconf.ProviderConfiguration())

        dbapi.get_engine()
コード例 #9
0
 def test_add_duplicate_provider(self):
     pconf = provconf.ProviderConfiguration()
     prov = {'service_type': constants.LOADBALANCER,
             'name': 'name',
             'driver': 'path',
             'default': False}
     pconf.add_provider(prov)
     self.assertRaises(n_exc.Invalid, pconf.add_provider, prov)
     self.assertEqual(1, len(pconf.providers))
コード例 #10
0
 def test_ensure_default_unique(self):
     pconf = provconf.ProviderConfiguration([])
     pconf.providers[('svctype', 'name')] = {'driver': 'driver',
                                             'default': True}
     self.assertRaises(n_exc.Invalid,
                       pconf._ensure_default_unique,
                       'svctype', True)
     self.assertIsNone(pconf._ensure_default_unique('svctype', False))
     self.assertIsNone(pconf._ensure_default_unique('svctype1', True))
     self.assertIsNone(pconf._ensure_default_unique('svctype1', False))
コード例 #11
0
 def __init__(self):
     LOG.debug("ISOFLAT PLUGIN INITIALIZED")
     self.service_type_manager = st_db.ServiceTypeManager.get_instance()
     self.service_type_manager.add_provider_configuration(constants.ISOFLAT,
                                                          pconf.ProviderConfiguration('neutron_isoflat'))
     drivers, default_provider = service_base.load_drivers(constants.ISOFLAT, self)
     if default_provider in drivers:
         self.driver = drivers[default_provider]
     else:
         raise n_exc.Invalid("Error retrieving driver for provider %s" % default_provider)
コード例 #12
0
 def test_add_provider(self):
     pconf = provconf.ProviderConfiguration()
     prov = {'service_type': constants.LOADBALANCER,
             'name': 'name',
             'driver': 'path',
             'default': False}
     pconf.add_provider(prov)
     self.assertEqual(1, len(pconf.providers))
     self.assertEqual([(constants.LOADBALANCER, 'name')],
                      list(pconf.providers.keys()))
     self.assertEqual([{'driver': 'path', 'default': False}],
                      list(pconf.providers.values()))
コード例 #13
0
 def setUp(self, plugin=None, service_plugins=None, ext_mgr=None):
     ext_mgr = TaasExtensionManager()
     service_plugins = {'taas_plugin_name': DB_TAAS_PLUGIN_KLASS}
     taas_provider = (taas_const.TAAS + ':BSN:' + BSN_TAAS_DRIVER_KLASS +
                      ':default')
     mock.patch.object(provconf.NeutronModule,
                       'service_providers',
                       return_value=[taas_provider]).start()
     manager = sdb.ServiceTypeManager.get_instance()
     manager.add_provider_configuration(taas_const.TAAS,
                                        provconf.ProviderConfiguration())
     super(TestBSNTaasCase, self).setUp(service_plugins=service_plugins,
                                        ext_mgr=ext_mgr)
     self.ext_api = test_ex.setup_extensions_middleware(ext_mgr)
コード例 #14
0
 def setUp(self):
     self.service_providers = mock.patch.object(
         provconf.NeutronModule, 'service_providers').start()
     service_providers = [
         constants.LOADBALANCER + ':lbaas:driver_path',
         constants.DUMMY + ':dummy:dummy_dr'
     ]
     self.service_providers.return_value = service_providers
     # Blank out service type manager instance
     st_db.ServiceTypeManager._instance = None
     self.manager = st_db.ServiceTypeManager.get_instance()
     for provider in service_providers:
         self.manager.add_provider_configuration(
             provider.split(':')[0], provconf.ProviderConfiguration())
     super(ServiceTypeManagerExtTestCase, self).setUp()
コード例 #15
0
    def setUp(self):
        service_plugins = {
            'vpn_plugin_name': DB_VPN_PLUGIN_KLASS,
            'flavors_plugin': FLAVOR_PLUGIN_KLASS
        }
        vpnaas_provider = (plugin_const.VPN + ':vpnaas:' + MN_DRIVER_KLASS +
                           ':default')
        mock.patch.object(provconf.NeutronModule,
                          'service_providers',
                          return_value=[vpnaas_provider]).start()
        manager = sdb.ServiceTypeManager.get_instance()
        manager.add_provider_configuration(plugin_const.VPN,
                                           provconf.ProviderConfiguration())

        super(VPNTestCaseMixin, self).setUp(service_plugins=service_plugins,
                                            ext_mgr=VPNTestExtensionManager())
コード例 #16
0
ファイル: plugin.py プロジェクト: vpickard/networking-l2gw
 def __init__(self):
     """Do the initialization for the l2 gateway service plugin here."""
     config.register_l2gw_opts_helper()
     self.service_type_manager = st_db.ServiceTypeManager.get_instance()
     self.service_type_manager.add_provider_configuration(
         constants.L2GW, pconf.ProviderConfiguration('networking_l2gw'))
     self._load_drivers()
     LOG.info("L2Gateway Service Plugin using Service Driver: %s",
              self.default_provider)
     self.driver = self.drivers[self.default_provider]
     if len(self.drivers) > 1:
         LOG.warning("Multiple drivers configured for L2Gateway, "
                     "although running multiple drivers in parallel"
                     " is not yet supported")
     super(L2GatewayPlugin, self).__init__()
     l2gateway_db.subscribe()
コード例 #17
0
 def setUp(self):
     self.service_providers = mock.patch.object(
         provconf.NeutronModule, 'service_providers').start()
     service_providers = [
         constants.FIREWALL + ':fwaas:driver_path',
         dp.DUMMY_SERVICE_TYPE + ':dummy:dummy_dr'
     ]
     self.service_providers.return_value = service_providers
     # Blank out service type manager instance
     st_db.ServiceTypeManager._instance = None
     self.manager = st_db.ServiceTypeManager.get_instance()
     for provider in service_providers:
         service_type = provider.split(':')[0]
         self.manager.add_provider_configuration(
             service_type,
             provconf.ProviderConfiguration(svc_type=service_type))
     super(ServiceTypeManagerExtTestCase, self).setUp()
コード例 #18
0
    def __init__(self):
        super(BGPVPNPlugin, self).__init__()

        # Need to look into /etc/neutron/networking_bgpvpn.conf for
        # service_provider definitions:
        service_type_manager = st_db.ServiceTypeManager.get_instance()
        service_type_manager.add_provider_configuration(
            constants.BGPVPN, pconf.ProviderConfiguration('networking_bgpvpn'))

        # Load the default driver
        drivers, default_provider = service_base.load_drivers(
            constants.BGPVPN, self)
        LOG.info(_LI("BGP VPN Service Plugin using Service Driver: %s"),
                 default_provider)
        self.driver = drivers[default_provider]

        if len(drivers) > 1:
            LOG.warning(
                _LI("Multiple drivers configured for BGPVPN, although"
                    "running multiple drivers in parallel is not yet"
                    "supported"))
コード例 #19
0
    def setUp(self, plugin=None, ext_mgr=None):

        service_plugins = {'l2gw_plugin_name': MN_PLUGIN_KLASS,
                           'gateway_device_plugin_name':
                               test_gw.DB_GATEWAY_DEVICE_PLUGIN_KLASS}
        l2gw_provider = (l2gw_consts.L2GW + ':' +
                         mido_const.MIDONET_L2GW_PROVIDER +
                         ':' + MN_DRIVER_KLASS + ':default')
        mock.patch.object(provconf.NeutronModule, 'service_providers',
                          return_value=[l2gw_provider]).start()
        manager = st_db.ServiceTypeManager.get_instance()
        manager.add_provider_configuration(
            l2gw_consts.L2GW, provconf.ProviderConfiguration())
        l2_gw_mgr = MidonetL2GatewayTestExtensionManager()

        super(MidonetL2GatewayTestCaseMixin, self).setUp(
            service_plugins=service_plugins, ext_mgr=l2_gw_mgr)
        self.ext_api = test_ex.setup_extensions_middleware(l2_gw_mgr)

        network = self._make_network(self.fmt, 'net1', True)
        self._network_id = network['network']['id']
        self._subnet = self._make_subnet(self.fmt, network, "10.0.0.1",
                                         '10.0.0.0/24')
        self._subnet_id = self._subnet['subnet']['id']
        network2 = self._make_network(self.fmt, 'net2', True)
        self._network_id2 = network2['network']['id']
        self._subnet2 = self._make_subnet(self.fmt, network2, "20.0.0.1",
                                          '20.0.0.0/24')
        self._subnet_id2 = self._subnet2['subnet']['id']
        router1 = self._make_router('json', uuidutils.generate_uuid(),
                                    'router1', True)
        self._router_id = router1['router']['id']
        router2 = self._make_router('json', uuidutils.generate_uuid(),
                                    'router2', True)
        self._router_id2 = router2['router']['id']

        # for network_vlan gateway device setting
        res = self._create_network(self.fmt, 'gateway_network_vlan', True)
        self._vlan_network_id = self.deserialize(
            self.fmt, res)['network']['id']
コード例 #20
0
ファイル: servicetype_db.py プロジェクト: rhel-osp/neutron
 def _load_conf(self):
     self.conf = pconf.ProviderConfiguration(
         pconf.parse_service_provider_opt())
コード例 #21
0
def add_provider_configuration(type_manager, service_type):
    type_manager.add_provider_configuration(
        service_type, pconf.ProviderConfiguration('neutron_vpnaas'))
コード例 #22
0
ファイル: plugin.py プロジェクト: oferby/networking-l2gw
def add_provider_configuration(type_manager, service_type):
    type_manager.add_provider_configuration(
        service_type, pconf.ProviderConfiguration('networking_l2gw'))