From 8e4a0421a4222de9c5f9ae75b666d84881570cf5 Mon Sep 17 00:00:00 2001 From: Melissa Wang Date: Wed, 18 Nov 2020 15:06:00 -0500 Subject: [PATCH] Add option to create an image compatible with AWS The qcow2 image generated by build-img currently cannot be loaded onto an AWS EC2 instance. This update introduces a new option to the build-img script for creating an image that can run on AWS. When running the script with the --aws flag, build-img will: * Add necessary network-scripts for ssh access * Add ENA driver config files * Add dracut config file for building a generic image * Regenerate the initramfs Story: 2007858 Task: 41288 Change-Id: Ic29c9b4ba17a2116b9e1dafc8e6390c326cd24c0 Signed-off-by: Melissa Wang --- build-tools/build-img | 77 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/build-tools/build-img b/build-tools/build-img index b08c5f65..1b3d43cd 100755 --- a/build-tools/build-img +++ b/build-tools/build-img @@ -12,6 +12,7 @@ DHCPV6C=yes OAM_DEV=ens3 IPV4_GW_ADDR= IPV6_GW_ADDR= +AWS_COMPATIBLE=0 declare -A PASSWORDS : KVM= KVM_OPTS=() @@ -83,6 +84,10 @@ Create a QCOW2/QEMU image with StarlingX pre-installed Default with --graphical: \$MY_WORKSPACE/export/stx_\${MODE}_graphical.qcow2) + --aws + Prepare an image that can be loaded onto an AWS EC2 + instance + ENVIRONMENT MY_REPO source repo directory @@ -230,10 +235,67 @@ find_kvm() { fi } +# Perform setup work for an image to run on AWS +# Create config files for adding ENA driver module, network scripts, and for +# regenerating a generic initramfs image +add_aws_setup(){ + local ks_addon=$1 + AWS_OAM_IF=ens5 + AWS_MGMT_IF=ens6 + cat >>"$ks_addon" <<_END +cat >/etc/modules-load.d/ena.conf </etc/dracut.conf.d/add-ena.conf </etc/dracut.conf.d/no-hostonly.conf </etc/sysconfig/network-scripts/ifcfg-${AWS_OAM_IF} </etc/sysconfig/network-scripts/ifcfg-${AWS_MGMT_IF} <"$ks_addon" @@ -452,6 +522,11 @@ fi _END fi +# Add necessary setup work for an aws image to the ks_addon script +if [[ $AWS_COMPATIBLE == 1 ]] ; then + add_aws_setup $ks_addon +fi + echo "#### end ks-addon.cfg" >>"$ks_addon" cmd+=(-a "$ks_addon")