Browse Source

fixed device mapping locations in /dev, fixed stale swi directory problems

master
Sebastian Rieger 10 years ago
parent
commit
ad46da85e7
  1. 21
      create-arista-veos-image/create-arista-veos-image.sh

21
create-arista-veos-image/create-arista-veos-image.sh

@ -25,6 +25,7 @@ VEOS_VMDK_BASENAME=$(basename -s .vmdk $2)
GLANCE_IMAGE_NAME=$3
GLANCE_IMAGE_RELEASE=$VEOS_VMDK_BASENAME-$ABOOT_SERIAL_ISO_BASENAME
TMP_NAME="vEOS-$GLANCE_IMAGE_RELEASE"
TIMESTAMP=$(date +%Y%m%d%H%M%S)
echo
echo "Creating vEOS image..."
@ -41,8 +42,8 @@ echo "==========================================================="
# convert vmdk to raw and extract two partitions in it
qemu-img convert -O raw $2 $VEOS_VMDK_BASENAME.raw
kpartx -av $VEOS_VMDK_BASENAME.raw
dd if=/dev/loop0p1 of=$VEOS_VMDK_BASENAME-p1.raw
dd if=/dev/loop0p2 of=$VEOS_VMDK_BASENAME-p2.raw
dd if=/dev/mapper/loop0p1 of=$VEOS_VMDK_BASENAME-p1.raw
dd if=/dev/mapper/loop0p2 of=$VEOS_VMDK_BASENAME-p2.raw
kpartx -d $VEOS_VMDK_BASENAME.raw
echo
@ -50,9 +51,9 @@ echo "Injecting rc.eos startup script to get switch config..."
echo "==========================================================="
# inject rc.eos script in first partition of the image, to get switch config defined in VM Maestro (config-drive)
mkdir swi
mount -o loop $VEOS_VMDK_BASENAME-p1.raw swi
cd swi
mkdir swi-$TIMESTAMP
mount -o loop $VEOS_VMDK_BASENAME-p1.raw swi-$TIMESTAMP
cd swi-$TIMESTAMP
cat << EOF > rc.eos
#!/bin/sh
#
@ -80,8 +81,8 @@ cp /mnt/flash/startup-config.tmp /mnt/flash/startup-config
EOF
chmod 755 rc.eos
cd ..
umount swi
rmdir swi
umount swi-$TIMESTAMP
rm -rf swi-$TIMESTAMP
echo
echo "Injecting new partitions from vEOS vmdk in Aboot image..."
@ -117,10 +118,10 @@ t
12
w" | fdisk $TMP_NAME.raw >/dev/null
# copy the partitions from vEOS vmdk to new image
# copy the partitions from vEOS vmdk to new image
kpartx -av $TMP_NAME.raw
dd if=$VEOS_VMDK_BASENAME-p1.raw of=/dev/loop0p2
dd if=$VEOS_VMDK_BASENAME-p2.raw of=/dev/loop0p3
dd if=$VEOS_VMDK_BASENAME-p1.raw of=/dev/mapper/loop0p2
dd if=$VEOS_VMDK_BASENAME-p2.raw of=/dev/mapper/loop0p3
kpartx -d $TMP_NAME.raw
echo

Loading…
Cancel
Save