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.Nodes import Node, Nodes
6 from PLC.Auth import Auth
8 class DeleteConfFileFromNode(Method):
10 Deletes a configuration file from the specified node. If the node
11 is not linked to the configuration file, no errors are returned.
13 Returns 1 if successful, faults otherwise.
20 ConfFile.fields['conf_file_id'],
21 Mixed(Node.fields['node_id'],
22 Node.fields['hostname'])
25 returns = Parameter(int, '1 if successful')
27 event_type = 'DeleteFrom'
28 object_type = 'ConfFile'
31 def call(self, auth, conf_file_id, node_id_or_hostname):
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.values()[0]
39 nodes = Nodes(self.api, [node_id_or_hostname])
41 raise PLCInvalidArgument, "No such node"
42 node = nodes.values()[0]
44 # Link configuration file to node
45 if node['node_id'] in conf_file['node_ids']:
46 conf_file.remove_node(node)
48 # Log affected objects
49 self.object_ids = [conf_file_id, node['node_id']]