Skip to content

Commit 369c26c

Browse files
ironic nautobot device interface sync
1 parent dac4dcd commit 369c26c

File tree

11 files changed

+887
-5
lines changed

11 files changed

+887
-5
lines changed

components/site-workflows/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ resources:
2222
- sensors/sensor-neutron-olso-event.yaml
2323
- sensors/sensor-ironic-reclean.yaml
2424
- sensors/sensor-ironic-node-port.yaml
25-
- sensors/sensor-ironic-oslo-event.yaml
25+
- sensors/sensor-ironic-oslo-deploying-event.yaml
26+
- sensors/sensor-ironic-oslo-inspecting-event.yaml
2627

2728
helmCharts:
2829
- name: nautobot-token

components/site-workflows/sensors/sensor-ironic-oslo-event.yaml renamed to components/site-workflows/sensors/sensor-ironic-oslo-deploying-event.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: argoproj.io/v1alpha1
33
kind: Sensor
44
metadata:
5-
name: ironic-oslo-event
5+
name: ironic-oslo-deploying-event
66
annotations:
77
workflows.argoproj.io/title: Process oslo_events for ironic project
88
workflows.argoproj.io/description: |+
@@ -13,11 +13,11 @@ metadata:
1313
Resulting code should be very similar to:
1414
1515
```
16-
argo -n argo-events submit --from workflowtemplate/ironic-oslo-event \
16+
argo -n argo-events submit --from workflowtemplate/openstack-oslo-event \
1717
-p event-json "JSON-payload" -p device_id=<UUID> -p project_id=<UUID>
1818
```
1919
20-
Defined in `workflows/argo-events/sensors/sensor-ironic-oslo-event.yaml`
20+
Defined in `workflows/argo-events/sensors/sensor-sensor-ironic-oslo-deploying-event.yaml`
2121
spec:
2222
dependencies:
2323
- eventName: openstack
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
apiVersion: argoproj.io/v1alpha1
3+
kind: Sensor
4+
metadata:
5+
name: ironic-oslo-inspecting-event
6+
annotations:
7+
workflows.argoproj.io/title: Process oslo_events for ironic project
8+
workflows.argoproj.io/description: |+
9+
Triggers on the following Ironic Events:
10+
11+
- baremetal.node.provision_set.end which happens after a state change on the node
12+
13+
Resulting code should be very similar to:
14+
15+
```
16+
argo -n argo-events submit --from workflowtemplate/openstack-oslo-event \
17+
-p event-json "JSON-payload" -p device_id=<UUID> -p project_id=<UUID>
18+
```
19+
20+
Defined in `workflows/argo-events/sensors/sensor-ironic-oslo-inspecting-event.yaml`
21+
spec:
22+
dependencies:
23+
- eventName: openstack
24+
eventSourceName: openstack-ironic
25+
name: ironic-dep
26+
transform:
27+
# the event is a string-ified JSON so we need to decode it
28+
# replace the whole event body
29+
jq: |
30+
(
31+
.body = (.body["oslo.message"] | fromjson) |
32+
.body.ironic_object = .body.payload["ironic_object.data"]
33+
)
34+
filters:
35+
# applies each of the items in data with 'and' but there's only one
36+
dataLogicalOperator: "and"
37+
data:
38+
- path: "body.event_type"
39+
type: "string"
40+
value:
41+
- "baremetal.node.provision_set.end"
42+
- path: "body.ironic_object.previous_provision_state"
43+
type: "string"
44+
value:
45+
- "inspecting"
46+
template:
47+
serviceAccountName: sensor-submit-workflow
48+
triggers:
49+
- template:
50+
name: update-nautobot
51+
k8s:
52+
operation: create
53+
parameters:
54+
# first parameter is the parsed oslo.message
55+
- dest: spec.arguments.parameters.0.value # event-json
56+
src:
57+
dataKey: body
58+
dependencyName: ironic-dep
59+
source:
60+
# create a workflow in argo-events prefixed with ironic-prov-
61+
resource:
62+
apiVersion: argoproj.io/v1alpha1
63+
kind: Workflow
64+
metadata:
65+
generateName: update-nautobot-
66+
namespace: argo-events
67+
spec:
68+
serviceAccountName: workflow
69+
entrypoint: main
70+
# defines the parameters being replaced above
71+
arguments:
72+
parameters:
73+
- name: event-json
74+
templates:
75+
- name: main
76+
steps:
77+
- - name: oslo-events
78+
templateRef:
79+
name: update-nautobot-on-openstack-oslo-event
80+
template: main
81+
arguments:
82+
parameters:
83+
- name: event-json
84+
value: "{{workflow.parameters.event-json}}"

0 commit comments

Comments
 (0)