- merge from PlanetLab Europe
[plcapi.git] / PLC / Methods / UpdateNode.py
index 0e40564..d8128e0 100644 (file)
@@ -38,15 +38,18 @@ class UpdateNode(Method):
        # Remove admin only fields
        if 'admin' not in self.caller['roles']:
             for key in 'key', 'session', 'boot_nonce':
-                del node_fields[key]
+                if node_fields.has_key(key):
+                    del node_fields[key]
 
         # Get account information
         nodes = Nodes(self.api, [node_id_or_hostname])
         if not nodes:
             raise PLCInvalidArgument, "No such node"
-
         node = nodes[0]
 
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
+
         # Authenticated function
         assert self.caller is not None
 
@@ -57,7 +60,14 @@ class UpdateNode(Method):
                 raise PLCPermissionDenied, "Not allowed to delete nodes from specified site"
 
         node.update(node_fields)
+       node.update_last_updated(False)
         node.sync()
-       self.object_ids = [node['node_id']]
+       
+       # Logging variables
+       self.event_objects = {'Node': [node['node_id']]}
+       self.message = 'Node %d updated: %s.' % \
+               (node['node_id'], ", ".join(node_fields.keys()))
+       if 'boot_state' in node_fields.keys():
+               self.message += ' boot_state updated to %s' %  node_fields['boot_state']
 
         return 1