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")
예제 #2
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])
예제 #3
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])
예제 #4
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])
예제 #5
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])
예제 #6
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])
    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")
예제 #8
0
    def create_port(self, tenant_id, net_id, port_state=None, **kwargs):
        """
        Creates a port on the specified Virtual Network.
        """
        LOG.debug("create_port() called\n")

        port = db.port_create(net_id, port_state)
        unique_port_id_string = port[const.UUID]
        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, port_state, unique_port_id_string])
        new_port_dict = cutil.make_port_dict(
            port[const.UUID], port[const.PORTSTATE], port[const.NETWORKID], port[const.INTERFACEID]
        )
        return new_port_dict
예제 #9
0
 def create_port(self, net_id):
     """Add a port"""
     port_dict = {}
     try:
         port = db.port_create(net_id)
         LOG.debug("Creating port %s" % port.uuid)
         port_dict["port-id"] = str(port.uuid)
         port_dict["net-id"] = str(port.network_id)
         port_dict["int-id"] = port.interface_id
         port_dict["state"] = port.state
         return port_dict
     except Exception, exc:
         LOG.error("Failed to create port: %s" % str(exc))
예제 #10
0
    def test_create_port(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_create_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
        ])

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

        self.assertEqual(self.port_id, port[0][const.PORTID])
        LOG.debug("test_create_port - END")
예제 #11
0
    def create_port(self, tenant_id, net_id, port_state=None, **kwargs):
        """
        Creates a port on the specified Virtual Network.
        """
        LOG.debug("create_port() called\n")

        port = db.port_create(net_id, port_state)
        unique_port_id_string = port[const.UUID]
        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
                                                     port_state,
                                                     unique_port_id_string])
        new_port_dict = cutil.make_port_dict(port[const.UUID],
                                             port[const.PORTSTATE],
                                             port[const.NETWORKID],
                                             port[const.INTERFACEID])
        return new_port_dict
예제 #12
0
    def test_unplug_interface(self,
                              remote_interface_id=None,
                              new_vlanid=10,
                              new_vlan_name='new_vlan'):
        """
        Tests whether remote interface detaches from the specified port on the
        specified Virtual Network.
        """
        LOG.debug("UCSVICTestPlugin:_test_unplug_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)
        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)

        port_bind = self._cisco_ucs_plugin.unplug_interface(
            self.tenant_id,
            new_net_dict[const.NET_ID],
            port_dict[const.PORTID],
            device_ip=self.device_ip)
        self.assertEqual(port_bind[const.VLANNAME], self.vlan_name)
        self.assertEqual(port_bind[const.VLANID], self.vlan_id)
        self.tear_down_network_port_interface(self.tenant_id,
                                              new_net_dict[const.NET_ID],
                                              new_port[const.UUID])
    def test_plug_interface_networkDNE(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_plug_interface_networkDNE - 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.assertRaises(
            exc.NetworkNotFound,
            self._l2network_multiblade.plug_interface,
            [tenant_id, net_id, self.port_id, interface_id],
        )

        LOG.debug("test_plug_interface_networkDNE - END")
예제 #14
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])
예제 #15
0
    def create_multiport(self, tenant_id, net_id_list, port_state, ports_desc):
        """
        Creates multiple ports on the specified Virtual Network.
        """
        LOG.debug("create_ports() called\n")
        ports_num = len(net_id_list)
        ports_id_list = []
        ports_dict_list = []

        for net_id in net_id_list:
            port = db.port_create(net_id, port_state)
            ports_id_list.append(port[const.UUID])
            port_dict = {const.PORT_ID: port[const.UUID]}
            ports_dict_list.append(port_dict)

        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id_list, ports_num, ports_id_list])
        return ports_dict_list
예제 #16
0
    def test_create_port(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_create_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])

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

        self.assertEqual(self.port_id, port[0][const.PORTID])
        LOG.debug("test_create_port - END")
예제 #17
0
    def create_multiport(self, tenant_id, net_id_list, port_state, ports_desc):
        """
        Creates multiple ports on the specified Virtual Network.
        """
        LOG.debug("create_ports() called\n")
        ports_num = len(net_id_list)
        ports_id_list = []
        ports_dict_list = []

        for net_id in net_id_list:
            port = db.port_create(net_id, port_state)
            ports_id_list.append(port[const.UUID])
            port_dict = {const.PORT_ID: port[const.UUID]}
            ports_dict_list.append(port_dict)

        self._invoke_device_plugins(
            self._func_name(),
            [tenant_id, net_id_list, ports_num, ports_id_list])
        return ports_dict_list
예제 #18
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)
예제 #19
0
    def test_plug_interface_networkDNE(self):
        """Support for the Quantum core API call"""
        LOG.debug("test_plug_interface_networkDNE - 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.assertRaises(exc.NetworkNotFound,
                          self._l2network_multiblade.plug_interface,
                          [tenant_id, net_id, self.port_id, interface_id])

        LOG.debug("test_plug_interface_networkDNE - END")
예제 #20
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)
예제 #21
0
    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")
예제 #22
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)
예제 #23
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)
예제 #24
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])