コード例 #1
0
ファイル: test_ovs_db.py プロジェクト: PFZheng/neutron
    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
ファイル: test_ovs_db.py プロジェクト: pjh03/quantum
    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
ファイル: test_ovs_db.py プロジェクト: PFZheng/neutron
    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
ファイル: test_ovs_db.py プロジェクト: pjh03/quantum
    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)