1
|
|
|
from st2reactor.sensor.base import PollingSensor
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
class WorkOrderSensor(PollingSensor):
|
5
|
|
|
"""
|
6
|
|
|
* self._sensor_service
|
7
|
|
|
- provides utilities like
|
8
|
|
|
get_logger() for writing to logs.
|
9
|
|
|
dispatch() for dispatching triggers into the system.
|
10
|
|
|
* self._config
|
11
|
|
|
- contains configuration that was specified as
|
12
|
|
|
config.yaml in the pack.
|
13
|
|
|
* self._poll_interval
|
14
|
|
|
- indicates the interval between two successive poll() calls.
|
15
|
|
|
"""
|
16
|
|
|
|
17
|
|
|
def setup(self):
|
18
|
|
|
# Setup stuff goes here. For example, you might establish connections
|
19
|
|
|
# to external system once and reuse it. This is called only once by the system.
|
20
|
|
|
pass
|
21
|
|
|
|
22
|
|
|
def poll(self):
|
23
|
|
|
# pylint: disable=no-member
|
24
|
|
|
entries = self.client.query(schema='TESTE_RENAN', qualifier='1=1',
|
25
|
|
|
fields=['Request ID', 'Short Description', 'Status'],
|
26
|
|
|
offset=0, limit=5)
|
27
|
|
|
# pylint: enable=no-member
|
28
|
|
|
|
29
|
|
|
for entry_id, entry_values in entries:
|
30
|
|
|
|
31
|
|
|
# self.client.update()
|
32
|
|
|
print('Entry ID: {}'.format(entry_id))
|
33
|
|
|
print('-' * 80)
|
34
|
|
|
for field, value in entry_values.items():
|
35
|
|
|
print('{}: {}'.format(field, value))
|
36
|
|
|
print()
|
37
|
|
|
|
38
|
|
|
pass
|
39
|
|
|
|
40
|
|
|
def cleanup(self):
|
41
|
|
|
# This is called when the st2 system goes down. You can perform cleanup operations like
|
42
|
|
|
# closing the connections to external system here.
|
43
|
|
|
pass
|
44
|
|
|
|
45
|
|
|
def add_trigger(self, trigger):
|
46
|
|
|
# This method is called when trigger is created
|
47
|
|
|
pass
|
48
|
|
|
|
49
|
|
|
def update_trigger(self, trigger):
|
50
|
|
|
# This method is called when trigger is updated
|
51
|
|
|
pass
|
52
|
|
|
|
53
|
|
|
def remove_trigger(self, trigger):
|
54
|
|
|
# This method is called when trigger is deleted
|
55
|
|
|
pass
|
56
|
|
|
|