+ if ip_profile['dhcp']['enabled'] is True and ip_profile['dhcp']['start-address'] is None:
+ addr_pool = list(ipaddress.ip_network(ip_profile['subnet-address']).hosts())
+ gateway_ip_addr = ip_profile.get('gateway-address', None)
+ if gateway_ip_addr is None:
+ gateway_ip_addr = str(next(iter(addr_pool)))
+ ip_profile['gateway-address'] = gateway_ip_addr
+
+ self._log.debug("Gateway Address {}".format(gateway_ip_addr))
+
+ if ipaddress.ip_address(gateway_ip_addr) in addr_pool:
+ addr_pool.remove(ipaddress.ip_address(gateway_ip_addr))
+ if len(addr_pool) > 0:
+ ip_profile['dhcp']['start-address'] = str(next(iter(addr_pool)))
+ #DHCP count more than 200 is not instantiating any instances using OPENMANO RO
+ #So restricting it to a feasible count of 100.
+ dhcp_count = ip_profile['dhcp']['count']
+ if dhcp_count is None or dhcp_count == 0 or dhcp_count > len(addr_pool):
+ ip_profile['dhcp']['count'] = min(len(addr_pool), 100)
+ self._log.debug("DHCP start Address {} DHCP count {}".
+ format(ip_profile['dhcp']['start-address'], ip_profile['dhcp']['count']))