From f9d2d4ef27d4d7a2bf67ce05ae4f71d23acee581 Mon Sep 17 00:00:00 2001 From: Matt McEuen Date: Wed, 8 Jul 2020 19:00:00 -0500 Subject: [PATCH] Add hardware profile / firmware plumbing This adds firmware definition into the hostgenerator-m3 function, along with a default hardwareProfile/firmware definition; it also adds a hardwareprofile-example function that can be used as an example for creating and consuming hardwareProfiles. In the future, other things will be added to hardwareProfiles in addition to firmware, for consumption by hostgenerator-m3 and/or by other functions. Closes: #291 Change-Id: I586284f07e5b98353af06ecb7559a64771297e44 --- .../hardwareprofile-example/README.md | 13 +++++++++++++ .../hardwareprofile.yaml | 10 ++++++++++ .../kustomization.yaml | 4 ++++ .../replacements/hosts.yaml | 19 +++++++++++++++++++ .../replacements/kustomization.yaml | 4 ++++ .../hostgenerator-m3/hosttemplate.yaml | 17 ++++++++++++++++- .../hostgenerator/kustomization.yaml | 4 ++++ .../hostgenerator/kustomization.yaml | 4 ++++ .../test-site/shared/catalogues/hosts.yaml | 2 ++ 9 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 manifests/function/hardwareprofile-example/README.md create mode 100644 manifests/function/hardwareprofile-example/hardwareprofile.yaml create mode 100644 manifests/function/hardwareprofile-example/kustomization.yaml create mode 100644 manifests/function/hardwareprofile-example/replacements/hosts.yaml create mode 100644 manifests/function/hardwareprofile-example/replacements/kustomization.yaml diff --git a/manifests/function/hardwareprofile-example/README.md b/manifests/function/hardwareprofile-example/README.md new file mode 100644 index 000000000..ecc652d75 --- /dev/null +++ b/manifests/function/hardwareprofile-example/README.md @@ -0,0 +1,13 @@ +Function: hardwareprofile-example +================================= + +This function defines a hardware profile that can be consumed by the +hostgenerator-m3 function, and which has the same values as the default +profile defined in that function. It serves as an example for how other +hardware profile functions can be created and consumed. + +The `/replacements` kustomization contains a substution rule that injects +the profile into the hostgenerator BMH template. Please see the +`manifests/type/gating` type and `manifests/type/test-site` +kustomization.yamls to see how a hardwareprofile function can be wired in. + diff --git a/manifests/function/hardwareprofile-example/hardwareprofile.yaml b/manifests/function/hardwareprofile-example/hardwareprofile.yaml new file mode 100644 index 000000000..0b71cf587 --- /dev/null +++ b/manifests/function/hardwareprofile-example/hardwareprofile.yaml @@ -0,0 +1,10 @@ +apiVersion: airshipit.org/v1alpha1 +kind: VariableCatalogue +metadata: + # NOTE: change this when copying this example + name: hardwareprofile-example +hardwareProfile: + firmware: + sriovEnabled: false + virtualizationDisabled: false + simultaneousMultithreadingDisabled: false diff --git a/manifests/function/hardwareprofile-example/kustomization.yaml b/manifests/function/hardwareprofile-example/kustomization.yaml new file mode 100644 index 000000000..4f81598b9 --- /dev/null +++ b/manifests/function/hardwareprofile-example/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - hardwareprofile.yaml diff --git a/manifests/function/hardwareprofile-example/replacements/hosts.yaml b/manifests/function/hardwareprofile-example/replacements/hosts.yaml new file mode 100644 index 000000000..fa406fea6 --- /dev/null +++ b/manifests/function/hardwareprofile-example/replacements/hosts.yaml @@ -0,0 +1,19 @@ +# These rules inject host-specific information from the `host-catalogue` +# into the hostgenerator-m3 function's Template plugin config. +apiVersion: airshipit.org/v1alpha1 +kind: ReplacementTransformer +metadata: + # NOTE: change this when copying this example + name: hardwareprofile-example-replacements +replacements: +- source: + objref: + # NOTE: change this to match your hardwareProfile's metadata.name + name: hardwareprofile-example + fieldref: hardwareProfile + target: + objref: + kind: Templater + name: m3-host-template + # NOTE: change "example" below when copying this example + fieldrefs: [values.hardwareProfiles.example] diff --git a/manifests/function/hardwareprofile-example/replacements/kustomization.yaml b/manifests/function/hardwareprofile-example/replacements/kustomization.yaml new file mode 100644 index 000000000..69030f1c9 --- /dev/null +++ b/manifests/function/hardwareprofile-example/replacements/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - hosts.yaml diff --git a/manifests/function/hostgenerator-m3/hosttemplate.yaml b/manifests/function/hostgenerator-m3/hosttemplate.yaml index 12b91d483..3de8bdc80 100644 --- a/manifests/function/hostgenerator-m3/hosttemplate.yaml +++ b/manifests/function/hostgenerator-m3/hosttemplate.yaml @@ -3,7 +3,7 @@ kind: Templater metadata: name: m3-host-template -# values: +values: # hosts: # (filled in from the comprehensive site-wide host-catalogue) # hostsToGenerate: @@ -11,11 +11,23 @@ metadata: # commonNetworking: # (filled in with the type-specific common-networking-catalogue) + # Additional hardwareProfiles can be defined within their own functions, + # and then substituted into the stanza below. + # See function/hardwareprofile-example for an example of how to do this. + hardwareProfiles: + default: + # Reference: https://github.com/metal3-io/metal3-docs/blob/master/design/baremetal-operator/bios-config.md + firmware: + sriovEnabled: false + virtualizationDisabled: false + simultaneousMultithreadingDisabled: false + template: | {{- $envAll := . }} {{- range .hostsToGenerate }} {{- $hostName := . }} {{- $host := index $envAll.hosts $hostName }} + {{- $hardwareProfile := index $envAll.hardwareProfiles $host.hardwareProfile }} --- apiVersion: metal3.io/v1alpha1 kind: BareMetalHost @@ -33,6 +45,9 @@ template: | bmc: address: {{ $host.bmcAddress }} credentialsName: {{ $hostName }}-bmc-secret + firmware: + {{ toYaml $hardwareProfile.firmware | indent 4 }} + --- apiVersion: v1 kind: Secret diff --git a/manifests/site/test-site/ephemeral/bootstrap/hostgenerator/kustomization.yaml b/manifests/site/test-site/ephemeral/bootstrap/hostgenerator/kustomization.yaml index 8de561b8c..ea23edf11 100644 --- a/manifests/site/test-site/ephemeral/bootstrap/hostgenerator/kustomization.yaml +++ b/manifests/site/test-site/ephemeral/bootstrap/hostgenerator/kustomization.yaml @@ -1,9 +1,13 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + # TODO: these two should move up to type level in the future - ../../../../../function/hostgenerator-m3 + - ../../../../../function/hardwareprofile-example - ../../../shared/catalogues/ - host-generation.yaml transformers: + # TODO: these two should move up to type level in the future - ../../../../../function/hostgenerator-m3/replacements + - ../../../../../function/hardwareprofile-example/replacements diff --git a/manifests/site/test-site/ephemeral/controlplane/hostgenerator/kustomization.yaml b/manifests/site/test-site/ephemeral/controlplane/hostgenerator/kustomization.yaml index 8de561b8c..ea23edf11 100644 --- a/manifests/site/test-site/ephemeral/controlplane/hostgenerator/kustomization.yaml +++ b/manifests/site/test-site/ephemeral/controlplane/hostgenerator/kustomization.yaml @@ -1,9 +1,13 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + # TODO: these two should move up to type level in the future - ../../../../../function/hostgenerator-m3 + - ../../../../../function/hardwareprofile-example - ../../../shared/catalogues/ - host-generation.yaml transformers: + # TODO: these two should move up to type level in the future - ../../../../../function/hostgenerator-m3/replacements + - ../../../../../function/hardwareprofile-example/replacements diff --git a/manifests/site/test-site/shared/catalogues/hosts.yaml b/manifests/site/test-site/shared/catalogues/hosts.yaml index 618f936fb..ae5936b5b 100644 --- a/manifests/site/test-site/shared/catalogues/hosts.yaml +++ b/manifests/site/test-site/shared/catalogues/hosts.yaml @@ -18,6 +18,7 @@ hosts: oam: 52:54:00:9b:27:4c pxe: 52:54:00:b6:ed:31 bootMode: legacy + hardwareProfile: default # defined in the hostgenerator-m3 function node02: macAddress: 52:54:00:b6:ed:02 bmcAddress: redfish+http://10.23.25.2:8000/redfish/v1/Systems/air-target-2 @@ -29,3 +30,4 @@ hosts: macAddresses: oam: 52:54:00:9b:27:02 pxe: 52:54:00:b6:ed:02 + hardwareProfile: example # defined in the hardwareprofile-example function