2021-05-14 19:11:33 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.
New format is:
{
'disks': [
{
'name': 'disk1.img',
'virtual_size': 10,
'format': 'qcow2'
},
{
'name': 'disk2.img',
'virtual_size': 15,
'format': 'qcow2'
},
{
'name': 'disk3.img',
}
],
'provider': 'libvirt',
'format': 'qcow2'
}
It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.
Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.
Partially fixes: #602
2020-09-10 10:03:00 +02:00
|
|
|
|
|
|
|
|
VAGRANT_HOME=${1:-$HOME/.vagrant.d/}
|
|
|
|
|
VAGRANT_CMD=${2:-vagrant}
|
|
|
|
|
|
|
|
|
|
echo 'Create box with two disks'
|
|
|
|
|
${VAGRANT_CMD} box list
|
|
|
|
|
if [ "$(${VAGRANT_CMD} box list | grep -c -E '^infernix/tinycore-two-disks\s')" -eq 0 ]
|
|
|
|
|
then
|
2021-05-14 19:11:33 +01:00
|
|
|
${VAGRANT_CMD} box list
|
Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.
New format is:
{
'disks': [
{
'name': 'disk1.img',
'virtual_size': 10,
'format': 'qcow2'
},
{
'name': 'disk2.img',
'virtual_size': 15,
'format': 'qcow2'
},
{
'name': 'disk3.img',
}
],
'provider': 'libvirt',
'format': 'qcow2'
}
It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.
Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.
Partially fixes: #602
2020-09-10 10:03:00 +02:00
|
|
|
if [ "$(${VAGRANT_CMD} box list | grep -c -E '^infernix/tinycore\s')" -eq 0 ]
|
|
|
|
|
then
|
|
|
|
|
${VAGRANT_CMD} box add infernix/tinycore
|
|
|
|
|
fi
|
|
|
|
|
NEW_PATH="${VAGRANT_HOME}/boxes/infernix-VAGRANTSLASH-tinycore-two-disks"
|
|
|
|
|
cp -r "${VAGRANT_HOME}/boxes/infernix-VAGRANTSLASH-tinycore" "${NEW_PATH}"
|
2021-05-14 19:11:33 +01:00
|
|
|
BOX_VERSION="$(${VAGRANT_CMD} box list --machine-readable | grep -A 10 infernix/tinycore-two-disks | grep box-version | head -n 1 | cut -d, -f4)"
|
Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.
New format is:
{
'disks': [
{
'name': 'disk1.img',
'virtual_size': 10,
'format': 'qcow2'
},
{
'name': 'disk2.img',
'virtual_size': 15,
'format': 'qcow2'
},
{
'name': 'disk3.img',
}
],
'provider': 'libvirt',
'format': 'qcow2'
}
It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.
Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.
Partially fixes: #602
2020-09-10 10:03:00 +02:00
|
|
|
qemu-img create -f qcow2 "${NEW_PATH}/${BOX_VERSION}/libvirt/disk2.qcow2" 10G
|
|
|
|
|
cat > "${NEW_PATH}/${BOX_VERSION}/libvirt/metadata.json" <<EOF
|
|
|
|
|
{
|
|
|
|
|
"provider": "libvirt",
|
|
|
|
|
"disks" : [
|
2021-05-10 23:02:25 +01:00
|
|
|
{
|
2021-05-14 19:11:33 +01:00
|
|
|
"path": "box.img"
|
2021-05-10 23:02:25 +01:00
|
|
|
},
|
|
|
|
|
{
|
2021-05-14 19:11:33 +01:00
|
|
|
"path": "disk2.qcow2"
|
2021-05-10 23:02:25 +01:00
|
|
|
}
|
Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.
New format is:
{
'disks': [
{
'name': 'disk1.img',
'virtual_size': 10,
'format': 'qcow2'
},
{
'name': 'disk2.img',
'virtual_size': 15,
'format': 'qcow2'
},
{
'name': 'disk3.img',
}
],
'provider': 'libvirt',
'format': 'qcow2'
}
It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.
Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.
Partially fixes: #602
2020-09-10 10:03:00 +02:00
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
fi
|