From f49b5095348c437a2876a645c1d1648f0ede8adf Mon Sep 17 00:00:00 2001
From: "Battina, Sai (sb464f)" <sb464f@att.com>
Date: Thu, 3 Dec 2020 13:24:35 -0600
Subject: [PATCH] Update IPA packages in ironic

This PS updates ironic deployment with IPA init container
which contains python agent agent packages which are ubuntu based
packages. The docker image for this can found here [0]

[0]
https://opendev.org/airship/images/src/branch/master/ipa-downloader-image

Change-Id: Idaaafb2ddb562cf22a62df36100dd1e6c76211fc
---
 .../config-file/inspector.ipxe                   |  4 ++--
 .../baremetal-operator/entrypoint/init-bootstrap | 14 --------------
 .../baremetal-operator/entrypoint/init-images    |  6 ++++++
 .../entrypoint/inspector-entrypoint              |  4 ++++
 .../entrypoint/kustomization.yaml                |  1 +
 .../function/baremetal-operator/ironic-vars.yaml |  6 ++----
 .../function/baremetal-operator/ironic.yaml      | 16 ++++++++++++++++
 playbooks/airship-airshipctl-build-gate.yaml     | 10 +++++-----
 8 files changed, 36 insertions(+), 25 deletions(-)
 create mode 100644 manifests/function/baremetal-operator/entrypoint/init-images

diff --git a/manifests/function/baremetal-operator/config-file/inspector.ipxe b/manifests/function/baremetal-operator/config-file/inspector.ipxe
index 16f7512be..e1ec284dc 100644
--- a/manifests/function/baremetal-operator/config-file/inspector.ipxe
+++ b/manifests/function/baremetal-operator/config-file/inspector.ipxe
@@ -4,6 +4,6 @@
 echo In inspector.ipxe
 imgfree
 # NOTE(dtantsur): keep inspection kernel params in [mdns]params in ironic-inspector-image
-kernel --timeout 60000 http://$(PROVISIONING_IP):80/images/tinyipa-stable-ussuri.vmlinuz ipa-inspection-callback-url=http://$(PROVISIONING_IP):5050/v1/continue ipa-inspection-collectors=default,extra-hardware,logs systemd.journald.forward_to_console=yes BOOTIF=${mac} ipa-debug=1 ipa-inspection-dhcp-all-interfaces=1 ipa-collect-lldp=1 initrd=tinyipa-stable-ussuri.gz || goto retry_boot
-initrd --timeout 60000 http://$(PROVISIONING_IP):80/images/tinyipa-stable-ussuri.gz || goto retry_boot
+kernel --timeout 60000 http://$(PROVISIONING_IP):80/images/ipa-ubuntu-master.kernel ipa-inspection-callback-url=http://$(PROVISIONING_IP):5050/v1/continue ipa-inspection-collectors=default,extra-hardware,logs systemd.journald.forward_to_console=yes BOOTIF=${mac} ipa-debug=1 ipa-inspection-dhcp-all-interfaces=1 ipa-collect-lldp=1 initrd=ipa-ubuntu-master.initramfs || goto retry_boot
+initrd --timeout 60000 http://$(PROVISIONING_IP):80/images/ipa-ubuntu-master.initramfs || goto retry_boot
 boot
diff --git a/manifests/function/baremetal-operator/entrypoint/init-bootstrap b/manifests/function/baremetal-operator/entrypoint/init-bootstrap
index a2cc0fd0b..23329849e 100644
--- a/manifests/function/baremetal-operator/entrypoint/init-bootstrap
+++ b/manifests/function/baremetal-operator/entrypoint/init-bootstrap
@@ -31,20 +31,6 @@ for f in $( ls ); do
 done
 popd
 
-pushd /shared/html/images
-STATUSCODE=$(curl --silent --insecure --location -O --write-out "%{http_code}" ${IPA_RAMDISK})
-if test $STATUSCODE -ne 200; then
-    echo "Failed to load ${ARTS[${art}]}"
-    exit 1
-fi
-
-STATUSCODE=$(curl --silent --insecure --location -O --write-out "%{http_code}" ${IPA_KERNEL})
-if test $STATUSCODE -ne 200; then
-    echo "Failed to load ${ARTS[${art}]}"
-    exit 1
-fi
-popd
-
 chmod -R 0777 /shared/html
 
 touch /shared/init_finished
diff --git a/manifests/function/baremetal-operator/entrypoint/init-images b/manifests/function/baremetal-operator/entrypoint/init-images
new file mode 100644
index 000000000..09151eae9
--- /dev/null
+++ b/manifests/function/baremetal-operator/entrypoint/init-images
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -xe
+
+#Copy files to shared mount
+cp -f /ipa-ubuntu-master* /shared/html/images/
+chmod 777 -R /shared/html/images/
diff --git a/manifests/function/baremetal-operator/entrypoint/inspector-entrypoint b/manifests/function/baremetal-operator/entrypoint/inspector-entrypoint
index b2d588809..e2b2d9092 100644
--- a/manifests/function/baremetal-operator/entrypoint/inspector-entrypoint
+++ b/manifests/function/baremetal-operator/entrypoint/inspector-entrypoint
@@ -1,5 +1,9 @@
 #!/usr/bin/bash
 
+. /bin/ironic-common.sh
+
+wait_for_interface_or_ip
+
 ironic-inspector-dbsync --config-file /shared/inspector.conf upgrade
 
 exec /usr/bin/ironic-inspector --config-file /etc/ironic-inspector/inspector-dist.conf \
diff --git a/manifests/function/baremetal-operator/entrypoint/kustomization.yaml b/manifests/function/baremetal-operator/entrypoint/kustomization.yaml
index ee51456c4..31f0f841a 100644
--- a/manifests/function/baremetal-operator/entrypoint/kustomization.yaml
+++ b/manifests/function/baremetal-operator/entrypoint/kustomization.yaml
@@ -6,6 +6,7 @@ configMapGenerator:
   files:
     - dnsmasq-entrypoint
     - httpd-entrypoint
+    - init-images
     - init-bootstrap
     - inspector-entrypoint
     - ironic-entrypoint
diff --git a/manifests/function/baremetal-operator/ironic-vars.yaml b/manifests/function/baremetal-operator/ironic-vars.yaml
index e73649bd5..5267657d0 100644
--- a/manifests/function/baremetal-operator/ironic-vars.yaml
+++ b/manifests/function/baremetal-operator/ironic-vars.yaml
@@ -19,13 +19,11 @@ data:
   # Overrideable via the `replacements` entrypoint and networking catalogue
   PROVISIONING_INTERFACE: "pxe"
   HTTP: "80"
-  DEPLOY_KERNEL_PATH: "/images/tinyipa-stable-ussuri.vmlinuz"
-  DEPLOY_RAMDISK_PATH: "/images/tinyipa-stable-ussuri.gz"
+  DEPLOY_KERNEL_PATH: "/images/ipa-ubuntu-master.kernel"
+  DEPLOY_RAMDISK_PATH: "/images/ipa-ubuntu-master.initramfs"
   FAST_TRACK: "false"
   API_WORKERS: "4"
   AUTOMATED_CLEAN: "true"
   IRONIC_VOLUME_CAPACITY: "10Gi"
   IRONIC_STORAGE_CLASS_NAME: "default"
   IRONIC_HOST_PATH: "/opt/metal3-dev-env/ironic/"
-  IPA_RAMDISK: "https://tarballs.opendev.org/openstack/ironic-python-agent/tinyipa/files/tinyipa-stable-ussuri.gz"
-  IPA_KERNEL: "https://tarballs.opendev.org/openstack/ironic-python-agent/tinyipa/files/tinyipa-stable-ussuri.vmlinuz"
diff --git a/manifests/function/baremetal-operator/ironic.yaml b/manifests/function/baremetal-operator/ironic.yaml
index 37a4af8f8..cef93433f 100644
--- a/manifests/function/baremetal-operator/ironic.yaml
+++ b/manifests/function/baremetal-operator/ironic.yaml
@@ -36,6 +36,9 @@ spec:
           image: "centos"
           imagePullPolicy: Always
           command: ['/bin/init-bootstrap']
+          envFrom:
+            - configMapRef:
+                name: ironic-vars
           volumeMounts:
             - name: ironic-storage
               mountPath: "/shared"
@@ -46,6 +49,16 @@ spec:
               mountPath: /cfg
             - name: ironic-vars
               mountPath: /ironic-vars
+        - name: init-images
+          image: quay.io/airshipit/ipa:latest
+          imagePullPolicy: Always
+          command: ['/bin/init-images']
+          volumeMounts:
+            - name: ironic-storage
+              mountPath: "/shared"
+            - name: ironic-entrypoints
+              mountPath: /bin/init-images
+              subPath: init-images
       containers:
         - name: dnsmasq
           image: "quay.io/metal3-io/ironic:latest"
@@ -88,6 +101,9 @@ spec:
           image: "quay.io/metal3-io/ironic-inspector:latest"
           imagePullPolicy: Always
           command: ["/bin/runironic-inspector"]
+          envFrom:
+            - configMapRef:
+                name: ironic-vars
           securityContext:
             privileged: true
           volumeMounts:
diff --git a/playbooks/airship-airshipctl-build-gate.yaml b/playbooks/airship-airshipctl-build-gate.yaml
index 8180b0427..c2eb4c548 100644
--- a/playbooks/airship-airshipctl-build-gate.yaml
+++ b/playbooks/airship-airshipctl-build-gate.yaml
@@ -92,15 +92,15 @@
             ephemeral_vm_cfg: "{{ ephemeral_vm_cfg }}"
             ephemeral_vm_memory_mb: 6124
             ephemeral_vm_vcpus: 4
-            target_disk_size: 10G
+            target_disk_size: 20G
             target_vm_cfg: "{{ target_vm_cfg }}"
-            target_vm_memory_mb: 4096
+            target_vm_memory_mb: 6124
             target_vm_vcpus: 2
             target_vms_count: 1
-            worker_disk_size: 10G
+            worker_disk_size: 20G
             worker_vm_cfg: "{{ worker_vm_cfg }}"
-            worker_vm_memory_mb: 1024
-            worker_vm_vcpus: 1
+            worker_vm_memory_mb: 6124
+            worker_vm_vcpus: 2
             worker_vms_count: 1
         airship_gate_file_exchanger:
           servername: "localhost"