From 46e5c83c8820dbc552d8aff3396565e4e0cf501c Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Wed, 30 Jan 2013 16:07:46 +0800 Subject: [PATCH] Fixes if statement inefficiency in quantum.agent.linux.interface Changed logic of checking the existance of a port value Change-Id: Id06447a753fd0201ef44a047657bd747ce18d546 --- quantum/agent/linux/interface.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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']) -- 2.45.2