From 763b5c22486fbc21cb08b251886f9c5b06e76792 Mon Sep 17 00:00:00 2001
From: Matthew Fuller <mf4192@att.com>
Date: Thu, 25 Feb 2021 00:50:08 +0000
Subject: [PATCH] Add support for extra BMO replacements

Adds support for additional Baremetal Operator replacements
in the NetworkCatalogue CRD.

Relates-To: #469
Change-Id: I4788813b3db82459d2b975fca2b3e74d3792cb63
---
 .../networking.yaml                           |  7 ++
 .../airshipctl-schemas/network-catalogue.yaml | 15 ++++
 .../baremetal-operator/ironic-vars.yaml       | 10 +++
 .../replacements/networking.yaml              | 70 +++++++++++++++++++
 4 files changed, 102 insertions(+)

diff --git a/manifests/function/airshipctl-base-catalogues/networking.yaml b/manifests/function/airshipctl-base-catalogues/networking.yaml
index dfe555b19..c420f874d 100644
--- a/manifests/function/airshipctl-base-catalogues/networking.yaml
+++ b/manifests/function/airshipctl-base-catalogues/networking.yaml
@@ -23,6 +23,13 @@ spec:
     provisioningInterface: "pxe"
     provisioningIp: "10.23.25.102"
     dhcpRange: "10.23.25.200,10.23.25.250"
+    ironicAutomatedClean: ""
+    httpPort: ""
+    ironicFastTrack: ""
+    deployKernelUrl: ""
+    deployRamdiskUrl: ""
+    ironicEndpoint: ""
+    ironicInspectorEndpoint: ""
 
   # This section is only relevant when using Metal3 BareMetalHosts, and
   # is consumed by the `hostgenerator-m3` function.
diff --git a/manifests/function/airshipctl-schemas/network-catalogue.yaml b/manifests/function/airshipctl-schemas/network-catalogue.yaml
index e2701b683..e736913b4 100644
--- a/manifests/function/airshipctl-schemas/network-catalogue.yaml
+++ b/manifests/function/airshipctl-schemas/network-catalogue.yaml
@@ -119,3 +119,18 @@ spec:
                   dhcpRange:
                     # TODO(mfuller): should this be enforced with a pattern?
                     type: string
+                  ironicAutomatedClean:
+                    type: boolean
+                  httpPort:
+                    type: integer
+                    maximum: 65535
+                  ironicFastTrack:
+                    type: boolean
+                  deployKernelUrl:
+                    type: string
+                  deployRamdiskUrl:
+                    type: string
+                  ironicEndpoint:
+                    type: string
+                  ironicInspectorEndpoint:
+                    type: string
diff --git a/manifests/function/baremetal-operator/ironic-vars.yaml b/manifests/function/baremetal-operator/ironic-vars.yaml
index 5267657d0..e856ee158 100644
--- a/manifests/function/baremetal-operator/ironic-vars.yaml
+++ b/manifests/function/baremetal-operator/ironic-vars.yaml
@@ -27,3 +27,13 @@ data:
   IRONIC_VOLUME_CAPACITY: "10Gi"
   IRONIC_STORAGE_CLASS_NAME: "default"
   IRONIC_HOST_PATH: "/opt/metal3-dev-env/ironic/"
+
+  # Additional Baremetal Operator values overridable via the `replacements` entrypoint
+  # and networking catalogue
+  # IRONIC_AUTOMATED_CLEAN: “false”
+  # HTTP_PORT: "80"
+  # IRONIC_FAST_TRACK: "false"
+  # DEPLOY_KERNEL_URL: http://172.30.0.140:80/images/ipa-ubuntu-master.kernel
+  # DEPLOY_RAMDISK_URL: http://172.30.0.140:80/images/ipa-ubuntu-master.initramfs
+  # IRONIC_ENDPOINT: http://172.30.0.140:6385/v1/
+  # IRONIC_INSPECTOR_ENDPOINT: http://172.30.0.140:5050/v1/
diff --git a/manifests/function/baremetal-operator/replacements/networking.yaml b/manifests/function/baremetal-operator/replacements/networking.yaml
index 6e372119e..7fb0d41dc 100644
--- a/manifests/function/baremetal-operator/replacements/networking.yaml
+++ b/manifests/function/baremetal-operator/replacements/networking.yaml
@@ -39,3 +39,73 @@ replacements:
       kind: ConfigMap
       name: ironic-vars
     fieldrefs: ["data.DHCP_RANGE"]
+- source:
+    objref:
+      kind: NetworkCatalogue
+      name: networking
+    fieldref: spec.ironic.ironicAutomatedClean
+  target:
+    objref:
+      kind: ConfigMap
+      name: ironic-vars
+    fieldrefs: ["data.IRONIC_AUTOMATED_CLEAN"]
+- source:
+    objref:
+      kind: NetworkCatalogue
+      name: networking
+    fieldref: spec.ironic.httpPort
+  target:
+    objref:
+      kind: ConfigMap
+      name: ironic-vars
+    fieldrefs: ["data.HTTP_PORT"]
+- source:
+    objref:
+      kind: NetworkCatalogue
+      name: networking
+    fieldref: spec.ironic.ironicFastTrack
+  target:
+    objref:
+      kind: ConfigMap
+      name: ironic-vars
+    fieldrefs: ["data.IRONIC_FAST_TRACK"]
+- source:
+    objref:
+      kind: NetworkCatalogue
+      name: networking
+    fieldref: spec.ironic.deployKernelUrl
+  target:
+    objref:
+      kind: ConfigMap
+      name: ironic-vars
+    fieldrefs: ["data.DEPLOY_KERNEL_URL"]
+- source:
+    objref:
+      kind: NetworkCatalogue
+      name: networking
+    fieldref: spec.ironic.deployRamdiskUrl
+  target:
+    objref:
+      kind: ConfigMap
+      name: ironic-vars
+    fieldrefs: ["data.DEPLOY_RAMDISK_URL"]
+- source:
+    objref:
+      kind: NetworkCatalogue
+      name: networking
+    fieldref: spec.ironic.ironicEndpoint
+  target:
+    objref:
+      kind: ConfigMap
+      name: ironic-vars
+    fieldrefs: ["data.IRONIC_ENDPOINT"]
+- source:
+    objref:
+      kind: NetworkCatalogue
+      name: networking
+    fieldref: spec.ironic.ironicInspectorEndpoint
+  target:
+    objref:
+      kind: ConfigMap
+      name: ironic-vars
+    fieldrefs: ["data.IRONIC_INSPECTOR_ENDPOINT"]