Пример #1
0
 def __init__(self, configfile=None):
     self.extra_binding_dict = {
         portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS,
         portbindings.CAPABILITIES: {
             portbindings.CAP_PORT_FILTER:
             'security-group' in self.supported_extension_aliases}}
     ovs_db_v2.initialize()
     self._parse_network_vlan_ranges()
     ovs_db_v2.sync_vlan_allocations(self.network_vlan_ranges)
     self.tenant_network_type = cfg.CONF.OVS.tenant_network_type
     if self.tenant_network_type not in [constants.TYPE_LOCAL,
                                         constants.TYPE_VLAN,
                                         constants.TYPE_GRE,
                                         constants.TYPE_VXLAN,
                                         constants.TYPE_NONE]:
         LOG.error(_("Invalid tenant_network_type: %s. "
                   "Server terminated!"),
                   self.tenant_network_type)
         sys.exit(1)
     self.enable_tunneling = cfg.CONF.OVS.enable_tunneling
     self.tunnel_id_ranges = []
     if self.enable_tunneling:
         self._parse_tunnel_id_ranges()
         ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges)
     elif self.tenant_network_type in constants.TUNNEL_NETWORK_TYPES:
         LOG.error(_("Tunneling disabled but tenant_network_type is '%s'. "
                   "Server terminated!"), self.tenant_network_type)
         sys.exit(1)
     self.setup_rpc()
     self.network_scheduler = importutils.import_object(
         cfg.CONF.network_scheduler_driver
     )
     self.router_scheduler = importutils.import_object(
         cfg.CONF.router_scheduler_driver
     )
Пример #2
0
    def test_sync_with_allocated_false(self):
        vlan_ids = set()
        for x in moves.xrange(VLAN_MIN, VLAN_MAX + 1):
            physical_network, vlan_id = ovs_db_v2.reserve_vlan(self.session)
            self.assertEqual(physical_network, PHYS_NET)
            self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
            self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
            vlan_ids.add(vlan_id)

        ovs_db_v2.release_vlan(self.session, PHYS_NET, vlan_ids.pop(),
                               VLAN_RANGES)
        ovs_db_v2.sync_vlan_allocations({})
 def __init__(self, configfile=None):
     super(OVSNeutronPluginV2, self).__init__()
     self.base_binding_dict = {
         portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS,
         portbindings.VIF_DETAILS: {
             # TODO(rkukura): Replace with new VIF security details
             portbindings.CAP_PORT_FILTER:
             'security-group' in self.supported_extension_aliases,
             portbindings.OVS_HYBRID_PLUG: True}}
     self._parse_network_vlan_ranges()
     ovs_db_v2.sync_vlan_allocations(self.network_vlan_ranges)
     self.tenant_network_type = cfg.CONF.OVS.tenant_network_type
     if self.tenant_network_type not in [svc_constants.TYPE_LOCAL,
                                         svc_constants.TYPE_VLAN,
                                         svc_constants.TYPE_GRE,
                                         svc_constants.TYPE_VXLAN,
                                         svc_constants.TYPE_NONE]:
         LOG.error(_("Invalid tenant_network_type: %s. "
                   "Server terminated!"),
                   self.tenant_network_type)
         sys.exit(1)
     self.enable_tunneling = cfg.CONF.OVS.enable_tunneling
     self.tunnel_type = None
     if self.enable_tunneling:
         self.tunnel_type = (cfg.CONF.OVS.tunnel_type or
                             svc_constants.TYPE_GRE)
     elif cfg.CONF.OVS.tunnel_type:
         self.tunnel_type = cfg.CONF.OVS.tunnel_type
         self.enable_tunneling = True
     self.tunnel_id_ranges = []
     if self.enable_tunneling:
         self._parse_tunnel_id_ranges()
         ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges)
     elif self.tenant_network_type in constants.TUNNEL_NETWORK_TYPES:
         LOG.error(_("Tunneling disabled but tenant_network_type is '%s'. "
                   "Server terminated!"), self.tenant_network_type)
         sys.exit(1)
     self.setup_rpc()
     self.network_scheduler = importutils.import_object(
         cfg.CONF.network_scheduler_driver
     )
     self.router_scheduler = importutils.import_object(
         cfg.CONF.router_scheduler_driver
     )
Пример #4
0
    def test_sync_vlan_allocations(self):
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                        VLAN_MIN - 1))
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MIN).allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MIN + 1).allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MAX - 1).allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MAX).allocated)
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                        VLAN_MAX + 1))

        ovs_db_v2.sync_vlan_allocations(UPDATED_VLAN_RANGES)

        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                        VLAN_MIN + 5 - 1))
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MIN + 5).
                         allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MIN + 5 + 1).
                         allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MAX + 5 - 1).
                         allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MAX + 5).
                         allocated)
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                        VLAN_MAX + 5 + 1))

        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                        VLAN_MIN + 20 - 1))
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                       VLAN_MIN + 20).
                         allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                       VLAN_MIN + 20 + 1).
                         allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                       VLAN_MAX + 20 - 1).
                         allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                       VLAN_MAX + 20).
                         allocated)
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                        VLAN_MAX + 20 + 1))

        ovs_db_v2.sync_vlan_allocations(VLAN_RANGES)

        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                        VLAN_MIN - 1))
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MIN).allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MIN + 1).allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MAX - 1).allocated)
        self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                       VLAN_MAX).allocated)
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                                        VLAN_MAX + 1))

        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                        VLAN_MIN + 20))
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                                        VLAN_MAX + 20))
Пример #5
0
 def setUp(self):
     super(VlanAllocationsTest, self).setUp()
     db.configure_db()
     ovs_db_v2.sync_vlan_allocations(VLAN_RANGES)
     self.session = db.get_session()
     self.addCleanup(db.clear_db)
Пример #6
0
 def setUp(self):
     super(VlanAllocationsTest, self).setUp()
     ovs_db_v2.sync_vlan_allocations(VLAN_RANGES)
     self.session = db.get_session()
Пример #7
0
    def test_sync_vlan_allocations(self):
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(
            PHYS_NET, VLAN_MIN - 1))
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX - 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX).allocated)
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(
            PHYS_NET, VLAN_MAX + 1))

        ovs_db_v2.sync_vlan_allocations(UPDATED_VLAN_RANGES)

        self.assertIsNone(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5 - 1))
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                          VLAN_MIN + 5 + 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET,
                                          VLAN_MAX + 5 - 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5).allocated)
        self.assertIsNone(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5 + 1))

        self.assertIsNone(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MIN + 20 - 1))
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MIN + 20).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                          VLAN_MIN + 20 + 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2,
                                          VLAN_MAX + 20 - 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MAX + 20).allocated)
        self.assertIsNone(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MAX + 20 + 1))

        ovs_db_v2.sync_vlan_allocations(VLAN_RANGES)

        self.assertIsNone(ovs_db_v2.get_vlan_allocation(
            PHYS_NET, VLAN_MIN - 1))
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX - 1).allocated)
        self.assertFalse(
            ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX).allocated)
        self.assertIsNone(ovs_db_v2.get_vlan_allocation(
            PHYS_NET, VLAN_MAX + 1))

        self.assertIsNone(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MIN + 20))
        self.assertIsNone(
            ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MAX + 20))
Пример #8
0
 def setUp(self):
     super(VlanAllocationsTest, self).setUp()
     db.configure_db()
     ovs_db_v2.sync_vlan_allocations(VLAN_RANGES)
     self.session = db.get_session()
     self.addCleanup(db.clear_db)