From: tierno Date: Thu, 13 Jul 2017 15:50:59 +0000 (+0200) Subject: set network status to ACTIVE at service start X-Git-Tag: v2.0.2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=8e74f67347a8b37517b040194464757a46f9996a;p=osm%2Fopenvim.git set network status to ACTIVE at service start Fix issue at database VM iface store Change-Id: If282d2a0adb32adf34952362612364a3cb66d713 Signed-off-by: tierno --- diff --git a/osm_openvim/ovim.py b/osm_openvim/ovim.py index 6317421..5650cd5 100755 --- a/osm_openvim/ovim.py +++ b/osm_openvim/ovim.py @@ -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): """ diff --git a/osm_openvim/vim_db.py b/osm_openvim/vim_db.py index 0c2d9f1..355bbac 100644 --- a/osm_openvim/vim_db.py +++ b/osm_openvim/vim_db.py @@ -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)