- ips = IPNetwork(cidr)
- if "dhcp_first_ip" not in network:
- network["dhcp_first_ip"] = str(ips[2])
- if "dhcp_last_ip" not in network:
- network["dhcp_last_ip"] = str(ips[-2])
- if "gateway_ip" not in network:
- network["gateway_ip"] = str(ips[1])
+ # check valid params
+ net_provider = network.get('provider', network_old[0]['provider'])
+ net_type = network.get('type', network_old[0]['type'])
+ net_bind_net = network.get("bind_net")
+ net_bind_type = network.get("bind_type")
+ if net_bind_net:
+ # look for a valid net
+ if self._check_valid_uuid(net_bind_net):
+ net_bind_key = "uuid"
+ else:
+ net_bind_key = "name"
+ result, content = self.db.get_table(FROM='nets', WHERE={net_bind_key: net_bind_net})
+ if result < 0:
+ raise ovimException('Getting nets from db ' + content, HTTP_Internal_Server_Error)
+ elif result == 0:
+ raise ovimException("bind_net %s '%s'not found" % (net_bind_key, net_bind_net), HTTP_Bad_Request)
+ elif result > 1:
+ raise ovimException("More than one bind_net %s '%s' found, use uuid" % (net_bind_key, net_bind_net),
+ HTTP_Bad_Request)
+ network["bind_net"] = content[0]["uuid"]
+ if net_bind_type:
+ if net_bind_type[0:5] != "vlan:":
+ raise ovimException("Bad format for 'bind_type', must be 'vlan:<tag>'", HTTP_Bad_Request)
+ if int(net_bind_type[5:]) > 4095 or int(net_bind_type[5:]) <= 0:
+ raise ovimException("bad format for 'bind_type', must be 'vlan:<tag>' with a tag between 1 and 4095",
+ HTTP_Bad_Request)
+ if net_provider:
+ if net_provider[:9] == "openflow:":
+ if net_type != "ptp" and net_type != "data":
+ raise ovimException("Only 'ptp' or 'data' net types can be bound to 'openflow'", HTTP_Bad_Request)
+ else:
+ if net_type != "bridge_man" and net_type != "bridge_data":
+ raise ovimException("Only 'bridge_man' or 'bridge_data' net types can be bound to "
+ "'bridge', 'macvtap' or 'default", HTTP_Bad_Request)