Works around hpcloud's peculiar "all ip addresses are returned as private
    even though one is public" bug.  This is also what the official hpfog gem
    does in the ``Fog::Compute::HP::Server#public_ip_address`` method.

    :param dict server:  Contains the server ID, a list of public IP addresses,
        and a list of private IP addresses.

def fix_hp_addrs(server):
    """
    Works around hpcloud's peculiar "all ip addresses are returned as private
    even though one is public" bug.  This is also what the official hpfog gem
    does in the ``Fog::Compute::HP::Server#public_ip_address`` method.

    :param dict server:  Contains the server ID, a list of public IP addresses,
        and a list of private IP addresses.

    """
    fixed = {A.server.ID: server[A.server.ID]}
    both = server.get(A.server.PRIVATE_IPS)
    if both:
        fixed[A.server.PUBLIC_IPS] = [both[1]]
        fixed[A.server.PRIVATE_IPS] = [both[0]]
    return fixed