'Associate a floating IP with a fixed IP.'

@base_api.refresh_cache
def associate_floating_ip(self, context, instance, floating_address, fixed_address, affect_auto_assigned=False):

    client = get_client(context)
    port_id = self._get_port_id_by_fixed_address(client, instance, fixed_address)
    fip = self._get_floating_ip_by_address(client, floating_address)
    param = {'port_id': port_id, 'fixed_ip_address': fixed_address}
    try:
        client.update_floatingip(fip['id'], {'floatingip': param})
    except neutron_client_exc.Conflict as e:
        raise exception.FloatingIpAssociateFailed(six.text_type(e))
    if fip['port_id']:
        port = self._show_port(context, fip['port_id'], neutron_client=client)
        orig_instance_uuid = port['device_id']
        msg_dict = dict(address=floating_address, instance_id=orig_instance_uuid)
        LOG.info(_LI('re-assign    floating    IP    %(address)s    from    instance    %(instance_id)s'), msg_dict, instance=instance)
        orig_instance = objects.Instance.get_by_uuid(context, orig_instance_uuid)
        base_api.update_instance_cache_with_nw_info(self, context, orig_instance)
