'Handles deallocating floating IP resources for an instance.
calls super class deallocate_for_instance() as well.
rpc.called by network_api'

def deallocate_for_instance(self, context, **kwargs):

    if ('instance' in kwargs):
        instance_uuid = kwargs['instance'].uuid
    else:
        instance_uuid = kwargs['instance_id']
        if (not uuidutils.is_uuid_like(instance_uuid)):
            instance = objects.Instance.get_by_id(context.elevated(read_deleted='yes'), instance_uuid)
            instance_uuid = instance.uuid
    try:
        fixed_ips = objects.FixedIPList.get_by_instance_uuid(context, instance_uuid)
    except exception.FixedIpNotFoundForInstance:
        fixed_ips = []
    kwargs['fixed_ips'] = fixed_ips
    for fixed_ip in fixed_ips:
        fixed_id = fixed_ip.id
        floating_ips = objects.FloatingIPList.get_by_fixed_ip_id(context, fixed_id)
        for floating_ip in floating_ips:
            address = str(floating_ip.address)
            try:
                self.disassociate_floating_ip(context, address, affect_auto_assigned=True)
            except exception.FloatingIpNotAssociated:
                LOG.info(_LI('Floating    IP    %s    is    not    associated.    Ignore.'), address)
            if floating_ip.auto_assigned:
                self.deallocate_floating_ip(context, address, affect_auto_assigned=True)
    super(FloatingIP, self).deallocate_for_instance(context, **kwargs)
