704c57bdce33fa8306951447773b9dfdd329b8d6
[plcapi.git] / PLC / Methods / BootNotifyOwners.py
1 # $Id$
2 # $URL$
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Auth import Auth, BootAuth, SessionAuth
6 from PLC.Nodes import Node, Nodes
7 from PLC.Messages import Message, Messages
8
9 from PLC.Boot import notify_owners
10
11 class BootNotifyOwners(Method):
12     """
13     Notify the owners of the node, and/or support about an event that
14     happened on the machine.
15
16     Returns 1 if successful.
17     """
18
19     roles = ['node']
20
21     accepts = [
22         Mixed(BootAuth(), SessionAuth()),
23         Message.fields['message_id'],
24         Parameter(int, "Notify PIs"),
25         Parameter(int, "Notify technical contacts"),
26         Parameter(int, "Notify support")
27         ]
28
29     returns = Parameter(int, '1 if successful')
30
31     def call(self, auth, message_id, include_pis, include_techs, include_support):
32         assert isinstance(self.caller, Node)
33         notify_owners(self, self.caller, message_id, include_pis, include_techs, include_support)
34         return 1