Generates input for the ``network_mode`` of a Docker host configuration. If it points at a container, the
    configuration of the container is returned.

    :param value: Network mode input.
    :type value: unicode | str | tuple | list | NoneType
    :return: Network mode or container to re-use the network stack of.
    :rtype: unicode | str | tuple | NoneType

def get_network_mode(value):
    """
    Generates input for the ``network_mode`` of a Docker host configuration. If it points at a container, the
    configuration of the container is returned.

    :param value: Network mode input.
    :type value: unicode | str | tuple | list | NoneType
    :return: Network mode or container to re-use the network stack of.
    :rtype: unicode | str | tuple | NoneType
    """
    if not value or value == 'disabled':
        return 'none'
    if isinstance(value, (tuple, list)):
        if len(value) == 2:
            return tuple(value)
        return ValueError("Tuples or lists need to have length 2 for container network references.")
    if value in DEFAULT_PRESET_NETWORKS:
        return value
    if value.startswith('container:'):
        return value
    if value.startswith('/'):
        return 'container:{0}'.format(value[1:])
    ref_name, __, ref_instance = value.partition('.')
    return ref_name, ref_instance or None