Skip to content

Commit 63a1ffe

Browse files
author
Eugen Cusmaunsa
authored
Merge pull request #67 from floatingstatic/issue-66
Convert mistral workflows to orquesta
2 parents 99b16ae + 48ae79f commit 63a1ffe

8 files changed

Lines changed: 175 additions & 207 deletions

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 0.5.0
4+
5+
- Convert mistral workflows to orquesta
6+
37
## 0.4.1
48

59
- Restrict napalm dependency to < 3.0 to preserve Python 2.7 support

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ credentials:
107107
108108
The devices configuration is so that credentials and drivers for each device
109109
don't have to be entered manually. This is useful for automated action chains
110-
or mistral workflows where (most of the time) only the hostname is known
110+
or orquesta workflows where (most of the time) only the hostname is known
111111
(for example from a syslog logsource field.)
112112
113113
```YAML
@@ -171,7 +171,7 @@ being set to the IP address of the host and the logsoure being set to the hostna
171171
received from the box. The example rsyslog configuration example details more
172172
on this.
173173

174-
- **configuration_change_workflow**: Webhook trigger to run a remote backup mistral workflow when a configuration change is detected on a device.
174+
- **configuration_change_workflow**: Webhook trigger to run a remote backup orquesta workflow when a configuration change is detected on a device.
175175
- **interface_down_chain**: Webhook trigger to run an action chain when an interface goes down.
176176
- **bgp_prefix_exceeded_chain**: Webhook trigger to run an action chain when a bgp neighbor exceeds its prefix limit.
177177

@@ -189,8 +189,8 @@ st2 key set napalm_actionerror_mailto "stackstorm_errors@example.com"
189189
st2 key set napalm_actionerror_mailfrom "stackstorm@example.com"
190190
191191
# HTML header and footer files which get read in by some of the workflows to send nice emails.
192-
st2 key set napalm_html_mail_header_file "/opt/stackstorm/packs/napalm/examples/html_header.html"
193-
st2 key set napalm_html_mail_footer_file "/opt/stackstorm/packs/napalm/examples/html_footer.html"
192+
st2 key set napalm_html_mail_header_file "/opt/stackstorm/packs/napalm/examples/html_templates/html_header.html"
193+
st2 key set napalm_html_mail_footer_file "/opt/stackstorm/packs/napalm/examples/html_templates/html_footer.html"
194194
```
195195

196196
For the remote backup action chain the following commands will create the datastore key value pairs needed.

actions/configuration_change_workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: "configuration_change_workflow"
33
description: "Workflow to process a configuration change on a device."
4-
runner_type: "mistral-v2"
4+
runner_type: "orquesta"
55
pack: napalm
66
enabled: true
77
entry_point: "workflows/configuration_change_workflow.yaml"

actions/interface_down_workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: "interface_down_workflow"
33
description: "Workflow to process an interface down event on a device."
4-
runner_type: "mistral-v2"
4+
runner_type: "orquesta"
55
pack: napalm
66
enabled: true
77
entry_point: "workflows/interface_down_workflow.yaml"

actions/workflows/check_consistency_chatops.yaml

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,70 @@
1-
---
2-
version: '2.0'
1+
version: 1.0
32

4-
napalm.configuration_change_workflow:
3+
description: Configuration Change Workflow
54

6-
input:
7-
- hostname
8-
- driver
9-
- message
10-
- username
11-
12-
type: direct
5+
input:
6+
- hostname
7+
- driver
8+
- message
9+
- username
1310

14-
task-defaults:
15-
on-error:
16-
- notify_on_error
11+
vars:
12+
- stdout: ""
13+
- stderr: ""
1714

18-
tasks:
19-
send_detected_email:
20-
action: core.sendmail
21-
input:
22-
to: "<% st2kv('system.napalm_remotebackup_mailto') %>"
23-
from: "<% st2kv('system.napalm_remotebackup_mailfrom') %>"
24-
# Will work when this is in the code: https://github.com/StackStorm/st2/pull/3177
25-
#subject: "Stackstorm detected a configuration change on <% $.hostname %> {% if _.username %} by {{ _.username }} {% endif %}."
26-
subject: "Stackstorm detected a configuration change on <% $.hostname %> by <% $.username %>."
27-
content_type: "text/plain"
28-
body: "\r\n\r\nThe following syslog triggered this event: <% $.message %>\r\n\r\n"
29-
on-success:
30-
- backup_device
15+
tasks:
16+
send_detected_email:
17+
action: core.sendmail
18+
input:
19+
to: "{{ st2kv('system.napalm_remotebackup_mailto') }}"
20+
from: "{{ st2kv('system.napalm_remotebackup_mailfrom') }}"
21+
subject: "Stackstorm detected a configuration change on {{ ctx('hostname') }} by {{ ctx('username') }}."
22+
content_type: "text/plain"
23+
body: "\r\n\r\nThe following syslog triggered this event: {{ ctx('message') }}\r\n\r\n"
24+
next:
25+
- when: "{{ succeeded() }}"
26+
do: backup_device
27+
- when: "{{ failed() }}"
28+
do: notify_on_error
3129

32-
backup_device:
33-
action: "core.remote"
34-
wait-before: 60
35-
input:
36-
cmd: "<% st2kv('system.napalm_remotebackup_cmd') %> <% $.hostname %> <% $.driver %>"
37-
username: "<% st2kv('system.napalm_remotebackup_user') %>"
38-
private_key: "/home/stanley/.ssh/stanley_rsa"
39-
hosts: "<% st2kv('system.napalm_remotebackup_host') %>"
30+
backup_device:
31+
action: "core.remote"
32+
input:
33+
cmd: "{{ st2kv('system.napalm_remotebackup_cmd') }} {{ ctx('hostname') }} {{ ctx('driver') }}"
34+
username: "{{ st2kv('system.napalm_remotebackup_user') }}"
35+
private_key: "/home/stanley/.ssh/stanley_rsa"
36+
hosts: "{{ st2kv('system.napalm_remotebackup_host') }}"
37+
next:
38+
- when: "{{ succeeded() }}"
4039
publish:
41-
stdout: <% task(backup_device).result.get(st2kv('system.napalm_remotebackup_host')).stdout %>
42-
stderr: <% task(backup_device).result.get(st2kv('system.napalm_remotebackup_host')).stderr %>
43-
on-success:
44-
- send_complete_email
40+
- stdout: "{{ result()[st2kv('system.napalm_remotebackup_host')].stdout }}"
41+
- sterr: "{{ result()[st2kv('system.napalm_remotebackup_host')].stdout }}"
42+
do: send_complete_email
43+
- when: "{{ failed() }}"
44+
do: notify_on_error
4545

46-
send_complete_email:
47-
action: core.sendmail
48-
input:
49-
to: "<% st2kv('system.napalm_remotebackup_mailto') %>"
50-
from: "<% st2kv('system.napalm_remotebackup_mailfrom') %>"
51-
subject: "Stackstorm completed a backup of <% $.hostname %>."
52-
content_type: "text/plain"
53-
body: "\r\nThe following syslog triggered this event: <% $.message %>\r\n\r\n
54-
\r\n<% $.stderr %>\r\n
55-
\r\n<% $.stdout %>\r\n
56-
\r\n\r\n"
46+
send_complete_email:
47+
action: core.sendmail
48+
input:
49+
to: "{{ st2kv('system.napalm_remotebackup_mailto') }}"
50+
from: "{{ st2kv('system.napalm_remotebackup_mailfrom') }}"
51+
subject: "Stackstorm completed a backup of {{ ctx('hostname') }}."
52+
content_type: "text/plain"
53+
body: "\r\nThe following syslog triggered this event: {{ ctx('message') }}\r\n\r\n
54+
\r\n{{ ctx('stderr') }}\r\n
55+
\r\n{{ ctx('stdout') }}\r\n
56+
\r\n\r\n"
57+
58+
notify_on_error:
59+
action: core.sendmail
60+
input:
61+
to: "{{ st2kv('system.napalm_actionerror_mailto') }}"
62+
from: "{{ st2kv('system.napalm_actionerror_mailfrom') }}"
63+
subject: "Stackstorm device backup workflow error"
64+
body: "Something went wrong with the device backup workflow. Check stackstorm for the error. Execution ID {{ ctx('st2').action_execution_id }}\r\n\r\n"
65+
next:
66+
- do: fail
5767

58-
notify_on_error:
59-
action: core.sendmail
60-
input:
61-
to: "<% st2kv('system.napalm_actionerror_mailto') %>"
62-
from: "<% st2kv('system.napalm_actionerror_mailfrom') %>"
63-
subject: "Stackstorm device backup workflow error"
64-
body: "Something went wrong with the device backup workflow. Check stackstorm for the error. Execution ID <% env().st2_execution_id %>\r\n\r\n"
65-
on-complete:
66-
- fail
68+
output:
69+
- stdout: "{{ ctx('stdout') }}"
70+
- stderr: "{{ ctx('stderr') }}"

0 commit comments

Comments
 (0)