Merge from trunk
[plcapi.git] / trunk / PLC / Methods / AdmAddNode.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Nodes import Node, Nodes
5 from PLC.Sites import Site, Sites
6 from PLC.Auth import Auth
7 from PLC.Methods.AddNode import AddNode
8
9 can_update = lambda (field, value): field in \
10              ['model', 'version']
11
12 class AdmAddNode(AddNode):
13     """
14     Deprecated. See AddNode.
15     """
16
17     status = "deprecated"
18
19     node_fields = dict(filter(can_update, Node.fields.items()))
20
21     accepts = [
22         Auth(),
23         Site.fields['site_id'],
24         Node.fields['hostname'],
25         Node.fields['boot_state'],
26         node_fields
27         ]
28
29     def call(self, auth, site_id, hostname, boot_state, node_fields = {}):
30         node_fields['site_id'] = site_id
31         node_fields['hostname'] = hostname
32         node_fields['boot_state'] = boot_state
33         return AddNode.call(self, auth, node_fields)