implement file lock based on peername to prevent running two RefreshPeer at a time.
[plcapi.git] / PLC / Methods / AddConfFileToNode.py
index 47886a8..fa1de9c 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
@@ -24,9 +25,6 @@ class AddConfFileToNode(Method):
 
     returns = Parameter(int, '1 if successful')
 
-    event_type = 'AddTo'
-    object_type = 'ConfFile'
-
     def call(self, auth, conf_file_id, node_id_or_hostname):
        # Get configuration file
         conf_files = ConfFiles(self.api, [conf_file_id])
@@ -39,12 +37,16 @@ class AddConfFileToNode(Method):
        if not nodes:
                raise PLCInvalidArgument, "No such node"
        node = nodes[0]
+
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
        
        # Link configuration file to node
         if node['node_id'] not in conf_file['node_ids']:
             conf_file.add_node(node)
 
         # Log affected objects
-        self.object_ids = [conf_file_id, node['node_id']]
+        self.event_objects = {'ConfFile': [conf_file_id], 
+                             'Node': [node['node_id']] }
 
         return 1