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 DeleteConfFileFromNodeGroup(Method):
12 Deletes a configuration file from the specified nodegroup. If the nodegroup
13 is not linked to the configuration file, no errors are returned.
15 Returns 1 if successful, faults otherwise.
22 ConfFile.fields['conf_file_id'],
23 Mixed(NodeGroup.fields['nodegroup_id'],
24 NodeGroup.fields['groupname'])
27 returns = Parameter(int, '1 if successful')
30 def call(self, auth, conf_file_id, nodegroup_id_or_name):
31 # Get configuration file
32 conf_files = ConfFiles(self.api, [conf_file_id])
34 raise PLCInvalidArgument, "No such configuration file"
35 conf_file = conf_files[0]
38 nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
40 raise PLCInvalidArgument, "No such nodegroup"
41 nodegroup = nodegroups[0]
43 # Link configuration file to nodegroup
44 if nodegroup['nodegroup_id'] in conf_file['nodegroup_ids']:
45 conf_file.remove_nodegroup(nodegroup)
47 # Log affected objects
48 self.event_objects = {'ConfFile': [conf_file_id],
49 'NodeGroup': [nodegroup['nodegroup_id']]}