def test_logical_interface_create_qfx_l3(self):
        # create test device object
        phy_router_obj = PhysicalRouter(
            parent_type='global-system-config',
            fq_name=[
                "default-global-system-config",
                "test_device_qfx_%s" % self.id()
            ],
            physical_router_management_ip="1.1.1.1",
            physical_router_vendor_name="juniper",
            physical_router_product_name="qfx5k",
            physical_router_user_credentials={
                "username": "******",
                "password": "******"
            },
            physical_router_device_family='junos-qfx')
        self._vnc_lib.physical_router_create(phy_router_obj)

        phy_int_obj = PhysicalInterface(name="phy_intf_qfx_%s" % self.id(),
                                        parent_obj=phy_router_obj)
        self._vnc_lib.physical_interface_create(phy_int_obj)

        log_int_obj = LogicalInterface(name="log_intf_qfx_%s" % self.id(),
                                       parent_obj=phy_int_obj,
                                       logical_interface_vlan_tag=2,
                                       logical_interface_type='l3')

        self.assertIsNotNone(
            self._vnc_lib.logical_interface_create(log_int_obj))
    def test_logical_interface_create_qfx_l2(self):
        # create test device object
        phy_router_obj = PhysicalRouter(
            parent_type='global-system-config',
            fq_name=[
                "default-global-system-config",
                "test_device_qfx_%s" % self.id()
            ],
            physical_router_management_ip="1.1.1.1",
            physical_router_vendor_name="juniper",
            physical_router_product_name="qfx5k",
            physical_router_user_credentials={
                "username": "******",
                "password": "******"
            },
            physical_router_device_family='junos-qfx')
        self._vnc_lib.physical_router_create(phy_router_obj)

        phy_int_obj = PhysicalInterface(name="phy_intf_qfx_%s" % self.id(),
                                        parent_obj=phy_router_obj)
        self._vnc_lib.physical_interface_create(phy_int_obj)

        log_int_obj = LogicalInterface(name="log_intf_qfx_%s" % self.id(),
                                       parent_obj=phy_int_obj,
                                       logical_interface_vlan_tag=2,
                                       logical_interface_type='l2')

        regex_msg = (r"Vlan ids \[1, 2, 4094\] are not allowed on "
                     "QFX logical interface type: l2")
        self.assertRaisesRegexp(BadRequest, regex_msg,
                                self._vnc_lib.logical_interface_create,
                                log_int_obj)
Пример #3
0
 def test_existing_li_before_pt_create(self):
     # Create Logical Interface
     pi_obj = self.api.physical_interface_read(id=self.left_pnf_pi_uuid)
     li_name = 'ge-0/0/1-' + self.id() + '.100'
     li_obj = LogicalInterface(name=li_name,
                               display_name=li_name.replace("_", ":"),
                               logical_interface_vlan_tag='100',
                               parent_obj=pi_obj)
     self.api.logical_interface_create(li_obj)
     # Construct PT object
     si_obj = self.api.service_instance_read(id=self.si_uuid)
     left_lr_obj = self.api.logical_router_read(id=self.left_lr_uuid)
     right_lr_obj = self.api.logical_router_read(id=self.right_lr_uuid)
     pt_obj = PortTuple('pt-' + self.id(), parent_obj=si_obj)
     pt_obj.add_logical_router(left_lr_obj)
     pt_obj.add_logical_router(right_lr_obj)
     kvp_array = []
     kvp = KeyValuePair("left-lr", self.left_lr_uuid)
     kvp_array.append(kvp)
     kvp = KeyValuePair("right-lr", self.right_lr_uuid)
     kvp_array.append(kvp)
     kvps = KeyValuePairs()
     kvps.set_key_value_pair(kvp_array)
     pt_obj.set_annotations(kvps)
     # create PT
     self.api.port_tuple_create(pt_obj)
     # check if LIs and IIPs are created
     li_list_len = \
         len(self.api.logical_interfaces_list().get('logical-interfaces'))
     self.assertEqual(li_list_len, 5)
     iip_list_len = \
         len(self.api.instance_ips_list().get('instance-ips'))
     self.assertEqual(iip_list_len, 5)
     # cleanup
     self.api.port_tuple_delete(id=pt_obj.uuid)
    def test_physical_interface_esi(self):
        pr_name = self.id() + '_physical_router'
        pr = PhysicalRouter(pr_name)
        pr_uuid = self._vnc_lib.physical_router_create(pr)
        pr_obj = self._vnc_lib.physical_router_read(id=pr_uuid)

        esi_id = '00:11:22:33:44:55:66:77:88:99'

        pi1_name = self.id() + '_physical_interface1'
        pi1 = PhysicalInterface(name=pi1_name,
                                parent_obj=pr_obj,
                                ethernet_segment_identifier=esi_id)
        pi1_uuid = self._vnc_lib.physical_interface_create(pi1)
        pi1_obj = self._vnc_lib.physical_interface_read(id=pi1_uuid)

        li1_name = pi1_name + '_li1'
        li1 = LogicalInterface(name=li1_name,
                               parent_obj=pi1_obj,
                               logical_interface_vlan_tag=2)

        vn_name = self.id() + '_test_vn'
        vn = VirtualNetwork(vn_name)
        vn_uuid = self._vnc_lib.virtual_network_create(vn)
        vn_obj = self._vnc_lib.virtual_network_read(id=vn_uuid)

        vmi_name = self.id() + '_common_vmi'
        vmi_obj = self._create_vmi(vmi_name, vn_obj)

        li1.add_virtual_machine_interface(vmi_obj)
        li1_uuid = self._vnc_lib.logical_interface_create(li1)
        self._vnc_lib.logical_interface_read(id=li1_uuid)

        pi2_name = self.id() + '_physical_interface2'
        pi2 = PhysicalInterface(name=pi2_name,
                                parent_obj=pr_obj,
                                ethernet_segment_identifier=esi_id)
        pi2_uuid = self._vnc_lib.physical_interface_create(pi2)
        pi2_obj = self._vnc_lib.physical_interface_read(id=pi2_uuid)

        li2_name = pi2_name + '_li2'
        li2 = LogicalInterface(name=li2_name,
                               parent_obj=pi2_obj,
                               logical_interface_vlan_tag=2)

        second_vmi_name = self.id() + '_2nd_vmi'
        second_vmi_obj = self._create_vmi(second_vmi_name, vn_obj,
                                          'AA:AA:AA:AA:AA:AA')
        li2.add_virtual_machine_interface(second_vmi_obj)

        self.assertRaises(PermissionDenied,
                          self._vnc_lib.logical_interface_create, li2)

        li2 = LogicalInterface(name=li2_name,
                               parent_obj=pi2_obj,
                               logical_interface_vlan_tag=2)
        li2_uuid = self._vnc_lib.logical_interface_create(li2)
        li2_obj = self._vnc_lib.logical_interface_read(id=li2_uuid)
        li2_obj.add_virtual_machine_interface(second_vmi_obj)

        self.assertRaises(PermissionDenied,
                          self._vnc_lib.logical_interface_update, li2_obj)

        pi3_name = self.id() + '_physical_interface3'
        pi3 = PhysicalInterface(
            name=pi3_name,
            parent_obj=pr_obj,
            ethernet_segment_identifier='00:00:00:00:00:00:00:00:00:AA')
        pi3_uuid = self._vnc_lib.physical_interface_create(pi3)
        pi3_obj = self._vnc_lib.physical_interface_read(id=pi3_uuid)

        li3_name = pi3_name + '_li3'
        li3 = LogicalInterface(name=li3_name,
                               parent_obj=pi3_obj,
                               logical_interface_vlan_tag=2)

        li3.add_virtual_machine_interface(vmi_obj)
        self._vnc_lib.logical_interface_create(li3)
        pi3_obj.set_ethernet_segment_identifier(esi_id)
        self._vnc_lib.physical_interface_update(pi3_obj)
    def test_physical_interface_esi(self):
        pr_name = self.id() + '_physical_router'
        pr = PhysicalRouter(pr_name)
        pr_uuid = self._vnc_lib.physical_router_create(pr)
        pr_obj = self._vnc_lib.physical_router_read(id=pr_uuid)

        esi_id = '00:11:22:33:44:55:66:77:88:99'

        pi1_name = self.id() + '_physical_interface1'
        pi1 = PhysicalInterface(name=pi1_name,
                                parent_obj=pr_obj,
                                ethernet_segment_identifier=esi_id)
        pi1_uuid = self._vnc_lib.physical_interface_create(pi1)
        pi1_obj = self._vnc_lib.physical_interface_read(id=pi1_uuid)

        li1_name = pi1_name + '_li1'
        li1 = LogicalInterface(name=li1_name,
                               parent_obj=pi1_obj,
                               logical_interface_vlan_tag=2)

        vn_name = self.id() + '_test_vn'
        vn = VirtualNetwork(vn_name)
        vn_uuid = self._vnc_lib.virtual_network_create(vn)
        vn_obj = self._vnc_lib.virtual_network_read(id=vn_uuid)

        vmi_name = self.id() + '_common_vmi'
        vmi_obj = self._create_vmi(vmi_name, vn_obj)

        li1.add_virtual_machine_interface(vmi_obj)
        li1_uuid = self._vnc_lib.logical_interface_create(li1)
        self._vnc_lib.logical_interface_read(id=li1_uuid)

        pi2_name = self.id() + '_physical_interface2'
        pi2 = PhysicalInterface(name=pi2_name,
                                parent_obj=pr_obj,
                                ethernet_segment_identifier=esi_id)
        pi2_uuid = self._vnc_lib.physical_interface_create(pi2)
        pi2_obj = self._vnc_lib.physical_interface_read(id=pi2_uuid)

        li2_name = pi2_name + '_li2'
        li2 = LogicalInterface(name=li2_name,
                               parent_obj=pi2_obj,
                               logical_interface_vlan_tag=2)

        second_vmi_name = self.id() + '_2nd_vmi'
        second_vmi_obj = self._create_vmi(second_vmi_name, vn_obj,
                                          'AA:AA:AA:AA:AA:AA')
        li2.add_virtual_machine_interface(second_vmi_obj)

        self.assertRaises(
            PermissionDenied, self._vnc_lib.logical_interface_create, li2)

        li2 = LogicalInterface(name=li2_name,
                               parent_obj=pi2_obj,
                               logical_interface_vlan_tag=2)
        li2_uuid = self._vnc_lib.logical_interface_create(li2)
        li2_obj = self._vnc_lib.logical_interface_read(id=li2_uuid)
        li2_obj.add_virtual_machine_interface(second_vmi_obj)

        self.assertRaises(
            PermissionDenied, self._vnc_lib.logical_interface_update, li2_obj)

        pi3_name = self.id() + '_physical_interface3'
        pi3 = PhysicalInterface(
            name=pi3_name,
            parent_obj=pr_obj,
            ethernet_segment_identifier='00:00:00:00:00:00:00:00:00:AA')
        pi3_uuid = self._vnc_lib.physical_interface_create(pi3)
        pi3_obj = self._vnc_lib.physical_interface_read(id=pi3_uuid)

        li3_name = pi3_name + '_li3'
        li3 = LogicalInterface(name=li3_name,
                               parent_obj=pi3_obj,
                               logical_interface_vlan_tag=2)

        li3.add_virtual_machine_interface(vmi_obj)
        self._vnc_lib.logical_interface_create(li3)
        pi3_obj.set_ethernet_segment_identifier(esi_id)
        self._vnc_lib.physical_interface_update(pi3_obj)