def test_ip_comparison(self): self.assertTrue( NuageMechanismDriver.compare_ip('cafe:babe::1', 'cafe:babe:0::1')) self.assertFalse( NuageMechanismDriver.compare_cidr('cafe:babe::1', 'cafe:babe:1::1'))
def test_cidr_comparison(self): self.assertTrue( NuageMechanismDriver.compare_cidr('cafe:babe::1/64', 'cafe:babe:0::1/64')) self.assertFalse( NuageMechanismDriver.compare_cidr('cafe:babe::1/64', 'cafe:babe::1/63'))
def test_needs_vport_creation_using_prefix(self): conf = self.useFixture(oslo_fixture.Config(cfg.CONF)) conf.config(group='PLUGIN', device_owner_prefix='no_vport') # test match self.assertFalse( NuageMechanismDriver.needs_vport_creation('no_vport:something')) # test no match self.assertTrue( NuageMechanismDriver.needs_vport_creation('something:no_vport'))
def test_experimental_feature(self, logger, root_plugin): self.set_config_fixture() config.nuage_register_cfg_opts() conf = self.useFixture(oslo_fixture.Config(cfg.CONF)) conf.config(group='PLUGIN', experimental_features='experimental_test') NuageMechanismDriver().initialize() logger.info.assert_called_once_with('Have a nice day.') logger.info.reset_mock() conf.config(group='PLUGIN', experimental_features='') NuageMechanismDriver().initialize() logger.info.assert_not_called()
def test_init_missing_nuage_network_ml2_extension_for_l2bridge(self): self.set_config_fixture( ConfigTypes.NUAGE_L2BRIDGE_WITHOUT_NUAGE_NETWORK) self.assertRaisesRegex( oslo_config.cfg.ConfigFileValueError, 'Missing required extension ' r'\'nuage_network\' for service plugin NuageL2Bridge', NuageMechanismDriver().initialize)
def test_init_native_nmd_missing_ml2_extension(self): self.set_config_fixture(ConfigTypes.MISSING_ML2_EXTENSION) self.assertRaisesRegex( oslo_config.cfg.ConfigFileValueError, r'Missing required extension\(s\) ' r'\[\'port_security\'\] for mechanism driver nuage', NuageMechanismDriver().initialize)
def test_init_native_nmd_missing_service_plugin(self): self.set_config_fixture(ConfigTypes.MISSING_SERVICE_PLUGIN) self.assertRaisesRegex( oslo_config.cfg.ConfigFileValueError, r'Missing required service_plugin\(s\) ' r'\[\'NuageAPI\'\] for mechanism driver nuage', NuageMechanismDriver().initialize)
def test_init_native_nmd_invalid_server(self): self.set_config_fixture() self.assertRaisesRegex( RESTProxyError, 'Error in REST call to VSD: ' 'Could not establish a connection with the VSD. ' 'Please check VSD URI path in plugin config ' 'and verify IP connectivity.', NuageMechanismDriver().initialize)
def test_count_fixed_ips_per_version(self): self.assertEqual((1, 2), NuageMechanismDriver.count_fixed_ips_per_version([{ 'ip_address': 'cafe:babe::1' }, { 'ip_address': '69.69.69.69' }, { 'ip_address': 'dead:beef::1' }]))
def test_create_subnet_precommit_default(self, init_vsd_client): self.set_config_fixture() nmd = NuageMechanismDriver() nmd.initialize() network = { 'id': '1', 'provider:network_type': 'vxlan', 'router:external': False } subnet = {'id': '10', 'network_id': '1', 'ip_version': 4} nmd.create_subnet_precommit(Context(network, subnet))
def test_create_v6_subnet_precommit(self, init_vsd_client): self.set_config_fixture() nmd = NuageMechanismDriver() nmd.initialize() network = { 'id': '1', 'provider:network_type': 'vxlan', 'router:external': False } subnet = {'id': '10', 'network_id': '1', 'ip_version': 6} try: nmd.create_subnet_precommit(Context(network, subnet)) self.fail() # should not get here except NuageBadRequest as e: self.assertEqual( 'Bad request: Subnet with ip_version 6 is ' 'currently not supported ' 'for OpenStack managed subnets.', str(e))
def test_multi_init_nmd_invalid_server(self, raise_rest, get_cms): # init nmd 3 times, mock out the failures nmd1 = NuageMechanismDriver() nmd2 = NuageMechanismDriver() nmd3 = NuageMechanismDriver() self.set_invalid_config_fixture() nmd1.initialize() nmd2.initialize() nmd3.initialize() # validate there is actually only 1 vsdclient (memoize) self.assertEqual(nmd2.vsdclient, nmd1.vsdclient) self.assertEqual(nmd3.vsdclient, nmd1.vsdclient) # validate only 1 api call is made self.assertEqual(1, nmd1.vsdclient.restproxy.api_count)
def test_init_nmd_invalid_server(self): nmd = NuageMechanismDriver() self.set_config_fixture_connc() self.initialize(nmd)
def test_needs_vport_creation_basic(self): self.assertFalse( NuageMechanismDriver.needs_vport_creation('nuage:vip'))
def _get_mech_driver(): mech_driver = NuageMechanismDriver() mech_driver.initialize() mech_driver.core_plugin._create_port_db = MagicMock() return mech_driver
def get_me_a_nmd(self): self.set_config_fixture() nmd = NuageMechanismDriver() nmd._l2_plugin = nmd nmd.initialize() return nmd
def test_sort_ips(self): self.assertEqual([], NuageMechanismDriver.sort_ips([])) self.assertEqual(['cafe:babe:1::1', 'cafe:babe:12::1'], NuageMechanismDriver.sort_ips( ['cafe:babe:12::1', 'cafe:babe:1::1']))