def test_add_vxlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1['network']['id']

                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID)
                TEST_NETWORK_ID2 = network2['network']['id']
                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID2)
                p_v = _create_test_network_profile_if_not_there(
                    self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2,
                    c_const.NETWORK_TYPE_OVERLAY,
                    None, 5100, '224.10.10.10', p_v.id, None)
                p = _create_test_network_profile_if_not_there(
                    self.session,
                    TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, c_const.NETWORK_TYPE_TRUNK,
                    None, 0, '0.0.0.0', p.id,
                    [(TEST_NETWORK_ID2, 5)])
                binding = n1kv_db_v2.get_network_binding(
                    self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type,
                                 c_const.NETWORK_TYPE_TRUNK)
                self.assertIsNone(binding.physical_network)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = (n1kv_db_v2.get_trunk_network_binding(
                             self.session, TEST_NETWORK_ID,
                             (TEST_NETWORK_ID2, '5')))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, '5')
                t_members = (n1kv_db_v2.get_trunk_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members,
                                 [(TEST_NETWORK_ID2, '5')])
                self.assertTrue(n1kv_db_v2.is_trunk_member(
                    self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(
                    self.session, TEST_NETWORK_ID,
                    [(TEST_NETWORK_ID2, '5')])
                t_members = (n1kv_db_v2.get_multi_segment_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members, [])
Example #2
0
    def _get_segmentation_id(self, context, id):
        """
        Retreive segmentation ID for a given network.

        :param context: neutron api request context
        :param id: UUID of the network
        :returns: segmentation ID for the network
        """
        session = context.session
        binding = n1kv_db_v2.get_network_binding(session, id)
        return binding.segmentation_id
Example #3
0
    def test_add_vxlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1['network']['id']

                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID)
                TEST_NETWORK_ID2 = network2['network']['id']
                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID2)
                p_v = _create_test_network_profile_if_not_there(
                    self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2,
                    c_const.NETWORK_TYPE_OVERLAY,
                    None, 5100, '224.10.10.10', p_v.id, None)
                p = _create_test_network_profile_if_not_there(
                    self.session,
                    TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, c_const.NETWORK_TYPE_TRUNK,
                    None, 0, '0.0.0.0', p.id,
                    [(TEST_NETWORK_ID2, 5)])
                binding = n1kv_db_v2.get_network_binding(
                    self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type,
                                 c_const.NETWORK_TYPE_TRUNK)
                self.assertIsNone(binding.physical_network)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = (n1kv_db_v2.get_trunk_network_binding(
                             self.session, TEST_NETWORK_ID,
                             (TEST_NETWORK_ID2, '5')))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, '5')
                t_members = (n1kv_db_v2.get_trunk_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members,
                                 [(TEST_NETWORK_ID2, '5')])
                self.assertTrue(n1kv_db_v2.is_trunk_member(
                    self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(
                    self.session, TEST_NETWORK_ID,
                    [(TEST_NETWORK_ID2, '5')])
                t_members = (n1kv_db_v2.get_multi_segment_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members, [])
    def _get_segmentation_id(self, context, id):
        """
        Retreive segmentation ID for a given network.

        :param context: neutron api request context
        :param id: UUID of the network
        :returns: segmentation ID for the network
        """
        session = context.session
        binding = n1kv_db_v2.get_network_binding(session, id)
        return binding.segmentation_id
Example #5
0
 def _extend_network_dict_provider(self, context, network):
     """Add extended network parameters."""
     binding = n1kv_db_v2.get_network_binding(context.session,
                                              network['id'])
     network[providernet.NETWORK_TYPE] = binding.network_type
     if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
         network[providernet.PHYSICAL_NETWORK] = None
         network[providernet.SEGMENTATION_ID] = binding.segmentation_id
         network[n1kv_profile.MULTICAST_IP] = binding.multicast_ip
     elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
         network[providernet.PHYSICAL_NETWORK] = binding.physical_network
         network[providernet.SEGMENTATION_ID] = binding.segmentation_id
 def _extend_network_dict_provider(self, context, network):
     """Add extended network parameters."""
     binding = n1kv_db_v2.get_network_binding(context.session,
                                              network['id'])
     network[providernet.NETWORK_TYPE] = binding.network_type
     if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
         network[providernet.PHYSICAL_NETWORK] = None
         network[providernet.SEGMENTATION_ID] = binding.segmentation_id
         network[n1kv_profile.MULTICAST_IP] = binding.multicast_ip
     elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
         network[providernet.PHYSICAL_NETWORK] = binding.physical_network
         network[providernet.SEGMENTATION_ID] = binding.segmentation_id
    def test_add_vlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1['network']['id']

                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID)
                TEST_NETWORK_ID2 = network2['network']['id']
                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID2)
                p_v = _create_test_network_profile_if_not_there(self.session)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2, 'vlan',
                    PHYS_NET, 1234, '0.0.0.0', p_v.id, None)
                p = _create_test_network_profile_if_not_there(
                    self.session,
                    TEST_NETWORK_PROFILE_VLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, 'trunk',
                    None, 0, '0.0.0.0', p.id, [(TEST_NETWORK_ID2, 0)])
                binding = n1kv_db_v2.get_network_binding(
                    self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type, 'trunk')
                self.assertEqual(binding.physical_network, PHYS_NET)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = (n1kv_db_v2.get_trunk_network_binding(
                             self.session, TEST_NETWORK_ID,
                             (TEST_NETWORK_ID2, 0)))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, '0')
                t_members = (n1kv_db_v2.get_trunk_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members,
                                 [(TEST_NETWORK_ID2, '0')])
                self.assertTrue(n1kv_db_v2.is_trunk_member(
                                self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(
                    self.session, TEST_NETWORK_ID,
                    [(TEST_NETWORK_ID2, '0')])
                t_members = (n1kv_db_v2.get_multi_segment_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members, [])
Example #8
0
    def test_add_vlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1['network']['id']

                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID)
                TEST_NETWORK_ID2 = network2['network']['id']
                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID2)
                p_v = _create_test_network_profile_if_not_there(self.session)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2, 'vlan',
                    PHYS_NET, 1234, '0.0.0.0', p_v.id, None)
                p = _create_test_network_profile_if_not_there(
                    self.session,
                    TEST_NETWORK_PROFILE_VLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, 'trunk',
                    None, 0, '0.0.0.0', p.id, [(TEST_NETWORK_ID2, 0)])
                binding = n1kv_db_v2.get_network_binding(
                    self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type, 'trunk')
                self.assertEqual(binding.physical_network, PHYS_NET)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = (n1kv_db_v2.get_trunk_network_binding(
                             self.session, TEST_NETWORK_ID,
                             (TEST_NETWORK_ID2, 0)))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, '0')
                t_members = (n1kv_db_v2.get_trunk_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members,
                                 [(TEST_NETWORK_ID2, '0')])
                self.assertTrue(n1kv_db_v2.is_trunk_member(
                                self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(
                    self.session, TEST_NETWORK_ID,
                    [(TEST_NETWORK_ID2, '0')])
                t_members = (n1kv_db_v2.get_multi_segment_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members, [])
Example #9
0
    def test_add_network_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network["network"]["id"]

            self.assertRaises(
                c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID
            )

            p = _create_test_network_profile_if_not_there(self.session)
            n1kv_db_v2.add_network_binding(self.session, TEST_NETWORK_ID, "vlan", PHYS_NET, 1234, "0.0.0.0", p.id, None)
            binding = n1kv_db_v2.get_network_binding(self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, "vlan")
            self.assertEqual(binding.physical_network, PHYS_NET)
            self.assertEqual(binding.segmentation_id, 1234)
Example #10
0
    def test_create_vxlan_trunk_network(self):
        with self.network() as network:
            TEST_NETWORK_ID = network["network"]["id"]

            self.assertRaises(
                c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID
            )

            p = _create_test_network_profile_if_not_there(self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
            n1kv_db_v2.add_network_binding(self.session, TEST_NETWORK_ID, "trunk", None, 0, "0.0.0.0", p.id, None)
            binding = n1kv_db_v2.get_network_binding(self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, "trunk")
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
Example #11
0
    def test_add_multi_segment_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding,
                              self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(
                self.session,
                TEST_NETWORK_PROFILE_MULTI_SEGMENT)
            n1kv_db_v2.add_network_binding(
                self.session, TEST_NETWORK_ID,
                c_const.NETWORK_TYPE_MULTI_SEGMENT,
                None, 0, '0.0.0.0', p.id,
                [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            binding = n1kv_db_v2.get_network_binding(
                self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type,
                             c_const.NETWORK_TYPE_MULTI_SEGMENT)
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
            ms_binding = (n1kv_db_v2.get_multi_segment_network_binding(
                          self.session, TEST_NETWORK_ID,
                          (TEST_NETWORK_ID2, TEST_NETWORK_ID3)))
            self.assertIsNotNone(ms_binding)
            self.assertEqual(ms_binding.multi_segment_id, TEST_NETWORK_ID)
            self.assertEqual(ms_binding.segment1_id, TEST_NETWORK_ID2)
            self.assertEqual(ms_binding.segment2_id, TEST_NETWORK_ID3)
            ms_members = (n1kv_db_v2.get_multi_segment_members(
                          self.session, TEST_NETWORK_ID))
            self.assertEqual(ms_members,
                             [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            self.assertTrue(n1kv_db_v2.is_multi_segment_member(
                            self.session, TEST_NETWORK_ID2))
            self.assertTrue(n1kv_db_v2.is_multi_segment_member(
                            self.session, TEST_NETWORK_ID3))
            n1kv_db_v2.del_multi_segment_binding(
                self.session, TEST_NETWORK_ID,
                [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            ms_members = (n1kv_db_v2.get_multi_segment_members(
                          self.session, TEST_NETWORK_ID))
            self.assertEqual(ms_members, [])
    def test_add_multi_segment_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding,
                              self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(
                self.session,
                TEST_NETWORK_PROFILE_MULTI_SEGMENT)
            n1kv_db_v2.add_network_binding(
                self.session, TEST_NETWORK_ID,
                c_const.NETWORK_TYPE_MULTI_SEGMENT,
                None, 0, '0.0.0.0', p.id,
                [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            binding = n1kv_db_v2.get_network_binding(
                self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type,
                             c_const.NETWORK_TYPE_MULTI_SEGMENT)
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
            ms_binding = (n1kv_db_v2.get_multi_segment_network_binding(
                          self.session, TEST_NETWORK_ID,
                          (TEST_NETWORK_ID2, TEST_NETWORK_ID3)))
            self.assertIsNotNone(ms_binding)
            self.assertEqual(ms_binding.multi_segment_id, TEST_NETWORK_ID)
            self.assertEqual(ms_binding.segment1_id, TEST_NETWORK_ID2)
            self.assertEqual(ms_binding.segment2_id, TEST_NETWORK_ID3)
            ms_members = (n1kv_db_v2.get_multi_segment_members(
                          self.session, TEST_NETWORK_ID))
            self.assertEqual(ms_members,
                             [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            self.assertTrue(n1kv_db_v2.is_multi_segment_member(
                            self.session, TEST_NETWORK_ID2))
            self.assertTrue(n1kv_db_v2.is_multi_segment_member(
                            self.session, TEST_NETWORK_ID3))
            n1kv_db_v2.del_multi_segment_binding(
                self.session, TEST_NETWORK_ID,
                [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            ms_members = (n1kv_db_v2.get_multi_segment_members(
                          self.session, TEST_NETWORK_ID))
            self.assertEqual(ms_members, [])
Example #13
0
    def test_add_network_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding, self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(self.session)
            n1kv_db_v2.add_network_binding(self.session, TEST_NETWORK_ID,
                                           c_const.NETWORK_TYPE_VLAN, PHYS_NET,
                                           1234, '0.0.0.0', p.id, None)
            binding = n1kv_db_v2.get_network_binding(self.session,
                                                     TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, c_const.NETWORK_TYPE_VLAN)
            self.assertEqual(binding.physical_network, PHYS_NET)
            self.assertEqual(binding.segmentation_id, 1234)
Example #14
0
    def test_create_vxlan_trunk_network(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding, self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(
                self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
            n1kv_db_v2.add_network_binding(self.session, TEST_NETWORK_ID,
                                           c_const.NETWORK_TYPE_TRUNK, None, 0,
                                           '0.0.0.0', p.id, None)
            binding = n1kv_db_v2.get_network_binding(self.session,
                                                     TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, c_const.NETWORK_TYPE_TRUNK)
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
Example #15
0
    def test_create_multi_segment_network(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding, self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(
                self.session, TEST_NETWORK_PROFILE_MULTI_SEGMENT)
            n1kv_db_v2.add_network_binding(self.session, TEST_NETWORK_ID,
                                           'multi-segment', None, 0, '0.0.0.0',
                                           p.id, None)
            binding = n1kv_db_v2.get_network_binding(self.session,
                                                     TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, 'multi-segment')
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
Example #16
0
    def test_add_network_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding,
                              self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(self.session)
            n1kv_db_v2.add_network_binding(
                self.session, TEST_NETWORK_ID, c_const.NETWORK_TYPE_VLAN,
                PHYS_NET, 1234, '0.0.0.0', p.id, None)
            binding = n1kv_db_v2.get_network_binding(
                self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, c_const.NETWORK_TYPE_VLAN)
            self.assertEqual(binding.physical_network, PHYS_NET)
            self.assertEqual(binding.segmentation_id, 1234)
Example #17
0
    def test_create_multi_segment_network(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding,
                              self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(
                self.session,
                TEST_NETWORK_PROFILE_MULTI_SEGMENT)
            n1kv_db_v2.add_network_binding(
                self.session, TEST_NETWORK_ID, 'multi-segment',
                None, 0, '0.0.0.0', p.id, None)
            binding = n1kv_db_v2.get_network_binding(
                self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, 'multi-segment')
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
Example #18
0
    def test_add_vxlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1["network"]["id"]

                self.assertRaises(
                    c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID
                )
                TEST_NETWORK_ID2 = network2["network"]["id"]
                self.assertRaises(
                    c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID2
                )
                p_v = _create_test_network_profile_if_not_there(self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2, "overlay", None, 5100, "224.10.10.10", p_v.id, None
                )
                p = _create_test_network_profile_if_not_there(self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, "trunk", None, 0, "0.0.0.0", p.id, [(TEST_NETWORK_ID2, 5)]
                )
                binding = n1kv_db_v2.get_network_binding(self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type, "trunk")
                self.assertIsNone(binding.physical_network)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = n1kv_db_v2.get_trunk_network_binding(self.session, TEST_NETWORK_ID, (TEST_NETWORK_ID2, "5"))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, "5")
                t_members = n1kv_db_v2.get_trunk_members(self.session, TEST_NETWORK_ID)
                self.assertEqual(t_members, [(TEST_NETWORK_ID2, "5")])
                self.assertTrue(n1kv_db_v2.is_trunk_member(self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(self.session, TEST_NETWORK_ID, [(TEST_NETWORK_ID2, "5")])
                t_members = n1kv_db_v2.get_multi_segment_members(self.session, TEST_NETWORK_ID)
                self.assertEqual(t_members, [])
Example #19
0
    def delete_network(self, context, id):
        """
        Delete a network.

        :param context: neutron api request context
        :param id: UUID representing the network to delete
        """
        session = context.session
        with session.begin(subtransactions=True):
            binding = n1kv_db_v2.get_network_binding(session, id)
            network = self.get_network(context, id)
            super(N1kvNeutronPluginV2, self).delete_network(context, id)
            if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
                n1kv_db_v2.release_vxlan(session, binding.segmentation_id,
                                         self.vxlan_id_ranges)
            elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
                n1kv_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
        if self.agent_vsm:
            self._send_delete_network_request(network)
        LOG.debug(_("Deleted network: %s"), id)
    def delete_network(self, context, id):
        """
        Delete a network.

        :param context: neutron api request context
        :param id: UUID representing the network to delete
        """
        session = context.session
        with session.begin(subtransactions=True):
            binding = n1kv_db_v2.get_network_binding(session, id)
            network = self.get_network(context, id)
            super(N1kvNeutronPluginV2, self).delete_network(context, id)
            if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
                n1kv_db_v2.release_vxlan(session, binding.segmentation_id,
                                         self.vxlan_id_ranges)
            elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
                n1kv_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
        if self.agent_vsm:
            self._send_delete_network_request(network)
        LOG.debug(_("Deleted network: %s"), id)
Example #21
0
 def _extend_network_dict_profile(self, context, network):
     """Add the extended parameter network profile to the network."""
     binding = n1kv_db_v2.get_network_binding(context.session,
                                              network['id'])
     network[n1kv_profile.PROFILE_ID] = binding.profile_id
 def _extend_network_dict_profile(self, context, network):
     """Add the extended parameter network profile to the network."""
     binding = n1kv_db_v2.get_network_binding(context.session,
                                              network['id'])
     network[n1kv_profile.PROFILE_ID] = binding.profile_id