From 6bd6115b5f718bd888da6cf8b00bfb26b2ad3a01 Mon Sep 17 00:00:00 2001 From: Yichen Wang Date: Thu, 10 Sep 2015 14:13:23 -0700 Subject: [PATCH] Fix the traceback when checking on stale ports (Kilo) Change-Id: I2451ef79cc32cff5023bfbc8eaf56fddbff46ccb --- vmtp/network.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vmtp/network.py b/vmtp/network.py index 1625d1a..986f495 100644 --- a/vmtp/network.py +++ b/vmtp/network.py @@ -203,11 +203,13 @@ class Network(object): # Assumed that both management networks are created together so checking for one of them ports = self.neutron_client.list_ports()['ports'] for port in ports: - port_ip = port['fixed_ips'][0] - if (port['device_id'] == self.ext_router['id']) and \ - (port_ip['subnet_id'] == self.vm_int_net[0]['subnets'][0]): - print 'Ext router already associated to the internal network' - return + # Skip the check on stale ports + if port['fixed_ips']: + port_ip = port['fixed_ips'][0] + if (port['device_id'] == self.ext_router['id']) and \ + (port_ip['subnet_id'] == self.vm_int_net[0]['subnets'][0]): + print 'Ext router already associated to the internal network' + return for int_net in self.vm_int_net: body = {