Browse Source

cumulusvx: fixed detection of missing loop files for Ubuntu 16.04 in VIRL >=1.3, added default subtype creation, changed position of grub.cfg in cumulusvx >= 3.x (thanks to bobskye)

master
Sebastian Rieger 8 years ago
parent
commit
4fcfd45c8d
  1. 122
      create-cumulusvx-image/create-cumulus-vx-image.sh
  2. 23
      create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.2.x.json
  3. 24
      create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.3.x.json
  4. 23
      create-cumulusvx-image/dynamic-subtype-CumulusVX.json

122
create-cumulusvx-image/create-cumulus-vx-image.sh

@ -9,6 +9,8 @@
# V0.3.1 added support for newer glance releases (e.g. kilo) used in VIRL 1.0.0
# V0.4 fixed check for existing images, added support for Cumulus VX 3.x
# V0.41 removed debug bash
# V0.5 fixed detection of missing loop files for Ubuntu 16.04 in VIRL >=1.3, added default subtype creation
# V0.51 changed position of grub.cfg in cumulusvx >= 3.x (thanks to bobskye)
# usage
@ -97,6 +99,19 @@ elif [ $CUMULUS_VERSION == 3 ]; then
LOOPDEV_PART_ROOT=$(echo "$LOOPDEV" | sed '4q;d' | cut -d " " -f 3)
fi
echo -n "waiting for loop devs from kpartx"
LOOP_DEV_RETRIES=0
until dd if=/dev/mapper/$LOOPDEV_PART_BOOT of=/dev/null bs=1k count=1 &>/dev/null && dd if=/dev/mapper/$LOOPDEV_PART_ROOT of=/dev/null bs=1k count=1 &>/dev/null ; do
echo -n "."
LOOP_DEV_RETRIES=$(expr $LOOP_DEV_RETRIES + 1)
if [ $LOOP_DEV_RETRIES -eq 10 ]; then
echo
echo "ERROR: timeout waiting for loop devs from kaprtx"
exit
fi
sleep 1
done
echo
mkdir cumulusvx-boot-$TIMESTAMP
mkdir cumulusvx-root-$TIMESTAMP
@ -114,7 +129,7 @@ if [ $CUMULUS_VERSION == 2 ]; then
sed -i.bak -e s/"# S0:3:respawn:\/sbin\/getty -L \$(get-cmdline-console) vt100"/"S0:3:respawn:\/sbin\/getty -L \$(get-cmdline-console) vt100"/g cumulusvx-root-$TIMESTAMP/etc/inittab
elif [ $CUMULUS_VERSION == 3 ]; then
# changing grub to show boot log
sed -i.bak -e s/"console=tty0 quiet"/"console=tty0"/g cumulusvx-boot-$TIMESTAMP/grub/grub.cfg
sed -i.bak -e s/"${extra_cmdline} quiet"/"${extra_cmdline}"/g cumulusvx-root-$TIMESTAMP/boot/grub/grub.cfg
fi
# append a script to import the configuration defined in VM Maestro to rc.local
@ -136,14 +151,34 @@ safe_unmount cumulusvx-root-$TIMESTAMP
rm -rf cumulusvx-boot-$TIMESTAMP
rm -rf cumulusvx-root-$TIMESTAMP
kpartx -d $CUMULUS_QCOW2_BASENAME.raw
LOOP_DEV_DEL_RETRIES=0
echo "removing loop devs from kpartx"
until kpartx -vd $CUMULUS_QCOW2_BASENAME.raw ; do
echo -n "."
LOOP_DEV_DEL_RETRIES=$(expr $LOOP_DEV_DEL_RETRIES + 1)
if [ $LOOP_DEV_DEL_RETRIES -eq 10 ]; then
echo
echo "ERROR: timeout waiting for loop dev removal from kaprtx"
exit
fi
sleep 1
done
echo
echo "Saving CumulusVX image..."
echo "Converting new image to qcow2..."
echo "==========================================================="
qemu-img convert -O qcow2 $CUMULUS_QCOW2_BASENAME.raw $CUMULUS_PATCHED_QCOW2
echo
echo "Cleaning up..."
echo "==========================================================="
rm $CUMULUS_QCOW2_BASENAME.raw
echo
echo "Importing image into glance..."
echo "==========================================================="
# use e1000 for now as with virtio we get dhcp errors due to "bad udp checksum" in Debian
glance image-create --container-format bare --disk-format qcow2 --visibility public --name $GLANCE_IMAGE_NAME \
--file $CUMULUS_PATCHED_QCOW2 --property hw_disk_bus=ide --property serial=1 \
@ -157,9 +192,82 @@ if [ $? == 1 ]; then
nova flavor-create --is-public true CumulusVX.small auto 256 0 1
fi
# create default subtype
cat << EOF > dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-above-1.3
{
"dynamic-subtypes": [
{
"plugin_base": "generic",
"device_type": "switch",
"plugin_desc": "CumulusVX",
"cli_protocol": "ssh",
"plugin_name": "$GLANCE_IMAGE_NAME",
"cli_serial": 1,
"interface_range": 25,
"gui_visible": true,
"interface_pattern": "swp{0}",
"baseline_image": "$GLANCE_IMAGE_NAME",
"config_disk_type": "disk",
"hw_vm_extra": "",
"gui_icon": "iosvl2",
"config_file": "/cumulusvx.sh",
"interface_first": 1,
"deprecated_use": "",
"baseline_flavor": "$GLANCE_IMAGE_NAME.small",
"interface_management": "eth0"
}
]
}
EOF
cat << EOF > dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-below-1.3
{
"dynamic-subtypes": [
{
"plugin_base": "generic",
"plugin_desc": "CumulusVX",
"cli_protocol": "ssh",
"plugin_name": "$GLANCE_IMAGE_NAME",
"cli_serial": 1,
"interface_range": 25,
"gui_visible": true,
"interface_pattern": "swp{0}",
"baseline_image": "$GLANCE_IMAGE_NAME",
"config_disk_type": "disk",
"hw_vm_extra": "",
"gui_icon": "iosvl2",
"config_file": "/cumulusvx.sh",
"interface_first": 1,
"deprecated_use": "",
"baseline_flavor": "$GLANCE_IMAGE_NAME.small",
"interface_management": "eth0"
}
]
}
EOF
CHECKING_FOR_EXISTING_SUBTYPE=$(virl_uwm_client subtype-info --name $GLANCE_IMAGE_NAME 2>&1)
if [ $? == 255 ]; then
echo "Creating default subtype $GLANCE_IMAGE_NAME..."
echo "==========================================================="
CHECKING_FOR_EXISTING_DEVICE_TYPE=$(virl_uwm_client subtype-info 2>&1 | grep u\'device_type\':)
if [ $? == 1 ]; then
# device_type attribute is not available in VIRL < 1.3, use JSON definition of subtype without this attribute
echo "detected VIRL version < 1.3, selecting appropriate subtype to import"
virl_uwm_client subtype-import --dynamic-subtypes @dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-below-1.3
else
echo "detected VIRL version > 1.3.0, selecting appropriate subtype to import"
# device_type attribute is available, use JSON definition of subtype including this attribute
virl_uwm_client subtype-import --dynamic-subtypes @dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-above-1.3
fi
else
echo "Default subtype $GLANCE_IMAGE_NAME already exists..."
fi
rm dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-above-1.3
rm dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-below-1.3
echo
echo "Cleaning up..."
echo "Image creation successful."
echo "==========================================================="
rm $CUMULUS_QCOW2_BASENAME.raw
echo
echo "You can import and use the subtype $GLANCE_IMAGE_NAME in VM Maestro..."

23
create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.2.x.json

@ -0,0 +1,23 @@
{
"dynamic-subtypes": [
{
"plugin_base": "generic",
"plugin_desc": "CumulusVX",
"cli_protocol": "ssh",
"plugin_name": "CumulusVX",
"cli_serial": 1,
"interface_range": 25,
"gui_visible": true,
"interface_pattern": "swp{0}",
"baseline_image": "CumulusVX",
"config_disk_type": "disk",
"hw_vm_extra": "",
"gui_icon": "iosvl2",
"config_file": "/cumulusvx.sh",
"interface_first": 1,
"deprecated_use": "",
"baseline_flavor": "CumulusVX.small",
"interface_management": "eth0"
}
]
}

24
create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.3.x.json

@ -0,0 +1,24 @@
{
"dynamic-subtypes": [
{
"plugin_base": "generic",
"device_type": "switch",
"plugin_desc": "CumulusVX",
"cli_protocol": "ssh",
"plugin_name": "CumulusVX",
"cli_serial": 1,
"interface_range": 25,
"gui_visible": true,
"interface_pattern": "swp{0}",
"baseline_image": "CumulusVX",
"config_disk_type": "disk",
"hw_vm_extra": "",
"gui_icon": "iosvl2",
"config_file": "/cumulusvx.sh",
"interface_first": 1,
"deprecated_use": "",
"baseline_flavor": "CumulusVX.small",
"interface_management": "eth0"
}
]
}

23
create-cumulusvx-image/dynamic-subtype-CumulusVX.json

@ -1,23 +0,0 @@
{
"dynamic-subtypes": [
{
"cli_protocol": "ssh",
"gui_icon": "iosvl2",
"plugin_desc": "CumulusVX",
"interface_first": 1,
"baseline_flavor": "CumulusVX.small",
"plugin_base": "generic",
"interface_management": "eth0",
"interface_pattern": "swp{0}",
"config_file": "/cumulusvx.sh",
"deprecated_use": "",
"hw_vm_extra": "",
"cli_serial": 1,
"interface_range": 25,
"config_disk_type": "disk",
"plugin_name": "CumulusVX",
"gui_visible": true,
"baseline_image": "CumulusVX"
}
]
}
Loading…
Cancel
Save