예제 #1
0
def update_node(api, node_id, ou, collection_nodes):
    from gecoscc.models import Computer
    node = ChefNode(node_id, api)
    if not node.attributes.to_dict():
        return False
    try:
        computer_name = node.attributes.get_dotted('ohai_gecos.pclabel')
    except KeyError:
        computer_name = node_id
    comp_model = Computer()
    computer = comp_model.serialize({
        'path':
        '%s,%s' % (ou['path'], unicode(ou['_id'])),
        'name':
        computer_name,
        'type':
        'computer',
        'source':
        ou.get('source', SOURCE_DEFAULT),
        'node_chef_id':
        node_id
    })
    del computer['_id']
    node_id = collection_nodes.update({'node_chef_id': node_id}, computer)
    return node_id
예제 #2
0
def register_node(api, node_id, ou, collection_nodes):
    from gecoscc.models import Computer
    node = ChefNode(node_id, api)
    if not node.attributes.to_dict():
        return False
    try:
        computer_name = node.attributes.get_dotted('ohai_gecos.pclabel')
    except KeyError:
        computer_name = node_id
    comp_model = Computer()
    computer = comp_model.serialize({
        'path':
        '%s,%s' % (ou['path'], unicode(ou['_id'])),
        'name':
        computer_name,
        'type':
        'computer',
        'source':
        ou.get('source', SOURCE_DEFAULT),
        'node_chef_id':
        node_id
    })
    del computer['_id']
    if check_unique_node_name_by_type_at_domain(collection_nodes, computer):
        if collection_nodes.find_one({'node_chef_id': node_id}):
            return 'duplicated-node-id'
        node_id = collection_nodes.insert(computer)
        return node_id
    return 'duplicated'
예제 #3
0
파일: utils.py 프로젝트: Emergya/gecoscc-ui
def update_node(api, node_id, ou, collection_nodes):
    from gecoscc.models import Computer
    node = ChefNode(node_id, api)
    if not node.attributes.to_dict():
        return False
    try:
        computer_name = node.attributes.get_dotted('ohai_gecos.pclabel')
    except KeyError:
        computer_name = node_id
    comp_model = Computer()
    computer = comp_model.serialize({'path': '%s,%s' % (ou['path'], unicode(ou['_id'])),
                                     'name': computer_name,
                                     'type': 'computer',
                                     'source': ou.get('source', SOURCE_DEFAULT),
                                     'node_chef_id': node_id})
    del computer['_id']
    node_id = collection_nodes.update({'node_chef_id': node_id},
                                      computer)
    return node_id
예제 #4
0
파일: utils.py 프로젝트: Emergya/gecoscc-ui
def register_node(api, node_id, ou, collection_nodes):
    from gecoscc.models import Computer
    node = ChefNode(node_id, api)
    if not node.attributes.to_dict():
        return False
    try:
        computer_name = node.attributes.get_dotted('ohai_gecos.pclabel')
    except KeyError:
        computer_name = node_id
    comp_model = Computer()
    computer = comp_model.serialize({'path': '%s,%s' % (ou['path'], unicode(ou['_id'])),
                                     'name': computer_name,
                                     'type': 'computer',
                                     'source': ou.get('source', SOURCE_DEFAULT),
                                     'node_chef_id': node_id})
    del computer['_id']
    if check_unique_node_name_by_type_at_domain(collection_nodes, computer):
        if collection_nodes.find_one({'node_chef_id': node_id}):
            return 'duplicated-node-id'
        node_id = collection_nodes.insert(computer)
        return node_id
    return 'duplicated'