Skip to content

Commit 2522238

Browse files
using generic handler.
1 parent 935a047 commit 2522238

17 files changed

+1130
-493
lines changed

components/site-workflows/kustomization.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ 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-deploying-event.yaml
26-
- sensors/sensor-ironic-oslo-inspecting-event.yaml
25+
- sensors/sensor-ironic-oslo-event.yaml
2726

2827
helmCharts:
2928
- name: nautobot-token

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

Lines changed: 10 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-deploying-event
5+
name: ironic-oslo-event
66
annotations:
77
workflows.argoproj.io/title: Process oslo_events for ironic project
88
workflows.argoproj.io/description: |+
@@ -17,7 +17,7 @@ metadata:
1717
-p event-json "JSON-payload" -p device_id=<UUID> -p project_id=<UUID>
1818
```
1919
20-
Defined in `workflows/argo-events/sensors/sensor-sensor-ironic-oslo-deploying-event.yaml`
20+
Defined in `components/site-workflows/sensors/sensor-ironic-oslo-event.yaml`
2121
spec:
2222
dependencies:
2323
- eventName: openstack
@@ -43,6 +43,7 @@ spec:
4343
type: "string"
4444
value:
4545
- "deploying"
46+
- "inspecting"
4647
template:
4748
serviceAccountName: sensor-submit-workflow
4849
triggers:
@@ -64,6 +65,10 @@ spec:
6465
src:
6566
dataKey: body.ironic_object.lessee
6667
dependencyName: ironic-dep
68+
- dest: spec.arguments.parameters.3.value # previous_provision_state
69+
src:
70+
dataKey: body.ironic_object.previous_provision_state
71+
dependencyName: ironic-dep
6772
source:
6873
# create a workflow in argo-events prefixed with ironic-prov-
6974
resource:
@@ -81,6 +86,7 @@ spec:
8186
- name: event-json
8287
- name: device_id
8388
- name: project_id
89+
- name: previous_provision_state
8490
templates:
8591
- name: main
8692
steps:
@@ -93,6 +99,7 @@ spec:
9399
- name: event-json
94100
value: "{{workflow.parameters.event-json}}"
95101
- name: convert-project-id
102+
when: "\"{{workflow.parameters.previous_provision_state}}\" == deploying"
96103
inline:
97104
script:
98105
image: python:alpine
@@ -102,7 +109,7 @@ spec:
102109
project_id_without_dashes = "{{workflow.parameters.project_id}}"
103110
print(str(uuid.UUID(project_id_without_dashes)))
104111
- - name: ansible-storage-update
105-
when: "\"{{steps.oslo-events.outputs.parameters.storage}}\" == wanted"
112+
when: "\"{{steps.oslo-events.outputs.parameters.storage}}\" == wanted && \"{{workflow.parameters.previous_provision_state}}\" == deploying"
106113
templateRef:
107114
name: ansible-workflow-template
108115
template: ansible-run

components/site-workflows/sensors/sensor-ironic-oslo-inspecting-event.yaml

Lines changed: 0 additions & 84 deletions
This file was deleted.

docs/operator-guide/openstack-ironic-nautobot-device-interfaces-sync.md

Lines changed: 46 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ Server Enrollment → Redfish Inspection → Oslo Event Bus → Argo Events Sens
7070

7171
5. **Workflow Trigger**
7272
- Sensor creates an Argo Workflow named `update-nautobot-*`
73-
- Workflow uses template `update-nautobot-on-openstack-oslo-event`
73+
- Workflow uses template `openstack-oslo-event`
7474
- Event data is passed as workflow parameter
7575

7676
6. **Data Processing**
77-
- Workflow executes `update-nautobot-on-openstack-oslo-event` script
77+
- Workflow executes `openstack-oslo-event` script
7878
- Script fetches full inventory data from Ironic API using node UUID
7979
- Inventory data is parsed and transformed into Nautobot format
8080

@@ -88,7 +88,7 @@ Server Enrollment → Redfish Inspection → Oslo Event Bus → Argo Events Sens
8888

8989
### Sensor Configuration
9090

91-
**File:** `components/site-workflows/sensors/sensor-ironic-oslo-inspecting-event.yaml`
91+
**File:** `components/site-workflows/sensors/sensor-ironic-oslo-event.yaml`
9292

9393
The sensor configuration defines:
9494

@@ -99,11 +99,11 @@ The sensor configuration defines:
9999

100100
### Workflow Template
101101

102-
**File:** `workflows/argo-events/workflowtemplates/update-nautobot-on-openstack-oslo-event.yaml`
102+
**File:** `workflows/argo-events/workflowtemplates/openstack-oslo-event.yaml`
103103

104104
The workflow template:
105105

106-
- Runs the `update-nautobot-on-openstack-oslo-event` command
106+
- Runs the `openstack-oslo-event` command
107107
- Mounts Nautobot token and OpenStack credentials
108108
- Passes event JSON as input file
109109
- Uses service account with appropriate permissions
@@ -135,86 +135,47 @@ LLDP (Link Layer Discovery Protocol) data is extracted from inspection results:
135135
- **Port ID (Type 2)**: Remote switch port name
136136
- **Port Description (Type 4)**: Alternative port identifier
137137

138-
The system requires a minimum of 3 LLDP neighbors to be discovered for validation.
139-
140138
#### Device Information
141139

142140
The following device attributes are extracted:
143141

144-
- **Manufacturer**: System vendor (e.g., Dell)
145-
- **Model**: Product name
146-
- **Serial Number**: System serial number
147-
- **BMC IP Address**: Out-of-band management IP
148-
- **BIOS Version**: Firmware version
149-
- **Memory**: Total RAM in GiB
150-
- **CPU**: Processor model
151-
152-
### Nautobot Device Creation
153-
154-
**Module:** `understack_workflows.nautobot_device`
155-
156-
#### Device Creation Process
157-
158-
1. **Switch Discovery**
159-
- Identifies switches using LLDP MAC addresses
160-
- Queries Nautobot for devices with matching `chassis_mac_address` custom field
161-
- Validates all switches are in the same location/rack
162-
163-
2. **Device Lookup**
164-
- Searches for existing device by serial number
165-
- If not found, creates new device with:
166-
- Status: "Planned"
167-
- Role: "server"
168-
- Location and rack from connected switches
169-
- Device type based on manufacturer and model
170-
171-
3. **Interface Creation**
172-
- Creates or updates network interfaces
173-
- Sets MAC addresses
174-
- Assigns interface types:
175-
- BMC interfaces: `1000base-t`
176-
- Server interfaces: `25gbase-x-sfp28`
177-
- Sets status to "Active"
178-
179-
4. **Cable Documentation**
180-
- Creates cables between server and switch interfaces
181-
- Uses LLDP data to identify correct switch ports
182-
- Sets cable status to "Connected"
183-
184-
5. **IP Address Assignment**
185-
- Assigns IP addresses to BMC interfaces
186-
- Associates IP with interface in Nautobot IPAM
187-
- Converts DHCP leases to static assignments if applicable
188-
189-
## Validation and Error Handling
190-
191-
### LLDP Neighbor Validation
192-
193-
The system validates that sufficient LLDP neighbors are discovered:
194-
195-
```python
196-
MIN_REQUIRED_NEIGHBOR_COUNT = 3
197-
```
198-
199-
If fewer than 3 neighbors are found, the workflow fails with a detailed error message showing which interfaces have LLDP data.
200-
201-
### Location Consistency
202-
203-
All connected switches must be in the same location and rack. If switches span multiple locations, the workflow fails to prevent topology errors.
204-
205-
### IP Address Conflicts
206-
207-
The system detects and prevents:
208-
209-
- IP addresses already assigned to different interfaces
210-
- Interfaces already associated with different IP addresses
211-
212-
### Switch Port Conflicts
213-
214-
When creating cables, the system validates:
215-
216-
- Switch interface exists in Nautobot
217-
- Switch port is not already connected to another device
142+
- **Manufacturer**: System vendor from `system_vendor.manufacturer` (e.g., Dell)
143+
- **Model Number**: Product name from `system_vendor.product_name` (stripped of parenthetical suffixes)
144+
- **Serial Number**: System serial number from `system_vendor.serial_number`
145+
- **BMC IP Address**: Out-of-band management IP from `bmc_address`
146+
- **BMC MAC Address**: BMC interface MAC address from `bmc_mac`
147+
- **BIOS Version**: Firmware version from `system_vendor.firmware.version`
148+
- **Memory**: Total RAM in GiB (converted from `memory.physical_mb`)
149+
- **CPU**: Processor model from `cpu.model_name`
150+
- **Power State**: Assumed to be powered on during inspection
151+
- **Hostname**: System hostname from inventory
152+
153+
#### Interface Information
154+
155+
For each network interface discovered during inspection, the following attributes are extracted:
156+
157+
**BMC Interface (iDRAC):**
158+
159+
- **Name**: "iDRAC"
160+
- **Description**: "Dedicated iDRAC interface"
161+
- **MAC Address**: From `bmc_mac` (normalized to uppercase)
162+
- **Hostname**: System hostname
163+
- **IPv4 Address**: From `bmc_address` (assumed /26 subnet)
164+
- **IPv4 Gateway**: Not set for Ironic-sourced data
165+
- **DHCP**: False (assumed static)
166+
- **LLDP Data**: Not collected for BMC interface
167+
168+
**Server Interfaces:**
169+
170+
- **Name**: Linux interface name converted to Redfish format (e.g., `eno8303``NIC.Embedded.1-1-1`)
171+
- **Description**: Network driver name + " interface" (e.g., "bnxt_en interface")
172+
- **MAC Address**: From interface `mac_address` (normalized to uppercase)
173+
- **Hostname**: System hostname
174+
- **IPv4 Address**: Not collected for server interfaces (only BMC has IP)
175+
- **LLDP Neighbor Data** (parsed from LLDP TLVs):
176+
- **Remote Switch MAC Address**: From LLDP TLV Type 1 (Chassis ID, subtype 4 - MAC address)
177+
- **Remote Switch Port Name**: From LLDP TLV Type 2 (Port ID) or Type 4 (Port Description)
178+
- **Data Staleness**: Marked as fresh (not stale) for Ironic inspection data
218179

219180
## Monitoring and Troubleshooting
220181

@@ -266,13 +227,13 @@ This will publish the Oslo event and trigger Nautobot synchronization.
266227
You can manually trigger the Nautobot update workflow for testing:
267228

268229
```bash
269-
# Capture an event from Ironic
270-
openstack baremetal node show <node-uuid> -f json > node.json
230+
# To view inspect inventory data
231+
openstack baremetal node inventory save [--file <filename>] <node>
271232

272233
# Submit workflow manually
273234
argo -n argo-events submit \
274-
--from workflowtemplate/update-nautobot-on-openstack-oslo-event \
275-
-p event-json "$(cat node.json)"
235+
--from workflowtemplate/openstack-oslo-event \
236+
-p event-json '{"event_type":"baremetal.node.provision_set.end","payload":{"ironic_object.data":{"uuid":"<node-uuid>", "previous_provision_state":"inspecting"}}}'
276237
```
277238

278239
### Verifying Results

python/understack-workflows/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ sync-network-segment-range = "understack_workflows.main.sync_ucvni_group_range:m
4040
openstack-oslo-event = "understack_workflows.main.openstack_oslo_event:main"
4141
netapp-create-svm = "understack_workflows.main.netapp_create_svm:main"
4242
netapp-configure-interfaces = "understack_workflows.main.netapp_configure_net:main"
43-
update-nautobot-on-openstack-oslo-event = "understack_workflows.main.update_nautobot:main"
4443

4544
[dependency-groups]
4645
test = [

0 commit comments

Comments
 (0)