From 4ac57c34f2d3937b258e07dd5d3039827640c547 Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Sun, 6 Sep 2015 21:41:44 +0200 Subject: [PATCH] fixed dynamic handling of loop devices for partition extraction, added lines to import dynamic subtype --- .../create-arista-veos-image.sh | 19 +++++---- .../dynamic-subtype-vEOS.json | 40 ++++++++++--------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/create-arista-veos-image/create-arista-veos-image.sh b/create-arista-veos-image/create-arista-veos-image.sh index 5dbd7ba..c71ee6a 100644 --- a/create-arista-veos-image/create-arista-veos-image.sh +++ b/create-arista-veos-image/create-arista-veos-image.sh @@ -1,11 +1,12 @@ #!/bin/bash -# create-arista-veos-image.sh V1.12 +# create-arista-veos-image.sh V1.2 # HS-Fulda - sebastian.rieger@informatik.hs-fulda.de # # changelog: # V1.1 added injection of config defined in VM Maestro using config-drivex # V1.11 fixed device mapping of extracted partitions, fixed problems with stale swi directory # V1.12 rc.eos now supports e1000 and virtio as vnic types (virtio is supported in vEOS >=4.14.5F) +# V1.2 added dynamic handling of device mapping of extacted partitions # usage if [ ! $# -eq 3 ] ; then @@ -43,9 +44,11 @@ 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/mapper/loop0p1 of=$VEOS_VMDK_BASENAME-p1.raw -dd if=/dev/mapper/loop0p2 of=$VEOS_VMDK_BASENAME-p2.raw +LOOPDEV=$(kpartx -av $VEOS_VMDK_BASENAME.raw) +LOOPDEV_PART1=$(echo "$LOOPDEV" | sed '1q;d' | cut -d " " -f 3) +LOOPDEV_PART2=$(echo "$LOOPDEV" | sed '2q;d' | cut -d " " -f 3) +dd if=/dev/mapper/$LOOPDEV_PART1 of=$VEOS_VMDK_BASENAME-p1.raw +dd if=/dev/mapper/$LOOPDEV_PART2 of=$VEOS_VMDK_BASENAME-p2.raw kpartx -d $VEOS_VMDK_BASENAME.raw echo @@ -127,9 +130,11 @@ t w" | fdisk $TMP_NAME.raw >/dev/null # copy the partitions from vEOS vmdk to new image -kpartx -av $TMP_NAME.raw -dd if=$VEOS_VMDK_BASENAME-p1.raw of=/dev/mapper/loop0p2 -dd if=$VEOS_VMDK_BASENAME-p2.raw of=/dev/mapper/loop0p3 +LOOPDEV=$(kpartx -av $TMP_NAME.raw) +LOOPDEV_PART2=$(echo "$LOOPDEV" | sed '2q;d' | cut -d " " -f 3) +LOOPDEV_PART3=$(echo "$LOOPDEV" | sed '3q;d' | cut -d " " -f 3) +dd if=$VEOS_VMDK_BASENAME-p1.raw of=/dev/mapper/$LOOPDEV_PART2 +dd if=$VEOS_VMDK_BASENAME-p2.raw of=/dev/mapper/$LOOPDEV_PART3 kpartx -d $TMP_NAME.raw echo diff --git a/create-arista-veos-image/dynamic-subtype-vEOS.json b/create-arista-veos-image/dynamic-subtype-vEOS.json index 3173fe6..64bb030 100644 --- a/create-arista-veos-image/dynamic-subtype-vEOS.json +++ b/create-arista-veos-image/dynamic-subtype-vEOS.json @@ -1,20 +1,24 @@ { - "plugin_name": "vEOS", - "cli_serial": 1, - "plugin_desc": "Arista vEOS", - "baseline_image": "vEOS", - "hw_ram": 1024, - "hw_vm_extra": "", - "interface_wrap": 7, - "config_disk_type": "disk", - "interface_pattern": "Ethernet{0}", - "gui_visible": true, - "config_file": "/veos_config.txt", - "interface_first": 1, - "gui_icon": "iosvl2", - "plugin_base": "generic", - "vnc_available": false, - "interface_management": "Management1", - "interface_range": 7, - "baseline_flavor": "vEOS.small" + "dynamic-subtypes": [ + { + "plugin_name": "vEOS", + "cli_serial": 1, + "plugin_desc": "Arista vEOS", + "baseline_image": "vEOS", + "hw_ram": 1024, + "hw_vm_extra": "", + "interface_wrap": 7, + "config_disk_type": "disk", + "interface_pattern": "Ethernet{0}", + "gui_visible": true, + "config_file": "/veos_config.txt", + "interface_first": 1, + "gui_icon": "iosvl2", + "plugin_base": "generic", + "vnc_available": false, + "interface_management": "Management1", + "interface_range": 7, + "baseline_flavor": "vEOS.small" + } + ] } \ No newline at end of file