- define/modify logging variables
[plcapi.git] / PLC / Methods / DeleteBootState.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 DeleteBootState(Method):
8     """
9     Deletes a node boot state.
10
11     WARNING: This will cause the deletion of all nodes in this boot
12     state.
13
14     Returns 1 if successful, faults otherwise.
15     """
16
17     roles = ['admin']
18
19     accepts = [
20         Auth(),
21         BootState.fields['boot_state']
22         ]
23
24     returns = Parameter(int, '1 if successful')
25
26     event_type = 'Delete'
27     object_type = 'BootState'
28
29     def call(self, auth, name):
30         boot_states = BootStates(self.api, [name])
31         if not boot_states:
32             raise PLCInvalidArgument, "No such boot state"
33         boot_state = boot_states[0]
34
35         boot_state.delete()
36         
37         return 1