Merge "lib.sh: Cleanup previous /boot/efi contents" into stable/euphrates
[fuel.git] / mcp / scripts / lib.sh
index 8bdb5dd..c6d5d26 100644 (file)
@@ -35,6 +35,16 @@ function get_base_image {
   wget -P "${image_dir}" -N "${base_image}"
 }
 
+function cleanup_uefi {
+  # Clean up Ubuntu boot entry if cfg01, kvm nodes online from previous deploy
+  # shellcheck disable=SC2086
+  ssh ${SSH_OPTS} "${SSH_SALT}" "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 {}; \
+    rm -rf /boot/efi/*\"" || true
+}
+
 function cleanup_vms {
   # clean up existing nodes
   for node in $(virsh list --name | grep -P '\w{3}\d{2}'); do
@@ -52,6 +62,7 @@ function prepare_vms {
   local image_dir=$1; shift
   local vnodes=("$@")
 
+  cleanup_uefi
   cleanup_vms
   get_base_image "${base_image}" "${image_dir}"
   # shellcheck disable=SC2016
@@ -95,8 +106,8 @@ function create_vms {
   # AArch64: prepare arch specific arguments
   local virt_extra_args=""
   if [ "$(uname -i)" = "aarch64" ]; then
-    # No Cirrus VGA on AArch64, use vga std
-    virt_extra_args="$virt_extra_args --video=vga"
+    # No Cirrus VGA on AArch64, use virtio instead
+    virt_extra_args="$virt_extra_args --video=virtio"
   fi
 
   # create vms with specified options