9572332a339024fea5d916b091438067449b77f4
[plcapi.git] / PLC / Methods / AddBootState.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.BootStates import BootState, BootStates
5 from PLC.Auth import Auth
6
7 class AddBootState(Method):
8     """
9     Adds a new node boot state.
10
11     Returns 1 if successful, faults otherwise.
12     """
13
14     roles = ['admin']
15
16     accepts = [
17         Auth(),
18         BootState.fields['boot_state']
19         ]
20
21     returns = Parameter(int, '1 if successful')
22
23     event_type = 'Add'
24     object_type = 'BootState'
25     
26     def call(self, auth, name):
27         boot_state = BootState(self.api)
28         boot_state['boot_state'] = name
29         boot_state.sync(insert = True)
30
31         return 1