'Get the proper dhcp address to listen on.'

@utils.synchronized('get_dhcp')
def _get_dhcp_ip(self, context, network_ref, host=None):

    if self._uses_shared_ip(network_ref):
        return (network_ref.get('dhcp_server') or network_ref['gateway'])
    if (not host):
        host = self.host
    network_id = network_ref['id']
    try:
        fip = objects.FixedIP.get_by_network_and_host(context, network_id, host)
        return fip.address
    except exception.FixedIpNotFoundForNetworkHost:
        elevated = context.elevated()
        fip = objects.FixedIP.associate_pool(elevated, network_id, host=host)
        return fip.address
