def output_ip(gandi, ip, datacenters, vms, ifaces, output_keys, justify=11):
    """ Helper to output an ip information."""
    output_generic(gandi, ip, output_keys, justify)

    if 'type' in output_keys:
        iface = ifaces.get(ip['iface_id'])
        type_ = 'private' if iface.get('vlan') else 'public'
        output_line(gandi, 'type', type_, justify)
        if type_ == 'private':
            output_line(gandi, 'vlan', iface['vlan']['name'], justify)

    if 'vm' in output_keys:
        iface = ifaces.get(ip['iface_id'])
        vm_id = iface.get('vm_id')
        if vm_id:
            vm_name = vms.get(vm_id, {}).get('hostname')
            if vm_name:
                output_line(gandi, 'vm', vm_name, justify)

    if 'dc' in output_keys:
        for dc in datacenters:
            if dc['id'] == ip.get('datacenter_id',
                                  ip.get('datacenter', {}).get('id')):
                dc_name = dc.get('dc_code', dc.get('iso', ''))
                break

        output_line(gandi, 'datacenter', dc_name, justify)
Helper to output an ip information.