From 5f033726663e1d8c6cc5cb03c82c65fe6e31c035 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Tue, 30 Aug 2011 21:06:34 -0700 Subject: [PATCH] More fixes for multi-nic support. --- quantum/plugins/cisco/README | 63 +++++++++++++++---- quantum/plugins/cisco/l2network_plugin.py | 13 +++- .../cisco/tests/unit/test_l2networkApi.py | 3 +- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/quantum/plugins/cisco/README b/quantum/plugins/cisco/README index 29ebea720..83512d16f 100755 --- a/quantum/plugins/cisco/README +++ b/quantum/plugins/cisco/README @@ -40,8 +40,7 @@ If you plan to just leverage the plugin framework, you do not need these.) * One or more UCS B200 series blade servers with M81KR VIC (aka Palo adapters) installed. * UCSM 2.0 (Capitola) Build 230 or above. -* OpenStack Cactus release installation (additional patch is required, - details follow in this document) +* OpenStack Diablo D3 or later (should have VIF-driver support) * RHEL 6.1 (as of this writing, UCS only officially supports RHEL, but it should be noted that Ubuntu support is planned in coming releases as well) ** Package: python-configobj-4.6.0-3.el6.noarch (or newer) @@ -116,7 +115,17 @@ provider = quantum.plugins.cisco.l2network_plugin.L2Network --quantum_port=9696 --libvirt_vif_driver=quantum.plugins.cisco.nova.vifdirect.Libvirt802dot1QbhDriver --libvirt_vif_type=802.1Qbh - + + Note: To be able to bring up a VM on a UCS blade, you should first create a + port for that VM using the Quantum create port API. VM creation will + fail if an unused port is not available. If you have configured your + Nova project with more than one network, Nova will attempt to instantiate + the VM with one network interface (VIF) per configured network. To provide + plugin points for each of these VIFs, you will need to create multiple + Quantum ports, one for each of the networks, prior to starting the VM. + However, in this case you will need to use the Cisco multiport extension + API instead of the Quantum create port API. More details on using the + multiport extension follow in the section on mutli NIC support. 4. If you want to turn on support for Cisco Nexus switches: 4a. Uncomment the nexus_plugin property in @@ -152,11 +161,11 @@ name=quantum.plugins.cisco.nexus.cisco_nexus_network_driver.CiscoNEXUSDriver this step and remove the old hostkey from ~/.ssh/known_hosts. 5. Plugin Persistence framework setup: - 5a. Create quantum_l2network database in mysql with the following command - + 5a. Create quantum_l2network database in mysql with the following command - mysql -u -p -e "create database quantum_l2network" - 5b. Enter the quantum_l2network database configuration info in the + 5b. Enter the quantum_l2network database configuration info in the quantum/plugins/cisco/conf/db_conn.ini file. 5c. If there is a change in the plugin configuration, service would need @@ -175,12 +184,6 @@ mysql -u -p -e "create database quantum_l2network" username=admin password=mySecretPasswordForUCSM -# Provide the Nova DB credentials. -# The IP address should be the same as in nova.ini. -[10.0.0.3] -username=nova -password=mySecretPasswordForNova - # Provide the Nexus credentials, if you are using Nexus switches. # If not this will be ignored. [10.0.0.1] @@ -191,7 +194,7 @@ password=mySecretPasswordForNexus quantum/plugins/cisco/conf/ucs_inventory.ini file. You can configure multiple UCSMs per deployment, multiple chassis per UCSM, and multiple blades per chassis. Chassis ID and blade ID can be obtained from the UCSM (they will - typically numbers like 1, 2, 3, etc. + typically be numbers like 1, 2, 3, etc.) [ucsm-1] ip_address = @@ -224,6 +227,42 @@ host_name = Once you've put right what once went wrong, leap on. +Using the Command Line Client to work with this Plugin +------------------------------------------------------ +A command line client is packaged with this plugin. This module can be used +to invoke the core API as well as the extensions API, so that you don't have +to switch between different CLI modules (it internally invokes the Quantum +CLI module for the core APIs to ensure consistency when using either). This +command line client can be invoked as follows: + +PYTHONPATH=. python quantum/plugins/cisco/client/cli.py + + +Multi NIC support for VMs +------------------------- +As indicated earlier, if your Nova setup has a project with more than one network, +Nova will try to create a network interface (VIF) on the VM for each of those +networks. That in turn implies that you should have created Quantum ports for each +of those VIFs. These ports need to be using the following rest call: + +POST /v1.0/extensions/csco/tenants/{tenant_id}/multiport/ + +with request body: + +{'multiport': + {'status': 'ACTIVE', + 'net_id_list': net_id_list, + 'ports_desc': {'key': 'value'}}} + +where, + +net_id_list is a list of network IDs: [netid1, netid2, ...] + +The corresponding CLI for this operation is as follows: + +PYTHONPATH=. python quantum/plugins/cisco/client/cli.py create_multiport + + How to test the installation ---------------------------- The unit tests are located at quantum/plugins/cisco/tests/unit. They can be diff --git a/quantum/plugins/cisco/l2network_plugin.py b/quantum/plugins/cisco/l2network_plugin.py index 218d369ff..dfd05b39c 100644 --- a/quantum/plugins/cisco/l2network_plugin.py +++ b/quantum/plugins/cisco/l2network_plugin.py @@ -251,9 +251,16 @@ class L2Network(QuantumPluginBase): """ LOG.debug("plug_interface() called\n") network = db.network_get(net_id) - self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, - port_id, - remote_interface_id]) + port = db.port_get(net_id, port_id) + attachment_id = port[const.INTERFACEID] + if attachment_id and remote_interface_id != attachment_id: + raise exc.PortInUse(port_id=port_id, net_id=net_id, + att_id=attachment_id) + self._invoke_device_plugins(self._func_name(), [tenant_id, + net_id, port_id, + remote_interface_id]) + if attachment_id == None: + db.port_set_attachment(net_id, port_id, remote_interface_id) #Note: The remote_interface_id gets associated with the port # when the VM is instantiated. The plug interface call results # in putting the port on the VLAN associated with this network diff --git a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py index 901da1b8a..7b4bfac73 100644 --- a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py +++ b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py @@ -506,13 +506,14 @@ class CoreAPITestFunc(unittest.TestCase): """ LOG.debug("test_plug_interface_portInUse - START") + current_interface = "current_interface" new_net_dict = self._l2network_plugin.create_network( tenant_id, self.network_name) port_dict = self._l2network_plugin.create_port( tenant_id, new_net_dict[const.NET_ID], self.port_state) self._l2network_plugin.plug_interface( tenant_id, new_net_dict[const.NET_ID], - port_dict[const.PORT_ID], remote_interface) + port_dict[const.PORT_ID], current_interface) self.assertRaises(exc.PortInUse, self._l2network_plugin.plug_interface, tenant_id, new_net_dict[const.NET_ID], -- 2.45.2