Create a new node and generate a token for it

def add(node_name, **kwargs):
    """ Create a new node and generate a token for it """
    result = {}
    kwargs = kwargs.copy()
    overwrite = kwargs.pop('overwrite', False)
    node = nago.core.get_node(node_name)
    if not node:
        node = nago.core.Node()
    elif not overwrite:
        result['status'] = 'error'
        result['message'] = "node %s already exists. add argument overwrite=1 to overwrite it." % (node_name)
        return result
    else:
        node.delete()
        node = nago.core.Node()
    node['host_name'] = node_name
    for k, v in kwargs.items():
        node[k] = v
    node.save()
    result['message'] = "node successfully saved"
    result['node_data'] = node.data
    return result