Example #1
0
    def test_specific_vlan_inside_pool(self):
        vlan_id = VLAN_MIN + 5
        self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET, vlan_id).allocated)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET, vlan_id).allocated)

        self.assertRaises(n_exc.VlanIdInUse, n1kv_db_v2.reserve_specific_vlan, self.session, PHYS_NET, vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id)
        self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET, vlan_id).allocated)
Example #2
0
 def test_create_network_profile_populate_vlan_segment_pool(self):
     db_session = db.get_session()
     net_p_dict = self._prepare_net_profile_data("vlan")
     net_p_req = self.new_create_request("network_profiles", net_p_dict)
     self.deserialize(self.fmt, net_p_req.get_response(self.ext_api))
     for vlan in range(VLAN_MIN, VLAN_MAX + 1):
         self.assertIsNotNone(n1kv_db_v2.get_vlan_allocation(db_session, PHYS_NET, vlan))
         self.assertFalse(n1kv_db_v2.get_vlan_allocation(db_session, PHYS_NET, vlan).allocated)
     self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation, db_session, PHYS_NET, VLAN_MIN - 1)
     self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation, db_session, PHYS_NET, VLAN_MAX + 1)
Example #3
0
 def test_sync_vlan_allocations_unallocated_vlans(self):
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MIN).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MIN + 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MAX - 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MAX).allocated)
Example #4
0
 def test_sync_vlan_allocations_unallocated_vlans(self):
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MIN).allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MIN + 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MAX - 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MAX).allocated)
Example #5
0
 def test_create_network_profile_populate_vlan_segment_pool(self):
     db_session = db.get_session()
     net_p_dict = self._prepare_net_profile_data('vlan')
     net_p_req = self.new_create_request('network_profiles', net_p_dict)
     self.deserialize(self.fmt, net_p_req.get_response(self.ext_api))
     for vlan in range(VLAN_MIN, VLAN_MAX + 1):
         self.assertIsNotNone(
             n1kv_db_v2.get_vlan_allocation(db_session, PHYS_NET, vlan))
         self.assertFalse(
             n1kv_db_v2.get_vlan_allocation(db_session, PHYS_NET,
                                            vlan).allocated)
     self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation,
                       db_session, PHYS_NET, VLAN_MIN - 1)
     self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation,
                       db_session, PHYS_NET, VLAN_MAX + 1)
Example #6
0
    def test_specific_vlan_inside_pool(self):
        vlan_id = VLAN_MIN + 5
        self.assertFalse(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)

        self.assertRaises(n_exc.VlanIdInUse, n1kv_db_v2.reserve_specific_vlan,
                          self.session, PHYS_NET, vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id)
        self.assertFalse(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)
 def test_create_network_rollback_deallocate_vlan_segment(self):
     """Test vlan segment deallocation on network create failure."""
     profile_obj = self._make_test_profile(name='test_profile',
                                           segment_range='20-23')
     data = self._prepare_net_data(profile_obj.id)
     client_patch = patch(n1kv_client.__name__ + ".Client",
                          new=fake_client.TestClientInvalidResponse)
     client_patch.start()
     self.new_create_request('networks', data)
     db_session = db.get_session()
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(db_session, PHYS_NET, 20).allocated)
Example #8
0
 def test_create_network_rollback_deallocate_vlan_segment(self):
     """Test vlan segment deallocation on network create failure."""
     profile_obj = self._make_test_profile(name='test_profile',
                                           segment_range='20-23')
     data = self._prepare_net_data(profile_obj.id)
     client_patch = mock.patch(n1kv_client.__name__ + ".Client",
                               new=fake_client.TestClientInvalidResponse)
     client_patch.start()
     self.new_create_request('networks', data)
     db_session = db.get_session()
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(db_session,
                                                     PHYS_NET,
                                                     20).allocated)
Example #9
0
 def test_delete_network_profile_deallocate_vlan_segment_pool(self):
     db_session = db.get_session()
     net_p_dict = self._prepare_net_profile_data(c_const.NETWORK_TYPE_VLAN)
     net_p_req = self.new_create_request('network_profiles', net_p_dict)
     net_p = self.deserialize(self.fmt,
                              net_p_req.get_response(self.ext_api))
     self.assertIsNotNone(
         n1kv_db_v2.get_vlan_allocation(db_session, PHYS_NET, VLAN_MIN))
     self._delete('network_profiles', net_p['network_profile']['id'])
     for vlan in range(VLAN_MIN, VLAN_MAX + 1):
         self.assertRaises(c_exc.VlanIDNotFound,
                           n1kv_db_v2.get_vlan_allocation, db_session,
                           PHYS_NET, vlan)
Example #10
0
    def test_specific_vlan_outside_pool(self):
        vlan_id = VLAN_MAX + 5
        self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation,
                          self.session, PHYS_NET, vlan_id)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)

        self.assertRaises(q_exc.VlanIdInUse, n1kv_db_v2.reserve_specific_vlan,
                          self.session, PHYS_NET, vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
        self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation,
                          self.session, PHYS_NET, vlan_id)
Example #11
0
 def test_delete_network_profile_deallocate_vlan_segment_pool(self):
     db_session = db.get_session()
     net_p_dict = self._prepare_net_profile_data('vlan')
     net_p_req = self.new_create_request('network_profiles', net_p_dict)
     net_p = self.deserialize(self.fmt,
                              net_p_req.get_response(self.ext_api))
     self.assertIsNotNone(n1kv_db_v2.get_vlan_allocation(db_session,
                                                         PHYS_NET,
                                                         VLAN_MIN))
     self._delete('network_profiles', net_p['network_profile']['id'])
     for vlan in range(VLAN_MIN, VLAN_MAX + 1):
         self.assertRaises(c_exc.VlanIDNotFound,
                           n1kv_db_v2.get_vlan_allocation,
                           db_session,
                           PHYS_NET,
                           vlan)
Example #12
0
    def test_specific_vlan_outside_pool(self):
        vlan_id = VLAN_MAX + 5
        self.assertRaises(c_exc.VlanIDNotFound,
                          n1kv_db_v2.get_vlan_allocation,
                          self.session,
                          PHYS_NET,
                          vlan_id)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                                       vlan_id).allocated)

        self.assertRaises(q_exc.VlanIdInUse,
                          n1kv_db_v2.reserve_specific_vlan,
                          self.session,
                          PHYS_NET,
                          vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
        self.assertRaises(c_exc.VlanIDNotFound,
                          n1kv_db_v2.get_vlan_allocation,
                          self.session,
                          PHYS_NET,
                          vlan_id)
Example #13
0
 def test_sync_vlan_allocations_unallocated_vlans(self):
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MIN).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MIN + 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MAX - 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MAX).allocated)
     n1kv_db_v2.sync_vlan_allocations(self.session, UPDATED_VLAN_RANGES)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MIN + 20).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MIN + 20 + 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MAX + 20 - 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                        VLAN_MAX + 20).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET_2,
                                        VLAN_MIN + 40).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET_2,
                                        VLAN_MIN + 40 + 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET_2,
                                        VLAN_MAX + 40 - 1).allocated)
     self.assertFalse(
         n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET_2,
                                        VLAN_MAX + 40).allocated)
Example #14
0
 def test_sync_vlan_allocations_unallocated_vlans(self):
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MIN).allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MIN + 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MAX - 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MAX).allocated)
     n1kv_db_v2.sync_vlan_allocations(self.session, UPDATED_VLAN_RANGES)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MIN + 20).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MIN + 20 + 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET,
                                                     VLAN_MAX + 20 - 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                                     VLAN_MAX + 20).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET_2,
                                                     VLAN_MIN + 40).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET_2,
                                                     VLAN_MIN + 40 + 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET_2,
                                                     VLAN_MAX + 40 - 1).
                      allocated)
     self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session,
                                                     PHYS_NET_2,
                                                     VLAN_MAX + 40).
                      allocated)