p/fuel: Fix opnfv user missing _param
[armband.git] / patches / opnfv-fuel / 0017-lib.sh-rm-Ubuntu-boot-entry-on-EFI-systems.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 Enea AB and others.
3 :
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Thu, 24 Aug 2017 04:09:59 +0200
11 Subject: [PATCH] lib.sh: rm Ubuntu boot entry on EFI systems
12
13 On EFI-enabled systems, grub-install from grub-efi-* package
14 installs a boot entry named "ubuntu".
15
16 MaaS relies on IPMI to set boot order to PXE first; however
17 on systems with buggy firmware or without full IPMI support,
18 that fails, leading to booting Ubuntu from hard disk instead.
19
20 Work around this by clearing any previous Ubuntu boot entry
21 from board flash, before starting a new baremetal deploy.
22
23 NOTE: This only runs against nodes that are online from a
24 previous deploy.
25
26 Closes: ARMBAND-47
27
28 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
29 ---
30  mcp/scripts/lib.sh | 10 ++++++++++
31  1 file changed, 10 insertions(+)
32
33 diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh
34 index 3f74058..5389ced 100644
35 --- a/mcp/scripts/lib.sh
36 +++ b/mcp/scripts/lib.sh
37 @@ -25,6 +25,15 @@ get_base_image() {
38    wget -P /tmp -N "${base_image}"
39  }
40
41 +cleanup_uefi() {
42 +  # Clean up Ubuntu boot entry if cfg01, kvm nodes online from previous deploy
43 +  # shellcheck disable=SC2086
44 +  ssh ${SSH_OPTS} "ubuntu@${SALT_MASTER}" "sudo salt -C 'kvm* or cmp*' cmd.run \
45 +    \"which efibootmgr > /dev/null 2>&1 && \
46 +    efibootmgr | grep -oP '(?<=Boot)[0-9]+(?=.*ubuntu)' | \
47 +    xargs -I{} efibootmgr --delete-bootnum --bootnum {}\"" || true
48 +}
49 +
50  cleanup_vms() {
51    # clean up existing nodes
52    for node in $(virsh list --name | grep -P '\w{3}\d{2}'); do
53 @@ -39,6 +48,7 @@ prepare_vms() {
54    local -n vnodes=$1
55    local base_image=$2
56
57 +  cleanup_uefi
58    cleanup_vms
59    get_base_image "${base_image}"
60    envsubst < user-data.template > user-data.sh