5f477557eb726dc207d0bcff705d12e2c0f7faa0
[plcapi.git] / PLC / Methods / DeleteBootState.py
1 # $Id$
2 # $URL$
3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.BootStates import BootState, BootStates
7 from PLC.Auth import Auth
8
9 class DeleteBootState(Method):
10     """
11     Deletes a node boot state.
12
13     WARNING: This will cause the deletion of all nodes in this boot
14     state.
15
16     Returns 1 if successful, faults otherwise.
17     """
18
19     roles = ['admin']
20
21     accepts = [
22         Auth(),
23         BootState.fields['boot_state']
24         ]
25
26     returns = Parameter(int, '1 if successful')
27
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