- accept role_id_or_name
[plcapi.git] / PLC / Methods / AdmAddNode.py
index 9c65df9..2f9afb7 100644 (file)
@@ -32,7 +32,7 @@ class AdmAddNode(Method):
         update_fields
         ]
 
-    returns = Parameter(int, '1 if successful')
+    returns = Parameter(int, 'New node_id (> 0) if successful')
 
     def call(self, auth, site_id_or_login_base, hostname, boot_state, optional_vals = {}):
         if filter(lambda field: field not in self.update_fields, optional_vals):
@@ -45,13 +45,6 @@ class AdmAddNode(Method):
 
         site = sites.values()[0]
 
-        # Get site node group information
-        nodegroups = NodeGroups(self.api, [site['nodegroup_id']])
-        if not nodegroups:
-            raise PLCAPIError, "Site %d does not have a nodegroup" % site['site_id']
-
-        nodegroup = nodegroups.values()[0]
-
         # Authenticated function
         assert self.caller is not None
 
@@ -67,9 +60,7 @@ class AdmAddNode(Method):
         node = Node(self.api, optional_vals)
         node['hostname'] = hostname
         node['boot_state'] = boot_state
-        node.flush(commit = False)
-
-        # Now associate the node with the site
-        nodegroup.add_node(node, commit = True)
+        node['site_id'] = site['site_id']
+        node.sync(commit = False)
 
         return node['node_id']