from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.ConfFiles import ConfFile, ConfFiles
-from PLC.NodeGroups import NodeGroup, NodeGroups
from PLC.Nodes import Node, Nodes
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
class AddConfFileToNode(Method):
"""
roles = ['admin']
accepts = [
- PasswordAuth(),
+ Auth(),
ConfFile.fields['conf_file_id'],
Mixed(Node.fields['node_id'],
Node.fields['hostname'])
returns = Parameter(int, '1 if successful')
- event_type = 'AddTo'
- object_type = 'ConfFile'
- object_ids = []
+ object_type = 'Node'
+
def call(self, auth, conf_file_id, node_id_or_hostname):
# Get configuration file
conf_files = ConfFiles(self.api, [conf_file_id])
if not conf_files:
raise PLCInvalidArgument, "No such configuration file"
- conf_file = conf_files.values()[0]
+ conf_file = conf_files[0]
# Get node
nodes = Nodes(self.api, [node_id_or_hostname])
if not nodes:
raise PLCInvalidArgument, "No such node"
- node = nodes.values()[0]
+ node = nodes[0]
+
+ if node['peer_id'] is not None:
+ raise PLCInvalidArgument, "Not a local node"
# Link configuration file to node
if node['node_id'] not in conf_file['node_ids']: