Merge "don't ask for cinder vg data if present in answers file" into folsom

This commit is contained in:
Jenkins
2013-02-12 11:09:19 +00:00
committed by Gerrit Code Review
6 changed files with 81 additions and 96 deletions

View File

@@ -5,16 +5,12 @@ __all__ = (
'InstallError', 'InstallError',
'FlagValidationError', 'FlagValidationError',
'MissingRequirements',
'PluginError', 'PluginError',
'ParamProcessingError', 'ParamProcessingError',
'ParamValidationError',
'NetworkError', 'NetworkError',
'ScriptRuntimeError', 'ScriptRuntimeError',
) )
@@ -24,7 +20,7 @@ class PackStackError(Exception):
class MissingRequirements(PackStackError): class MissingRequirements(PackStackError):
"""Raised when minimum install requirements are not met""" """Raised when minimum install requirements are not met."""
pass pass
@@ -32,12 +28,10 @@ class InstallError(PackStackError):
"""Exception for generic errors during setup run.""" """Exception for generic errors during setup run."""
pass pass
class FlagValidationError(InstallError): class FlagValidationError(InstallError):
"""Raised when single flag validation fails.""" """Raised when single flag validation fails."""
pass pass
class ParamValidationError(InstallError): class ParamValidationError(InstallError):
"""Raised when parameter value validation fails.""" """Raised when parameter value validation fails."""
pass pass
@@ -46,7 +40,6 @@ class ParamValidationError(InstallError):
class PluginError(PackStackError): class PluginError(PackStackError):
pass pass
class ParamProcessingError(PluginError): class ParamProcessingError(PluginError):
pass pass

View File

@@ -50,6 +50,7 @@ WARN_VAL_IS_HOSTNAME = ("Warning: Packstack failed to change given "
INFO_STRING_LEN_LESS_THAN_MIN="String length is less than the minimum allowed: %s" INFO_STRING_LEN_LESS_THAN_MIN="String length is less than the minimum allowed: %s"
INFO_STRING_EXCEEDS_MAX_LENGTH="String length exceeds the maximum length allowed: %s" INFO_STRING_EXCEEDS_MAX_LENGTH="String length exceeds the maximum length allowed: %s"
INFO_STRING_CONTAINS_ILLEGAL_CHARS="String contains illegal characters" INFO_STRING_CONTAINS_ILLEGAL_CHARS="String contains illegal characters"
INFO_CINDER_VOLUMES_EXISTS="Did not create a cinder volume group, one already existed"
WARN_WEAK_PASS="Warning: Weak Password." WARN_WEAK_PASS="Warning: Weak Password."

View File

@@ -72,13 +72,13 @@ def gethostlist(CONF):
for key, value in CONF.items(): for key, value in CONF.items():
if key.endswith("_HOST"): if key.endswith("_HOST"):
value = value.split('/')[0] value = value.split('/')[0]
if value not in hosts: if value not in hosts and value:
hosts.append(value) hosts.append(value)
if key.endswith("_HOSTS"): if key.endswith("_HOSTS"):
for host in value.split(","): for host in value.split(","):
host = host.strip() host = host.strip()
host = host.split('/')[0] host = host.split('/')[0]
if host not in hosts: if host not in hosts and host:
hosts.append(host) hosts.append(host)
return hosts return hosts

View File

@@ -7,17 +7,18 @@ import uuid
import logging import logging
from packstack.installer import exceptions from packstack.installer import exceptions
from packstack.installer import run_setup as setup
from packstack.installer import engine_validators as validate
from packstack.installer import engine_processors as process from packstack.installer import engine_processors as process
from packstack.installer import engine_validators as validate
from packstack.installer import basedefs from packstack.installer import basedefs
import packstack.installer.common_utils as utils import packstack.installer.common_utils as utils
from packstack.installer.exceptions import InstallError
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile
from packstack.installer.exceptions import ScriptRuntimeError
from packstack.installer import output_messages
# Controller object will be initialized from main flow # Controller object will
# be initialized from main flow
controller = None controller = None
# Plugin name # Plugin name
@@ -26,6 +27,7 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
logging.debug("plugin %s loaded", __name__) logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controllerObject):
global controller global controller
controller = controllerObject controller = controllerObject
@@ -67,47 +69,11 @@ def initConfig(controllerObject):
"USE_DEFAULT" : True, "USE_DEFAULT" : True,
"NEED_CONFIRM" : True, "NEED_CONFIRM" : True,
"CONDITION" : False }, "CONDITION" : False },
{"CMD_OPTION" : "cinder-volumes-size",
"USAGE" : "Cinder's volumes group size",
"PROMPT" : "Enter Cinder's volumes group size",
"OPTION_LIST" : [],
"VALIDATION_FUNC" : validate.validateStringNotEmpty,
"DEFAULT_VALUE" : "2G",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_VOLUMES_SIZE",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "cinder-volumes-path",
"USAGE" : "Cinder's volumes group path",
"PROMPT" : "Enter Cinder's volumes group path",
"OPTION_LIST" : [],
"VALIDATION_FUNC" : validate.validateStringNotEmpty,
"DEFAULT_VALUE" : "/var/lib/cinder",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_VOLUMES_PATH",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "cinder-volumes",
"USAGE" : "Cinder's volumes group name",
"PROMPT" : "Enter Cinder's volumes group name",
"OPTION_LIST" : [],
"VALIDATION_FUNC" : validate.validateStringNotEmpty,
"DEFAULT_VALUE" : "cinder-volumes",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_VOLUMES",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "cinder-volumes-create", {"CMD_OPTION" : "cinder-volumes-create",
"USAGE" : "Create Cinder's volumes group", "USAGE" : "Create Cinder's volumes group",
"PROMPT" : "Should Cinder's volumes group be created?", "PROMPT" : "Should Cinder's volumes group be created?",
"OPTION_LIST" : ["y", "n"], "OPTION_LIST" : ["y", "n"],
"VALIDATION_FUNC" : createVolume, "VALIDATORS" : [validate.validate_options],
"DEFAULT_VALUE" : "y", "DEFAULT_VALUE" : "y",
"MASK_INPUT" : False, "MASK_INPUT" : False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -126,54 +92,80 @@ def initConfig(controllerObject):
controller.addGroup(groupDict, paramsList) controller.addGroup(groupDict, paramsList)
paramsList = [
{"CMD_OPTION" : "cinder-volumes-size",
"USAGE" : "Cinder's volumes group size",
"PROMPT" : "Enter Cinder's volumes group size",
"OPTION_LIST" : [],
"VALIDATORS" : [validate.validate_not_empty],
"DEFAULT_VALUE" : "20G",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_VOLUMES_SIZE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "CINDERVOLUMECREATE",
"DESCRIPTION" : "Cinder volume create Config parameters",
"PRE_CONDITION" : "CONFIG_CINDER_VOLUMES_CREATE",
"PRE_CONDITION_MATCH" : "y",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
if controller.CONF['CONFIG_CINDER_INSTALL'] != 'y': if controller.CONF['CONFIG_CINDER_INSTALL'] != 'y':
return return
cindersteps = [ cinder_steps = [
{'title': 'Adding Cinder Keystone manifest entries', 'functions':[createkeystonemanifest]}, {'title': 'Adding Cinder Keystone manifest entries', 'functions':[create_keystone_manifest]},
{'title': 'Checking if the Cinder server has a cinder-volumes vg', 'functions':[checkcindervg]}, {'title': 'Checking if the Cinder server has a cinder-volumes vg', 'functions':[check_cinder_vg]},
{'title': 'Adding Cinder manifest entries', 'functions':[createmanifest]} {'title': 'Adding Cinder manifest entries', 'functions':[create_manifest]}
] ]
controller.addSequence("Installing OpenStack Cinder", [], [], cindersteps) controller.addSequence("Installing OpenStack Cinder", [], [], cinder_steps)
def check_cinder_vg():
def createVolume(param, options=[]): cinders_volume = 'cinder-volumes'
"""
Check that provided host is listening on port 22
"""
if param == "n":
return True
for option in ['CONFIG_CINDER_VOLUMES_SIZE', 'CONFIG_CINDER_VOLUMES_PATH']: # Do we have a cinder-volumes vg?
param = controller.getParamByName(option) have_cinders_volume = False
param.setKey('USE_DEFAULT', False)
setup.input_param(param)
return True
def checkcindervg():
server = utils.ScriptRunner(controller.CONF['CONFIG_CINDER_HOST']) server = utils.ScriptRunner(controller.CONF['CONFIG_CINDER_HOST'])
server.append('vgdisplay %s' % cinders_volume)
cinders_volume = controller.CONF['CONFIG_CINDER_VOLUMES'] try:
server.execute()
have_cinders_volume = True
except ScriptRuntimeError:
pass
if controller.CONF["CONFIG_CINDER_VOLUMES_CREATE"] != "y": if controller.CONF["CONFIG_CINDER_VOLUMES_CREATE"] != "y":
server.append('vgdisplay %s' % cinders_volume) if not have_cinders_volume:
err = "The cinder server should contain a cinder-volumes volume group" raise exceptions.MissingRequirements("The cinder server should"
" contain a cinder-volumes volume group")
else: else:
if have_cinders_volume:
controller.MESSAGES.append(
output_messages.INFO_CINDER_VOLUMES_EXISTS)
return
server = utils.ScriptRunner(controller.CONF['CONFIG_CINDER_HOST'])
logging.info("A new cinder volumes group will be created") logging.info("A new cinder volumes group will be created")
err = "Cinder's volume group '%s' could not be created" % \ err = "Cinder's volume group '%s' could not be created" % \
controller.CONF['CONFIG_CINDER_VOLUMES'] cinders_volume
cinders_volume_path = controller.CONF['CONFIG_CINDER_VOLUMES_PATH'] cinders_volume_path = '/var/lib/cinder'
server.append('mkdir -p %s' % cinders_volume_path) server.append('mkdir -p %s' % cinders_volume_path)
logging.debug("Volume's path: %s" % cinders_volume_path) logging.debug("Volume's path: %s" % cinders_volume_path)
cinders_volume_path = os.path.join(cinders_volume_path, cinders_volume) cinders_volume_path = os.path.join(cinders_volume_path, cinders_volume)
server.append('dd if=/dev/zero of=%s bs=1 count=0 seek=%s' % \ server.append('dd if=/dev/zero of=%s bs=1 count=0 seek=%s' % \
(cinders_volume_path, controller.CONF['CONFIG_CINDER_VOLUMES_SIZE'])) (cinders_volume_path,
controller.CONF['CONFIG_CINDER_VOLUMES_SIZE']))
server.append('losetup /dev/loop2 %s' % cinders_volume_path) server.append('losetup /dev/loop2 %s' % cinders_volume_path)
server.append('pvcreate /dev/loop2') server.append('pvcreate /dev/loop2')
server.append('vgcreate %s /dev/loop2' % cinders_volume) server.append('vgcreate %s /dev/loop2' % cinders_volume)
@@ -181,30 +173,29 @@ def checkcindervg():
# Let's make sure it exists # Let's make sure it exists
server.append('vgdisplay %s' % cinders_volume) server.append('vgdisplay %s' % cinders_volume)
try: try:
server.execute() server.execute()
except: except:
if controller.CONF["CONFIG_CINDER_VOLUMES_CREATE"] == "y":
# Release loop device if cinder's volume creation # Release loop device if cinder's volume creation
# fails. # fails.
try: try:
logging.debug("Release loop device since volume's creation failed") logging.debug("Release loop device, volume creation failed")
server = utils.ScriptRunner(controller.CONF['CONFIG_CINDER_HOST']) server = utils.ScriptRunner(controller.CONF['CONFIG_CINDER_HOST'])
server.append('losetup -d /dev/loop2') server.append('losetup -d /dev/loop2')
server.execute() server.execute()
except: except:
pass pass
raise exceptions.MissingRequirements(err) raise exceptions.MissingRequirements(err)
def createkeystonemanifest(): def create_keystone_manifest():
manifestfile = "%s_keystone.pp" % controller.CONF['CONFIG_KEYSTONE_HOST'] manifestfile = "%s_keystone.pp" % controller.CONF['CONFIG_KEYSTONE_HOST']
manifestdata = getManifestTemplate("keystone_cinder.pp") manifestdata = getManifestTemplate("keystone_cinder.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def createmanifest(): def create_manifest():
manifestfile = "%s_cinder.pp" % controller.CONF['CONFIG_CINDER_HOST'] manifestfile = "%s_cinder.pp" % controller.CONF['CONFIG_CINDER_HOST']
manifestdata = getManifestTemplate("cinder.pp") manifestdata = getManifestTemplate("cinder.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)

View File

@@ -51,7 +51,7 @@ def initSequences(controller):
controller.insertSequence("Clean Up", [], [], puppetpresteps, index=0) controller.insertSequence("Clean Up", [], [], puppetpresteps, index=0)
puppetsteps = [ puppetsteps = [
{'title': 'Installing dependencies', 'functions': [installpuppet]}, {'title': 'Installing Dependencies', 'functions':[installdeps]},
{'title': 'Copying Puppet modules and manifests', 'functions':[copyPuppetModules]}, {'title': 'Copying Puppet modules and manifests', 'functions':[copyPuppetModules]},
{'title': 'Applying Puppet manifests', 'functions':[applyPuppetManifest]}, {'title': 'Applying Puppet manifests', 'functions':[applyPuppetManifest]},
] ]

View File

@@ -80,7 +80,7 @@ def initConfig(controllerObject):
"PROMPT" : ("To subscribe each server with RHN Satellite " "PROMPT" : ("To subscribe each server with RHN Satellite "
"enter RHN Satellite server URL"), "enter RHN Satellite server URL"),
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : False, "MASK_INPUT" : False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -93,7 +93,7 @@ def initConfig(controllerObject):
"PROMPT" : ("Enter RHN Satellite username or leave plain " "PROMPT" : ("Enter RHN Satellite username or leave plain "
"if you will use activation key instead"), "if you will use activation key instead"),
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : False, "MASK_INPUT" : False,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": True,
@@ -106,7 +106,7 @@ def initConfig(controllerObject):
"PROMPT" : ("Enter RHN Satellite password or leave plain " "PROMPT" : ("Enter RHN Satellite password or leave plain "
"if you will use activation key instead"), "if you will use activation key instead"),
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -119,7 +119,7 @@ def initConfig(controllerObject):
"PROMPT" : ("Enter RHN Satellite activation key or leave plain " "PROMPT" : ("Enter RHN Satellite activation key or leave plain "
"if you used username/password instead"), "if you used username/password instead"),
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -131,7 +131,7 @@ def initConfig(controllerObject):
"USAGE" : "Specify a path or URL to a SSL CA certificate to use", "USAGE" : "Specify a path or URL to a SSL CA certificate to use",
"PROMPT" : "Specify a path or URL to a SSL CA certificate to use", "PROMPT" : "Specify a path or URL to a SSL CA certificate to use",
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -147,7 +147,7 @@ def initConfig(controllerObject):
"be used as an identifier for the system in RHN " "be used as an identifier for the system in RHN "
"Satellite"), "Satellite"),
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -159,7 +159,7 @@ def initConfig(controllerObject):
"USAGE" : "Specify a HTTP proxy to use with RHN Satellite", "USAGE" : "Specify a HTTP proxy to use with RHN Satellite",
"PROMPT" : "Specify a HTTP proxy to use with RHN Satellite", "PROMPT" : "Specify a HTTP proxy to use with RHN Satellite",
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -171,7 +171,7 @@ def initConfig(controllerObject):
"USAGE" : "Specify a username to use with an authenticated HTTP proxy", "USAGE" : "Specify a username to use with an authenticated HTTP proxy",
"PROMPT" : "Specify a username to use with an authenticated HTTP proxy", "PROMPT" : "Specify a username to use with an authenticated HTTP proxy",
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -183,7 +183,7 @@ def initConfig(controllerObject):
"USAGE" : "Specify a password to use with an authenticated HTTP proxy.", "USAGE" : "Specify a password to use with an authenticated HTTP proxy.",
"PROMPT" : "Specify a password to use with an authenticated HTTP proxy.", "PROMPT" : "Specify a password to use with an authenticated HTTP proxy.",
"OPTION_LIST" : [], "OPTION_LIST" : [],
"VALIDATION_FUNC" : lambda a,b: True, "VALIDATORS" : [lambda a,b: True],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
@@ -196,7 +196,7 @@ def initConfig(controllerObject):
"flags are: novirtinfo, norhnsd, nopackages"), "flags are: novirtinfo, norhnsd, nopackages"),
"PROMPT" : "Enter comma separated list of flags passed to rhnreg_ks", "PROMPT" : "Enter comma separated list of flags passed to rhnreg_ks",
"OPTION_LIST" : ['novirtinfo', 'norhnsd', 'nopackages'], "OPTION_LIST" : ['novirtinfo', 'norhnsd', 'nopackages'],
"VALIDATION_FUNC" : validate_multi_options, "VALIDATORS" : [validate_multi_options],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE" : "",
"MASK_INPUT" : True, "MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,