2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.ConfFiles import ConfFile, ConfFiles
6 from PLC.Nodes import Node, Nodes
7 from PLC.Auth import Auth
9 class DeleteConfFileFromNode(Method):
11 Deletes a configuration file from the specified node. If the node
12 is not linked to the configuration file, no errors are returned.
14 Returns 1 if successful, faults otherwise.
21 ConfFile.fields['conf_file_id'],
22 Mixed(Node.fields['node_id'],
23 Node.fields['hostname'])
26 returns = Parameter(int, '1 if successful')
28 def call(self, auth, conf_file_id, node_id_or_hostname):
29 # Get configuration file
30 conf_files = ConfFiles(self.api, [conf_file_id])
32 raise PLCInvalidArgument, "No such configuration file"
33 conf_file = conf_files[0]
36 nodes = Nodes(self.api, [node_id_or_hostname])
38 raise PLCInvalidArgument, "No such node"
41 # Link configuration file to node
42 if node['node_id'] in conf_file['node_ids']:
43 conf_file.remove_node(node)
45 # Log affected objects
46 self.event_objects = {'ConfFile': [conf_file_id],
47 'Node': [node['node_id']]}