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')
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):
"""
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)