示例#1
0
    def test_delete_port(self):
        """
        Tests Deletion of a port on a specified Virtual Network,
        if the port contains a remote interface attachment,
        the remote interface should first be un-plugged and
        then the port can be deleted.
        """
        LOG.debug("UCSVICTestPlugin:_test_delete_port() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
                self.tenant_id, new_network[const.NETWORKNAME],
                new_network[const.UUID], self.vlan_name, self.vlan_id,
                device_ip=self.device_ip)
        new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict = self._cisco_ucs_plugin.create_port(
                            self.tenant_id, self.net_id, const.PORT_UP,
                            new_port[const.UUID], device_ip=self.device_ip,
                            ucs_inventory=self._ucs_inventory,
                            least_rsvd_blade_dict=self._ucs_inventory.\
                            _get_least_reserved_blade())
        port_bind = self._cisco_ucs_plugin.delete_port(
                         self.tenant_id, new_net_dict[const.NET_ID],
                         port_dict[const.PORTID], device_ip=self.device_ip,
                         ucs_inventory=self._ucs_inventory,
                         chassis_id=self.chassis_id, blade_id=self.blade_id,
                         blade_intf_distinguished_name=self.\
                         blade_intf_distinguished_name,
                         least_rsvd_blade_dict=self._ucs_inventory.\
                         _get_least_reserved_blade())

        self.assertEqual(port_bind[const.PORTID], new_port[const.UUID])
        self.tearDownNetwork(self.tenant_id, new_net_dict[const.NET_ID])
示例#2
0
    def test_create_port(self):
        """
        Tests creation of a port on the specified Virtual Network.
        """
        LOG.debug("UCSVICTestPlugin:_test_create_port() called\n")

        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network[const.NETWORKNAME],
            new_network[const.UUID], self.vlan_name, self.vlan_id,
            device_ip=self.device_ip)
        new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict = self._cisco_ucs_plugin.create_port(
            self.tenant_id, self.net_id, const.PORT_UP,
            new_port[const.UUID], device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))
        self.assertEqual(port_dict[const.PORTID], new_port[const.UUID])
        profile_name = (
            self._cisco_ucs_plugin._get_profile_name(port_dict[const.PORTID]))
        self.assertTrue(profile_name is not None)
        self.tear_down_network_port(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict[const.PORTID])
示例#3
0
    def test_delete_network(self, net_tenant_id=None, network_name=None):
        """
        Tests deletion of a Virtual Network.
        """

        LOG.debug("test_delete_network - START")

        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id
        if network_name:
            net_name = network_name
        else:
            net_name = self.net_name

        network_created = self.create_network(tenant_id, net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        deleted_net_dict = self._cisco_nexus_plugin.delete_network(
            tenant_id, new_net_dict[const.NET_ID])
        self.assertEqual(deleted_net_dict[const.NET_ID],
                         network_created["net-id"])
        LOG.debug("test_delete_network - END")
    def test_delete_port(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_delete_port - START")
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        self._l2network_multiblade.create_network([tenant_id,
                                                   net_name,
                                                   self.net_id,
                                                   vlan_name(self.net_id),
                                                   vlan_id])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
        self._l2network_multiblade.create_port([tenant_id,
                                                self.net_id,
                                                port_state, self.port_id])

        port = self._l2network_multiblade.delete_port([tenant_id,
                                                       self.net_id,
                                                       self.port_id])

        self.assertEqual(self.port_id, port[0][const.PORTID])

        # Recreating port so tear down doesn't cause an error
        self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
        self._l2network_multiblade.create_port([tenant_id,
                                                self.net_id,
                                                port_state, self.port_id])

        LOG.debug("test_delete_port - END")
    def test_unplug_interface(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_unplug_interface - START")
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        self._l2network_multiblade.create_network([tenant_id,
                                                   net_name,
                                                   self.net_id,
                                                   vlan_name(self.net_id),
                                                   vlan_id])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
        self._l2network_multiblade.create_port([tenant_id,
                                                self.net_id,
                                                port_state, self.port_id])

        self._l2network_multiblade.plug_interface([tenant_id, self.net_id,
                                                   self.port_id, interface_id])
        db.port_set_attachment(self.net_id, self.port_id, interface_id)
        interface = self._l2network_multiblade.unplug_interface([tenant_id,
                                                                 self.net_id,
                                                                 self.port_id])

        self.assertEqual(self.port_id, interface[0][const.PORTID])
        LOG.debug("test_unplug_interface - END")
示例#6
0
    def _test_get_port_details(self, port_state):
        """
        Tests whether  user is able  to retrieve a remote interface
        that is attached to this particular port when port state is Up.
        """
        LOG.debug("UCSVICTestPlugin:_test_get_port_details() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network[const.NETWORKNAME],
            new_network[const.UUID], self.vlan_name, self.vlan_id,
            device_ip=self.device_ip)
        new_port = db.port_create(new_network[const.UUID], port_state)
        port_dict = self._cisco_ucs_plugin.create_port(
            self.tenant_id, self.net_id, port_state,
            new_port[const.UUID], device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))

        port_detail = self._cisco_ucs_plugin.get_port_details(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict[const.PORTID], device_ip=self.device_ip)
        self.assertEqual(str(port_dict), str(port_detail))
        self.tear_down_network_port(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict[const.PORTID])
示例#7
0
    def test_update_network(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_update_network - START")

        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]

        self._l2network_multiblade.create_network([
            tenant_id, net_name, self.net_id,
            vlan_name(self.net_id), vlan_id
        ])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        net_details = db.network_update(self.net_id,
                                        tenant_id,
                                        name=new_net_name)
        networks = self._l2network_multiblade.update_network([
            tenant_id,
            self.net_id,
            {
                'name': new_net_name
            },
        ])

        for network in networks:
            self.assertEqual(network[const.NET_ID], self.net_id)
            self.assertEqual(network[const.NET_NAME], new_net_name)
        LOG.debug("test_update_network - END")
示例#8
0
 def test_plug_interface(self, remote_interface_id=None,
                         new_vlanid=10, new_vlan_name='new_vlan'):
     """
     Attaches a remote interface to the specified port on the
     specified Virtual Network.
     """
     LOG.debug("UCSVICTestPlugin:_test_plug_interface() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
     port_dict = self._cisco_ucs_plugin.create_port(
         self.tenant_id, new_net_dict[const.NET_ID],
         const.PORT_UP, new_port[const.UUID],
         device_ip=self.device_ip,
         ucs_inventory=self._ucs_inventory,
         least_rsvd_blade_dict=(
             self._ucs_inventory._get_least_reserved_blade()))
     cdb.update_vlan_binding(new_network[const.UUID],
                             str(new_vlanid), new_vlan_name)
     port_bind = self._cisco_ucs_plugin.plug_interface(
         self.tenant_id, new_net_dict[const.NET_ID],
         port_dict[const.PORTID], remote_interface_id,
         device_ip=self.device_ip)
     self.assertEqual(port_bind[const.VLANNAME], new_vlan_name)
     self.assertEqual(port_bind[const.VLANID], new_vlanid)
     self.tear_down_network_port_interface(
         self.tenant_id, new_net_dict[const.NET_ID],
         new_port[const.UUID])
示例#9
0
    def test_get_all_networks(self):
        """
        Tests whether  dictionary is returned containing all
        <network_uuid, network_name> for
        the specified tenant.
        """
        LOG.debug("UCSVICTestPlugin:test_get_all_networks() called\n")
        new_network1 = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network1[const.UUID])
        new_net_dict1 = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network1[const.NETWORKNAME],
            new_network1[const.UUID], self.vlan_name, self.vlan_id,
            device_ip=self.device_ip)
        new_network2 = db.network_create(self.tenant_id, "test_network2")
        cdb.add_vlan_binding("6", "q-000006vlan", new_network2[const.UUID])
        new_net_dict2 = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network2[const.NETWORKNAME],
            new_network2[const.UUID], "q-000006vlan", "6",
            device_ip=self.device_ip)

        net_list = self._cisco_ucs_plugin.get_all_networks(
            self.tenant_id, device_ip=self.device_ip)
        net_id_list = [new_net_dict1, new_net_dict2]

        self.assertTrue(net_list[0] in net_id_list)
        self.assertTrue(net_list[1] in net_id_list)
        self.tear_down_network(self.tenant_id, new_network1[const.UUID])
        self.tear_down_network(self.tenant_id, new_network2[const.UUID])
示例#10
0
    def test_delete_network(self, net_tenant_id=None, network_name=None):
        """
        Tests deletion of a Virtual Network.
        """

        LOG.debug("test_delete_network - START")

        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id
        if network_name:
            net_name = network_name
        else:
            net_name = self.net_name

        network_created = self.create_network(tenant_id, net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        deleted_net_dict = self._cisco_nexus_plugin.delete_network(
            tenant_id, new_net_dict[const.NET_ID])
        self.assertEqual(deleted_net_dict[const.NET_ID],
                         network_created["net-id"])
        LOG.debug("test_delete_network - END")
示例#11
0
    def test_list_all_networks(self, net_tenant_id=None):
        """
        Tests listing of all the Virtual Networks .
        """

        LOG.debug("test_list_all_networks - START")
        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id

        network_created = self.create_network(tenant_id, self.net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict1 = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        network_created2 = self.create_network(tenant_id, 'test_network2')
        cdb.add_vlan_binding(self.second_vlan_id, 'second_vlan',
                             network_created2["net-id"])
        new_net_dict2 = self._cisco_nexus_plugin.create_network(
            tenant_id, "New_Network2", network_created2["net-id"],
            "second_vlan", self.second_vlan_id)
        list_net_dict = self._cisco_nexus_plugin.get_all_networks(tenant_id)
        net_temp_list = [new_net_dict1, new_net_dict2]
        self.assertTrue(net_temp_list[0] in list_net_dict)
        self.assertTrue(net_temp_list[1] in list_net_dict)
        self.tearDownNetwork(tenant_id, new_net_dict1[const.NET_ID])
        self.tearDownNetwork(tenant_id, new_net_dict2[const.NET_ID])
        LOG.debug("test_list_all_networks - END")
示例#12
0
    def test_list_all_networks(self, net_tenant_id=None):
        """
        Tests listing of all the Virtual Networks .
        """

        LOG.debug("test_list_all_networks - START")
        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id

        network_created = self.create_network(tenant_id, self.net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict1 = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        network_created2 = self.create_network(tenant_id, 'test_network2')
        cdb.add_vlan_binding(self.second_vlan_id, 'second_vlan',
                             network_created2["net-id"])
        new_net_dict2 = self._cisco_nexus_plugin.create_network(
            tenant_id, "New_Network2", network_created2["net-id"],
            "second_vlan", self.second_vlan_id)
        list_net_dict = self._cisco_nexus_plugin.get_all_networks(tenant_id)
        net_temp_list = [new_net_dict1, new_net_dict2]
        self.assertTrue(net_temp_list[0] in list_net_dict)
        self.assertTrue(net_temp_list[1] in list_net_dict)
        self.tearDownNetwork(tenant_id, new_net_dict1[const.NET_ID])
        self.tearDownNetwork(tenant_id, new_net_dict2[const.NET_ID])
        LOG.debug("test_list_all_networks - END")
示例#13
0
    def test_get_vlan_id_for_network(self, net_tenant_id=None,
                                     network_name=None):
        """
        Tests retrieval of vlan id for a Virtual Networks .
        """

        LOG.debug("test_get_vlan_id_for_network - START")
        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id
        if network_name:
            net_name = network_name
        else:
            net_name = self.net_name

        network_created = self.create_network(tenant_id, net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        result_vlan_id = self._cisco_nexus_plugin._get_vlan_id_for_network(
            tenant_id, network_created["net-id"])
        self.assertEqual(result_vlan_id, self.vlan_id)
        self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
        LOG.debug("test_get_vlan_id_for_network - END")
示例#14
0
    def test_get_network_details(self, net_tenant_id=None, network_name=None):
        """
        Tests displays details of a Virtual Network .
        """

        LOG.debug("test_get_network_details - START")

        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id
        if network_name:
            net_name = network_name
        else:
            net_name = self.net_name

        network_created = self.create_network(tenant_id, net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        check_net_dict = self._cisco_nexus_plugin.get_network_details(
            tenant_id, network_created["net-id"])
        self.assertEqual(check_net_dict[const.NET_ID],
                         network_created["net-id"])
        self.assertEqual(check_net_dict[const.NET_NAME], self.net_name)
        self.assertEqual(check_net_dict[const.NET_VLAN_NAME], self.vlan_name)
        self.assertEqual(check_net_dict[const.NET_VLAN_ID], self.vlan_id)
        self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
        LOG.debug("test_get_network_details - END")
示例#15
0
    def test_get_vlan_id_for_network(self,
                                     net_tenant_id=None,
                                     network_name=None):
        """
        Tests retrieval of vlan id for a Virtual Networks .
        """

        LOG.debug("test_get_vlan_id_for_network - START")
        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id
        if network_name:
            net_name = network_name
        else:
            net_name = self.net_name

        network_created = self.create_network(tenant_id, net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        result_vlan_id = self._cisco_nexus_plugin._get_vlan_id_for_network(
            tenant_id, network_created["net-id"])
        self.assertEqual(result_vlan_id, self.vlan_id)
        self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
        LOG.debug("test_get_vlan_id_for_network - END")
示例#16
0
    def test_delete_port_PortNotFound(self):
        """
        Negative Test for delete port when port not found
        """
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id,
            new_network[const.NETWORKNAME],
            new_network[const.UUID],
            self.vlan_name,
            self.vlan_id,
            device_ip=self.device_ip)

        self.assertRaises(c_exc.PortVnicNotFound,
                          self._cisco_ucs_plugin.delete_port,
                          self.tenant_id, new_net_dict[const.NET_ID],
                          self.port_id, device_ip=self.device_ip,
                          ucs_inventory=self._ucs_inventory,
                          chassis_id=self.chassis_id, blade_id=self.blade_id,
                          blade_intf_distinguished_name=None,
                          least_rsvd_blade_dict=self._ucs_inventory.\
                          _get_least_reserved_blade())

        self.tear_down_network(self.tenant_id, new_net_dict[const.NET_ID])
示例#17
0
    def test_get_all_networks(self):
        """
        Tests whether  dictionary is returned containing all
        <network_uuid, network_name> for
        the specified tenant.
        """
        LOG.debug("UCSVICTestPlugin:test_get_all_networks() called\n")
        new_network1 = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network1[const.UUID])
        new_net_dict1 = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network1[const.NETWORKNAME],
            new_network1[const.UUID], self.vlan_name, self.vlan_id,
            device_ip=self.device_ip)
        new_network2 = db.network_create(self.tenant_id, "test_network2")
        cdb.add_vlan_binding("6", "q-000006vlan", new_network2[const.UUID])
        new_net_dict2 = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network2[const.NETWORKNAME],
            new_network2[const.UUID], "q-000006vlan", "6",
            device_ip=self.device_ip)

        net_list = self._cisco_ucs_plugin.get_all_networks(
            self.tenant_id, device_ip=self.device_ip)
        net_id_list = [new_net_dict1, new_net_dict2]

        self.assertTrue(net_list[0] in net_id_list)
        self.assertTrue(net_list[1] in net_id_list)
        self.tear_down_network(self.tenant_id, new_network1[const.UUID])
        self.tear_down_network(self.tenant_id, new_network2[const.UUID])
示例#18
0
    def test_get_network_details(self, net_tenant_id=None, network_name=None):
        """
        Tests displays details of a Virtual Network .
        """

        LOG.debug("test_get_network_details - START")

        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id
        if network_name:
            net_name = network_name
        else:
            net_name = self.net_name

        network_created = self.create_network(tenant_id, net_name)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created["net-id"])
        new_net_dict = self._cisco_nexus_plugin.create_network(
            tenant_id, self.net_name, network_created["net-id"],
            self.vlan_name, self.vlan_id)
        check_net_dict = self._cisco_nexus_plugin.get_network_details(
            tenant_id, network_created["net-id"])
        self.assertEqual(check_net_dict[const.NET_ID],
                         network_created["net-id"])
        self.assertEqual(check_net_dict[const.NET_NAME], self.net_name)
        self.assertEqual(check_net_dict[const.NET_VLAN_NAME], self.vlan_name)
        self.assertEqual(check_net_dict[const.NET_VLAN_ID], self.vlan_id)
        self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
        LOG.debug("test_get_network_details - END")
示例#19
0
    def _test_get_port_details(self, port_state):
        """
        Tests whether  user is able  to retrieve a remote interface
        that is attached to this particular port when port state is Up.
        """
        LOG.debug("UCSVICTestPlugin:_test_get_port_details() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network[const.NETWORKNAME],
            new_network[const.UUID], self.vlan_name, self.vlan_id,
            device_ip=self.device_ip)
        new_port = db.port_create(new_network[const.UUID], port_state)
        port_dict = self._cisco_ucs_plugin.create_port(
            self.tenant_id, self.net_id, port_state,
            new_port[const.UUID], device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))

        port_detail = self._cisco_ucs_plugin.get_port_details(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict[const.PORTID], device_ip=self.device_ip)
        self.assertEqual(str(port_dict), str(port_detail))
        self.tear_down_network_port(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict[const.PORTID])
示例#20
0
 def test_plug_interface(self, remote_interface_id=None,
                         new_vlanid=10, new_vlan_name='new_vlan'):
     """
     Attaches a remote interface to the specified port on the
     specified Virtual Network.
     """
     LOG.debug("UCSVICTestPlugin:_test_plug_interface() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
     port_dict = self._cisco_ucs_plugin.create_port(
         self.tenant_id, new_net_dict[const.NET_ID],
         const.PORT_UP, new_port[const.UUID],
         device_ip=self.device_ip,
         ucs_inventory=self._ucs_inventory,
         least_rsvd_blade_dict=(
             self._ucs_inventory._get_least_reserved_blade()))
     cdb.update_vlan_binding(new_network[const.UUID],
                             str(new_vlanid), new_vlan_name)
     port_bind = self._cisco_ucs_plugin.plug_interface(
         self.tenant_id, new_net_dict[const.NET_ID],
         port_dict[const.PORTID], remote_interface_id,
         device_ip=self.device_ip)
     self.assertEqual(port_bind[const.VLANNAME], new_vlan_name)
     self.assertEqual(port_bind[const.VLANID], new_vlanid)
     self.tear_down_network_port_interface(
         self.tenant_id, new_net_dict[const.NET_ID],
         new_port[const.UUID])
示例#21
0
    def test_delete_port(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_delete_port - START")
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        self._l2network_multiblade.create_network([
            tenant_id, net_name, self.net_id,
            vlan_name(self.net_id), vlan_id
        ])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
        self._l2network_multiblade.create_port(
            [tenant_id, self.net_id, port_state, self.port_id])

        port = self._l2network_multiblade.delete_port(
            [tenant_id, self.net_id, self.port_id])

        self.assertEqual(self.port_id, port[0][const.PORTID])

        # Recreating port so tear down doesn't cause an error
        self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
        self._l2network_multiblade.create_port(
            [tenant_id, self.net_id, port_state, self.port_id])

        LOG.debug("test_delete_port - END")
示例#22
0
    def test_create_port(self):
        """
        Tests creation of a port on the specified Virtual Network.
        """
        LOG.debug("UCSVICTestPlugin:_test_create_port() called\n")

        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network[const.NETWORKNAME],
            new_network[const.UUID], self.vlan_name, self.vlan_id,
            device_ip=self.device_ip)
        new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict = self._cisco_ucs_plugin.create_port(
            self.tenant_id, self.net_id, const.PORT_UP,
            new_port[const.UUID], device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))
        self.assertEqual(port_dict[const.PORTID], new_port[const.UUID])
        profile_name = (
            self._cisco_ucs_plugin._get_profile_name(port_dict[const.PORTID]))
        self.assertTrue(profile_name is not None)
        self.tear_down_network_port(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict[const.PORTID])
    def test_update_network(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_update_network - START")

        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]

        self._l2network_multiblade.create_network([tenant_id,
                                                   net_name,
                                                   self.net_id,
                                                   vlan_name(self.net_id),
                                                   vlan_id])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        net_details = db.network_update(self.net_id, tenant_id,
                                        name=new_net_name)
        networks = self._l2network_multiblade.update_network([
            tenant_id,
            self.net_id,
            {'name': new_net_name},
            ])

        for network in networks:
            self.assertEqual(network[const.NET_ID], self.net_id)
            self.assertEqual(network[const.NET_NAME], new_net_name)
        LOG.debug("test_update_network - END")
    def test_delete_network(self):
        """
        Create a network on a catalyst switch and then delete it
        """

        LOG.debug("test_delete_network - START\n")
        # network dict for create
        net = {'name': self.network_name,
               'admin_status_up': self.admin_status_up}
        # create a network using a locally defined method
        # and call create_network in the catalyst plugin
        network_created = self.create_network(context, net)
        cdb.add_vlan_binding(self.vlan_name, self.vlan_id,
                             network_created['id'])
        network_plugin = self._cisco_catalyst_plugin.create_network(
            context, network_created, self.vlan_name, self.vlan_id)
        # delete the created network by calling delete_network defined at the cat plugin
        # returns a dictionary
        deleted_network_dict = self._cisco_catalyst_plugin.delete_network(
            context, network_created['id'])
        # Check if network id returned by delete_network and create_network
        # are the same
        self.assertEqual(deleted_network_dict[const.ID],
                         network_created['id'])
        # destroy the created network
        self.tearDownNetwork(network_created)
        LOG.debug("test_delete_network - END\n")
示例#25
0
 def test_get_vlan_id_for_network(self):
     LOG.debug("UCSVICTestPlugin:test_get_vlan_id_for_network() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     vlan_bind_id = self._cisco_ucs_plugin._get_vlan_id_for_network(
                                 self.tenant_id, new_network[const.UUID])
     self.assertEqual(str(vlan_bind_id), self.vlan_id)
示例#26
0
    def test_get_all_ports(self):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        """
        LOG.debug("UCSVICPlugin:get_all_ports() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id,
            new_network[const.NETWORKNAME],
            new_network[const.UUID],
            self.vlan_name,
            self.vlan_id,
            device_ip=self.device_ip)
        new_port1 = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict1 = self._cisco_ucs_plugin.create_port(
                            self.tenant_id, self.net_id, const.PORT_UP,
                            new_port1[const.UUID], device_ip=self.device_ip,
                            ucs_inventory=self._ucs_inventory,
                            least_rsvd_blade_dict=self._ucs_inventory.\
                            _get_least_reserved_blade())
        new_port2 = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict2 = self._cisco_ucs_plugin.create_port(
                               self.tenant_id, self.net_id, const.PORT_UP,
                               new_port2[const.UUID], device_ip=self.device_ip,
                               ucs_inventory=self._ucs_inventory,
                               least_rsvd_blade_dict=self._ucs_inventory.\
                               _get_least_reserved_blade())
        ports_on_net = self._cisco_ucs_plugin.get_all_ports(
                           self.tenant_id, new_net_dict[const.NET_ID],
                           device_ip=self.device_ip,
                           ucs_inventory=self._ucs_inventory,
                           least_rsvd_blade_dict=self._ucs_inventory.\
                           _get_least_reserved_blade())
        port_list = [port_dict1, port_dict2]
        self.assertTrue(
            str(ports_on_net[1]) == str(port_list[1])
            or str(ports_on_net[1]) == str(port_list[0]))
        self.assertTrue(
            str(ports_on_net[0]) == str(port_list[1])
            or str(ports_on_net[0]) == str(port_list[0]))

        blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
            self.tenant_id, port_dict1[const.PORTID])
        self._cisco_ucs_plugin.delete_port(
                     self.tenant_id, new_net_dict[const.NET_ID],
                     port_dict1[const.PORTID], device_ip=self.device_ip,
                     ucs_inventory=self._ucs_inventory,
                     chassis_id=self.chassis_id, blade_id=self.blade_id,
                     blade_intf_distinguished_name=blade_intf_details[\
                     const.BLADE_INTF_DN],
                     least_rsvd_blade_dict=self._ucs_inventory.\
                     _get_least_reserved_blade())
        self.tear_down_network_port(self.tenant_id, new_net_dict[const.NET_ID],
                                    port_dict2[const.PORTID])
示例#27
0
 def test_release_segmentation_id(self):
     LOG.debug("test_release_segmentation_id - START")
     db.network_create(self.tenant_id, self.net_name)
     vlan_id = self.vlan_mgr.reserve_segmentation_id(self.tenant_id,
                                                     self.net_name)
     cdb.add_vlan_binding(vlan_id, self.vlan_name, self.net_id)
     release_return = self.vlan_mgr.release_segmentation_id(self.tenant_id,
                                                            self.net_id)
     self.assertEqual(release_return, False)
     LOG.debug("test_release_segmentation_id - END")
示例#28
0
 def test_get_vlan_id_for_network(self):
     """
     Tests retrieval of vlan id
     """
     LOG.debug("UCSVICTestPlugin:test_get_vlan_id_for_network() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     vlan_bind_id = self._cisco_ucs_plugin._get_vlan_id_for_network(
         self.tenant_id, new_network[const.UUID])
     self.assertEqual(str(vlan_bind_id), self.vlan_id)
示例#29
0
    def test_get_all_ports(self):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        """
        LOG.debug("UCSVICPlugin:get_all_ports() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id, new_network[const.NETWORKNAME],
            new_network[const.UUID], self.vlan_name, self.vlan_id,
            device_ip=self.device_ip)
        new_port1 = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict1 = self._cisco_ucs_plugin.create_port(
            self.tenant_id, self.net_id, const.PORT_UP,
            new_port1[const.UUID], device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))
        new_port2 = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict2 = self._cisco_ucs_plugin.create_port(
            self.tenant_id, self.net_id, const.PORT_UP,
            new_port2[const.UUID], device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))
        ports_on_net = self._cisco_ucs_plugin.get_all_ports(
            self.tenant_id, new_net_dict[const.NET_ID],
            device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))
        port_list = [port_dict1, port_dict2]
        self.assertTrue(str(ports_on_net[1]) == str(port_list[1]) or
                        str(ports_on_net[1]) == str(port_list[0]))
        self.assertTrue(str(ports_on_net[0]) == str(port_list[1]) or
                        str(ports_on_net[0]) == str(port_list[0]))

        blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
            self.tenant_id, port_dict1[const.PORTID])
        self._cisco_ucs_plugin.delete_port(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict1[const.PORTID], device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            chassis_id=self.chassis_id, blade_id=self.blade_id,
            blade_intf_distinguished_name=blade_intf_details[
                const.BLADE_INTF_DN],
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))
        self.tear_down_network_port(
            self.tenant_id, new_net_dict[const.NET_ID],
            port_dict2[const.PORTID])
    def test_plug_interface_portDNE(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_plug_interface_portDNE - START")
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        self._l2network_multiblade.create_network([tenant_id, net_name, self.net_id, vlan_name(self.net_id), vlan_id])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        self.assertRaises(
            exc.PortNotFound, self._l2network_multiblade.plug_interface, [tenant_id, self.net_id, port_id, interface_id]
        )

        LOG.debug("test_plug_interface_portDNE - START")
 def create_network(self, context, network):
     LOG.debug("L2Network's create_network() called")
     n = super().create_network(context, network)
     tenant_id = n['tenant_id']
     new_net_id = n['id']
     net_name = n['name']
     vlan_id = self._get_vlan_for_tenant(tenant_id, net_name)
     vlan_name = self._get_vlan_name(str(new_net_id), str(vlan_id))
     self._invoke_device_plugins(self._func_name(), [context,
                                                     n, vlan_name,
                                                     vlan_id])
     cdb.add_vlan_binding(vlan_id, vlan_name, str(new_net_id))
     return n
示例#32
0
 def create_network(self, tenant_id, net_name, **kwargs):
     """
     Creates a new Virtual Network, and assigns it
     a symbolic name.
     """
     LOG.debug("create_network() called\n")
     new_network = db.network_create(tenant_id, net_name)
     new_net_id = new_network[const.UUID]
     vlan_id = self._get_vlan_for_tenant(tenant_id, net_name)
     vlan_name = self._get_vlan_name(new_net_id, str(vlan_id))
     self._invoke_device_plugins(self._func_name(), [tenant_id, net_name, new_net_id, vlan_name, vlan_id])
     cdb.add_vlan_binding(vlan_id, vlan_name, new_net_id)
     new_net_dict = {const.NET_ID: new_net_id, const.NET_NAME: net_name, const.NET_PORTS: []}
     return new_net_dict
 def test_get_subnets(self):
     """
     Tests the displaing all existing Subnets
     """
     LOG.debug("test_get_subnets - START\n")
     # create a network
     network = {'name': self.network_name,
                'admin_state_up': self.admin_state_up)
     network_created = self.create_network(context, network)
     cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                          network_created['id'])
     net_plugin_dict = self._cisco_catalyst_plugin.create_network(
                         context, network_created, self.vlan_name,
                         self.vlan_id)
     # Sanity check
     self.assertEqual(network_created['id'],
                      net_plugin_dict['id'])
     # Create 2 subnets
     subnet1 = {'id': network_created['id'],
                'ip_version': self.ipversion,
                'cidr': self.cidr,
                'gateway_ip': self.gateway_ip)
     subnet_created1 = self.create_subnet(context, subnet1)
     sub_plugin_dict1 = self._cisco_catalyst_plugin.create_subnet(
                         context, subnet_created1)
     # Subnet1 sanity check
     self.assertEqual(subnet_created1['id'],
                      sub_plugin_dict1['id'])
     subnet2 = {'id': network_created['id'],
                'ip_version': '4',
                'cidr': '10.10.0.0/16',
                'gateway_ip': self.gateway_ip}
     subnet_created2 = self.create_subnet(context, subnet2)
     sub_plugin_dict2 = self._cisco_catalyst_plugin.create_subnet(
                         context, subnet_created2)
     # Subnet2 sanity check
     self.assertEqual(subnet_created2['id'],
                      sub_plugin_dict2['id'])
     sub_temp_list = [sub_plugin_dict1, sub_plugin_dict2]
     # Use get_subnets to get a list of subnets
     subnet_list = _cisco_catayst_plugin.get_subnets(context)
     # Check if these match those of the created subnets
     self.assertTrue(sub_temp_list[0] in subnet_list)
     self.assertTrue(sub_temp_list[1] in subnet_list)
     # Destroy both subnets and the network
     self.tearDownSubnet(context, subnet_created1['id'])
     self.tearDownsubnet(context, subnet_created2['id'])
     self.tearDownNetwork(context, network_created['id'])
     LOG.debug("test_get_subnets - END\n")
    def test_plug_interface_portDNE(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_plug_interface_portDNE - START")
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        self._l2network_multiblade.create_network([
            tenant_id, net_name, self.net_id,
            vlan_name(self.net_id), vlan_id
        ])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        self.assertRaises(exc.PortNotFound,
                          self._l2network_multiblade.plug_interface,
                          [tenant_id, self.net_id, port_id, interface_id])

        LOG.debug("test_plug_interface_portDNE - START")
示例#35
0
 def test_create_network(self):
     """
     Tests creation of new Virtual Network.
     """
     LOG.debug("UCSVICTestPlugin:_test_create_network() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
     self.assertEqual(new_net_dict[const.NET_NAME],
                      new_network[const.NETWORKNAME])
     self.tear_down_network(self.tenant_id, new_network[const.UUID])
示例#36
0
 def test_delete_network(self):
     """
     Tests deletion of  the network with the specified network identifier
     belonging to the specified tenant.
     """
     LOG.debug("UCSVICTestPlugin:test_delete_network() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     new_net_dict = self._cisco_ucs_plugin.delete_network(
         self.tenant_id, new_network[const.UUID], device_ip=self.device_ip)
     self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
    def test_create_network(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_create_network - START")

        # Create the network in the test DB, then with the model
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        networks = self._l2network_multiblade.create_network(
            [tenant_id, net_name, self.net_id, vlan_name(self.net_id), vlan_id]
        )
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        for network in networks:
            self.assertEqual(network[const.NET_ID], self.net_id)
            self.assertEqual(network[const.NET_NAME], net_name)

        LOG.debug("test_create_network - END")
示例#38
0
 def test_create_network(self):
     """
     Tests creation of new Virtual Network.
     """
     LOG.debug("UCSVICTestPlugin:_test_create_network() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
     self.assertEqual(new_net_dict[const.NET_NAME],
                      new_network[const.NETWORKNAME])
     self.tear_down_network(self.tenant_id, new_network[const.UUID])
示例#39
0
 def test_delete_network(self):
     """
     Tests deletion of  the network with the specified network identifier
     belonging to the specified tenant.
     """
     LOG.debug("UCSVICTestPlugin:test_delete_network() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     new_net_dict = self._cisco_ucs_plugin.delete_network(
         self.tenant_id, new_network[const.UUID], device_ip=self.device_ip)
     self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
示例#40
0
    def test_delete_port(self):
        """
        Tests Deletion of a port on a specified Virtual Network,
        if the port contains a remote interface attachment,
        the remote interface should first be un-plugged and
        then the port can be deleted.
        """
        LOG.debug("UCSVICTestPlugin:_test_delete_port() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
            self.tenant_id,
            new_network[const.NETWORKNAME],
            new_network[const.UUID],
            self.vlan_name,
            self.vlan_id,
            device_ip=self.device_ip)
        new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
        port_dict = self._cisco_ucs_plugin.create_port(
            self.tenant_id,
            self.net_id,
            const.PORT_UP,
            new_port[const.UUID],
            device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))

        blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
            self.tenant_id, port_dict[const.PORTID])
        port_bind = self._cisco_ucs_plugin.delete_port(
            self.tenant_id,
            new_net_dict[const.NET_ID],
            port_dict[const.PORTID],
            device_ip=self.device_ip,
            ucs_inventory=self._ucs_inventory,
            chassis_id=self.chassis_id,
            blade_id=self.blade_id,
            blade_intf_distinguished_name=blade_intf_details[
                const.BLADE_INTF_DN],
            least_rsvd_blade_dict=(
                self._ucs_inventory._get_least_reserved_blade()))

        self.assertEqual(port_bind[const.PORTID], new_port[const.UUID])
        self.tear_down_network(self.tenant_id, new_net_dict[const.NET_ID])
示例#41
0
 def create_network(self, tenant_id, net_name, **kwargs):
     """
     Creates a new Virtual Network, and assigns it
     a symbolic name.
     """
     LOG.debug("create_network() called\n")
     new_network = db.network_create(tenant_id, net_name)
     new_net_id = new_network[const.UUID]
     vlan_id = self._get_vlan_for_tenant(tenant_id, net_name)
     vlan_name = self._get_vlan_name(new_net_id, str(vlan_id))
     self._invoke_device_plugins(self._func_name(), [tenant_id, net_name,
                                                  new_net_id, vlan_name,
                                                  vlan_id])
     cdb.add_vlan_binding(vlan_id, vlan_name, new_net_id)
     new_net_dict = {const.NET_ID: new_net_id,
                     const.NET_NAME: net_name,
                     const.NET_PORTS: []}
     return new_net_dict
    def test_get_vlan_id_for_network(self):
        """
        Test retrieval of Vlan id for network
        """

        LOG.debug("test_get_vlan_id_for_network - START\n")
        # Create a network   
        network = {'name': self.network_name,
                   'admin_status_up': self.admin_status_up}
        network_created = self.create_network(context, network)
        cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                             network_created['id'])
        network_plugin_dict = self._cisco_catalyst_plugin.create_network(
            context, network_created, self.vlan_name, self.vlan_id)
        # Obtain vlan id for the created network
        result_vlan_id = self._cisco_catalyst_plugin.
                        _get_vlan_id_for_network(
            network_created['tenant_id'], network_created['id'])
 def test_create_subnet(self):
     """
     Test creation of a subnet
     """
     LOG.debug("test_create_subnet - START\n")
     # first create a network
     net = {'name': self.network_name,
            'admin_state_up': self.admin_state_up}
     network_created = self.create_network(context, net)
     cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
                          network_created['id'])
     network_plugin_dict = self._cisco_catayst_plugin.create_network(
             context, network_created, self.vlan_name, self.vlan_id)
     # Do a sanity check wrt network id
     self.assertEqual(network_created['id'],
                      network_plugin_dict['id'])
     # Then create a subnet on the network
     subnet = {'network_id': network_created['id'],
               'ip_version': self.ip_version,
               'cidr': self.cidr,
               'gateway_ip': self.gateway_ip}
     subnet_created = self.create_subnet(context, subnet)
     subnet_plugin_dict = self._cisco_catalyst_plugin.create_subnet(
         context, subnet)
     # Check if subnet created using the local create_subnet method 
     # Is the same as that returned by the device method 
     # create_subnet
     self.assertEqual(network_created['id'],
                      network_plugin_dict['id'])
     self.assertEqual(network_created['id'],
                      subnet_created['network_id'])
     self.assertEqual(subnet_created['network_id'],
                      subnet_plugin_dict['network_id'])
     self.assertEqual(subnet_created['cidr'],
                      subnet_plugin_dict['cidr'])
     self.assertEqual(subnet_created['gateway_ip'],
                      subnet_plugin_dict['gateway_ip'])
     self.assertEqual(subnet_created['id'],
                      subnet_plugin_dict['id'])
     # First destroy the subnet and then destroy 
     # the network
     self.tearDownSubnet(context, subnet_created['id'])
     self.tearDownNetwork(context, network_created['id'])
     LOG.debug("test_create_subnet - END\n")
示例#44
0
    def test_delete_port_profile(self):
        LOG.debug("UCSVICTestPlugin:test_delete_port_profile() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
        self._cisco_ucs_plugin._set_ucsm(self.device_ip)
        self._cisco_ucs_plugin._create_port_profile(
                                self.tenant_id, new_network[const.UUID],
                                new_port[const.UUID], self.vlan_name,
                                self.vlan_id)
        profile_name = self._cisco_ucs_plugin.\
                            _get_profile_name(new_port[const.UUID])

        counter1 = self._cisco_ucs_plugin._port_profile_counter
        self._cisco_ucs_plugin._delete_port_profile(new_port[const.UUID],
                                                    profile_name)
        counter2 = self._cisco_ucs_plugin._port_profile_counter
        self.assertEqual(counter1 - 1, counter2)
示例#45
0
 def test_get_network_details(self):
     """
     Tests the deletion the Virtual Network belonging to a the
     spec
     """
     LOG.debug("UCSVICTestPlugin:test_get_network_details() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     new_net_dict = self._cisco_ucs_plugin.get_network_details(
         self.tenant_id, new_network[const.UUID],
         device_ip=self.device_ip)
     self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
     self.assertEqual(new_net_dict[const.NET_NAME],
                      new_network[const.NETWORKNAME])
     self.tear_down_network(self.tenant_id, new_network[const.UUID])
示例#46
0
 def test_get_network_details(self):
     """
     Tests the deletion the Virtual Network belonging to a the
     spec
     """
     LOG.debug("UCSVICTestPlugin:test_get_network_details() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_net_dict = self._cisco_ucs_plugin.create_network(
         self.tenant_id, new_network[const.NETWORKNAME],
         new_network[const.UUID], self.vlan_name, self.vlan_id,
         device_ip=self.device_ip)
     new_net_dict = self._cisco_ucs_plugin.get_network_details(
         self.tenant_id, new_network[const.UUID],
         device_ip=self.device_ip)
     self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
     self.assertEqual(new_net_dict[const.NET_NAME],
                      new_network[const.NETWORKNAME])
     self.tear_down_network(self.tenant_id, new_network[const.UUID])
示例#47
0
    def test_create_network(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_create_network - START")

        # Create the network in the test DB, then with the model
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        networks = self._l2network_multiblade.create_network([
            tenant_id,
            net_name,
            self.net_id,
            vlan_name(self.net_id),
            vlan_id,
        ])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        for network in networks:
            self.assertEqual(network[const.NET_ID], self.net_id)
            self.assertEqual(network[const.NET_NAME], net_name)

        LOG.debug("test_create_network - END")
示例#48
0
 def create_vlan_binding(self, vlan_id, vlan_name, network_id):
     """Create a vlan binding."""
     vlan_dict = {}
     try:
         res = l2network_db.add_vlan_binding(vlan_id, vlan_name, network_id)
         LOG.debug("Created vlan binding for vlan: %s" % res.vlan_id)
         vlan_dict["vlan-id"] = str(res.vlan_id)
         vlan_dict["vlan-name"] = res.vlan_name
         vlan_dict["net-id"] = str(res.network_id)
         return vlan_dict
     except Exception as exc:
         LOG.error("Failed to create vlan binding: %s" % str(exc))
    def test_plug_interface(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_plug_interface - START")
        self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
        self._l2network_multiblade.create_network([
            tenant_id, net_name, self.net_id,
            vlan_name(self.net_id), vlan_id
        ])
        cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)

        self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
        self._l2network_multiblade.create_port(
            [tenant_id, self.net_id, port_state, self.port_id])

        interface = self._l2network_multiblade.plug_interface(
            [tenant_id, self.net_id, self.port_id, interface_id])
        port = db.port_set_attachment(self.net_id, self.port_id, interface_id)

        self.assertEqual(self.port_id, interface[0][const.PORTID])
        self.assertEqual(port[const.INTERFACEID], interface_id)
        LOG.debug("test_plug_interface - END")
示例#50
0
 def test_create_port_profile(self):
     """
     Tests creation of port profile
     """
     LOG.debug("UCSVICTestPlugin:test_create_port_profile() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
     self._cisco_ucs_plugin._set_ucsm(self.device_ip)
     new_port_profile = self._cisco_ucs_plugin._create_port_profile(
         self.tenant_id, new_network[const.UUID], new_port[const.UUID],
         self.vlan_name, self.vlan_id)
     profile_name = self._cisco_ucs_plugin.\
                         _get_profile_name(new_port[const.UUID])
     self.assertEqual(new_port_profile[const.PROFILE_NAME], profile_name)
     self.assertEqual(new_port_profile[const.PROFILE_VLAN_NAME],
                      self.vlan_name)
     self.assertEqual(new_port_profile[const.PROFILE_VLAN_ID], self.vlan_id)
     self._cisco_ucs_plugin._delete_port_profile(new_port[const.UUID],
                                                 profile_name)
示例#51
0
 def create_vlan_binding(self, vlan_id, vlan_name, network_id):
     """Create a vlan binding"""
     vlan_dict = {}
     try:
         res = l2network_db.add_vlan_binding(vlan_id, vlan_name, network_id)
         LOG.debug("Created vlan binding for vlan: %s" % res.vlan_id)
         vlan_dict["vlan-id"] = str(res.vlan_id)
         vlan_dict["vlan-name"] = res.vlan_name
         vlan_dict["net-id"] = str(res.network_id)
         return vlan_dict
     except Exception, exc:
         LOG.error("Failed to create vlan binding: %s" % str(exc))
示例#52
0
    def test_delete_port_PortNotFound(self):
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_net_dict = self._cisco_ucs_plugin.create_network(
                self.tenant_id, new_network[const.NETWORKNAME],
                new_network[const.UUID], self.vlan_name, self.vlan_id,
                device_ip=self.device_ip)

        self.assertRaises(c_exc.PortVnicNotFound,
                          self._cisco_ucs_plugin.delete_port,
                          self.tenant_id, new_net_dict[const.NET_ID],
                          self.port_id, device_ip=self.device_ip,
                          ucs_inventory=self._ucs_inventory,
                          chassis_id=self.chassis_id, blade_id=self.blade_id,
                          blade_intf_distinguished_name=self.\
                          blade_intf_distinguished_name,
                          least_rsvd_blade_dict=self._ucs_inventory.\
                          _get_least_reserved_blade())

        self.tearDownNetwork(self.tenant_id, new_net_dict[const.NET_ID])
示例#53
0
 def test_create_port_profile(self):
     """
     Tests creation of port profile
     """
     LOG.debug("UCSVICTestPlugin:test_create_port_profile() called\n")
     new_network = db.network_create(self.tenant_id, self.net_name)
     cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                          new_network[const.UUID])
     new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
     self._cisco_ucs_plugin._set_ucsm(self.device_ip)
     new_port_profile = self._cisco_ucs_plugin._create_port_profile(
         self.tenant_id, new_network[const.UUID],
         new_port[const.UUID], self.vlan_name,
         self.vlan_id)
     profile_name = (
         self._cisco_ucs_plugin._get_profile_name(new_port[const.UUID]))
     self.assertEqual(new_port_profile[const.PROFILE_NAME], profile_name)
     self.assertEqual(new_port_profile[const.PROFILE_VLAN_NAME],
                      self.vlan_name)
     self.assertEqual(new_port_profile[const.PROFILE_VLAN_ID], self.vlan_id)
     self._cisco_ucs_plugin._delete_port_profile(new_port[const.UUID],
                                                 profile_name)
示例#54
0
    def test_delete_port_profile(self):
        """
        Tests deletion of port profile
        """
        LOG.debug("UCSVICTestPlugin:test_delete_port_profile() called\n")
        new_network = db.network_create(self.tenant_id, self.net_name)
        cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
                             new_network[const.UUID])
        new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
        self._cisco_ucs_plugin._set_ucsm(self.device_ip)
        self._cisco_ucs_plugin._create_port_profile(
            self.tenant_id, new_network[const.UUID],
            new_port[const.UUID], self.vlan_name,
            self.vlan_id)
        profile_name = (
            self._cisco_ucs_plugin._get_profile_name(new_port[const.UUID]))

        counter1 = self._cisco_ucs_plugin._port_profile_counter
        self._cisco_ucs_plugin._delete_port_profile(new_port[const.UUID],
                                                    profile_name)
        counter2 = self._cisco_ucs_plugin._port_profile_counter
        self.assertEqual(counter1 - 1, counter2)
示例#55
0
    def test_create_network(self,
                            net_tenant_id=None,
                            network_name=None,
                            net_vlan_name=None,
                            net_vlan_id=None):
        """
        Tests creation of new Virtual Network.
        """

        LOG.debug("test_create_network - START")
        if net_tenant_id:
            tenant_id = net_tenant_id
        else:
            tenant_id = self.tenant_id
        if network_name:
            net_name = network_name
        else:
            net_name = self.net_name
        if net_vlan_name:
            vlan_name = net_vlan_name
        else:
            vlan_name = self.vlan_name
        if net_vlan_id:
            vlan_id = net_vlan_id
        else:
            vlan_id = self.vlan_id

        network_created = self.create_network(tenant_id, net_name)
        cdb.add_vlan_binding(vlan_id, vlan_name, network_created["net-id"])
        new_net_dict = self._cisco_nexus_plugin.create_network(
            tenant_id, net_name, network_created["net-id"], vlan_name, vlan_id)
        self.assertEqual(new_net_dict[const.NET_ID], network_created["net-id"])
        self.assertEqual(new_net_dict[const.NET_NAME], self.net_name)
        self.assertEqual(new_net_dict[const.NET_VLAN_NAME], self.vlan_name)
        self.assertEqual(new_net_dict[const.NET_VLAN_ID], self.vlan_id)
        self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
        LOG.debug("test_create_network - END")