]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes if statement inefficiency in quantum.agent.linux.interface
authorZhongyue Luo <zhongyue.nah@intel.com>
Wed, 30 Jan 2013 08:07:46 +0000 (16:07 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Thu, 31 Jan 2013 01:42:11 +0000 (09:42 +0800)
Changed logic of checking the existance of a port value

Change-Id: Id06447a753fd0201ef44a047657bd747ce18d546

quantum/agent/linux/interface.py

index f5f62ab1a2f614801afe80573c93cca7d643a41e..1dc8e791ef3740bbcddf148e45d145bc7fc15a4b 100644 (file)
@@ -28,6 +28,7 @@ from quantum.openstack.common import cfg
 from quantum.openstack.common import importutils
 from quantum.openstack.common import log as logging
 
+
 LOG = logging.getLogger(__name__)
 
 OPTS = [
@@ -269,7 +270,7 @@ class MetaInterfaceDriver(LinuxInterfaceDriver):
         device = ip_lib.IPDevice(device_name, self.conf.root_helper, namespace)
         mac_address = device.link.address
         ports = self.quantum.list_ports(mac_address=mac_address)
-        if not 'ports' in ports or len(ports['ports']) < 1:
+        if not ports.get('ports'):
             raise Exception(_('No port for this device %s') % device_name)
         return self._get_driver_by_network_id(ports['ports'][0]['network_id'])