Merge from trunk
[plcapi.git] / trunk / PLC / Methods / DeleteBootState.py
diff --git a/trunk/PLC/Methods/DeleteBootState.py b/trunk/PLC/Methods/DeleteBootState.py
new file mode 100644 (file)
index 0000000..507fc7b
--- /dev/null
@@ -0,0 +1,35 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.BootStates import BootState, BootStates
+from PLC.Auth import Auth
+
+class DeleteBootState(Method):
+    """
+    Deletes a node boot state.
+
+    WARNING: This will cause the deletion of all nodes in this boot
+    state.
+
+    Returns 1 if successful, faults otherwise.
+    """
+
+    roles = ['admin']
+
+    accepts = [
+        Auth(),
+        BootState.fields['boot_state']
+        ]
+
+    returns = Parameter(int, '1 if successful')
+
+
+    def call(self, auth, name):
+        boot_states = BootStates(self.api, [name])
+        if not boot_states:
+            raise PLCInvalidArgument, "No such boot state"
+        boot_state = boot_states[0]
+
+        boot_state.delete()
+       
+        return 1