Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 15 additions & 33 deletions components/site-workflows/sensors/sensor-ironic-node-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ metadata:
workflows.argoproj.io/description: |+
Triggers on the following Ironic Events:

- baremetal.node.provision_set.end which happens after a state change on the node
- baremetal.node.update.end which happens when node fields are updated.

Currently parses out the following fields:

- provision_state
- baremetal.node.create.end which happens when a baremetal node is created
- baremetal.node.update.end which happens when node fields are updated
- baremetal.node.delete.end which happens when a node is deleted

Resulting code should be very similar to:

```
argo -n argo-events submit --from workflowtemplate/sync-provision-state-to-nautobot \
-p device_uuid=00000000-0000-0000-0000-000000000000 -p provision_state=available
argo -n argo-events submit --from workflowtemplate/openstack-oslo-event \
-p event-json "JSON-payload"
```

Defined in `workflows/argo-events/sensors/ironic-node-update.yaml`
Expand All @@ -30,16 +27,19 @@ spec:
name: ironic-dep
transform:
# the event is a string-ified JSON so we need to decode it
jq: ".body[\"oslo.message\"] | fromjson"
# replace the whole event body
jq: |
.body = (.body["oslo.message"] | fromjson)
filters:
# applies each of the items in data with 'and' but there's only one
dataLogicalOperator: "and"
data:
- path: "event_type"
- path: "body.event_type"
type: "string"
value:
- "baremetal.node.create.end"
- "baremetal.node.update.end"
- "baremetal.node.provision_set.end"
- "baremetal.node.delete.end"
template:
serviceAccountName: sensor-submit-workflow
triggers:
Expand All @@ -49,25 +49,10 @@ spec:
k8s:
operation: create
parameters:
# first parameter's value is replaced with the uuid
# first parameter is the parsed oslo.message
- dest: spec.arguments.parameters.0.value
src:
dataKey: payload.ironic_object\.data.uuid
dependencyName: ironic-dep
# second parameter's value is replaced with the provision_state
- dest: spec.arguments.parameters.1.value
src:
dataKey: payload.ironic_object\.data.provision_state
dependencyName: ironic-dep
# third parameter's value is replaced with the lessee
- dest: spec.arguments.parameters.2.value
src:
dataKey: payload.ironic_object\.data.lessee
dependencyName: ironic-dep
# fourth parameter's value is replaced with the resource_class
- dest: spec.arguments.parameters.3.value
src:
dataKey: payload.ironic_object\.data.resource_class
dataKey: body
dependencyName: ironic-dep
source:
# create a workflow in argo-events prefixed with ironic-node-update-
Expand All @@ -81,10 +66,7 @@ spec:
# defines the parameters being replaced above
arguments:
parameters:
- name: device_uuid
- name: provision_state
- name: lessee
- name: resource_class
- name: event-json
# references the workflow
workflowTemplateRef:
name: sync-provision-state-to-nautobot
name: openstack-oslo-event
24 changes: 13 additions & 11 deletions components/site-workflows/sensors/sensor-ironic-oslo-event.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ metadata:

- baremetal.node.provision_set.end which happens after a state change on the node

This sensor handles ALL provision state changes. The event handlers internally
filter for specific states:
- deploying: Sets up storage (volume connectors) for instances with storage enabled
- inspecting: Updates Nautobot device with inspection data (inventory, ports)

Resulting code should be very similar to:

```
argo -n argo-events submit --from workflowtemplate/ironic-oslo-event \
-p event-json "JSON-payload" -p device_id=<UUID> -p project_id=<UUID>
argo -n argo-events submit --from workflowtemplate/openstack-oslo-event \
-p event-json "JSON-payload"
```

Defined in `workflows/argo-events/sensors/sensor-ironic-oslo-event.yaml`
Defined in `components/site-workflows/sensors/sensor-ironic-oslo-event.yaml`
spec:
dependencies:
- eventName: openstack
Expand All @@ -39,10 +44,6 @@ spec:
type: "string"
value:
- "baremetal.node.provision_set.end"
- path: "body.ironic_object.previous_provision_state"
type: "string"
value:
- "deploying"
template:
serviceAccountName: sensor-submit-workflow
triggers:
Expand All @@ -56,9 +57,9 @@ spec:
src:
dataKey: body
dependencyName: ironic-dep
- dest: spec.arguments.parameters.1.value # device_id
- dest: spec.arguments.parameters.1.value # previous_provision_state
src:
dataKey: body.ironic_object.uuid
dataKey: body.ironic_object.previous_provision_state
dependencyName: ironic-dep
- dest: spec.arguments.parameters.2.value # project_id
src:
Expand All @@ -79,7 +80,7 @@ spec:
arguments:
parameters:
- name: event-json
- name: device_id
- name: previous_provision_state
- name: project_id
templates:
- name: main
Expand All @@ -93,6 +94,7 @@ spec:
- name: event-json
value: "{{workflow.parameters.event-json}}"
- name: convert-project-id
when: "\"{{workflow.parameters.previous_provision_state}}\" == deploying"
inline:
script:
image: python:alpine
Expand All @@ -102,7 +104,7 @@ spec:
project_id_without_dashes = "{{workflow.parameters.project_id}}"
print(str(uuid.UUID(project_id_without_dashes)))
- - name: ansible-storage-update
when: "\"{{steps.oslo-events.outputs.parameters.storage}}\" == wanted"
when: "\"{{steps.oslo-events.outputs.parameters.storage}}\" == wanted && \"{{workflow.parameters.previous_provision_state}}\" == deploying"
templateRef:
name: ansible-workflow-template
template: ansible-run
Expand Down
1 change: 0 additions & 1 deletion python/understack-workflows/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies = [

[project.scripts]
sync-keystone = "understack_workflows.main.sync_keystone:main"
sync-provision-state = "understack_workflows.main.sync_provision_state:main"
undersync-switch = "understack_workflows.main.undersync_switch:main"
enroll-server = "understack_workflows.main.enroll_server:main"
bmc-password = "understack_workflows.main.print_bmc_password:main"
Expand Down
Loading
Loading