1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.ConfFiles import ConfFile, ConfFiles
5 from PLC.NodeGroups import NodeGroup, NodeGroups
6 from PLC.Auth import Auth
8 class AddConfFileToNodeGroup(Method):
10 Adds a configuration file to the specified node group. If the node
11 group is already linked to the configuration file, no errors are
14 Returns 1 if successful, faults otherwise.
21 ConfFile.fields['conf_file_id'],
22 Mixed(NodeGroup.fields['nodegroup_id'],
23 NodeGroup.fields['name'])
26 returns = Parameter(int, '1 if successful')
29 object_type = 'ConfFile'
32 def call(self, auth, conf_file_id, nodegroup_id_or_name):
33 # Get configuration file
34 conf_files = ConfFiles(self.api, [conf_file_id])
36 raise PLCInvalidArgument, "No such configuration file"
37 conf_file = conf_files.values()[0]
40 nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
42 raise PLCInvalidArgument, "No such node group"
43 nodegroup = nodegroups.values()[0]
45 # Link configuration file to node
46 if nodegroup['nodegroup_id'] not in conf_file['nodegroup_ids']:
47 conf_file.add_nodegroup(nodegroup)
49 # Log affected objects
50 self.object_ids = [conf_file_id, nodegroup['nodegroup_id']]