Files
packstack/packstack/plugins/mysql_001.py
Martin Magr e86cdf3d7f Fail when Nova API, Nova network and Swift hosts are not set as IP addresses
- Refactor value validator system - cleanup, pep8, documentation, tests and allow multiple validators for each parameter

Change-Id: I69ac806d9efdb46196070d518d5ef5c5c174e6bb
Fixes: rhbz#886603
2013-02-11 12:53:15 +01:00

104 lines
4.1 KiB
Python

"""
Installs and configures MySQL
"""
import uuid
import logging
import packstack.installer.engine_validators as validate
import packstack.installer.engine_processors as process
from packstack.installer import basedefs
import packstack.installer.common_utils as utils
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile
# Controller object will be initialized from main flow
controller = None
# Plugin name
PLUGIN_NAME = "OS-MySQL"
PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject):
global controller
controller = controllerObject
logging.debug("Adding MySQL OpenStack configuration")
paramsList = [
{"CMD_OPTION" : "mysql-host",
"USAGE" : "The IP address of the server on which to install MySQL",
"PROMPT" : "Enter the IP address of the MySQL server",
"OPTION_LIST" : [],
"VALIDATORS" : [validate.validate_ssh],
"DEFAULT_VALUE" : utils.getLocalhostIP(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_MYSQL_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "mysql-user",
"USAGE" : "Username for the MySQL admin user",
"PROMPT" : "Enter the username for the MySQL admin user",
"OPTION_LIST" : [],
"VALIDATORS" : [validate.validate_not_empty],
"DEFAULT_VALUE" : "root",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_MYSQL_USER",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "mysql-pw",
"USAGE" : "Password for the MySQL admin user",
"PROMPT" : "Enter the password for the MySQL admin user",
"OPTION_LIST" : [],
"VALIDATORS" : [validate.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_MYSQL_PW",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "MYSQL",
"DESCRIPTION" : "MySQL Config parameters",
"PRE_CONDITION" : utils.returnYes,
"PRE_CONDITION_MATCH" : "yes",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller):
mysqlsteps = [
{'title': 'Adding MySQL manifest entries',
'functions':[createmanifest]}
]
controller.addSequence("Installing MySQL", [], [], mysqlsteps)
def createmanifest():
host = controller.CONF['CONFIG_MYSQL_HOST']
manifestfile = "%s_mysql.pp" % host
manifestdata = [getManifestTemplate("mysql.pp")]
def append_for(module):
# Modules have be appended to the existing mysql.pp
# otherwise pp will fail for some of them saying that
# Mysql::Config definition is missing.
manifestdata.append(getManifestTemplate("mysql_%s.pp" % module))
if controller.CONF['CONFIG_NOVA_INSTALL'] == "y":
append_for("nova")
if controller.CONF['CONFIG_CINDER_INSTALL'] == "y":
append_for("cinder")
if controller.CONF['CONFIG_GLANCE_INSTALL'] == "y":
append_for("glance")
appendManifestFile(manifestfile, "\n".join(manifestdata), 'pre')