예제 #1
0
    def test_specific_tunnel_outside_pool(self):
        tunnel_id = TUN_MAX + 5
        self.assertIsNone(ovs_db_v2.get_tunnel_allocation(tunnel_id))
        ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)
        self.assertTrue(ovs_db_v2.get_tunnel_allocation(tunnel_id).allocated)

        with testtools.ExpectedException(n_exc.TunnelIdInUse):
            ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)

        ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
        self.assertIsNone(ovs_db_v2.get_tunnel_allocation(tunnel_id))
예제 #2
0
    def test_specific_tunnel_outside_pool(self):
        tunnel_id = TUN_MAX + 5
        self.assertIsNone(ovs_db_v2.get_tunnel_allocation(tunnel_id))
        ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)
        self.assertTrue(ovs_db_v2.get_tunnel_allocation(tunnel_id).allocated)

        with testtools.ExpectedException(n_exc.TunnelIdInUse):
            ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)

        ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
        self.assertIsNone(ovs_db_v2.get_tunnel_allocation(tunnel_id))
예제 #3
0
 def delete_network(self, context, id):
     session = context.session
     with session.begin(subtransactions=True):
         binding = ovs_db_v2.get_network_binding(session, id)
         super(OVSNeutronPluginV2, self).delete_network(context, id)
         if binding.network_type in constants.TUNNEL_NETWORK_TYPES:
             ovs_db_v2.release_tunnel(session, binding.segmentation_id, self.tunnel_id_ranges)
         elif binding.network_type in [svc_constants.TYPE_VLAN, svc_constants.TYPE_FLAT]:
             ovs_db_v2.release_vlan(
                 session, binding.physical_network, binding.segmentation_id, self.network_vlan_ranges
             )
         # the network_binding record is deleted via cascade from
         # the network record, so explicit removal is not necessary
     self.notifier.network_delete(context, id)
예제 #4
0
 def delete_network(self, context, id):
     session = context.session
     with session.begin(subtransactions=True):
         binding = ovs_db_v2.get_network_binding(session, id)
         super(OVSNeutronPluginV2, self).delete_network(context, id)
         if binding.network_type in constants.TUNNEL_NETWORK_TYPES:
             ovs_db_v2.release_tunnel(session, binding.segmentation_id,
                                      self.tunnel_id_ranges)
         elif binding.network_type in [svc_constants.TYPE_VLAN,
                                       svc_constants.TYPE_FLAT]:
             ovs_db_v2.release_vlan(session, binding.physical_network,
                                    binding.segmentation_id,
                                    self.network_vlan_ranges)
         # the network_binding record is deleted via cascade from
         # the network record, so explicit removal is not necessary
     self.notifier.network_delete(context, id)
예제 #5
0
    def test_tunnel_pool(self):
        tunnel_ids = set()
        for x in moves.xrange(TUN_MIN, TUN_MAX + 1):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
            self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
            self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
            tunnel_ids.add(tunnel_id)

        with testtools.ExpectedException(n_exc.NoNetworkAvailable):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)

        ovs_db_v2.release_tunnel(self.session, tunnel_ids.pop(), TUNNEL_RANGES)
        tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
        self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
        self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
        tunnel_ids.add(tunnel_id)

        for tunnel_id in tunnel_ids:
            ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
예제 #6
0
    def test_tunnel_pool(self):
        tunnel_ids = set()
        for x in xrange(TUN_MIN, TUN_MAX + 1):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
            self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
            self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
            tunnel_ids.add(tunnel_id)

        with testtools.ExpectedException(n_exc.NoNetworkAvailable):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)

        ovs_db_v2.release_tunnel(self.session, tunnel_ids.pop(), TUNNEL_RANGES)
        tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
        self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
        self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
        tunnel_ids.add(tunnel_id)

        for tunnel_id in tunnel_ids:
            ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)