p/fuel: UEFI: Rework Ubuntu boot entry cleanup 43/40443/1
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Mon, 28 Aug 2017 19:06:07 +0000 (21:06 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Mon, 28 Aug 2017 19:08:04 +0000 (21:08 +0200)
JIRA: ARMBAND-287

Change-Id: Ib4a5d1c1bebe8fe09696fcb1cb882f42679d6738
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
patches/opnfv-fuel/0018-lib.sh-rm-Ubuntu-boot-entry-on-EFI-systems.patch [new file with mode: 0644]
patches/opnfv-fuel/0018-states-maas-rm-Ubuntu-boot-entry-on-EFI-systems.patch [deleted file]

diff --git a/patches/opnfv-fuel/0018-lib.sh-rm-Ubuntu-boot-entry-on-EFI-systems.patch b/patches/opnfv-fuel/0018-lib.sh-rm-Ubuntu-boot-entry-on-EFI-systems.patch
new file mode 100644 (file)
index 0000000..0dea963
--- /dev/null
@@ -0,0 +1,52 @@
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Thu, 24 Aug 2017 04:09:59 +0200
+Subject: [PATCH] lib.sh: rm Ubuntu boot entry on EFI systems
+
+On EFI-enabled systems, grub-install from grub-efi-* package
+installs a boot entry named "ubuntu".
+
+MaaS relies on IPMI to set boot order to PXE first; however
+on systems with buggy firmware or without full IPMI support,
+that fails, leading to booting Ubuntu from hard disk instead.
+
+Work around this by clearing any previous Ubuntu boot entry
+from board flash, before starting a new baremetal deploy.
+
+NOTE: This only runs against nodes that are online from a
+previous deploy.
+
+Closes: ARMBAND-47
+
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+---
+ mcp/scripts/lib.sh | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh
+index bbb66a8..de7b9ec 100644
+--- a/mcp/scripts/lib.sh
++++ b/mcp/scripts/lib.sh
+@@ -20,6 +20,15 @@ get_base_image() {
+   wget -P /tmp -nc "${base_image}"
+ }
+
++cleanup_uefi() {
++  # Clean up Ubuntu boot entry if cfg01, kvm nodes online from previous deploy
++  # shellcheck disable=SC2086
++  ssh ${SSH_OPTS} "ubuntu@${SALT_MASTER}" "sudo salt -C 'kvm* or cmp*' cmd.run \
++    \"which efibootmgr > /dev/null 2>&1 && \
++    efibootmgr | grep -oP '(?<=Boot)[0-9]+(?=.*ubuntu)' | \
++    xargs -I{} efibootmgr --delete-bootnum --bootnum {}\"" || true
++}
++
+ cleanup_vms() {
+   # clean up existing nodes
+   for node in $(virsh list --name | grep -P '\w{3}\d{2}'); do
+@@ -34,6 +43,7 @@ prepare_vms() {
+   local -n vnodes=$1
+   local base_image=$2
+
++  cleanup_uefi
+   cleanup_vms
+   get_base_image "${base_image}"
+   envsubst < user-data.template > user-data.sh
diff --git a/patches/opnfv-fuel/0018-states-maas-rm-Ubuntu-boot-entry-on-EFI-systems.patch b/patches/opnfv-fuel/0018-states-maas-rm-Ubuntu-boot-entry-on-EFI-systems.patch
deleted file mode 100644 (file)
index 0443318..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
-Date: Thu, 24 Aug 2017 04:09:59 +0200
-Subject: [PATCH] states/maas: rm Ubuntu boot entry on EFI systems
-
-On EFI-enabled systems, grub-install from grub-efi-* package
-installs a boot entry named "ubuntu".
-
-MaaS relies on IPMI to set boot order to PXE first; however
-on systems with buggy firmware or without full IPMI support,
-that fails, leading to booting Ubuntu from hard disk instead.
-
-Work around this by clearing any previous Ubuntu boot entry
-from board flash.
-
-NOTE: This only runs against nodes that are online from a
-previous deploy, and already automatically registered with
-the new Salt master node.
-
-Closes: ARMBAND-47
-
-Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
----
- mcp/config/states/maas | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/mcp/config/states/maas b/mcp/config/states/maas
-index 9e0093b..4f27984 100755
---- a/mcp/config/states/maas
-+++ b/mcp/config/states/maas
-@@ -44,6 +44,11 @@ function maas_fixup() {
-   return 0
- }
-
-+# UEFI: Clean up Ubuntu boot entry if kvm node online from previous deploy
-+salt -C 'kvm* or cmp*' cmd.run "(which efibootmgr > /dev/null 2>&1 && \
-+  efibootmgr | grep -oP '(?<=Boot)[0-9]+(?=.*ubuntu)' | \
-+  xargs -I{} efibootmgr --delete-bootnum --bootnum {}) || true"
-+
- # MaaS rack/region controller, node commissioning
- salt -C 'mas01*' cmd.run "add-apt-repository ppa:maas/stable"
-