def expand(host):
    """ expand the host (be it a single name or a dotted field).
    It should be possible to run the unalias or expand in either order and get the
    same result.

    For example:
       mongod             --> mongod.0.public_ip
       mongod.0           --> mongod.0.public_ip
       mongod.0.public_ip --> mongod.0.public_ip

       md                 --> md.0.public_ip
       md.0               --> md.0.public_ip
       md.0.public_ip     --> md.0.public_ip

    :param host str the (optionally) dotted host spec.

    :returns str the expanded version of the dotted name
    :raises ValueError if there are more than 2 dot's
    """

    nesting = host.count(".") + 1
    if nesting > 3:
        raise ValueError("The max level of nesting is 3: '{}'".format(host))

    if nesting == 1:
        host += ".0.public_ip"
    if nesting == 2:
        host += ".public_ip"

    return host