adds support for configuration of cinder nfs backend driver

a new config options is added: CONFIG_CINDER_NFS_MOUNTS , also adds
validate_multi_regepx for use with both NFS mounts and GlusterFS mounts

Change-Id: I5cf0ef0114c7eaa0bedd8528e6b1fe805221443a
This commit is contained in:
Giulio Fidente 2013-08-08 18:41:23 +02:00
parent dbb86c4a6e
commit 275fce4c94
8 changed files with 96 additions and 12 deletions

View File

@ -86,13 +86,28 @@ Cinder Config parameters
**CONFIG_CINDER_KS_PW** : The password to use for the Cinder to authenticate with Keystone
**CONFIG_CINDER_VOLUMES_CREATE** : Create Cinder's volumes group ['y', 'n']
**CONFIG_CINDER_BACKEND** : The Cinder backend to use ['lvm', 'gluster', 'nfs']
Cinder volume create Config parameters
--------------------------------------
**CONFIG_CINDER_VOLUMES_CREATE** : Create Cinder's volumes group ['y', 'n']
Cinder volume size Config parameters
------------------------------------
**CONFIG_CINDER_VOLUMES_SIZE** : Cinder's volumes group size
Cinder gluster Config parameters
--------------------------------
**CONFIG_CINDER_GLUSTER_MOUNTS** : A single or comma separated list of gluster volume shares
Cinder NFS Config parameters
----------------------------
**CONFIG_CINDER_NFS_MOUNTS** : A single or comma seprated list of NFS exports to mount
Nova Options
------------

View File

@ -46,3 +46,19 @@ def process_ssh_key(param, process_args=None):
param = param.endswith('.pub') and param or ('%s.pub' % param)
create_key(key_file)
return param
def process_add_quotes_around_values(param, process_args=None):
"""
Add a single quote character around each element of a comma
separated list of values
"""
params_list = param.split(',')
for index, elem in enumerate(params_list):
if not elem.startswith("'"):
elem = "'" + elem
if not elem.endswith("'"):
elem = elem + "'"
params_list[index] = elem
param = ','.join(params_list)
return param

View File

@ -69,6 +69,16 @@ def validate_regexp(param, options=None):
raise ParamValidationError(msg % param)
def validate_multi_regexp(param, options=None):
"""
Raises ParamValidationError if any of the comma separated values given
in param doesn't match one of the regular expressions given in options.
"""
options = options or []
for i in param.split(','):
validate_regexp(i.strip(), options=options)
def validate_port(param, options=None):
"""
Raises ParamValidationError if given param is not a decimal number

View File

@ -7,6 +7,7 @@ import uuid
import logging
from packstack.installer import exceptions
from packstack.installer import processors
from packstack.installer import validators
from packstack.installer import basedefs
@ -70,9 +71,9 @@ def initConfig(controllerObject):
"CONDITION" : False },
{"CMD_OPTION" : "cinder-backend",
"USAGE" : ("The Cinder backend to use, valid options are: "
"lvm, gluster"),
"lvm, gluster, nfs"),
"PROMPT" : "Enter the Cinder backend to be configured",
"OPTION_LIST" : ["lvm", "gluster"],
"OPTION_LIST" : ["lvm", "gluster", "nfs"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "lvm",
"MASK_INPUT" : False,
@ -159,13 +160,13 @@ def initConfig(controllerObject):
paramsList = [
{"CMD_OPTION" : "cinder-gluster-mounts",
"USAGE" : ("A gluster volume to mount, eg: "
"ip-address:/vol-name "
"You don't need to create a local volume group when "
"using gluster."),
"PROMPT" : "Enter a gluster volume for use with Cinder",
"OPTION_LIST" : ["^([\d]{1,3}\.){3}[\d]{1,3}:/.*"],
"VALIDATORS" : [validators.validate_regexp],
"USAGE" : ("A single or comma separated list of gluster volume shares "
"to mount, eg: ip-address:/vol-name "),
"PROMPT" : ("Enter a single or comma separated list of gluster volume "
"shares to use with Cinder"),
"OPTION_LIST" : ["^'([\d]{1,3}\.){3}[\d]{1,3}:/.*'"],
"VALIDATORS" : [validators.validate_multi_regexp],
"PROCESSORS" : [processors.process_add_quotes_around_values],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
@ -176,7 +177,7 @@ def initConfig(controllerObject):
]
groupDict = { "GROUP_NAME" : "CINDERGLUSTERMOUNTS",
"DESCRIPTION" : "Cinder gluster mounts",
"DESCRIPTION" : "Cinder gluster Config parameters",
"PRE_CONDITION" : check_gluster_options,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
@ -184,6 +185,37 @@ def initConfig(controllerObject):
controller.addGroup(groupDict, paramsList)
def check_nfs_options(config):
return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and
config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'nfs')
paramsList = [
{"CMD_OPTION" : "cinder-nfs-mounts",
"USAGE" : ("A single or comma seprated list of NFS exports to mount, "
"eg: ip-address:/export-name "),
"PROMPT" : ("Enter a single or comma seprated list of NFS exports to "
"use with Cinder"),
"OPTION_LIST" : ["^'([\d]{1,3}\.){3}[\d]{1,3}:/.*'"],
"VALIDATORS" : [validators.validate_multi_regexp],
"PROCESSORS" : [processors.process_add_quotes_around_values],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_CINDER_NFS_MOUNTS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "CINDERNFSMOUNTS",
"DESCRIPTION" : "Cinder NFS Config parameters",
"PRE_CONDITION" : check_nfs_options,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller):
if controller.CONF['CONFIG_CINDER_INSTALL'] != 'y':
@ -316,5 +348,7 @@ def create_manifest(config):
if controller.CONF['CONFIG_CINDER_BACKEND'] == "gluster":
manifestdata += getManifestTemplate("cinder_gluster.pp")
if controller.CONF['CONFIG_CINDER_BACKEND'] == "nfs":
manifestdata += getManifestTemplate("cinder_nfs.pp")
appendManifestFile(manifestfile, manifestdata)

View File

@ -370,6 +370,8 @@ def createcomputemanifest(config):
manifestdata = getManifestTemplate("nova_compute.pp")
if controller.CONF['CONFIG_CINDER_INSTALL'] == 'y' and controller.CONF['CONFIG_CINDER_BACKEND'] == 'gluster':
manifestdata += getManifestTemplate("nova_gluster.pp")
if controller.CONF['CONFIG_CINDER_INSTALL'] == 'y' and controller.CONF['CONFIG_CINDER_BACKEND'] == 'nfs':
manifestdata += getManifestTemplate("nova_nfs.pp")
manifestfile = "%s_nova.pp"%host
nova_config_options = NovaConfig()

View File

@ -1,6 +1,6 @@
package { 'glusterfs-fuse': ensure => present }
class { 'cinder::volume::glusterfs':
glusterfs_shares => ['%(CONFIG_CINDER_GLUSTER_MOUNTS)s'],
glusterfs_shares => [%(CONFIG_CINDER_GLUSTER_MOUNTS)s],
require => Package['glusterfs-fuse'],
}

View File

@ -0,0 +1,6 @@
package { 'nfs-utils': ensure => present }
class { 'cinder::volume::nfs':
nfs_servers => [%(CONFIG_CINDER_NFS_MOUNTS)s],
require => Package['nfs-utils'],
}

View File

@ -0,0 +1 @@
package { 'nfs-utils': ensure => present }