Merge remote-tracking branch 'origin/pycurl' into planetlab-4_0-branch
[plcapi.git] / PLC / Methods / AddNode.py
index 1b243d0..8d253df 100644 (file)
@@ -4,7 +4,7 @@ from PLC.Parameter import Parameter, Mixed
 from PLC.Nodes import Node, Nodes
 from PLC.NodeGroups import NodeGroup, NodeGroups
 from PLC.Sites import Site, Sites
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
 
 can_update = lambda (field, value): field in \
              ['hostname', 'boot_state', 'model', 'version']
@@ -25,7 +25,7 @@ class AddNode(Method):
     node_fields = dict(filter(can_update, Node.fields.items()))
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         Mixed(Site.fields['site_id'],
               Site.fields['login_base']),
         node_fields
@@ -33,10 +33,6 @@ class AddNode(Method):
 
     returns = Parameter(int, 'New node_id (> 0) if successful')
 
-    event_type = 'Add'
-    object_type = 'Node'
-    object_ids = []
-
     def call(self, auth, site_id_or_login_base, node_fields):
         node_fields = dict(filter(can_update, node_fields.items()))
 
@@ -45,7 +41,7 @@ class AddNode(Method):
         if not sites:
             raise PLCInvalidArgument, "No such site"
 
-        site = sites.values()[0]
+        site = sites[0]
 
         # Authenticated function
         assert self.caller is not None
@@ -63,6 +59,8 @@ class AddNode(Method):
         node['site_id'] = site['site_id']
         node.sync()
 
-       self.object_ids = [site['site_id'], node['node_id']]    
+       self.event_objects = {'Site': [site['site_id']],
+                            'Node': [node['node_id']]} 
+       self.message = "Node %s created" % node['node_id']
 
         return node['node_id']