|
1
|
|
|
""" |
|
2
|
|
|
Enarksh |
|
3
|
|
|
|
|
4
|
|
|
Copyright 2013-2016 Set Based IT Consultancy |
|
5
|
|
|
|
|
6
|
|
|
Licence MIT |
|
7
|
|
|
""" |
|
8
|
|
|
from enarksh.message.Message import Message |
|
9
|
|
|
from enarksh.message.MessageController import MessageController |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class NodeActionMessage(Message): |
|
13
|
|
|
""" |
|
14
|
|
|
Message type for requesting a node action made through the CLI application. |
|
15
|
|
|
""" |
|
16
|
|
|
MESSAGE_TYPE = 'controller:NodeActionMessage' |
|
17
|
|
|
""" |
|
18
|
|
|
The message type. |
|
19
|
|
|
|
|
20
|
|
|
:type: str |
|
21
|
|
|
""" |
|
22
|
|
|
|
|
23
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
24
|
|
|
def __init__(self, uri, act_id, mail_on_completion, mail_on_error): |
|
25
|
|
|
""" |
|
26
|
|
|
Object constructor. |
|
27
|
|
|
|
|
28
|
|
|
:param str uri: The URI of the (trigger) node that must be triggered. |
|
29
|
|
|
:param int act_id: The ID of the requested action. |
|
30
|
|
|
:param bool mail_on_completion: If True the user wants to receive a mail when the schedule has completed. |
|
31
|
|
|
:param bool mail_on_error: If True the user wants to receive a mail when an error occurs. |
|
32
|
|
|
""" |
|
33
|
|
|
Message.__init__(self, NodeActionMessage.MESSAGE_TYPE) |
|
34
|
|
|
|
|
35
|
|
|
self.uri = uri |
|
36
|
|
|
""" |
|
37
|
|
|
The URI of the (trigger) node that must be triggered. |
|
38
|
|
|
|
|
39
|
|
|
:type: str |
|
40
|
|
|
""" |
|
41
|
|
|
|
|
42
|
|
|
self.act_id = act_id |
|
43
|
|
|
""" |
|
44
|
|
|
The ID of the requested action. |
|
45
|
|
|
|
|
46
|
|
|
:type: int |
|
47
|
|
|
""" |
|
48
|
|
|
|
|
49
|
|
|
self.mail_on_completion = mail_on_completion |
|
50
|
|
|
""" |
|
51
|
|
|
If True the user wants to receive a mail when the schedule has completed. |
|
52
|
|
|
|
|
53
|
|
|
:type: bool |
|
54
|
|
|
""" |
|
55
|
|
|
|
|
56
|
|
|
self.mail_on_error = mail_on_error |
|
57
|
|
|
""" |
|
58
|
|
|
If True the user wants to receive a mail when an error occurs. |
|
59
|
|
|
|
|
60
|
|
|
:type: bool |
|
61
|
|
|
""" |
|
62
|
|
|
|
|
63
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
64
|
|
|
def send_message(self, end_point): |
|
65
|
|
|
""" |
|
66
|
|
|
Sends the message to an end point. |
|
67
|
|
|
|
|
68
|
|
|
:param str end_point: The end point. |
|
69
|
|
|
|
|
70
|
|
|
:rtype: None |
|
71
|
|
|
""" |
|
72
|
|
|
self.message_controller.send_message(end_point, self) |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
76
|
|
|
|