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