'Set up the existing DHCP port, if there is one.'

def _setup_existing_dhcp_port(self, network, device_id, dhcp_subnets):

    port = None
    for port in network.ports:
        port_device_id = getattr(port, 'device_id', None)
        if (port_device_id == device_id):
            if self.driver.use_gateway_ips:
                return port
            break
    else:
        return None
    dhcp_enabled_subnet_ids = set(dhcp_subnets)
    port_subnet_ids = set((ip.subnet_id for ip in port.fixed_ips))
    if (dhcp_enabled_subnet_ids != port_subnet_ids):
        wanted_fixed_ips = []
        for fixed_ip in port.fixed_ips:
            if (fixed_ip.subnet_id in dhcp_enabled_subnet_ids):
                wanted_fixed_ips.append({'subnet_id': fixed_ip.subnet_id, 'ip_address': fixed_ip.ip_address})
        wanted_fixed_ips.extend((dict(subnet_id=s) for s in (dhcp_enabled_subnet_ids - port_subnet_ids)))
        port = self.plugin.update_dhcp_port(port.id, {'port': {'network_id': network.id, 'fixed_ips': wanted_fixed_ips}})
        if (not port):
            raise exceptions.Conflict()
    return port
