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 <melissa.wang@windriver.com>
This commit is contained in:
parent
e5f5b25e95
commit
8e4a0421a4
@ -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 <<END
|
||||
ena
|
||||
END
|
||||
|
||||
cat >/etc/dracut.conf.d/add-ena.conf <<END
|
||||
add_drivers+=" ena "
|
||||
END
|
||||
|
||||
cat >/etc/dracut.conf.d/no-hostonly.conf <<END
|
||||
hostonly="no"
|
||||
END
|
||||
|
||||
cat >/etc/sysconfig/network-scripts/ifcfg-${AWS_OAM_IF} <<END
|
||||
DEVICE=${AWS_OAM_IF}
|
||||
BOOTPROTO=dhcp
|
||||
ONBOOT=yes
|
||||
TYPE=Ethernet
|
||||
USERCTL=yes
|
||||
PEERDNS=yes
|
||||
DHCPV6C=yes
|
||||
DHCPV6C_OPTIONS=-nw
|
||||
PERSISTENT_DHCLIENT=yes
|
||||
RES_OPTIONS="timeout:2 attempts:5"
|
||||
DHCP_ARP_CHECK=no
|
||||
END
|
||||
|
||||
cat >/etc/sysconfig/network-scripts/ifcfg-${AWS_MGMT_IF} <<END
|
||||
DEVICE=${AWS_MGMT_IF}
|
||||
BOOTPROTO=dhcp
|
||||
ONBOOT=yes
|
||||
TYPE=Ethernet
|
||||
USERCTL=yes
|
||||
PEERDNS=yes
|
||||
DHCPV6C=yes
|
||||
DHCPV6C_OPTIONS=-nw
|
||||
PERSISTENT_DHCLIENT=yes
|
||||
RES_OPTIONS="timeout:2 attempts:5"
|
||||
DHCP_ARP_CHECK=no
|
||||
END
|
||||
|
||||
if [ ! -d /var/tmp ]; then
|
||||
mkdir -m 1777 /var/tmp
|
||||
fi
|
||||
|
||||
KERNEL_VERSION=\$(rpm -q kernel --qf '%{version}-%{release}.%{arch}')
|
||||
/sbin/dracut -f /boot/initramfs-\$KERNEL_VERSION.img \$KERNEL_VERSION
|
||||
_END
|
||||
}
|
||||
|
||||
# Process command line
|
||||
init() {
|
||||
local temp
|
||||
temp=$(getopt -o hf4w:W:e:p:P:Sm:gs:i:o: --long help,force,ipv4,ipv4-default-gateway:,ipv6-default-gateway:,oam-dev:,password:,passwords-from:,passwords-from-stdin,mode:,graphical,sudo,size:,iso:,output: -n "$PROGNAME" -- "$@") || cmdline_error
|
||||
temp=$(getopt -o hf4w:W:e:p:P:Sm:gs:i:o: --long help,force,ipv4,ipv4-default-gateway:,ipv6-default-gateway:,oam-dev:,password:,passwords-from:,passwords-from-stdin,mode:,graphical,sudo,size:,iso:,output:,aws -n "$PROGNAME" -- "$@") || cmdline_error
|
||||
eval set -- "$temp"
|
||||
while true ; do
|
||||
case "$1" in
|
||||
@ -302,6 +364,10 @@ init() {
|
||||
IMG_FILE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--aws)
|
||||
AWS_COMPATIBLE=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -373,6 +439,10 @@ if [[ $SUDO == 1 ]] ; then
|
||||
fi
|
||||
cmd+=("$UPDATE_ISO" -i "$BOOTIMAGE_ISO" -o "$auto_iso" -d "$menu_item" -t 3)
|
||||
|
||||
if [[ $AWS_COMPATIBLE == 1 ]] ; then
|
||||
cmd+=(-p rdloaddriver=ena)
|
||||
fi
|
||||
|
||||
# generate a kickstart add-on
|
||||
ks_addon="$TEMPFILES_DIR/ks_addon.sh"
|
||||
echo "#### start ks-addon.cfg" >"$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")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user