3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.ConfFiles import ConfFile, ConfFiles
7 from PLC.NodeGroups import NodeGroup, NodeGroups
8 from PLC.Auth import Auth
10 class AddConfFileToNodeGroup(Method):
12 Adds a configuration file to the specified node group. If the node
13 group is already linked to the configuration file, no errors are
16 Returns 1 if successful, faults otherwise.
23 ConfFile.fields['conf_file_id'],
24 Mixed(NodeGroup.fields['nodegroup_id'],
25 NodeGroup.fields['groupname'])
28 returns = Parameter(int, '1 if successful')
31 def call(self, auth, conf_file_id, nodegroup_id_or_name):
32 # Get configuration file
33 conf_files = ConfFiles(self.api, [conf_file_id])
35 raise PLCInvalidArgument, "No such configuration file"
36 conf_file = conf_files[0]
39 nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
41 raise PLCInvalidArgument, "No such node group"
42 nodegroup = nodegroups[0]
44 # Link configuration file to node
45 if nodegroup['nodegroup_id'] not in conf_file['nodegroup_ids']:
46 conf_file.add_nodegroup(nodegroup)
48 # Log affected objects
49 self.event_objects = {'ConfFile': [conf_file_id],
50 'NodeGroup': [nodegroup['nodegroup_id']] }