Example #1
0
 def test_get_provider_for_none_flavor_id(self):
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         provider = driver_plugin._get_provider_for_flavor(
             self.adminContext, None)
         self.assertEqual(
             driver_plugin.default_provider, provider)
Example #2
0
 def setUp(self):
     super(TestCiscoValidatorSelection, self).setUp()
     # TODO(armax): remove this if branch as soon as the ServiceTypeManager
     # API for adding provider configurations becomes available
     if not hasattr(st_db.ServiceTypeManager, 'add_provider_configuration'):
         vpnaas_provider = (constants.VPN + ':vpnaas:' +
                            CISCO_IPSEC_SERVICE_DRIVER + ':default')
         cfg.CONF.set_override('service_provider', [vpnaas_provider],
                               'service_providers')
     else:
         vpnaas_provider = [{
             'service_type': constants.VPN,
             'name': 'vpnaas',
             'driver': CISCO_IPSEC_SERVICE_DRIVER,
             'default': True
         }]
         # override the default service provider
         self.service_providers = (mock.patch.object(
             st_db.ServiceTypeManager, 'get_service_providers').start())
         self.service_providers.return_value = vpnaas_provider
     mock.patch('neutron.common.rpc.create_connection').start()
     stm = st_db.ServiceTypeManager()
     stm.get_provider_names_by_resource_ids = mock.Mock(return_value={})
     mock.patch('neutron.db.servicetype_db.ServiceTypeManager.get_instance',
                return_value=stm).start()
     mock.patch('neutron_vpnaas.db.vpn.vpn_db.VPNPluginDb.get_vpnservices',
                return_value=[]).start()
     self.vpn_plugin = vpn_plugin.VPNDriverPlugin()
Example #3
0
 def test_get_provider_for_flavor_id_plugin_not_loaded(self):
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertRaises(
             vpn_flavors.FlavorsPluginNotLoaded,
             driver_plugin._get_provider_for_flavor,
             self.adminContext,
             _uuid())
Example #4
0
 def test_multiple_drivers_loaded(self):
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertEqual(2, len(driver_plugin.drivers))
         self.assertEqual('ipsec', driver_plugin.default_provider)
         self.assertIn('ipsec', driver_plugin.drivers)
         self.assertEqual('ipsec', driver_plugin.drivers['ipsec'].name)
         self.assertIn('cisco', driver_plugin.drivers)
         self.assertEqual('cisco', driver_plugin.drivers['cisco'].name)
Example #5
0
 def test_unasso_vpnservices(self):
     UNASSO_SERVICE_ID = _uuid()
     with self.vpnservices_providers_set(
             vpnservices=[{'id': UNASSO_SERVICE_ID}]
     ) as stm:
         stm.add_resource_association = mock.Mock()
         vpn_plugin.VPNDriverPlugin()
         stm.add_resource_association.assert_called_once_with(
             mock.ANY, p_constants.VPN, 'ipsec', UNASSO_SERVICE_ID)
Example #6
0
 def test_get_driver_for_ipsec_site_connection(self):
     IPSEC_VPNSERVICE_ID = _uuid()
     IPSEC_SITE_CONNECTION = {'vpnservice_id': IPSEC_VPNSERVICE_ID}
     provider_names = {IPSEC_VPNSERVICE_ID: 'ipsec'}
     with self.vpnservices_providers_set(provider_names=provider_names):
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertEqual(
             driver_plugin.drivers['ipsec'],
             driver_plugin._get_driver_for_ipsec_site_connection(
                 self.adminContext, IPSEC_SITE_CONNECTION))
Example #7
0
 def test_get_driver_for_vpnservice(self):
     CISCO_VPNSERVICE_ID = _uuid()
     CISCO_VPNSERVICE = {'id': CISCO_VPNSERVICE_ID}
     provider_names = {CISCO_VPNSERVICE_ID: 'cisco'}
     with self.vpnservices_providers_set(provider_names=provider_names):
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertEqual(
             driver_plugin.drivers['cisco'],
             driver_plugin._get_driver_for_vpnservice(
                 self.adminContext, CISCO_VPNSERVICE))
Example #8
0
 def test_get_driver_for_vpnservice(self):
     DUMMY_VPNSERVICE_ID = _uuid()
     DUMMY_VPNSERVICE = {'id': DUMMY_VPNSERVICE_ID}
     provider_names = {DUMMY_VPNSERVICE_ID: 'dummy'}
     with self.vpnservices_providers_set(provider_names=provider_names):
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertEqual(
             driver_plugin.drivers['dummy'],
             driver_plugin._get_driver_for_vpnservice(
                 self.adminContext, DUMMY_VPNSERVICE))
Example #9
0
 def test_get_provider_for_flavor_id_flavor_disabled(self):
     FAKE_FLAVOR = {'service_type': p_constants.VPN, 'enabled': False}
     directory.add_plugin(p_constants.FLAVORS, FlavorsPlugin())
     mock.patch(
         'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
         return_value=FAKE_FLAVOR).start()
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertRaises(flav_exc.FlavorDisabled,
                           driver_plugin._get_provider_for_flavor,
                           self.adminContext, _uuid())
Example #10
0
 def test_get_provider_for_flavor_id_invalid_type(self):
     FAKE_FLAVOR = {'service_type': 'NOT_VPN'}
     directory.add_plugin(p_constants.FLAVORS, FlavorsPlugin())
     mock.patch(
         'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
         return_value=FAKE_FLAVOR).start()
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertRaises(lib_exc.InvalidServiceType,
                           driver_plugin._get_provider_for_flavor,
                           self.adminContext, _uuid())
Example #11
0
 def setUp(self):
     super(TestValidatorSelection, self).setUp()
     vpnaas_provider = [{
         'service_type': nconstants.VPN,
         'name': 'vpnaas',
         'driver': IPSEC_SERVICE_DRIVER,
         'default': True
     }]
     # override the default service provider
     self.service_providers = (mock.patch.object(
         st_db.ServiceTypeManager, 'get_service_providers').start())
     self.service_providers.return_value = vpnaas_provider
     mock.patch('neutron.common.rpc.create_connection').start()
     stm = st_db.ServiceTypeManager()
     mock.patch('neutron.db.servicetype_db.ServiceTypeManager.get_instance',
                return_value=stm).start()
     self.vpn_plugin = vpn_plugin.VPNDriverPlugin()
Example #12
0
 def setUp(self):
     super(TestValidatorSelection, self).setUp()
     vpnaas_provider = [{
         'service_type': constants.VPN,
         'name': 'vpnaas',
         'driver': IPSEC_SERVICE_DRIVER,
         'default': True
     }]
     # override the default service provider
     self.service_providers = (mock.patch.object(
         st_db.ServiceTypeManager, 'get_service_providers').start())
     self.service_providers.return_value = vpnaas_provider
     mock.patch('neutron_lib.rpc.Connection').start()
     stm = st_db.ServiceTypeManager()
     stm.get_provider_names_by_resource_ids = mock.Mock(return_value={})
     mock.patch('neutron.db.servicetype_db.ServiceTypeManager.get_instance',
                return_value=stm).start()
     mock.patch('neutron_vpnaas.db.vpn.vpn_db.VPNPluginDb.get_vpnservices',
                return_value=[]).start()
     self.vpn_plugin = vpn_plugin.VPNDriverPlugin()
Example #13
0
 def test_get_provider_for_flavor_id_provider_not_found(self):
     FLAVOR_ID = _uuid()
     FAKE_FLAVOR = {
         'id': FLAVOR_ID,
         'service_type': p_constants.VPN,
         'enabled': True
     }
     PROVIDERS = [{'provider': 'SOME_PROVIDER'}]
     directory.add_plugin(p_constants.FLAVORS, FlavorsPlugin())
     mock.patch(
         'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
         return_value=FAKE_FLAVOR).start()
     mock.patch(
         'neutron.services.flavors.flavors_plugin.'
         'FlavorsPlugin.get_flavor_next_provider',
         return_value=PROVIDERS).start()
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertRaises(vpn_flavors.NoProviderFoundForFlavor,
                           driver_plugin._get_provider_for_flavor,
                           self.adminContext, FLAVOR_ID)