7b7e6d389ad4a378898270a7bb24e55312c8ea95
[plcapi.git] / PLC / Methods / DeleteBootState.py
1 # $Id$
2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.BootStates import BootState, BootStates
6 from PLC.Auth import Auth
7
8 class DeleteBootState(Method):
9     """
10     Deletes a node boot state.
11
12     WARNING: This will cause the deletion of all nodes in this boot
13     state.
14
15     Returns 1 if successful, faults otherwise.
16     """
17
18     roles = ['admin']
19
20     accepts = [
21         Auth(),
22         BootState.fields['boot_state']
23         ]
24
25     returns = Parameter(int, '1 if successful')
26
27
28     def call(self, auth, name):
29         boot_states = BootStates(self.api, [name])
30         if not boot_states:
31             raise PLCInvalidArgument, "No such boot state"
32         boot_state = boot_states[0]
33
34         boot_state.delete()
35         
36         return 1