Allow devstack plugin to manage zfs

Allow devstack to install the zfs package
for Ubuntu and create the needed zfs pools.

This will only happen when LXD_BACKEND_DRIVER
is set to zfs otherwise no configuration will
take place.

The goal is to use this with nova-lxd devstack-gate.

Change-Id: I03affa47f5628747c1ccfde6984831331ff9a815
Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
Chuck Short 2016-10-13 11:25:01 -04:00
parent c3ed3574a5
commit d37571cb2c
1 changed files with 26 additions and 1 deletions

View File

@ -12,6 +12,12 @@ NOVA_DIR=${NOVA_DIR:-$DEST/nova}
NOVA_CONF_DIR=${NOVA_CONF_DIR:-/etc/nova}
NOVA_CONF=${NOVA_CONF:-NOVA_CONF_DIR/nova.conf}
# Configure LXD storage backends
LXD_BACKEND_DRIVER=${LXD_BACKEND_DRIVER:default}
LXD_DISK_IMAGE=${DATA_DIR}/lxd.img
LXD_ZFS_ZPOOL=devstack
LXD_LOOPBACK_DISK_SIZE=${LXD_LOOPBACK_DISK_SIZE:-8G}
# nova-lxd directories
NOVA_COMPUTE_LXD_DIR=${NOVA_COMPUTE_LXD_DIR:-${DEST}/nova-lxd}
NOVA_COMPUTE_LXD_PLUGIN_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
@ -82,6 +88,22 @@ function init_nova-lxd() {
fi
}
function configure_lxd_block() {
echo_summary "Configure LXD storage backend"
if is_ubuntu; then
if [ $LXD_BACKEND_DRIVER == "default" ]; then
echo "Nothing to be done"
elif [ $LXD_BACKEND_DRIVER == "zfs" ]; then
echo "Configuring ZFS backend"
truncate -s $LXD_LOOPBACK_DISK_SIZE $LXD_DISK_IMAGE
sudo apt-get install -y zfs
lxd_dev=`sudo losetup --show -f ${LXD_DISK_IMAGE}`
sudo lxd init --auto --storage-backend zfs --storage-pool $LXD_ZFS_ZPOOL \
--storage-create-device $lxd_dev
fi
fi
}
function shutdown_nova-lxd() {
# Shut the service down.
:
@ -89,7 +111,9 @@ function shutdown_nova-lxd() {
function cleanup_nova-lxd() {
# Cleanup the service.
:
if [ $LXD_BACKEND_DRIVER == "zfs" ]; then
sudo zpool destroy ${LXD_ZFS_ZPOOL}
fi
}
if is_service_enabled nova-lxd; then
@ -98,6 +122,7 @@ if is_service_enabled nova-lxd; then
# Set up system services
echo_summary "Configuring system services nova-lxd"
pre_install_nova-lxd
configure_lxd_block
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of service source