def name_from_doc(doc):
    """Find the string identifier for a doc."""
    if 'name' in doc:
        return doc['name']

    # Special case for node without a name, their name defaults to their hostname
    if set(doc.keys()) == {'hostname'}:
        return doc['hostname']

    if set(doc.keys()) == {'nodes'}:
        raise ValueError("Please create a name for NodePool %s" % doc)

    raise ValueError("Could not find a name for %s" % doc)