예제 #1
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 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, [])
예제 #3
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, [])
예제 #4
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, [])
예제 #5
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, [])