diff --git a/content/params/machine-meta.color.yaml b/content/params/machine-meta.color.yaml new file mode 100644 index 00000000..1905f170 --- /dev/null +++ b/content/params/machine-meta.color.yaml @@ -0,0 +1,8 @@ +Description: The color for machines icon +Meta: + color: blue + icon: info + title: RackN Content +Name: machine-meta/color +Schema: + type: string diff --git a/content/params/machine-meta.icon.yaml b/content/params/machine-meta.icon.yaml new file mode 100644 index 00000000..3af592ea --- /dev/null +++ b/content/params/machine-meta.icon.yaml @@ -0,0 +1,8 @@ +Description: The icon for machines icon +Meta: + color: blue + icon: info + title: RackN Content +Name: machine-meta/icon +Schema: + type: string diff --git a/content/stages/machine-meta.yaml b/content/stages/machine-meta.yaml new file mode 100644 index 00000000..a492ce4e --- /dev/null +++ b/content/stages/machine-meta.yaml @@ -0,0 +1,10 @@ +Description: Stage to assign the machine icon and color +Meta: + color: yellow + icon: info +Name: machine-meta +Reboot: false +RunnerWait: true +Tasks: +- machine-meta-setter + diff --git a/content/tasks/machine-meta-setter.yaml b/content/tasks/machine-meta-setter.yaml new file mode 100644 index 00000000..fbd3823e --- /dev/null +++ b/content/tasks/machine-meta-setter.yaml @@ -0,0 +1,14 @@ +Description: A task to set the color and icon for a machine +Meta: + color: blue + icon: info +Name: machine-meta-setter +OptionalParams: + - "machine-meta/color" + - "machine-meta/icon" +Templates: +- Contents: "" + ID: machine-meta-setter.sh.tmpl + Name: "Set Icons" + Path: "" + diff --git a/content/templates/machine-meta-setter.sh.tmpl b/content/templates/machine-meta-setter.sh.tmpl new file mode 100644 index 00000000..24f2be49 --- /dev/null +++ b/content/templates/machine-meta-setter.sh.tmpl @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Set the Machine Meta: Icon and Color + +set -e + +export RS_UUID="{{.Machine.UUID}}" + +{{template "setup.tmpl" .}} + +{{if .ParamExists "machine-meta/color" -}} +COLOR={{.Param "machine-meta/color"}} +{{else -}} +COLOR="black" +{{end -}} + +{{if .ParamExists "machine-meta/icon" -}} +ICON={{.Param "machine-meta/icon"}} +{{else -}} +ICON="server" +{{end -}} + +echo "Setting the Color to $COLOR and Icon to $ICON" + +# do work! +drpcli machines update $RS_UUID "{\"Meta\":{\"color\":\"$COLOR\", \"icon\": \"$ICON\"}}" | jq .Meta + +echo "Finished successfully" +exit 0 + diff --git a/content/templates/setup.tmpl b/content/templates/setup.tmpl index 72e0aa18..8b82cd51 100644 --- a/content/templates/setup.tmpl +++ b/content/templates/setup.tmpl @@ -1,4 +1,6 @@ #!/usr/local/bin/env bash +# Helper to setup DRP tasks for other templates +# ### # This is a BASH script snippet intended to be run inside other BASH templates. #