Example #1
0
 def test_allocate_tenant_segment_in_order_of_config(self):
     ranges = NETWORK_VLAN_RANGES + ['phys_net3:20:30']
     cfg.CONF.set_override('network_vlan_ranges',
                           ranges,
                           group='ml2_type_vlan')
     driver = type_vlan.VlanTypeDriver()
     driver.physnet_mtus = []
     driver._sync_vlan_allocations()
     # swap config order from DB order after sync has happened to
     # ensure config order is followed and not DB order
     cfg.CONF.set_override('network_vlan_ranges',
                           list(reversed(ranges)),
                           group='ml2_type_vlan')
     driver._parse_network_vlan_ranges()
     ctx = context.Context()
     for vlan in range(11):
         # all of physnet3 should be exhausted first
         self.assertEqual(
             {
                 'network_type': 'vlan',
                 'physical_network': 'phys_net3',
                 'segmentation_id': mock.ANY,
                 'mtu': 1500
             }, driver.allocate_tenant_segment(ctx))
     for vlan in range(10):
         # then physnet2
         self.assertEqual(
             {
                 'network_type': 'vlan',
                 'physical_network': 'phys_net2',
                 'segmentation_id': mock.ANY,
                 'mtu': 1500
             }, driver.allocate_tenant_segment(ctx))
     # then nothing
     self.assertFalse(driver.allocate_tenant_segment(ctx))
Example #2
0
 def setUp(self):
     super(VlanTypeTest, self).setUp()
     db.configure_db()
     self.driver = type_vlan.VlanTypeDriver()
     self.driver.network_vlan_ranges = NETWORK_VLAN_RANGES
     self.driver._sync_vlan_allocations()
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
Example #3
0
 def test_allocate_tenant_segment_no_available(self):
     cfg.CONF.set_override('network_vlan_ranges',
                           TENANT_VLAN_RANGES,
                           group='ml2_type_vlan')
     driver = type_vlan.VlanTypeDriver()
     driver._sync_vlan_allocations()
     for __ in range(VLAN_MIN, VLAN_MAX + 1):
         driver.allocate_tenant_segment(self.context)
     self.assertIsNone(driver.allocate_tenant_segment(self.context))
 def setUp(self):
     super(HelpersTest, self).setUp()
     self.driver = type_vlan.VlanTypeDriver()
     self.driver.network_vlan_ranges = NETWORK_VLAN_RANGES
     self.driver._sync_vlan_allocations()
     self.session = db.get_session()
     self.useFixture(
         fixtures.FakeLogger(name=helpers.__name__,
                             format=base.LOG_FORMAT,
                             level=logging.DEBUG))
Example #5
0
 def setUp(self):
     super(VlanTypeTest, self).setUp()
     cfg.CONF.set_override('network_vlan_ranges',
                           NETWORK_VLAN_RANGES,
                           group='ml2_type_vlan')
     self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
         NETWORK_VLAN_RANGES)
     self.driver = type_vlan.VlanTypeDriver()
     self.driver._sync_vlan_allocations()
     self.session = db.get_session()
Example #6
0
 def setUp(self):
     super(VlanTypeTest, self).setUp()
     config.cfg.CONF.set_override('network_vlan_ranges',
                                  NETWORK_VLAN_RANGES,
                                  group='ml2_type_vlan')
     self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
         NETWORK_VLAN_RANGES)
     self.driver = type_vlan.VlanTypeDriver()
     self.driver._sync_vlan_allocations()
     self.context = context.Context()
     self.driver.physnet_mtus = []
Example #7
0
 def setUp(self):
     super(HelpersTestWithNetworkSegmentRange, self).setUp()
     cfg.CONF.set_override('network_vlan_ranges',
                           NETWORK_VLAN_RANGES_CFG_ENTRIES,
                           group='ml2_type_vlan')
     cfg.CONF.set_override('service_plugins', [SERVICE_PLUGIN_KLASS])
     self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
         NETWORK_VLAN_RANGES_CFG_ENTRIES)
     self.context = context.get_admin_context()
     self.driver = type_vlan.VlanTypeDriver()
     self.driver.initialize_network_segment_range_support()
     self.driver._sync_vlan_allocations()
Example #8
0
 def setUp(self):
     super(VlanTypeTestWithNetworkSegmentRange, self).setUp()
     cfg.CONF.set_override('network_vlan_ranges',
                           NETWORK_VLAN_RANGES,
                           group='ml2_type_vlan')
     cfg.CONF.set_override('service_plugins', [SERVICE_PLUGIN_KLASS])
     self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(
         NETWORK_VLAN_RANGES)
     self.driver = type_vlan.VlanTypeDriver()
     self.driver._sync_vlan_allocations()
     self.context = context.Context()
     self.setup_coreplugin(CORE_PLUGIN)
Example #9
0
 def test_allocate_tenant_segment(self):
     cfg.CONF.set_override('network_vlan_ranges',
                           TENANT_VLAN_RANGES,
                           group='ml2_type_vlan')
     driver = type_vlan.VlanTypeDriver()
     driver._sync_vlan_allocations()
     for __ in range(VLAN_MIN, VLAN_MAX + 1):
         segment = self.driver.allocate_tenant_segment(self.context)
         alloc = self._get_allocation(self.context, segment)
         self.assertTrue(alloc.allocated)
         vlan_id = segment[api.SEGMENTATION_ID]
         self.assertGreater(vlan_id, VLAN_MIN - 1)
         self.assertLess(vlan_id, VLAN_MAX + 1)
         self.assertEqual(TENANT_NET, segment[api.PHYSICAL_NETWORK])
Example #10
0
 def setUp(self):
     super(HelpersTest, self).setUp()
     self.driver = type_vlan.VlanTypeDriver()
     self.driver.network_vlan_ranges = NETWORK_VLAN_RANGES
     self.driver._sync_vlan_allocations()
     self.session = db.get_session()
Example #11
0
 def setUp(self):
     super(HelpersTest, self).setUp()
     self.driver = type_vlan.VlanTypeDriver()
     self.driver.network_vlan_ranges = NETWORK_VLAN_RANGES
     self.driver._sync_vlan_allocations()
     self.context = context.get_admin_context()