From d0860cc26d78c3f1c70b332ecc793442a1c8048d Mon Sep 17 00:00:00 2001 From: john-griffith Date: Thu, 23 Jan 2014 11:31:10 -0700 Subject: [PATCH] Replace custom cinder driver configs The devstack/lib/cinder file has a number of third party driver config options hard-coded in it. Rather than add yet another if driver== statement here let's use plugin files and do something similar to what's already in place for nova_hypervisors and neutron plugins. This works the same way folks were implementing their drivers already, the key is to use a CINDER_DRIVER variable in your localrc file that matches the name of the lib/cinder_plugin file to use. The existing third party driver entries that were in lib/cinder have been migrated to cooresponding plugin files. Change-Id: I4ee51ea542d5aa63879afd5297311a9df727c57f --- lib/cinder | 44 ++++++------------------------- lib/cinder_plugins/XenAPINFS | 44 +++++++++++++++++++++++++++++++ lib/cinder_plugins/glusterfs | 50 ++++++++++++++++++++++++++++++++++++ lib/cinder_plugins/nfs | 42 ++++++++++++++++++++++++++++++ lib/cinder_plugins/sheepdog | 39 ++++++++++++++++++++++++++++ lib/cinder_plugins/solidfire | 48 ++++++++++++++++++++++++++++++++++ lib/cinder_plugins/vsphere | 42 ++++++++++++++++++++++++++++++ 7 files changed, 273 insertions(+), 36 deletions(-) create mode 100644 lib/cinder_plugins/XenAPINFS create mode 100644 lib/cinder_plugins/glusterfs create mode 100644 lib/cinder_plugins/nfs create mode 100644 lib/cinder_plugins/sheepdog create mode 100644 lib/cinder_plugins/solidfire create mode 100644 lib/cinder_plugins/vsphere diff --git a/lib/cinder b/lib/cinder index 9f70b2a0c9..51eb3c1262 100644 --- a/lib/cinder +++ b/lib/cinder @@ -27,6 +27,12 @@ set +o xtrace # set up default driver CINDER_DRIVER=${CINDER_DRIVER:-default} +CINDER_PLUGINS=$TOP_DIR/lib/cinder_plugins + +# grab plugin config if specified via cinder_driver +if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then + source $CINDER_PLUGINS/$CINDER_DRIVER +fi # set up default directories CINDER_DIR=$DEST/cinder @@ -300,42 +306,8 @@ function configure_cinder() { setup_colorized_logging $CINDER_CONF DEFAULT "project_id" "user_id" fi - if [ "$CINDER_DRIVER" == "XenAPINFS" ]; then - ( - set -u - iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.xenapi.sm.XenAPINFSDriver" - iniset $CINDER_CONF DEFAULT xenapi_connection_url "$CINDER_XENAPI_CONNECTION_URL" - iniset $CINDER_CONF DEFAULT xenapi_connection_username "$CINDER_XENAPI_CONNECTION_USERNAME" - iniset $CINDER_CONF DEFAULT xenapi_connection_password "$CINDER_XENAPI_CONNECTION_PASSWORD" - iniset $CINDER_CONF DEFAULT xenapi_nfs_server "$CINDER_XENAPI_NFS_SERVER" - iniset $CINDER_CONF DEFAULT xenapi_nfs_serverpath "$CINDER_XENAPI_NFS_SERVERPATH" - ) - elif [ "$CINDER_DRIVER" == "nfs" ]; then - iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.nfs.NfsDriver" - iniset $CINDER_CONF DEFAULT nfs_shares_config "$CINDER_CONF_DIR/nfs_shares.conf" - echo "$CINDER_NFS_SERVERPATH" | sudo tee "$CINDER_CONF_DIR/nfs_shares.conf" - sudo chmod 666 $CINDER_CONF_DIR/nfs_shares.conf - elif [ "$CINDER_DRIVER" == "sheepdog" ]; then - iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.sheepdog.SheepdogDriver" - elif [ "$CINDER_DRIVER" == "glusterfs" ]; then - # To use glusterfs, set the following in localrc: - # CINDER_DRIVER=glusterfs - # CINDER_GLUSTERFS_SHARES="127.0.0.1:/vol1;127.0.0.1:/vol2" - # Shares are : and separated by semicolons. - - iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.glusterfs.GlusterfsDriver" - iniset $CINDER_CONF DEFAULT glusterfs_shares_config "$CINDER_CONF_DIR/glusterfs_shares" - touch $CINDER_CONF_DIR/glusterfs_shares - if [ ! -z "$CINDER_GLUSTERFS_SHARES" ]; then - CINDER_GLUSTERFS_SHARES=$(echo $CINDER_GLUSTERFS_SHARES | tr ";" "\n") - echo "$CINDER_GLUSTERFS_SHARES" > $CINDER_CONF_DIR/glusterfs_shares - fi - elif [ "$CINDER_DRIVER" == "vsphere" ]; then - echo_summary "Using VMware vCenter driver" - iniset $CINDER_CONF DEFAULT vmware_host_ip "$VMWAREAPI_IP" - iniset $CINDER_CONF DEFAULT vmware_host_username "$VMWAREAPI_USER" - iniset $CINDER_CONF DEFAULT vmware_host_password "$VMWAREAPI_PASSWORD" - iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver" + if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then + configure_cinder_driver fi if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then diff --git a/lib/cinder_plugins/XenAPINFS b/lib/cinder_plugins/XenAPINFS new file mode 100644 index 0000000000..72e1c1398c --- /dev/null +++ b/lib/cinder_plugins/XenAPINFS @@ -0,0 +1,44 @@ +# lib/cinder_plugins/XenAPINFS +# Configure the XenAPINFS driver + +# Enable with: +# +# CINDER_DRIVER=XenAPINFS + +# Dependencies: +# +# - ``functions`` file +# - ``cinder`` configurations + +# configure_cinder_driver - make configuration changes, including those to other services + +# Save trace setting +MY_XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +# Defaults +# -------- + +# Set up default directories + + +# Entry Points +# ------------ + +# configure_cinder_driver - Set config files, create data dirs, etc +function configure_cinder_driver() { + iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.xenapi.sm.XenAPINFSDriver" + iniset $CINDER_CONF DEFAULT xenapi_connection_url "$CINDER_XENAPI_CONNECTION_URL" + iniset $CINDER_CONF DEFAULT xenapi_connection_username "$CINDER_XENAPI_CONNECTION_USERNAME" + iniset $CINDER_CONF DEFAULT xenapi_connection_password "$CINDER_XENAPI_CONNECTION_PASSWORD" + iniset $CINDER_CONF DEFAULT xenapi_nfs_server "$CINDER_XENAPI_NFS_SERVER" + iniset $CINDER_CONF DEFAULT xenapi_nfs_serverpath "$CINDER_XENAPI_NFS_SERVERPATH" +} + +# Restore xtrace +$MY_XTRACE + +# Local variables: +# mode: shell-script +# End: diff --git a/lib/cinder_plugins/glusterfs b/lib/cinder_plugins/glusterfs new file mode 100644 index 0000000000..a0c5ae8d5e --- /dev/null +++ b/lib/cinder_plugins/glusterfs @@ -0,0 +1,50 @@ +# lib/cinder_plugins/glusterfs +# Configure the glusterfs driver + +# Enable with: +# +# CINDER_DRIVER=glusterfs + +# Dependencies: +# +# - ``functions`` file +# - ``cinder`` configurations + +# configure_cinder_driver - make configuration changes, including those to other services + +# Save trace setting +MY_XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +# Defaults +# -------- + +# Set up default directories + + +# Entry Points +# ------------ + +# configure_cinder_driver - Set config files, create data dirs, etc +function configure_cinder_driver() { + # To use glusterfs, set the following in localrc: + # CINDER_DRIVER=glusterfs + # CINDER_GLUSTERFS_SHARES="127.0.0.1:/vol1;127.0.0.1:/vol2" + # Shares are : and separated by semicolons. + + iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.glusterfs.GlusterfsDriver" + iniset $CINDER_CONF DEFAULT glusterfs_shares_config "$CINDER_CONF_DIR/glusterfs_shares" + touch $CINDER_CONF_DIR/glusterfs_shares + if [ ! -z "$CINDER_GLUSTERFS_SHARES" ]; then + CINDER_GLUSTERFS_SHARES=$(echo $CINDER_GLUSTERFS_SHARES | tr ";" "\n") + echo "$CINDER_GLUSTERFS_SHARES" > $CINDER_CONF_DIR/glusterfs_shares + fi +} + +# Restore xtrace +$MY_XTRACE + +# Local variables: +# mode: shell-script +# End: diff --git a/lib/cinder_plugins/nfs b/lib/cinder_plugins/nfs new file mode 100644 index 0000000000..ea2c9ce665 --- /dev/null +++ b/lib/cinder_plugins/nfs @@ -0,0 +1,42 @@ +# lib/cinder_plugins/nfs +# Configure the nfs driver + +# Enable with: +# +# CINDER_DRIVER=nfs + +# Dependencies: +# +# - ``functions`` file +# - ``cinder`` configurations + +# configure_cinder_driver - make configuration changes, including those to other services + +# Save trace setting +MY_XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +# Defaults +# -------- + +# Set up default directories + + +# Entry Points +# ------------ + +# configure_cinder_driver - Set config files, create data dirs, etc +function configure_cinder_driver() { + iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.nfs.NfsDriver" + iniset $CINDER_CONF DEFAULT nfs_shares_config "$CINDER_CONF_DIR/nfs_shares.conf" + echo "$CINDER_NFS_SERVERPATH" | sudo tee "$CINDER_CONF_DIR/nfs_shares.conf" + sudo chmod 660 $CINDER_CONF_DIR/nfs_shares.conf +} + +# Restore xtrace +$MY_XTRACE + +# Local variables: +# mode: shell-script +# End: diff --git a/lib/cinder_plugins/sheepdog b/lib/cinder_plugins/sheepdog new file mode 100644 index 0000000000..4435932371 --- /dev/null +++ b/lib/cinder_plugins/sheepdog @@ -0,0 +1,39 @@ +# lib/cinder_plugins/sheepdog +# Configure the sheepdog driver + +# Enable with: +# +# CINDER_DRIVER=sheepdog + +# Dependencies: +# +# - ``functions`` file +# - ``cinder`` configurations + +# configure_cinder_driver - make configuration changes, including those to other services + +# Save trace setting +MY_XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +# Defaults +# -------- + +# Set up default directories + + +# Entry Points +# ------------ + +# configure_cinder_driver - Set config files, create data dirs, etc +function configure_cinder_driver() { + iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.sheepdog.SheepdogDriver" +} + +# Restore xtrace +$MY_XTRACE + +# Local variables: +# mode: shell-script +# End: diff --git a/lib/cinder_plugins/solidfire b/lib/cinder_plugins/solidfire new file mode 100644 index 0000000000..47c113e1a2 --- /dev/null +++ b/lib/cinder_plugins/solidfire @@ -0,0 +1,48 @@ +# lib/cinder_plugins/solidfire +# Configure the solidfire driver + +# Enable with: +# +# CINDER_DRIVER=solidfire + +# Dependencies: +# +# - ``functions`` file +# - ``cinder`` configurations + +# configure_cinder_driver - make configuration changes, including those to other services + +# Save trace setting +MY_XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +# Defaults +# -------- + +# Set up default directories + + +# Entry Points +# ------------ + +# configure_cinder_driver - Set config files, create data dirs, etc +function configure_cinder_driver() { + # To use solidfire, set the following in localrc: + # CINDER_DRIVER=solidfire + # SAN_IP= + # SAN_LOGIN= + # SAN_PASSWORD= + + iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.solidfire.SolidFireDriver" + iniset $CINDER_CONF DEFAULT san_ip $SAN_IP + iniset $CINDER_CONF DEFAULT san_login $SAN_LOGIN + iniset $CINDER_CONF DEFAULT san_password $SAN_PASSWORD +} + +# Restore xtrace +$MY_XTRACE + +# Local variables: +# mode: shell-script +# End: diff --git a/lib/cinder_plugins/vsphere b/lib/cinder_plugins/vsphere new file mode 100644 index 0000000000..c8cab6a8c1 --- /dev/null +++ b/lib/cinder_plugins/vsphere @@ -0,0 +1,42 @@ +# lib/cinder_plugins/vsphere +# Configure the vsphere driver + +# Enable with: +# +# CINDER_DRIVER=vsphere + +# Dependencies: +# +# - ``functions`` file +# - ``cinder`` configurations + +# configure_cinder_driver - make configuration changes, including those to other services + +# Save trace setting +MY_XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +# Defaults +# -------- + +# Set up default directories + + +# Entry Points +# ------------ + +# configure_cinder_driver - Set config files, create data dirs, etc +function configure_cinder_driver() { + iniset $CINDER_CONF DEFAULT vmware_host_ip "$VMWAREAPI_IP" + iniset $CINDER_CONF DEFAULT vmware_host_username "$VMWAREAPI_USER" + iniset $CINDER_CONF DEFAULT vmware_host_password "$VMWAREAPI_PASSWORD" + iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver" +} + +# Restore xtrace +$MY_XTRACE + +# Local variables: +# mode: shell-script +# End: