'Retrieve internal port data for floating IP.
Retrieve information concerning the internal port where
the floating IP should be associated to.'

def _internal_fip_assoc_data(self, context, fip, tenant_id):

    internal_port = self._core_plugin.get_port(context, fip['port_id'])
    if ((internal_port['tenant_id'] != tenant_id) and (not context.is_admin)):
        port_id = fip['port_id']
        msg = (_('Cannot    process    floating    IP    association    with    Port    %s,    since    that    port    is    owned    by    a    different    tenant') % port_id)
        raise n_exc.BadRequest(resource='floatingip', msg=msg)
    internal_subnet_id = None
    if fip.get('fixed_ip_address'):
        internal_ip_address = fip['fixed_ip_address']
        if (netaddr.IPAddress(internal_ip_address).version != 4):
            msg = (_('Cannot    process    floating    IP    association    with    %s,    since    that    is    not    an    IPv4    address') % internal_ip_address)
            raise n_exc.BadRequest(resource='floatingip', msg=msg)
        for ip in internal_port['fixed_ips']:
            if (ip['ip_address'] == internal_ip_address):
                internal_subnet_id = ip['subnet_id']
        if (not internal_subnet_id):
            msg = (_('Port    %(id)s    does    not    have    fixed    ip    %(address)s') % {'id': internal_port['id'], 'address': internal_ip_address})
            raise n_exc.BadRequest(resource='floatingip', msg=msg)
    else:
        ipv4_fixed_ips = self._port_ipv4_fixed_ips(internal_port)
        if (not ipv4_fixed_ips):
            msg = (_('Cannot    add    floating    IP    to    port    %s    that    has    no    fixed    IPv4    addresses') % internal_port['id'])
            raise n_exc.BadRequest(resource='floatingip', msg=msg)
        if (len(ipv4_fixed_ips) > 1):
            msg = (_('Port    %s    has    multiple    fixed    IPv4    addresses.        Must    provide    a    specific    IPv4    address    when    assigning    a    floating    IP') % internal_port['id'])
            raise n_exc.BadRequest(resource='floatingip', msg=msg)
        internal_ip_address = ipv4_fixed_ips[0]['ip_address']
        internal_subnet_id = ipv4_fixed_ips[0]['subnet_id']
    return (internal_port, internal_subnet_id, internal_ip_address)
