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
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'
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
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'