Skip to content

Commit a566828

Browse files
committed
add new oslo sensor
1 parent 6ab9ab8 commit a566828

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

workflows/openstack/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ resources:
1717
- serviceaccounts/serviceaccount-k8s-openstack-events.yaml
1818
- sensors/sensor-ironic-node-update.yaml
1919
- sensors/sensor-keystone-event-project.yaml
20+
- sensors/sensor-keystone-oslo-event.yaml
2021
- sensors/sensor-k8s-neutron-deployment.yaml
2122
- sensors/sensor-neutron-event-network-segment-range.yaml
2223
- sensors/sensor-ironic-reclean.yaml
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
apiVersion: argoproj.io/v1alpha1
3+
kind: Sensor
4+
metadata:
5+
name: keystone-oslo-event
6+
annotations:
7+
workflows.argoproj.io/title: Process oslo_events for keystone project
8+
workflows.argoproj.io/description: |+
9+
Triggers on the following Keystone Events:
10+
11+
- identity.project.created
12+
- identity.project.deleted
13+
- other events are silently ignored now
14+
15+
Resulting code should be very similar to:
16+
17+
```
18+
argo -n argo-events submit --from workflowtemplate/openstack-oslo-event \
19+
-p event-json "JSON-payload"
20+
```
21+
22+
Defined in `workflows/argo-events/sensors/keystone-project.yaml`
23+
spec:
24+
dependencies:
25+
- eventName: notifications
26+
eventSourceName: openstack-keystone
27+
name: keystone-dep
28+
transform:
29+
# the event is a string-ified JSON so we need to decode it
30+
# replace the whole event body
31+
jq: |
32+
.body = (.body["oslo.message"] | fromjson)
33+
filters:
34+
# applies each of the items in data with 'and' but there's only one
35+
dataLogicalOperator: "and"
36+
data:
37+
- path: "body.event_type"
38+
type: "string"
39+
value:
40+
- "identity.project.created"
41+
- "identity.project.deleted"
42+
template:
43+
serviceAccountName: sensor-submit-workflow
44+
triggers:
45+
- template:
46+
name: keystone-project
47+
# uses 'argo' CLI instead of 'kubectl'
48+
argoWorkflow:
49+
# sets the operation to 'argo submit'
50+
operation: submit
51+
# edits source section
52+
parameters:
53+
# first parameter is the parsed oslo.message
54+
- dest: spec.arguments.parameters.0.value
55+
src:
56+
dataKey: body
57+
dependencyName: keystone-dep
58+
source:
59+
# create a workflow in argo-events prefixed with keystone-project-
60+
resource:
61+
apiVersion: argoproj.io/v1alpha1
62+
kind: Workflow
63+
metadata:
64+
generateName: keystone-project-
65+
namespace: argo-events
66+
spec:
67+
# defines the parameters being replaced above
68+
arguments:
69+
parameters:
70+
- name: event-json
71+
# references the workflow
72+
workflowTemplateRef:
73+
name: openstack-oslo-event

0 commit comments

Comments
 (0)