From: Zhongyue Luo Date: Wed, 30 Jan 2013 08:07:46 +0000 (+0800) Subject: Fixes if statement inefficiency in quantum.agent.linux.interface X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=46e5c83c8820dbc552d8aff3396565e4e0cf501c;p=openstack-build%2Fneutron-build.git Fixes if statement inefficiency in quantum.agent.linux.interface Changed logic of checking the existance of a port value Change-Id: Id06447a753fd0201ef44a047657bd747ce18d546 --- diff --git a/quantum/agent/linux/interface.py b/quantum/agent/linux/interface.py index f5f62ab1a..1dc8e791e 100644 --- a/quantum/agent/linux/interface.py +++ b/quantum/agent/linux/interface.py @@ -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'])