Skip to content

Commit

Permalink
[lib] Skip base/VCP image fetch when not used
Browse files Browse the repository at this point in the history
If a POD only has baremetal nodes, without VCP, skip fetching Ubuntu
cloud image.

While at it, prepare for supporting Ubuntu 18.04 base image:
- workaround systemd-resolved being used instead of resolvconf;
- preinstall ifupdown to workaround [1];

[1] saltstack/salt#49078

Change-Id: If51db0bc95eff1a497e1df5d457e26a7b902aa5a
Signed-off-by: Alexandru Avadanii <[email protected]>
  • Loading branch information
alexandruavadanii committed Feb 22, 2019
1 parent f4dc20b commit cdf8db3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions mcp/config/scenario/defaults.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ x86_64:
- saltstack 500 deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7 xenial main
pkg:
install:
- ifupdown
- linux-generic-hwe-16.04
- salt-minion
control:
Expand All @@ -55,6 +56,7 @@ aarch64:
- armband_3 1201 deb [arch=arm64] http://linux.enea.com/mcp-repos/rocky/xenial rocky-armband main
pkg:
install:
- ifupdown
- python-futures
- salt-minion
control:
Expand Down
4 changes: 2 additions & 2 deletions mcp/scripts/docker-compose/files/entrypoint_maas.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{%- set pxebr_addr = nm.net_admin | ipnet_hostaddr(nm.start_ip[nm.net_admin] + nm.net_admin_hosts.index('opnfv_infra_maas_node01_deploy_address') +1) %}
if [ ! -e /var/lib/postgresql/*/main ]; then
cp -ar /var/lib/opnfv/{postgresql,maas} /var/lib/
cp -ar /var/lib/opnfv/etc/{ssh,maas} /etc/
cp -ar /var/lib/opnfv/etc/maas /etc/
fi
chown -R maas:maas /var/lib/maas
chown -R maas:maas /var/lib/maas /etc/maas
chown -R postgres:postgres /var/lib/postgresql
chown -R proxy:proxy /var/spool/maas-proxy

Expand Down
19 changes: 15 additions & 4 deletions mcp/scripts/lib_jump_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ function __mount_image {
sudo mount -t proc proc "${OPNFV_MNT_DIR}/proc"
sudo mount -t sysfs sys "${OPNFV_MNT_DIR}/sys"
sudo mount -o bind /dev "${OPNFV_MNT_DIR}/dev"
sudo mkdir -p "${OPNFV_MNT_DIR}/run/resolvconf"
sudo mkdir -p "${OPNFV_MNT_DIR}/run/resolvconf" \
"${OPNFV_MNT_DIR}/run/systemd/resolve"
sudo cp /etc/resolv.conf "${OPNFV_MNT_DIR}/run/resolvconf"
sudo cp /etc/resolv.conf "${OPNFV_MNT_DIR}/run/systemd/resolve/stub-resolv.conf"
echo "GRUB_DISABLE_OS_PROBER=true" | \
sudo tee -a "${OPNFV_MNT_DIR}/etc/default/grub"
sudo sed -i -e 's/^\(GRUB_TIMEOUT\)=.*$/\1=1/g' -e 's/^GRUB_HIDDEN.*$//g' \
Expand Down Expand Up @@ -220,9 +222,15 @@ function prepare_vms {

cleanup_uefi
__cleanup_vms
__get_base_image "${base_image}" "${image_dir}"
IFS='^' read -r -a repos_pkgs <<< "${repos_pkgs_str}"

if [ ${#vnodes[@]} -eq 0 ] && \
([[ "${repos_pkgs_str}" =~ \^{3}$ ]] || [ -z "${repos_pkgs[*]:4}" ]); then
echo "[INFO] Patched base image / VCP image not required, skipping"
return 0
fi
__get_base_image "${base_image}" "${image_dir}"

local _h=$(echo "${repos_pkgs_str}.$(md5sum "${image_dir}/${_o}")" | \
md5sum | cut -c -8)
local _tmp="${image%.*}.${_h}.img"
Expand Down Expand Up @@ -405,7 +413,6 @@ function prepare_containers {
mkdir -p "${image_dir}/"{salt/master.d,salt/minion.d}

if grep -q -e 'maas' 'docker-compose/docker-compose.yaml'; then
chmod +x docker-compose/files/entrypoint*.sh
# Apparmor workaround for bind9 inside Docker containers using AUFS
for profile in 'usr.sbin.ntpd' 'usr.sbin.named' \
'usr.sbin.dhcpd' 'usr.bin.tcpdump'; do
Expand All @@ -422,6 +429,9 @@ function start_containers {
local image_dir=$1
[ -n "${image_dir}" ] || exit 1
[ ! -e "${image_dir}/docker-compose" ] || COMPOSE_PREFIX="${image_dir}/"
if grep -q -e 'maas' 'docker-compose/docker-compose.yaml'; then
chmod +x docker-compose/files/entrypoint*.sh
fi
"${COMPOSE_PREFIX}docker-compose" -f docker-compose/docker-compose.yaml up -d
}

Expand Down Expand Up @@ -454,7 +464,8 @@ function cleanup_mounts {
sudo sed -i -e 's/^\s*set root=.*$//g' -e 's/^\s*loopback.*$//g' \
"${OPNFV_MNT_DIR}/boot/grub/grub.cfg"
fi
sudo rm -f "${OPNFV_MNT_DIR}/run/resolvconf/resolv.conf"
sudo rm -f "${OPNFV_MNT_DIR}/run/resolvconf/resolv.conf" \
"${OPNFV_MNT_DIR}/run/systemd/resolve/stub-resolv.conf"
sync
if mountpoint -q "${OPNFV_MNT_DIR}"; then
sudo umount -l "${OPNFV_MNT_DIR}" || true
Expand Down

0 comments on commit cdf8db3

Please sign in to comment.