-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
65 lines (51 loc) · 1.58 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
import random
import typing
import pycamunda.variable
import worker
from parse_report import parse_report
from run_napalm_validate import run_napalm_validate
from run_napalm_ping import run_napalm_ping
from run_napalm_cli import run_napalm_cli
from get_block import get_block
if __name__ == '__main__':
import pycamunda.processdef
url = 'http://localhost:8080/engine-rest'
worker_id = '1'
# start_instance = pycamunda.processdef.StartInstance(url=url, key='Audit_001')
# start_instance.add_variable(name='config_path', value='config.yaml')
# for _ in range(3):
# start_instance()
# exit()
worker = worker.Worker(url=url, worker_id=worker_id)
worker.subscribe(
topic='block_expression',
func=get_block,
variables=['start_expression', 'end_expression', 'result']
)
print('Subscribed to check_inventory topic')
worker.subscribe(
topic='napalm_get',
func=run_napalm_cli,
variables=['config_path', 'commands']
)
print('Subscribed to napalm_cli topic')
worker.subscribe(
topic='napalm_ping',
func=run_napalm_ping,
variables=['config_path']
)
print('Subscribed to napalm_ping topic')
worker.subscribe(
topic='parse_report',
func=parse_report,
variables=['result']
)
print('Subscribed to parsed_report topic')
worker.subscribe(
topic='napalm_validate',
func=run_napalm_validate,
variables=['config_path']
)
print('Subscribed to napalm_validate topic')
worker.run()