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',
'FlagValidationError',
'MissingRequirements',
'PluginError',
'ParamProcessingError',
'ParamValidationError',
'NetworkError',
'ScriptRuntimeError',
)
@@ -24,7 +20,7 @@ class PackStackError(Exception):
class MissingRequirements(PackStackError):
"""Raised when minimum install requirements are not met"""
"""Raised when minimum install requirements are not met."""
pass
@@ -32,12 +28,10 @@ class InstallError(PackStackError):
"""Exception for generic errors during setup run."""
pass
class FlagValidationError(InstallError):
"""Raised when single flag validation fails."""
pass
class ParamValidationError(InstallError):
"""Raised when parameter value validation fails."""
pass
@@ -46,7 +40,6 @@ class ParamValidationError(InstallError):
class PluginError(PackStackError):
pass
class ParamProcessingError(PluginError):
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_EXCEEDS_MAX_LENGTH="String length exceeds the maximum length allowed: %s"
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."

View File

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

View File

@@ -7,17 +7,18 @@ import uuid
import logging
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_validators as validate
from packstack.installer import basedefs
import packstack.installer.common_utils as utils
from packstack.installer.exceptions import InstallError
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
# Plugin name
@@ -26,6 +27,7 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject):
global controller
controller = controllerObject
@@ -67,47 +69,11 @@ def initConfig(controllerObject):
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"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",
"USAGE" : "Create Cinder's volumes group",
"PROMPT" : "Should Cinder's volumes group be created?",
"OPTION_LIST" : ["y", "n"],
"VALIDATION_FUNC" : createVolume,
"VALIDATORS" : [validate.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
@@ -126,54 +92,80 @@ def initConfig(controllerObject):
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):
if controller.CONF['CONFIG_CINDER_INSTALL'] != 'y':
return
cindersteps = [
{'title': 'Adding Cinder Keystone manifest entries', 'functions':[createkeystonemanifest]},
{'title': 'Checking if the Cinder server has a cinder-volumes vg', 'functions':[checkcindervg]},
{'title': 'Adding Cinder manifest entries', 'functions':[createmanifest]}
cinder_steps = [
{'title': 'Adding Cinder Keystone manifest entries', 'functions':[create_keystone_manifest]},
{'title': 'Checking if the Cinder server has a cinder-volumes vg', 'functions':[check_cinder_vg]},
{'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=[]):
"""
Check that provided host is listening on port 22
"""
if param == "n":
return True
cinders_volume = 'cinder-volumes'
for option in ['CONFIG_CINDER_VOLUMES_SIZE', 'CONFIG_CINDER_VOLUMES_PATH']:
param = controller.getParamByName(option)
param.setKey('USE_DEFAULT', False)
setup.input_param(param)
return True
def checkcindervg():
# Do we have a cinder-volumes vg?
have_cinders_volume = False
server = utils.ScriptRunner(controller.CONF['CONFIG_CINDER_HOST'])
cinders_volume = controller.CONF['CONFIG_CINDER_VOLUMES']
server.append('vgdisplay %s' % cinders_volume)
try:
server.execute()
have_cinders_volume = True
except ScriptRuntimeError:
pass
if controller.CONF["CONFIG_CINDER_VOLUMES_CREATE"] != "y":
server.append('vgdisplay %s' % cinders_volume)
err = "The cinder server should contain a cinder-volumes volume group"
if not have_cinders_volume:
raise exceptions.MissingRequirements("The cinder server should"
" contain a cinder-volumes volume group")
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")
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)
logging.debug("Volume's path: %s" % cinders_volume_path)
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' % \
(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('pvcreate /dev/loop2')
server.append('vgcreate %s /dev/loop2' % cinders_volume)
@@ -181,30 +173,29 @@ def checkcindervg():
# Let's make sure it exists
server.append('vgdisplay %s' % cinders_volume)
try:
server.execute()
except:
if controller.CONF["CONFIG_CINDER_VOLUMES_CREATE"] == "y":
try:
server.execute()
except:
# Release loop device if cinder's volume creation
# fails.
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.append('losetup -d /dev/loop2')
server.execute()
except:
pass
raise exceptions.MissingRequirements(err)
raise exceptions.MissingRequirements(err)
def createkeystonemanifest():
def create_keystone_manifest():
manifestfile = "%s_keystone.pp" % controller.CONF['CONFIG_KEYSTONE_HOST']
manifestdata = getManifestTemplate("keystone_cinder.pp")
appendManifestFile(manifestfile, manifestdata)
def createmanifest():
def create_manifest():
manifestfile = "%s_cinder.pp" % controller.CONF['CONFIG_CINDER_HOST']
manifestdata = getManifestTemplate("cinder.pp")
appendManifestFile(manifestfile, manifestdata)

View File

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

View File

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