Skip to content

Commit

Permalink
PUC-598: create or set baremetal flavour
Browse files Browse the repository at this point in the history
  • Loading branch information
haseebsyed12 committed Nov 8, 2024
1 parent 73d9a22 commit ecdab59
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions workflows/argo-events/workflowtemplates/baremetal-flavor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
apiVersion: argoproj.io/v1alpha1
metadata:
name: openstack-flavor-create
annotations:
workflows.argoproj.io/title: Set or Create flavors for use with the Bare Metal service
workflows.argoproj.io/description: |
Set or create a flavor with specified properties if it does not already exist.
kind: WorkflowTemplate
spec:
entrypoint: flavor-check
arguments:
parameters:
- name: flavor_name
value: "gp2.small"
- name: flavor_properties
value: "--property resources:CUSTOM_BAREMETAL_GP2SMALL=1 --property resources:VCPU=0 --property resources:MEMORY_MB=0 --property resources:DISK_GB=0"
templates:
- name: flavor-check
steps:
- - name: check-flavor
template: check-flavor
- - name: create-flavor
template: create-flavor
arguments:
parameters:
- name: flavor_properties
value: "{{workflow.parameters.flavor_properties}}"
when: "{{steps.check-flavor.outputs.parameters.flavor_exists}} == false"
- - name: set-flavor
template: set-flavor
arguments:
parameters:
- name: flavor_properties
value: "{{workflow.parameters.flavor_properties}}"
when: "{{steps.check-flavor.outputs.parameters.flavor_exists}} == true"
- - name: show-flavor
template: show-flavor

- name: show-flavor
container:
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy
command:
- openstack
args:
- flavor
- show
- "{{workflow.parameters.flavor_name}}"
env:
- name: OS_CLOUD
value: understack
volumeMounts:
- mountPath: /etc/openstack
name: openstack-svc-acct
readOnly: true

- name: check-flavor
container:
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy
command:
- sh
- -c
- |
echo "Checking if {{workflow.parameters.flavor_name}} flavor exists..."
flavor_check=$(openstack --os-cloud understack flavor show {{workflow.parameters.flavor_name}} 2>/dev/null | head -1)
if [ -n "$flavor_check" ]; then
echo -n "true" > /tmp/flavor_result.txt
else
echo -n "false" > /tmp/flavor_result.txt
fi
env:
- name: OS_CLOUD
value: understack
volumeMounts:
- mountPath: /etc/openstack
name: openstack-svc-acct
readOnly: true
outputs:
parameters:
- name: flavor_exists
valueFrom:
default: "false"
path: /tmp/flavor_result.txt

- name: create-flavor
inputs:
parameters:
- name: flavor_properties
container:
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy
command:
- sh
- -c
- |
eval "openstack flavor create '{{workflow.parameters.flavor_name}}' {{inputs.parameters.flavor_properties}}"
args:
- "{{inputs.parameters.flavor_properties}}"
env:
- name: OS_CLOUD
value: understack
volumeMounts:
- mountPath: /etc/openstack
name: openstack-svc-acct
readOnly: true

- name: set-flavor
inputs:
parameters:
- name: flavor_properties
container:
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy
command:
- sh
- -c
- |
eval "openstack flavor set '{{workflow.parameters.flavor_name}}' {{inputs.parameters.flavor_properties}}"
args:
- "{{inputs.parameters.flavor_properties}}"
env:
- name: OS_CLOUD
value: understack
volumeMounts:
- mountPath: /etc/openstack
name: openstack-svc-acct
readOnly: true

volumes:
- name: openstack-svc-acct
secret:
secretName: openstack-svc-acct

0 comments on commit ecdab59

Please sign in to comment.