Additional options for XenAPINFS cinder driver

Related to bp xenapi-storage-manager-nfs

Add configuration options to devstack scripts, so it is easier to set up
a system with a XenAPINFS volume backend. It makes possible to test this
configuration with exercises. To enable the XenAPINFS driver, specify:

CINDER_DRIVER=XenAPINFS
CINDER_XENAPI_CONNECTION_URL=<url for a xenserver>
CINDER_XENAPI_CONNECTION_USERNAME=<username for the xenserver>
CINDER_XENAPI_CONNECTION_PASSWORD=<password for the xenserver>
CINDER_XENAPI_NFS_SERVER=<a box that has an nfs export>
CINDER_XENAPI_NFS_SERVERPATH=<exported catalog>

in your localrc

Change-Id: Ia214172aac377d273a03849c8cc2adcbf5b8f607
diff --git a/lib/cinder b/lib/cinder
index 058fcc2..1aa34cd 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -24,6 +24,9 @@
 # Defaults
 # --------
 
+# set up default driver
+CINDER_DRIVER=${CINDER_DRIVER:-default}
+
 # set up default directories
 CINDER_DIR=$DEST/cinder
 CINDERCLIENT_DIR=$DEST/python-cinderclient
@@ -145,6 +148,19 @@
         iniset $CINDER_CONF DEFAULT logging_debug_format_suffix "from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
         iniset $CINDER_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s TRACE %(name)s %(instance)s"
     fi
+
+    if [ "$CINDER_DRIVER" == "XenAPINFS" ]; then
+        (
+            set -u
+            iniset $CINDER_CONF DEFAULT volume_driver "cinder.volume.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"
+        )
+        [ $? -ne 0 ] && exit 1
+    fi
 }
 
 # init_cinder() - Initialize database and volume group