set network status to ACTIVE at service start 31/2031/1 v2.0.2
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 13 Jul 2017 15:50:59 +0000 (17:50 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 14 Jul 2017 08:30:23 +0000 (10:30 +0200)
Fix issue at database VM iface store

Change-Id: If282d2a0adb32adf34952362612364a3cb66d713
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_openvim/ovim.py
osm_openvim/vim_db.py

index 6317421..5650cd5 100755 (executable)
@@ -283,7 +283,7 @@ class ovim():
 
         for net in content:
             net_type = net['type']
-            if (net_type == 'bridge_data' or net_type == 'bridge_man') and \
+            if net['status'] != "INACTIVE" and (net_type == 'bridge_data' or net_type == 'bridge_man') and \
                     net["provider"][:4] == 'OVS:' and net["enable_dhcp"] == "true":
                 try:
                     config_routes = net.get('routes')
@@ -309,12 +309,15 @@ class ovim():
                                             dns,
                                             routes)
                     self.launch_link_bridge_to_ovs(net['vlan'], net.get('gateway_ip'), net.get('cidr'), links, routes)
+                    if net["status"] == "ERROR":
+                        self.db.update_rows("nets", UPDATE={"status": "ACTIVE", "last_error": None},
+                                            WHERE={"uuid": net["uuid"]})
                 except Exception as e:
                     self.logger.error("Fail at launching dhcp server for net_id='%s' net_name='%s': %s",
                                       net["uuid"], net["name"], str(e))
-                    self.db.update_rows("nets", {"status": "ERROR",
+                    self.db.update_rows("nets", UPDATE={"status": "ERROR",
                                                  "last_error": "Fail at launching dhcp server: " + str(e)},
-                                        {"uuid": net["uuid"]})
+                                        WHERE={"uuid": net["uuid"]})
 
     def _start_of_db_tasks(self):
         """
index 0c2d9f1..355bbac 100644 (file)
@@ -1428,9 +1428,12 @@ class vim_db():
                             used_dhcp_ips = self._get_dhcp_ip_used_list(iface["net_id"])
                             iface["ip_address"] = self.get_free_ip_from_range(dhcp_first_ip, dhcp_last_ip,
                                                                               dhcp_cidr, used_dhcp_ips)
-                            del iface['links']
-                            del iface['dns']
-                            del iface['routes']
+                            if 'links' in iface:
+                                del iface['links']
+                            if 'dns' in iface:
+                                del iface['dns']
+                            if 'routes' in iface:
+                                del iface['routes']
 
                         iface['uuid'] = str(myUuid.uuid1()) # create_uuid
                         cmd = "INSERT INTO uuids (uuid, root_uuid, used_at) VALUES ('%s','%s', 'ports')" % (iface['uuid'], uuid)