metal/bsp-files/kickstarts/post_pxeboot_controller.cfg
Shrikumar Sharma 06626151de Install package_checksums in /usr/local/share/pkg-list
In order to prepare shared software packages on the system
controller for subcloud prestaging, the file
"package-checksums" containing a list of packages and
their checksums, must be copied to /usr/local/share/pkg-list
and renamed as packages_list.

The prestaging process needs the package-and-checksum list
for the version of the load on the controller and the version
of the load on the subcloud.

This file needs to be copied over to /var/www/pages/feed/rel-<id>
on the controller so that the subclouds can download it.

This file can be obtained by downloading from the system
controller. If the system is being installed directly from
a boot iso, the appropriate kickstart is called to install
the file from the mounted bootimage.iso.

There are a few cases which determine how to get the file.

Cases:
1. Install load directly from bootimage.iso (both controller and
   subcloud) - copy from mounted iso to location. The iso
   may be present on a peripheral device like a CD/DVD.

2. Install load over lan - download the file from server and copy
   to locations (all controllers)

3. Version upgrade by importing a new load - copy the file
   to the appropriate location on the system controller.
   The subcloud will download the package_checksums belonging
   to the imported load as part of the upgrade process.

Test Plan:
PASS: Verify that the file is copied over to /usr/local/share/
      pkg-list and /var/www/feed/rel-<rel-id>/ when installing
      System Controller or subcloud from bootimage.iso

PASS: Verify that the file is copied to the locations when
      installing controller-1 via pxeboot

PASS: Verify that the file is copied to the locations when upgrading
      the System Controller (using load-import)

PASS: Verify that the file is copied when adding a subcloud with
      dcmanager subcloud add

Depends On: https://review.opendev.org/c/starlingx/distcloud/+/841828
Story: 2009799
Task: 45376

Change-Id: If14b197999f2ae03e15fdc08ec27511ca1d41767
Signed-off-by: Shrikumar Sharma <shrikumar.sharma@windriver.com>
2022-05-19 22:29:55 -04:00

160 lines
5.4 KiB
INI

%pre --erroronfail
# Source common functions
. /tmp/ks-functions.sh
echo "repo --name=base --baseurl=xxxHTTP_URLxxx/" > /tmp/repo-include
echo "repo --name=updates --baseurl=xxxHTTP_URLxxx/patches/" > /tmp/repo-include
%end
# Repository arguments from %pre
%include /tmp/repo-include
%post --erroronfail
# Source common functions
. /tmp/ks-functions.sh
# Obtain the boot interface from the PXE boot
BOOTIF=$(cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=)
BOOTIF=${BOOTIF#BOOTIF=}
mgmt_dev=none
if [ -n "$BOOTIF" ] ; then
BOOTIF=$(echo $BOOTIF | sed -r -e 's/.*(..-..-..-..-..-..)$/\1/' -e 's/-/:/g')
ndev=$(ip -br link | awk -v mac="$BOOTIF" '$0 ~ mac {print $1}')
if [ -n "$ndev" ] ; then
mgmt_dev=$ndev
# Persist the boot device to the platform configuration. This will get
# overwritten when config_controller is run.
echo management_interface=$mgmt_dev >> /etc/platform/platform.conf
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev
DEVICE=$mgmt_dev
BOOTPROTO=dhcp
ONBOOT=yes
IPV6_AUTOCONF=no
EOF
else
report_post_failure_with_msg "ERROR: Unable to determine mgmt interface from BOOTIF=$BOOTIF."
fi
else
# This is a hybrid ISO/network install. Mount the media to ensure Anaconda
# ejects it on reboot.
if [ -e /dev/disk/by-label/oe_iso_boot ]; then
mkdir /mnt/iso
mount /dev/disk/by-label/oe_iso_boot /mnt/iso
fi
fi
# persist the default http port number to platform configuration. This
# will get overwritten when config_controller is run.
echo http_port=8080 >> /etc/platform/platform.conf
# Build networking scripts
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
BROADCAST=127.255.255.255
ONBOOT=yes
IPV6_AUTOCONF=no
NAME=loopback
EOF
%end
%post --erroronfail
# Source common functions
. /tmp/ks-functions.sh
KS="pxeboot post:"
anaconda_logdir=/var/log/anaconda
mkdir -p $anaconda_logdir
# Check for inst.noverifyssl
if grep -q inst.noverifyssl /proc/cmdline; then
NOVERIFYSSL_WGET_OPT="--no-check-certificate"
else
NOVERIFYSSL_WGET_OPT=""
fi
FEED_DIR=/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx
mkdir -p ${FEED_DIR}/Packages
mkdir -p ${FEED_DIR}/repodata
cd ${FEED_DIR}
feed_url=xxxHTTP_URLxxx
declare -i cut_dirs=NUM_DIRS
# download the package_checksums file if /mnt/sysimage is mounted
if [ mountpoint -q /mnt/sysimage ]; then
wlog "${KS} Downloading package_checksums from controller"
pkg_file=packages_list
pkg_file_loc=/mnt/sysimage/usr/local/share/pkg-list
if [ ! -d ${pkg_file_loc} ]; then
mkdir -p ${pkg_file_loc}
fi
wlog "${KS} Downloading from ${feed_url} to ${pkg_file_loc}/${pkg_file}"
wget ${NOVERIFYSSL_WGET_OPT} -O ${pkg_file_loc} ${feed_url}/${pkg_file} \
-o $anaconda_logdir/${pkg_file}.log \
|| wlog "${KS} Failed to download packages_list from controller"
wlog "${KS} Copying ${pkg_file_loc}/${pkg_file} to ${FEED_DIR}"
cp ${pkg_file_loc}/${pkg_file} ${FEED_DIR}
fi
echo "Mirroring software repository (may take several minutes)..." >/dev/console
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$cut_dirs $feed_url/Packages/ -o $anaconda_logdir/rpmget.log \
|| report_post_failure_with_logfile $anaconda_logdir/rpmget.log
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$cut_dirs $feed_url/repodata/ -o $anaconda_logdir/rpmget_repo.log \
|| report_post_failure_with_logfile $anaconda_logdir/rpmget_repo.log
echo "Done" >/dev/console
patches_url=xxxHTTP_URLxxx/patches
wget ${NOVERIFYSSL_WGET_OPT} -q --spider ${patches_url}/
if [ $? -eq 0 ]; then
echo "Downloading patches..." >/dev/console
cd /var/www/pages
mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/Packages
mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/repodata
cd updates/rel-xxxPLATFORM_RELEASExxx
declare -i patches_cut_dirs=$((cut_dirs+1))
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/Packages/ -o $anaconda_logdir/patches_rpmget.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget.log
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/repodata/ -o $anaconda_logdir/patches_rpmget_repo.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_repo.log
mkdir -p /opt/patching/metadata
mkdir -p /opt/patching/packages/xxxPLATFORM_RELEASExxx
cd /opt/patching
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/metadata/ -o $anaconda_logdir/patches_rpmget_metadata.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_metadata.log
find /var/www/pages/updates/rel-xxxPLATFORM_RELEASExxx/Packages -name '*.rpm' \
| xargs --no-run-if-empty -I files cp --preserve=all files /opt/patching/packages/xxxPLATFORM_RELEASExxx/
echo "Done" >/dev/console
fi
# Create a uuid specific to this installation
INSTALL_UUID=`uuidgen`
echo $INSTALL_UUID > /var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid
echo "INSTALL_UUID=$INSTALL_UUID" >> /etc/platform/platform.conf
%end