'Remove a fixed IP from the instance.'

@base_api.refresh_cache
def remove_fixed_ip_from_instance(self, context, instance, address):

    neutron = get_client(context)
    zone = ('compute:%s' % instance.availability_zone)
    search_opts = {'device_id': instance.uuid, 'device_owner': zone, 'fixed_ips': ('ip_address=%s' % address)}
    data = neutron.list_ports(**search_opts)
    ports = data['ports']
    for p in ports:
        fixed_ips = p['fixed_ips']
        new_fixed_ips = []
        for fixed_ip in fixed_ips:
            if (fixed_ip['ip_address'] != address):
                new_fixed_ips.append(fixed_ip)
        port_req_body = {'port': {'fixed_ips': new_fixed_ips}}
        try:
            neutron.update_port(p['id'], port_req_body)
        except Exception as ex:
            msg = 'Unable    to    update    port    %(portid)s    with    failure:    %(exception)s'
            LOG.debug(msg, {'portid': p['id'], 'exception': ex}, instance=instance)
        return self._get_instance_nw_info(context, instance)
    raise exception.FixedIpNotFoundForSpecificInstance(instance_uuid=instance.uuid, ip=address)
