From: Aaron Rosen Date: Tue, 23 Apr 2013 20:23:17 +0000 (-0700) Subject: update-port error if port does not exist in nvp X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=31946ebb5d7748fada269bd867f0e6d6e02ef736;p=openstack-build%2Fneutron-build.git update-port error if port does not exist in nvp Previously the NVP plugin would query NVP for the quantum port id that was stored in the port as a tag in NVP. Later, a look up table was added in order to directly look up the ID without having to go to NVP. The problem that can arise is that if a port was created in folsom before this lookup table was added and then deleted from NVP directly an error will be raised when calling update_port(). This patch fixes this potential problem. Fixes bug 1172006 Change-Id: I08c74e305449f7fe32897abf43ceb430c959b02d --- diff --git a/quantum/plugins/nicira/QuantumPlugin.py b/quantum/plugins/nicira/QuantumPlugin.py index 52879c2a2..0b58a1f4e 100644 --- a/quantum/plugins/nicira/QuantumPlugin.py +++ b/quantum/plugins/nicira/QuantumPlugin.py @@ -1262,28 +1262,38 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2, LOG.warn(_("Update port request: %s"), port) nvp_port_id = self._nvp_get_port_id( context, self.cluster, ret_port) - nvplib.update_port(self.cluster, - ret_port['network_id'], - nvp_port_id, id, tenant_id, - ret_port['name'], ret_port['device_id'], - ret_port['admin_state_up'], - ret_port['mac_address'], - ret_port['fixed_ips'], - ret_port[psec.PORTSECURITY], - ret_port[ext_sg.SECURITYGROUPS], - ret_port[ext_qos.QUEUE]) + if nvp_port_id: + try: + nvplib.update_port(self.cluster, + ret_port['network_id'], + nvp_port_id, id, tenant_id, + ret_port['name'], ret_port['device_id'], + ret_port['admin_state_up'], + ret_port['mac_address'], + ret_port['fixed_ips'], + ret_port[psec.PORTSECURITY], + ret_port[ext_sg.SECURITYGROUPS], + ret_port[ext_qos.QUEUE]) + + # Update the port status from nvp. If we fail here hide it + # since the port was successfully updated but we were not + # able to retrieve the status. + ret_port['status'] = nvplib.get_port_status( + self.cluster, ret_port['network_id'], + nvp_port_id) + # FIXME(arosen) improve exception handling. + except Exception: + ret_port['status'] = constants.PORT_STATUS_ERROR + LOG.exception(_("Unable to update port id: %s."), + nvp_port_id) + + # If nvp_port_id is not in database or in nvp put in error state. + else: + ret_port['status'] = constants.PORT_STATUS_ERROR # remove since it will be added in extend based on policy del ret_port[ext_qos.QUEUE] self._extend_port_qos_queue(context, ret_port) - # Update the port status from nvp. If we fail here hide it since - # the port was successfully updated but we were not able to retrieve - # the status. - try: - ret_port['status'] = nvplib.get_port_status( - self.cluster, ret_port['network_id'], nvp_port_id) - except Exception: - LOG.warn(_("Unable to retrieve port status for:%s."), nvp_port_id) return ret_port def delete_port(self, context, id, l3_port_check=True,