Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PUC-598: create or set baremetal flavor #454

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
68 changes: 68 additions & 0 deletions workflows/argo-events/workflowtemplates/baremetal-flavor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
apiVersion: argoproj.io/v1alpha1
metadata:
name: baremetal-flavor
annotations:
workflows.argoproj.io/title: Set or Create flavors for use with the Bare Metal service
workflows.argoproj.io/description: |
Defined in `workflows/argo-events/workflowtemplates/baremetal-flavor.yaml`
Set or create a flavor with specified properties if it does not already exist.
kind: WorkflowTemplate
spec:
serviceAccountName: workflow
entrypoint: main
arguments:
parameters:
- name: flavors
value:
'[{"name": "gp2.small", "properties": "--property resources:CUSTOM_BAREMETAL_GP2SMALL=1 --property resources:VCPU=0 --property resources:MEMORY_MB=0 --property resources:DISK_GB=0"},
{"name": "gp3.medium", "properties": "--property resources:CUSTOM_BAREMETAL_GP3MEDIUM=1 --property resources:VCPU=2 --property resources:MEMORY_MB=4096 --property resources:DISK_GB=40"}]'

templates:
- name: main
inputs:
parameters:
- name: flavors
steps:
- - name: create-flavor
template: create-flavor
arguments:
parameters:
- name: flavor_name
value: "{{item.name}}"
- name: flavor_properties
value: "{{item.properties}}"
withParam: "{{inputs.parameters.flavors}}"

- name: create-flavor
inputs:
parameters:
- name: flavor_name
- name: flavor_properties
script:
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy
command: [sh]
source: |
echo "Checking if flavor '{{inputs.parameters.flavor_name}}' exists..."
flavor_name=$(openstack --os-cloud understack flavor show '{{inputs.parameters.flavor_name}}' -f value -c name 2>/dev/null)
echo "$flavor_name"
if [ "$flavor_name" = "{{inputs.parameters.flavor_name}}" ]; then
echo "Setting flavor '{{inputs.parameters.flavor_name}}' with properties {{inputs.parameters.flavor_properties}}"
result=$(openstack flavor set '{{inputs.parameters.flavor_name}}' {{inputs.parameters.flavor_properties}})
else
echo "Creating flavor '{{inputs.parameters.flavor_name}}' with properties {{inputs.parameters.flavor_properties}}"
result=$(openstack flavor create '{{inputs.parameters.flavor_name}}' {{inputs.parameters.flavor_properties}})
fi
echo "$result"
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