'Return port_id from a fixed address.'

def _get_port_id_by_fixed_address(self, client, instance, address):

    zone = ('compute:%s' % instance.availability_zone)
    search_opts = {'device_id': instance.uuid, 'device_owner': zone}
    data = client.list_ports(**search_opts)
    ports = data['ports']
    port_id = None
    for p in ports:
        for ip in p['fixed_ips']:
            if (ip['ip_address'] == address):
                port_id = p['id']
                break
    if (not port_id):
        raise exception.FixedIpNotFoundForAddress(address=address)
    return port_id
