Merge from trunk
[plcapi.git] / trunk / PLC / Methods / BootNotifyOwners.py
diff --git a/trunk/PLC/Methods/BootNotifyOwners.py b/trunk/PLC/Methods/BootNotifyOwners.py
new file mode 100644 (file)
index 0000000..c1da332
--- /dev/null
@@ -0,0 +1,32 @@
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Auth import Auth, BootAuth
+from PLC.Nodes import Node, Nodes
+from PLC.Messages import Message, Messages
+
+from PLC.Boot import notify_owners
+
+class BootNotifyOwners(Method):
+    """
+    Notify the owners of the node, and/or support about an event that
+    happened on the machine.
+
+    Returns 1 if successful.
+    """
+
+    roles = ['node']
+
+    accepts = [
+        BootAuth(),
+        Message.fields['message_id'],
+        Parameter(int, "Notify PIs"),
+        Parameter(int, "Notify technical contacts"),
+        Parameter(int, "Notify support")
+        ]
+
+    returns = Parameter(int, '1 if successful')
+
+    def call(self, auth, message_id, include_pis, include_techs, include_support):
+        assert isinstance(self.caller, Node)
+        notify_owners(self, self.caller, message_id, include_pis, include_techs, include_support)
+        return 1