Fix error at some openstacks getting floating ip for neutron port 89/6289/4
authortierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 20 Jun 2018 08:44:32 +0000 (10:44 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 20 Jun 2018 11:16:30 +0000 (13:16 +0200)
Change-Id: I7b0706098db372e80c310ff7f8a545755d1fbdc4

openmanod
osm_ro/vimconn_openstack.py

index b2a4b6d..4f30888 100755 (executable)
--- a/openmanod
+++ b/openmanod
@@ -48,8 +48,8 @@ import osm_ro
 
 __author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
 __date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.5.67-r577"
-version_date = "May 2018"
+__version__ = "0.5.68-r578"
+version_date = "Jun 2018"
 database_version = 31      # expected database schema version
 
 
index 35aed88..43fdbc5 100644 (file)
@@ -1401,7 +1401,7 @@ class vimconnector(vimconn.vimconnector):
                 #get interfaces
                 try:
                     self._reload_connection()
-                    port_dict=self.neutron.list_ports(device_id=vm_id)
+                    port_dict = self.neutron.list_ports(device_id=vm_id)
                     for port in port_dict["ports"]:
                         interface={}
                         try:
@@ -1435,16 +1435,20 @@ class vimconnector(vimconn.vimconnector):
                             interface["vlan"] = network['network'].get('provider:segmentation_id')
                         ips=[]
                         #look for floating ip address
-                        floating_ip_dict = self.neutron.list_floatingips(port_id=port["id"])
-                        if floating_ip_dict.get("floatingips"):
-                            ips.append(floating_ip_dict["floatingips"][0].get("floating_ip_address") )
+                        try:
+                            floating_ip_dict = self.neutron.list_floatingips(port_id=port["id"])
+                            if floating_ip_dict.get("floatingips"):
+                                ips.append(floating_ip_dict["floatingips"][0].get("floating_ip_address") )
+                        except Exception:
+                            pass
 
                         for subnet in port["fixed_ips"]:
                             ips.append(subnet["ip_address"])
                         interface["ip_address"] = ";".join(ips)
                         vm["interfaces"].append(interface)
                 except Exception as e:
-                    self.logger.error("Error getting vm interface information " + type(e).__name__ + ": "+  str(e))
+                    self.logger.error("Error getting vm interface information {}: {}".format(type(e).__name__, e),
+                                      exc_info=True)
             except vimconn.vimconnNotFoundException as e:
                 self.logger.error("Exception getting vm status: %s", str(e))
                 vm['status'] = "DELETED"