Plugins refactor

- Replaced CONFIG_<OS-component>_HOST(S) parameters for CONFIG_CONTROLLER_HOST,
  CONFIG_COMPUTE_HOSTS and CONFIG_NETWORK_HOSTS to minimize count of potential
  deployment architecture to maintainable level
- Unified coding style in plugins, PEP8-tized and forced pep8 check on them

Implements: blueprint simplification

Change-Id: I597f209b62d8d0c3709bb446cb33c804509eef9f
This commit is contained in:
Martin Magr 2014-05-06 14:53:23 +02:00
parent 8f2f18b302
commit 3d92f24ccc
60 changed files with 3129 additions and 3221 deletions

View File

@ -26,15 +26,16 @@ class Step(object):
"Object %s is not callable." % function) "Object %s is not callable." % function)
self.function = function self.function = function
def run(self, config=None): def run(self, config=None, messages=None):
config = config or {} config = config if config is not None else {}
messages = messages if messages is not None else []
# TO-DO: complete logger name when logging will be setup correctly # TO-DO: complete logger name when logging will be setup correctly
logger = logging.getLogger() logger = logging.getLogger()
logger.debug('Running step %s.' % self.name) logger.debug('Running step %s.' % self.name)
# execute and report state # execute and report state
try: try:
self.function(config) self.function(config, messages)
except Exception, ex: except Exception, ex:
logger.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
state = utils.state_message(self.title, 'ERROR', 'red') state = utils.state_message(self.title, 'ERROR', 'red')
@ -75,16 +76,17 @@ class Sequence(object):
result = config.get(self.condition) result = config.get(self.condition)
return result == self.cond_match return result == self.cond_match
def run(self, config=None, step=None): def run(self, config=None, messages=None, step=None):
""" """
Runs sequence of steps. Runs only specific step if step's name Runs sequence of steps. Runs only specific step if step's name
is given via 'step' parameter. is given via 'step' parameter.
""" """
config = config or {} config = config if config is not None else {}
messages = messages if messages is not None else []
if not self.validate_condition(config): if not self.validate_condition(config):
return return
if step: if step:
self.steps[step].run(config=config) self.steps[step].run(config=config, messages=messages)
return return
logger = logging.getLogger() logger = logging.getLogger()
@ -93,4 +95,4 @@ class Sequence(object):
sys.stdout.write('%s\n' % self.title) sys.stdout.write('%s\n' % self.title)
sys.stdout.flush() sys.stdout.flush()
for step in self.steps.itervalues(): for step in self.steps.itervalues():
step.run(config=config) step.run(config=config, messages=messages)

View File

@ -671,15 +671,12 @@ def single_step_install(options):
hosts = [host.strip() for host in hosts.split(',')] hosts = [host.strip() for host in hosts.split(',')]
for group in controller.getAllGroups(): for group in controller.getAllGroups():
for param in group.parameters.itervalues(): for param in group.parameters.itervalues():
# we don't need magic in case CONFIG_NEUTRON_LBAAS_HOSTS
if param.CONF_NAME == 'CONFIG_NEUTRON_LBAAS_HOSTS':
continue
# and directives that contain _HOST are set to the controller node # and directives that contain _HOST are set to the controller node
if param.CONF_NAME.find("_HOST") != -1: if param.CONF_NAME.find("_HOST") != -1:
overrides[param.CONF_NAME] = hosts[0] overrides[param.CONF_NAME] = hosts[0]
# If there are more than one host, all but the first are a compute nodes # If there are more than one host, all but the first are a compute nodes
if len(hosts) > 1: if len(hosts) > 1:
overrides["CONFIG_NOVA_COMPUTE_HOSTS"] = ','.join(hosts[1:]) overrides["CONFIG_COMPUTE_HOSTS"] = ','.join(hosts[1:])
# We can also override defaults with command line options # We can also override defaults with command line options
_set_command_line_values(options) _set_command_line_values(options)

View File

@ -35,22 +35,6 @@ class Controller(object):
self.__single = object.__new__(self, *args, **kwargs) self.__single = object.__new__(self, *args, **kwargs)
return self.__single return self.__single
def __init__(self):
# Resources that should be copied to each host along with the puppet
# files, on the remote host the file will be placed in
# $PACKSTACK_VAR_DIR/resources. This controller should copy the files,
# for now the puppet plugin is doing it format
# {'host':[('/path/to/fileordirectory', 'filenameonremotehost'), ..]}
self.resources = {}
def addResource(self, host, localpath, remotename):
""" Populates self.resources """
current_value_for_host = self.resources.get(host, [])
current_value_for_host.append((localpath,remotename))
self.resources[host] = current_value_for_host
# PLugins # PLugins
def addPlugin(self, plugObj): def addPlugin(self, plugObj):
self.__PLUGINS.append(plugObj) self.__PLUGINS.append(plugObj)
@ -81,7 +65,7 @@ class Controller(object):
def runAllSequences(self): def runAllSequences(self):
for sequence in self.__SEQUENCES: for sequence in self.__SEQUENCES:
sequence.run(self.CONF) sequence.run(config=self.CONF, messages=self.MESSAGES)
def getSequenceByDesc(self, desc): def getSequenceByDesc(self, desc):
for sequence in self.getAllSequences(): for sequence in self.getAllSequences():

View File

@ -2,4 +2,4 @@
def get_mq(config, plugin): def get_mq(config, plugin):
return plugin + "_%s.pp" % config.get('CONFIG_AMQP_SERVER') return plugin + "_%s.pp" % config.get('CONFIG_AMQP_BACKEND')

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures amqp Installs and configures amqp
""" """
@ -11,214 +13,221 @@ from packstack.installer import basedefs
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.common import filtered_hosts from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import gethostlist,\ from packstack.modules.ospluginutils import (getManifestTemplate,
getManifestTemplate,\ appendManifestFile)
appendManifestFile
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-AMQP"
PLUGIN_NAME = "AMQP"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller params = [
controller = controllerObject {"CMD_OPTION": "amqp-backend",
logging.debug("Adding OpenStack AMQP configuration") "USAGE": ("Set the AMQP service backend. Allowed values are: "
paramsList = [ "qpid, rabbitmq"),
{"CMD_OPTION" : "amqp-server", "PROMPT": "Set the AMQP service backend",
"USAGE" : "Set the server for the AMQP service", "OPTION_LIST": ["qpid", "rabbitmq"],
"PROMPT" : "Set the server for the AMQP service (qpid, rabbitmq)? ", "VALIDATORS": [validators.validate_options],
"OPTION_LIST" : ["qpid", "rabbitmq"], "DEFAULT_VALUE": "rabbitmq",
"VALIDATORS" : [validators.validate_options], "MASK_INPUT": False,
"DEFAULT_VALUE" : "rabbitmq", "LOOSE_VALIDATION": False,
"MASK_INPUT" : False, "CONF_NAME": "CONFIG_AMQP_BACKEND",
"LOOSE_VALIDATION": False, "USE_DEFAULT": False,
"CONF_NAME" : "CONFIG_AMQP_SERVER", "NEED_CONFIRM": False,
"USE_DEFAULT" : False, "CONDITION": False},
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "amqp-host",
"USAGE" : "The IP address of the server on which to install the AMQP service",
"PROMPT" : "Enter the IP address of the AMQP service",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_AMQP_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "amqp-enable-ssl",
"USAGE" : "Enable SSL for the AMQP service",
"PROMPT" : "Enable SSL for the AMQP service?",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_AMQP_ENABLE_SSL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "amqp-enable-auth",
"USAGE" : "Enable Authentication for the AMQP service",
"PROMPT" : "Enable Authentication for the AMQP service?",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_AMQP_ENABLE_AUTH",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
{"CMD_OPTION": "amqp-host",
"USAGE": ("The IP address of the server on which to install the "
"AMQP service"),
"PROMPT": "Enter the IP address of the AMQP service",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_AMQP_HOST",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
groupDict = { "GROUP_NAME" : "AMQPLANCE", {"CMD_OPTION": "amqp-enable-ssl",
"DESCRIPTION" : "AMQP Config parameters", "USAGE": "Enable SSL for the AMQP service",
"PRE_CONDITION" : False, "PROMPT": "Enable SSL for the AMQP service?",
"PRE_CONDITION_MATCH" : True, "OPTION_LIST": ["y", "n"],
"POST_CONDITION" : False, "VALIDATORS": [validators.validate_options],
"POST_CONDITION_MATCH" : True} "DEFAULT_VALUE": "n",
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_AMQP_ENABLE_SSL",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
controller.addGroup(groupDict, paramsList) {"CMD_OPTION": "amqp-enable-auth",
"USAGE": "Enable Authentication for the AMQP service",
"PROMPT": "Enable Authentication for the AMQP service?",
"OPTION_LIST": ["y", "n"],
"VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE": "n",
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_AMQP_ENABLE_AUTH",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "AMQP",
"DESCRIPTION": "AMQP Config parameters",
"PRE_CONDITION": False,
"PRE_CONDITION_MATCH": True,
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
paramsList = [ params = [
{"CMD_OPTION" : "amqp-nss-certdb-pw", {"CMD_OPTION": "amqp-nss-certdb-pw",
"USAGE" : "The password for the NSS certificate database of the AMQP service", "USAGE": ("The password for the NSS certificate database of the AMQP "
"PROMPT" : "Enter the password for NSS certificate database", "service"),
"OPTION_LIST" : [], "PROMPT": "Enter the password for NSS certificate database",
"VALIDATORS" : [validators.validate_not_empty], "OPTION_LIST": [],
"DEFAULT_VALUE" : uuid.uuid4().hex[:32], "VALIDATORS": [validators.validate_not_empty],
"MASK_INPUT" : False, "DEFAULT_VALUE": uuid.uuid4().hex[:32],
"LOOSE_VALIDATION": True, "MASK_INPUT": False,
"CONF_NAME" : "CONFIG_AMQP_NSS_CERTDB_PW", "LOOSE_VALIDATION": True,
"USE_DEFAULT" : False, "CONF_NAME": "CONFIG_AMQP_NSS_CERTDB_PW",
"NEED_CONFIRM" : False, "USE_DEFAULT": False,
"CONDITION" : False }, "NEED_CONFIRM": False,
{"CMD_OPTION" : "amqp-ssl-port", "CONDITION": False},
"USAGE" : "The port in which the AMQP service listens to SSL connections",
"PROMPT" : "Enter the SSL port for the AMQP service",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "5671",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_AMQP_SSL_PORT",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "amqp-ssl-cert-file",
"USAGE" : "The filename of the certificate that the AMQP service is going to use",
"PROMPT" : "Enter the filename of the SSL certificate for the AMQP service",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "/etc/pki/tls/certs/amqp_selfcert.pem",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_AMQP_SSL_CERT_FILE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "amqp-ssl-key-file",
"USAGE" : "The filename of the private key that the AMQP service is going to use",
"PROMPT" : "Enter the private key filename",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "/etc/pki/tls/private/amqp_selfkey.pem",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_AMQP_SSL_KEY_FILE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "amqp-ssl-self-signed",
"USAGE" : "Auto Generates self signed SSL certificate and key",
"PROMPT" : "Generate Self Signed SSL Certificate",
"OPTION_LIST" : ["y","n"],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_AMQP_SSL_SELF_SIGNED",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "AMQPSSL", {"CMD_OPTION": "amqp-ssl-port",
"DESCRIPTION" : "AMQP Config SSL parameters", "USAGE": ("The port in which the AMQP service listens to SSL "
"PRE_CONDITION" : "CONFIG_AMQP_ENABLE_SSL", "connections"),
"PRE_CONDITION_MATCH" : "y", "PROMPT": "Enter the SSL port for the AMQP service",
"POST_CONDITION" : False, "OPTION_LIST": [],
"POST_CONDITION_MATCH" : True} "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": "5671",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_AMQP_SSL_PORT",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
controller.addGroup(groupDict, paramsList) {"CMD_OPTION": "amqp-ssl-cert-file",
"USAGE": ("The filename of the certificate that the AMQP service "
"is going to use"),
"PROMPT": ("Enter the filename of the SSL certificate for the AMQP "
"service"),
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": "/etc/pki/tls/certs/amqp_selfcert.pem",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_AMQP_SSL_CERT_FILE",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
paramsList = [ {"CMD_OPTION": "amqp-ssl-key-file",
{"CMD_OPTION" : "amqp-auth-user", "USAGE": ("The filename of the private key that the AMQP service "
"USAGE" : "User for amqp authentication", "is going to use"),
"PROMPT" : "Enter the user for amqp authentication", "PROMPT": "Enter the private key filename",
"OPTION_LIST" : [], "OPTION_LIST": [],
"VALIDATORS" : [validators.validate_not_empty], "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE" : "amqp_user", "DEFAULT_VALUE": "/etc/pki/tls/private/amqp_selfkey.pem",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_AMQP_AUTH_USER", "CONF_NAME": "CONFIG_AMQP_SSL_KEY_FILE",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "amqp-auth-password",
"USAGE" : "Password for user authentication",
"PROMPT" : "Enter the password for user authentication",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_AMQP_AUTH_PASSWORD",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
] {"CMD_OPTION": "amqp-ssl-self-signed",
"USAGE": "Auto Generates self signed SSL certificate and key",
"PROMPT": "Generate Self Signed SSL Certificate",
"OPTION_LIST": ["y", "n"],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": "y",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_AMQP_SSL_SELF_SIGNED",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "AMQPSSL",
"DESCRIPTION": "AMQP Config SSL parameters",
"PRE_CONDITION": "CONFIG_AMQP_ENABLE_SSL",
"PRE_CONDITION_MATCH": "y",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
groupDict = { "GROUP_NAME" : "AMQPAUTH", params = [
"DESCRIPTION" : "AMQP Config Athentication parameters", {"CMD_OPTION": "amqp-auth-user",
"PRE_CONDITION" : "CONFIG_AMQP_ENABLE_AUTH", "USAGE": "User for amqp authentication",
"PRE_CONDITION_MATCH" : "y", "PROMPT": "Enter the user for amqp authentication",
"POST_CONDITION" : False, "OPTION_LIST": [],
"POST_CONDITION_MATCH" : True} "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": "amqp_user",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_AMQP_AUTH_USER",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "amqp-auth-password",
"USAGE": "Password for user authentication",
"PROMPT": "Enter the password for user authentication",
"OPTION_LIST": ["y", "n"],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_AMQP_AUTH_PASSWORD",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "AMQPAUTH",
"DESCRIPTION": "AMQP Config Athentication parameters",
"PRE_CONDITION": "CONFIG_AMQP_ENABLE_AUTH",
"PRE_CONDITION_MATCH": "y",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
amqpsteps = [ amqpsteps = [
{'title': 'Adding AMQP manifest entries', 'functions':[createmanifest]} {'title': 'Adding AMQP manifest entries',
'functions': [create_manifest]}
] ]
controller.addSequence("Installing AMQP", [], [], amqpsteps) controller.addSequence("Installing AMQP", [], [], amqpsteps)
def createmanifest(config):
manifestfile = "%s_amqp.pp"%config['CONFIG_AMQP_HOST'] #-------------------------- step functions --------------------------
manifestdata = ""
def create_manifest(config, messages):
server = utils.ScriptRunner(config['CONFIG_AMQP_HOST']) server = utils.ScriptRunner(config['CONFIG_AMQP_HOST'])
if config['CONFIG_AMQP_ENABLE_SSL'] == 'y': if config['CONFIG_AMQP_ENABLE_SSL'] == 'y':
config['CONFIG_AMQP_ENABLE_SSL'] = 'true' config['CONFIG_AMQP_ENABLE_SSL'] = 'true'
config['CONFIG_AMQP_PROTOCOL'] = 'ssl' config['CONFIG_AMQP_PROTOCOL'] = 'ssl'
config['CONFIG_AMQP_CLIENTS_PORT'] = "5671" config['CONFIG_AMQP_CLIENTS_PORT'] = "5671"
if config['CONFIG_AMQP_SSL_SELF_SIGNED'] == 'y': if config['CONFIG_AMQP_SSL_SELF_SIGNED'] == 'y':
server.append( "openssl req -batch -new -x509 -nodes -keyout %s -out %s -days 1095" server.append(
% (config['CONFIG_AMQP_SSL_KEY_FILE'], config['CONFIG_AMQP_SSL_CERT_FILE']) ) "openssl req -batch -new -x509 -nodes -keyout %s "
"-out %s -days 1095"
% (config['CONFIG_AMQP_SSL_KEY_FILE'],
config['CONFIG_AMQP_SSL_CERT_FILE'])
)
server.execute() server.execute()
else: else:
#Set default values # Set default values
config['CONFIG_AMQP_CLIENTS_PORT'] = "5672" config['CONFIG_AMQP_CLIENTS_PORT'] = "5672"
config['CONFIG_AMQP_SSL_PORT'] = "5671" config['CONFIG_AMQP_SSL_PORT'] = "5671"
config['CONFIG_AMQP_SSL_CERT_FILE'] = "" config['CONFIG_AMQP_SSL_CERT_FILE'] = ""
@ -231,11 +240,12 @@ def createmanifest(config):
config['CONFIG_AMQP_AUTH_PASSWORD'] = 'guest' config['CONFIG_AMQP_AUTH_PASSWORD'] = 'guest'
config['CONFIG_AMQP_AUTH_USER'] = 'guest' config['CONFIG_AMQP_AUTH_USER'] = 'guest'
manifestfile = "%s_amqp.pp" % config['CONFIG_AMQP_HOST']
manifestdata = getManifestTemplate('amqp.pp') manifestdata = getManifestTemplate('amqp.pp')
#All hosts should be able to talk to amqp # All hosts should be able to talk to amqp
config['FIREWALL_SERVICE_NAME'] = "amqp" config['FIREWALL_SERVICE_NAME'] = "amqp"
config['FIREWALL_PORTS'] = "'5671', '5672'" config['FIREWALL_PORTS'] = "'5671', '5672'"
config['FIREWALL_CHAIN'] = "INPUT" config['FIREWALL_CHAIN'] = "INPUT"
for host in filtered_hosts(config, exclude=False): for host in filtered_hosts(config, exclude=False):
config['FIREWALL_ALLOWED'] = "'%s'" % host config['FIREWALL_ALLOWED'] = "'%s'" % host

View File

@ -14,98 +14,81 @@ from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile) appendManifestFile)
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-Ceilometer" PLUGIN_NAME = "OS-Ceilometer"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject):
global controller
controller = controllerObject
logging.debug("Adding OpenStack Ceilometer configuration")
def initConfig(controller):
ceilometer_params = { ceilometer_params = {
"CEILOMETER" : [ "CEILOMETER": [
{"CMD_OPTION" : "ceilometer-host", {"CONF_NAME": "CONFIG_CEILOMETER_SECRET",
"USAGE" : ("The IP address of the server on which " "CMD_OPTION": "ceilometer-secret",
"to install Ceilometer"), "USAGE": "Secret key for signing metering messages",
"PROMPT" : ("Enter the IP address of the Ceilometer " "PROMPT": "Enter the Ceilometer secret key",
"server"), "OPTION_LIST": [],
"OPTION_LIST" : [], "VALIDATORS": [validators.validate_not_empty],
"VALIDATORS" : [validators.validate_ssh], "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"DEFAULT_VALUE" : utils.get_localhost_ip(), "MASK_INPUT": True,
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_CEILOMETER_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False},
{"CMD_OPTION" : "ceilometer-secret",
"USAGE" : "Secret key for signing metering messages.",
"PROMPT" : "Enter the Ceilometer secret key",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CEILOMETER_SECRET", "USE_DEFAULT": True,
"USE_DEFAULT" : True, "NEED_CONFIRM": True,
"NEED_CONFIRM" : True, "CONDITION": False},
"CONDITION" : False},
{"CMD_OPTION" : "ceilometer-ks-passwd", {"CONF_NAME": "CONFIG_CEILOMETER_KS_PW",
"USAGE" : "The password to use for Ceilometer to authenticate with Keystone", "CMD_OPTION": "ceilometer-ks-passwd",
"PROMPT" : "Enter the password for the Ceilometer Keystone access", "USAGE": ("The password to use for Ceilometer to authenticate "
"OPTION_LIST" : [], "with Keystone"),
"VALIDATORS" : [validators.validate_not_empty], "PROMPT": "Enter the password for the Ceilometer Keystone access",
"DEFAULT_VALUE" : uuid.uuid4().hex[:16], "OPTION_LIST": [],
"MASK_INPUT" : True, "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CEILOMETER_KS_PW", "USE_DEFAULT": True,
"USE_DEFAULT" : True, "NEED_CONFIRM": True,
"NEED_CONFIRM" : True, "CONDITION": False},
"CONDITION" : False}, ],
],
"MONGODB" : [ "MONGODB": [
{"CMD_OPTION" : "mongodb-host", {"CMD_OPTION": "mongodb-host",
"USAGE" : ("The IP address of the server on which " "USAGE": ("The IP address of the server on which to install "
"to install mongodb"), "MongoDB"),
"PROMPT" : ("Enter the IP address of the mongodb server"), "PROMPT": "Enter the IP address of the MongoDB server",
"OPTION_LIST" : [], "OPTION_LIST": [],
"VALIDATORS" : [validators.validate_ssh], "VALIDATORS": [validators.validate_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(), "DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_MONGODB_HOST", "CONF_NAME": "CONFIG_MONGODB_HOST",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False}, "CONDITION": False},
], ],
} }
ceilometer_groups = [ ceilometer_groups = [
{"GROUP_NAME" : "CEILOMETER", {"GROUP_NAME": "CEILOMETER",
"DESCRIPTION" : "Ceilometer Config parameters", "DESCRIPTION": "Ceilometer Config parameters",
"PRE_CONDITION" : "CONFIG_CEILOMETER_INSTALL", "PRE_CONDITION": "CONFIG_CEILOMETER_INSTALL",
"PRE_CONDITION_MATCH" : "y", "PRE_CONDITION_MATCH": "y",
"POST_CONDITION" : False, "POST_CONDITION": False,
"POST_CONDITION_MATCH": True}, "POST_CONDITION_MATCH": True},
{"GROUP_NAME" : "MONGODB",
"DESCRIPTION" : "MONGODB Config parameters", {"GROUP_NAME": "MONGODB",
"PRE_CONDITION" : "CONFIG_CEILOMETER_INSTALL", "DESCRIPTION": "MONGODB Config parameters",
"PRE_CONDITION_MATCH" : "y", "PRE_CONDITION": "CONFIG_CEILOMETER_INSTALL",
"POST_CONDITION" : False, "PRE_CONDITION_MATCH": "y",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}, "POST_CONDITION_MATCH": True},
] ]
for group in ceilometer_groups: for group in ceilometer_groups:
paramList = ceilometer_params[group["GROUP_NAME"]] paramList = ceilometer_params[group["GROUP_NAME"]]
controller.addGroup(group, paramList) controller.addGroup(group, paramList)
def initSequences(controller): def initSequences(controller):
if controller.CONF['CONFIG_CEILOMETER_INSTALL'] != 'y': if controller.CONF['CONFIG_CEILOMETER_INSTALL'] != 'y':
return return
@ -116,14 +99,17 @@ def initSequences(controller):
'functions': [create_manifest]}, 'functions': [create_manifest]},
{'title': 'Adding Ceilometer Keystone manifest entries', {'title': 'Adding Ceilometer Keystone manifest entries',
'functions': [create_keystone_manifest]}] 'functions': [create_keystone_manifest]}]
controller.addSequence("Installing OpenStack Ceilometer",[], [], controller.addSequence("Installing OpenStack Ceilometer", [], [],
steps) steps)
def create_manifest(config): #-------------------------- step functions --------------------------
manifestfile = "%s_ceilometer.pp" % config['CONFIG_CEILOMETER_HOST']
def create_manifest(config, messages):
manifestfile = "%s_ceilometer.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate(get_mq(config, "ceilometer")) manifestdata = getManifestTemplate(get_mq(config, "ceilometer"))
manifestdata += getManifestTemplate("ceilometer.pp") manifestdata += getManifestTemplate("ceilometer.pp")
config['FIREWALL_ALLOWED'] = "'ALL'" config['FIREWALL_ALLOWED'] = "'ALL'"
config['FIREWALL_SERVICE_NAME'] = 'ceilometer-api' config['FIREWALL_SERVICE_NAME'] = 'ceilometer-api'
config['FIREWALL_SERVICE_ID'] = 'ceilometer_api' config['FIREWALL_SERVICE_ID'] = 'ceilometer_api'
@ -136,16 +122,18 @@ def create_manifest(config):
manifestdata += getManifestTemplate("ceilometer_nova_disabled.pp") manifestdata += getManifestTemplate("ceilometer_nova_disabled.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def create_mongodb_manifest(config):
def create_mongodb_manifest(config, messages):
manifestfile = "%s_mongodb.pp" % config['CONFIG_MONGODB_HOST'] manifestfile = "%s_mongodb.pp" % config['CONFIG_MONGODB_HOST']
manifestdata = getManifestTemplate("mongodb.pp") manifestdata = getManifestTemplate("mongodb.pp")
config['FIREWALL_ALLOWED'] = "'%s'" % config['CONFIG_CEILOMETER_HOST'] config['FIREWALL_ALLOWED'] = "'%s'" % config['CONFIG_CONTROLLER_HOST']
config['FIREWALL_SERVICE_NAME'] = 'mongodb-server' config['FIREWALL_SERVICE_NAME'] = 'mongodb-server'
config['FIREWALL_PORTS'] = "'27017'" config['FIREWALL_PORTS'] = "'27017'"
manifestdata += getManifestTemplate("firewall.pp") manifestdata += getManifestTemplate("firewall.pp")
appendManifestFile(manifestfile, manifestdata, 'pre') appendManifestFile(manifestfile, manifestdata, 'pre')
def create_keystone_manifest(config):
manifestfile = "%s_keystone.pp" % config['CONFIG_KEYSTONE_HOST'] def create_keystone_manifest(config, messages):
manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("keystone_ceilometer.pp") manifestdata = getManifestTemplate("keystone_ceilometer.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures Cinder Installs and configures Cinder
""" """
@ -15,211 +17,188 @@ from packstack.installer.utils import split_hosts
from packstack.installer import basedefs from packstack.installer import basedefs
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile)
from packstack.installer import exceptions from packstack.installer import exceptions
from packstack.installer import output_messages from packstack.installer import output_messages
# Controller object will
# be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-Cinder" PLUGIN_NAME = "OS-Cinder"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controller):
params = [
{"CMD_OPTION": "cinder-db-passwd",
"USAGE": "The password to use for the Cinder to access DB",
"PROMPT": "Enter the password for the Cinder DB access",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": True,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_CINDER_DB_PW",
"USE_DEFAULT": True,
"NEED_CONFIRM": True,
"CONDITION": False},
def initConfig(controllerObject): {"CMD_OPTION": "cinder-ks-passwd",
global controller "USAGE": ("The password to use for the Cinder to authenticate with "
controller = controllerObject "Keystone"),
logging.debug("Adding OpenStack Cinder configuration") "PROMPT": "Enter the password for the Cinder Keystone access",
paramsList = [ "OPTION_LIST": [],
{"CMD_OPTION" : "cinder-host", "VALIDATORS": [validators.validate_not_empty],
"USAGE" : "The IP address of the server on which to install Cinder", "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"PROMPT" : "Enter the IP address of the Cinder server", "MASK_INPUT": True,
"OPTION_LIST" : [], "LOOSE_VALIDATION": False,
"VALIDATORS" : [validators.validate_ssh], "CONF_NAME": "CONFIG_CINDER_KS_PW",
"DEFAULT_VALUE" : utils.get_localhost_ip(), "USE_DEFAULT": True,
"MASK_INPUT" : False, "NEED_CONFIRM": True,
"LOOSE_VALIDATION": True, "CONDITION": False},
"CONF_NAME" : "CONFIG_CINDER_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "cinder-db-passwd",
"USAGE" : "The password to use for the Cinder to access DB",
"PROMPT" : "Enter the password for the Cinder DB access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_DB_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "cinder-ks-passwd",
"USAGE" : "The password to use for the Cinder to authenticate with Keystone",
"PROMPT" : "Enter the password for the Cinder Keystone access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_KS_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "cinder-backend",
"USAGE" : ("The Cinder backend to use, valid options are: "
"lvm, gluster, nfs, vmdk"),
"PROMPT" : "Enter the Cinder backend to be configured",
"OPTION_LIST" : ["lvm", "gluster", "nfs", "vmdk"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "lvm",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_BACKEND",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "CINDER", {"CMD_OPTION": "cinder-backend",
"DESCRIPTION" : "Cinder Config parameters", "USAGE": ("The Cinder backend to use, valid options are: lvm, "
"PRE_CONDITION" : "CONFIG_CINDER_INSTALL", "gluster, nfs"),
"PRE_CONDITION_MATCH" : "y", "PROMPT": "Enter the Cinder backend to be configured",
"POST_CONDITION" : False, "OPTION_LIST": ["lvm", "gluster", "nfs"],
"POST_CONDITION_MATCH" : True} "VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE": "lvm",
controller.addGroup(groupDict, paramsList) "MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_CINDER_BACKEND",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "CINDER",
"DESCRIPTION": "Cinder Config parameters",
"PRE_CONDITION": "CONFIG_CINDER_INSTALL",
"PRE_CONDITION_MATCH": "y",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
def check_lvm_options(config): def check_lvm_options(config):
return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and
config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'lvm') config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'lvm')
paramsList = [ params = [
{"CMD_OPTION" : "cinder-volumes-create", {"CMD_OPTION": "cinder-volumes-create",
"USAGE" : ("Create Cinder's volumes group. This should only be done for " "USAGE": ("Create Cinder's volumes group. This should only be done "
"testing on a proof-of-concept installation of Cinder. This " "for testing on a proof-of-concept installation of Cinder. "
"will create a file-backed volume group and is not suitable " "This will create a file-backed volume group and is not "
"for production usage."), "suitable for production usage."),
"PROMPT" : ("Should Cinder's volumes group be created (for proof-of-concept " "PROMPT": ("Should Cinder's volumes group be created (for "
"installation)?"), "proof-of-concept installation)?"),
"OPTION_LIST" : ["y", "n"], "OPTION_LIST": ["y", "n"],
"VALIDATORS" : [validators.validate_options], "VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE" : "y", "DEFAULT_VALUE": "y",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_VOLUMES_CREATE", "CONF_NAME": "CONFIG_CINDER_VOLUMES_CREATE",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
] ]
group = {"GROUP_NAME": "CINDERVOLUMECREATE",
groupDict = { "GROUP_NAME" : "CINDERVOLUMECREATE", "DESCRIPTION": "Cinder volume create Config parameters",
"DESCRIPTION" : "Cinder volume create Config parameters", "PRE_CONDITION": check_lvm_options,
"PRE_CONDITION" : check_lvm_options, "PRE_CONDITION_MATCH": True,
"PRE_CONDITION_MATCH" : True, "POST_CONDITION": False,
"POST_CONDITION" : False, "POST_CONDITION_MATCH": True}
"POST_CONDITION_MATCH" : True} controller.addGroup(group, params)
controller.addGroup(groupDict, paramsList)
def check_lvm_vg_options(config): def check_lvm_vg_options(config):
return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and
config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'lvm' and config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'lvm' and
config.get('CONFIG_CINDER_VOLUMES_CREATE', 'y') == 'y') config.get('CONFIG_CINDER_VOLUMES_CREATE', 'y') == 'y')
paramsList = [ params = [
{"CMD_OPTION" : "cinder-volumes-size", {"CMD_OPTION": "cinder-volumes-size",
"USAGE" : ("Cinder's volumes group size. Note that actual volume size " "USAGE": ("Cinder's volumes group size. Note that actual volume size "
"will be extended with 3% more space for VG metadata."), "will be extended with 3% more space for VG metadata."),
"PROMPT" : "Enter Cinder's volumes group usable size", "PROMPT": "Enter Cinder's volumes group usable size",
"OPTION_LIST" : [], "OPTION_LIST": [],
"VALIDATORS" : [validators.validate_not_empty], "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE" : "20G", "DEFAULT_VALUE": "20G",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_VOLUMES_SIZE", "CONF_NAME": "CONFIG_CINDER_VOLUMES_SIZE",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
] ]
group = {"GROUP_NAME": "CINDERVOLUMESIZE",
groupDict = { "GROUP_NAME" : "CINDERVOLUMESIZE", "DESCRIPTION": "Cinder volume size Config parameters",
"DESCRIPTION" : "Cinder volume size Config parameters", "PRE_CONDITION": check_lvm_vg_options,
"PRE_CONDITION" : check_lvm_vg_options, "PRE_CONDITION_MATCH": True,
"PRE_CONDITION_MATCH" : True, "POST_CONDITION": False,
"POST_CONDITION" : False, "POST_CONDITION_MATCH": True}
"POST_CONDITION_MATCH" : True} controller.addGroup(group, params)
controller.addGroup(groupDict, paramsList)
def check_gluster_options(config): def check_gluster_options(config):
return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and
config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'gluster') config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'gluster')
paramsList = [ params = [
{"CMD_OPTION" : "cinder-gluster-mounts", {"CMD_OPTION": "cinder-gluster-mounts",
"USAGE" : ("A single or comma separated list of gluster volume shares " "USAGE": ("A single or comma separated list of gluster volume shares "
"to mount, eg: ip-address:/vol-name, domain:/vol-name "), "to mount, eg: ip-address:/vol-name, domain:/vol-name "),
"PROMPT" : ("Enter a single or comma separated list of gluster volume " "PROMPT": ("Enter a single or comma separated list of gluster volume "
"shares to use with Cinder"), "shares to use with Cinder"),
"OPTION_LIST" : ["^'([\d]{1,3}\.){3}[\d]{1,3}:/.*'", \ "OPTION_LIST": ["^'([\d]{1,3}\.){3}[\d]{1,3}:/.*'",
"^'[a-zA-Z0-9][\-\.\w]*:/.*'"], "^'[a-zA-Z0-9][\-\.\w]*:/.*'"],
"VALIDATORS" : [validators.validate_multi_regexp], "VALIDATORS": [validators.validate_multi_regexp],
"PROCESSORS" : [processors.process_add_quotes_around_values], "PROCESSORS": [processors.process_add_quotes_around_values],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE": "",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_CINDER_GLUSTER_MOUNTS", "CONF_NAME": "CONFIG_CINDER_GLUSTER_MOUNTS",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
] ]
group = {"GROUP_NAME": "CINDERGLUSTERMOUNTS",
groupDict = { "GROUP_NAME" : "CINDERGLUSTERMOUNTS", "DESCRIPTION": "Cinder gluster Config parameters",
"DESCRIPTION" : "Cinder gluster Config parameters", "PRE_CONDITION": check_gluster_options,
"PRE_CONDITION" : check_gluster_options, "PRE_CONDITION_MATCH": True,
"PRE_CONDITION_MATCH" : True, "POST_CONDITION": False,
"POST_CONDITION" : False, "POST_CONDITION_MATCH": True}
"POST_CONDITION_MATCH" : True} controller.addGroup(group, params)
controller.addGroup(groupDict, paramsList)
def check_nfs_options(config): def check_nfs_options(config):
return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and return (config.get('CONFIG_CINDER_INSTALL', 'n') == 'y' and
config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'nfs') config.get('CONFIG_CINDER_BACKEND', 'lvm') == 'nfs')
paramsList = [ params = [
{"CMD_OPTION" : "cinder-nfs-mounts", {"CMD_OPTION": "cinder-nfs-mounts",
"USAGE" : ("A single or comma seprated list of NFS exports to mount, " "USAGE": ("A single or comma seprated list of NFS exports to mount, "
"eg: ip-address:/export-name "), "eg: ip-address:/export-name "),
"PROMPT" : ("Enter a single or comma seprated list of NFS exports to " "PROMPT": ("Enter a single or comma seprated list of NFS exports to "
"use with Cinder"), "use with Cinder"),
"OPTION_LIST" : ["^'([\d]{1,3}\.){3}[\d]{1,3}:/.*'"], "OPTION_LIST": ["^'([\d]{1,3}\.){3}[\d]{1,3}:/.*'"],
"VALIDATORS" : [validators.validate_multi_regexp], "VALIDATORS": [validators.validate_multi_regexp],
"PROCESSORS" : [processors.process_add_quotes_around_values], "PROCESSORS": [processors.process_add_quotes_around_values],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE": "",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_CINDER_NFS_MOUNTS", "CONF_NAME": "CONFIG_CINDER_NFS_MOUNTS",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
] ]
group = {"GROUP_NAME": "CINDERNFSMOUNTS",
groupDict = { "GROUP_NAME" : "CINDERNFSMOUNTS", "DESCRIPTION": "Cinder NFS Config parameters",
"DESCRIPTION" : "Cinder NFS Config parameters", "PRE_CONDITION": check_nfs_options,
"PRE_CONDITION" : check_nfs_options, "PRE_CONDITION_MATCH": True,
"PRE_CONDITION_MATCH" : True, "POST_CONDITION": False,
"POST_CONDITION" : False, "POST_CONDITION_MATCH": True}
"POST_CONDITION_MATCH" : True} controller.addGroup(group, params)
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
@ -227,30 +206,40 @@ def initSequences(controller):
return return
cinder_steps = [ cinder_steps = [
{'title': 'Installing dependencies for Cinder', 'functions':[install_cinder_deps]}, {'title': 'Installing dependencies for Cinder',
{'title': 'Adding Cinder Keystone manifest entries', 'functions':[create_keystone_manifest]}, 'functions': [install_cinder_deps]},
{'title': 'Adding Cinder manifest entries', 'functions':[create_manifest]} {'title': 'Adding Cinder Keystone manifest entries',
'functions': [create_keystone_manifest]},
{'title': 'Adding Cinder manifest entries',
'functions': [create_manifest]}
] ]
if controller.CONF['CONFIG_CINDER_BACKEND'] == 'lvm': if controller.CONF['CONFIG_CINDER_BACKEND'] == 'lvm':
cinder_steps.append({'title': 'Checking if the Cinder server has a cinder-volumes vg', 'functions':[check_cinder_vg]}) cinder_steps.append(
{'title': 'Checking if the Cinder server has a cinder-volumes vg',
'functions': [check_cinder_vg]})
controller.addSequence("Installing OpenStack Cinder", [], [], cinder_steps) controller.addSequence("Installing OpenStack Cinder", [], [], cinder_steps)
def install_cinder_deps(config):
server = utils.ScriptRunner(config['CONFIG_CINDER_HOST']) #-------------------------- step functions --------------------------
def install_cinder_deps(config, messages):
server = utils.ScriptRunner(config['CONFIG_CONTROLLER_HOST'])
pkgs = [] pkgs = []
if config['CONFIG_CINDER_BACKEND'] == 'lvm': if config['CONFIG_CINDER_BACKEND'] == 'lvm':
pkgs.append('lvm2') pkgs.append('lvm2')
for p in pkgs: for p in pkgs:
server.append("rpm -q --whatprovides %(package)s || yum install -y %(package)s" % dict(package=p)) server.append("rpm -q --whatprovides %(package)s || "
"yum install -y %(package)s" % dict(package=p))
server.execute() server.execute()
def check_cinder_vg(config):
def check_cinder_vg(config, messages):
cinders_volume = 'cinder-volumes' cinders_volume = 'cinder-volumes'
# Do we have a cinder-volumes vg? # Do we have a cinder-volumes vg?
have_cinders_volume = False have_cinders_volume = False
server = utils.ScriptRunner(config['CONFIG_CINDER_HOST']) server = utils.ScriptRunner(config['CONFIG_CONTROLLER_HOST'])
server.append('vgdisplay %s' % cinders_volume) server.append('vgdisplay %s' % cinders_volume)
try: try:
server.execute() server.execute()
@ -259,7 +248,7 @@ def check_cinder_vg(config):
pass pass
# Configure system LVM settings (snapshot_autoextend) # Configure system LVM settings (snapshot_autoextend)
server = utils.ScriptRunner(config['CONFIG_CINDER_HOST']) server = utils.ScriptRunner(config['CONFIG_CONTROLLER_HOST'])
server.append('sed -i -r "s/^ *snapshot_autoextend_threshold +=.*/' server.append('sed -i -r "s/^ *snapshot_autoextend_threshold +=.*/'
' snapshot_autoextend_threshold = 80/" ' ' snapshot_autoextend_threshold = 80/" '
'/etc/lvm/lvm.conf') '/etc/lvm/lvm.conf')
@ -271,18 +260,18 @@ def check_cinder_vg(config):
except exceptions.ScriptRuntimeError: except exceptions.ScriptRuntimeError:
logging.info("Warning: Unable to set system LVM settings.") logging.info("Warning: Unable to set system LVM settings.")
if config["CONFIG_CINDER_VOLUMES_CREATE"] != "y": if config["CONFIG_CINDER_VOLUMES_CREATE"] != "y":
if not have_cinders_volume: if not have_cinders_volume:
raise exceptions.MissingRequirements("The cinder server should" raise exceptions.MissingRequirements("The cinder server should "
" contain a cinder-volumes volume group") "contain a cinder-volumes "
"volume group")
else: else:
if have_cinders_volume: if have_cinders_volume:
controller.MESSAGES.append( messages.append(
output_messages.INFO_CINDER_VOLUMES_EXISTS) output_messages.INFO_CINDER_VOLUMES_EXISTS)
return return
server = utils.ScriptRunner(config['CONFIG_CINDER_HOST']) server = utils.ScriptRunner(config['CONFIG_CONTROLLER_HOST'])
server.append('systemctl') server.append('systemctl')
try: try:
server.execute() server.execute()
@ -292,8 +281,6 @@ def check_cinder_vg(config):
server.clear() server.clear()
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" % \
cinders_volume
cinders_volume_path = '/var/lib/cinder' cinders_volume_path = '/var/lib/cinder'
server.append('mkdir -p %s' % cinders_volume_path) server.append('mkdir -p %s' % cinders_volume_path)
@ -311,7 +298,7 @@ def check_cinder_vg(config):
cinders_volume_size = cinders_volume_size + cinders_reserve cinders_volume_size = cinders_volume_size + cinders_reserve
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=%sM' server.append('dd if=/dev/zero of=%s bs=1 count=0 seek=%sM'
% (cinders_volume_path, cinders_volume_size)) % (cinders_volume_path, cinders_volume_size))
server.append('LOFI=$(losetup --show -f %s)' % cinders_volume_path) server.append('LOFI=$(losetup --show -f %s)' % cinders_volume_path)
server.append('pvcreate $LOFI') server.append('pvcreate $LOFI')
server.append('vgcreate %s $LOFI' % cinders_volume) server.append('vgcreate %s $LOFI' % cinders_volume)
@ -319,8 +306,8 @@ def check_cinder_vg(config):
# Add the loop device on boot # Add the loop device on boot
server.append('grep %(volume)s /etc/rc.d/rc.local || ' server.append('grep %(volume)s /etc/rc.d/rc.local || '
'echo "losetup -f %(path)s && ' 'echo "losetup -f %(path)s && '
'vgchange -a y %(volume)s && ' 'vgchange -a y %(volume)s && '
'%(restart_cmd)s" ' '%(restart_cmd)s" '
'>> /etc/rc.d/rc.local' % '>> /etc/rc.d/rc.local' %
{'volume': cinders_volume, 'restart_cmd': rst_cmd, {'volume': cinders_volume, 'restart_cmd': rst_cmd,
'path': cinders_volume_path}) 'path': cinders_volume_path})
@ -338,26 +325,27 @@ def check_cinder_vg(config):
# fails. # fails.
try: try:
logging.debug("Release loop device, volume creation failed") logging.debug("Release loop device, volume creation failed")
server = utils.ScriptRunner(controller.CONF['CONFIG_CINDER_HOST']) server = utils.ScriptRunner(config['CONFIG_CONTROLLER_HOST'])
server.append('losetup -d $(losetup -j %s | cut -d : -f 1)' % server.append('losetup -d $(losetup -j %s | cut -d : -f 1)'
cinders_volume_path % cinders_volume_path)
)
server.execute() server.execute()
except: except:
pass pass
raise exceptions.MissingRequirements(err) raise exceptions.MissingRequirements("Cinder's volume group '%s' "
"could not be created"
% cinders_volume)
def create_keystone_manifest(config): def create_keystone_manifest(config, messages):
manifestfile = "%s_keystone.pp" % controller.CONF['CONFIG_KEYSTONE_HOST'] manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("keystone_cinder.pp") manifestdata = getManifestTemplate("keystone_cinder.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def create_manifest(config): def create_manifest(config, messages):
manifestdata = getManifestTemplate(get_mq(config, "cinder")) manifestdata = getManifestTemplate(get_mq(config, "cinder"))
manifestfile = "%s_cinder.pp" % controller.CONF['CONFIG_CINDER_HOST'] manifestfile = "%s_cinder.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata += getManifestTemplate("cinder.pp") manifestdata += getManifestTemplate("cinder.pp")
if config['CONFIG_CINDER_BACKEND'] == "gluster": if config['CONFIG_CINDER_BACKEND'] == "gluster":
@ -369,15 +357,15 @@ def create_manifest(config):
if config['CONFIG_CEILOMETER_INSTALL'] == 'y': if config['CONFIG_CEILOMETER_INSTALL'] == 'y':
manifestdata += getManifestTemplate('cinder_ceilometer.pp') manifestdata += getManifestTemplate('cinder_ceilometer.pp')
if config['CONFIG_SWIFT_INSTALL'] == 'y': if config['CONFIG_SWIFT_INSTALL'] == 'y':
config['CONFIG_SWIFT_PROXY'] = config['CONFIG_SWIFT_PROXY_HOSTS'].split(',')[0].strip()
manifestdata += getManifestTemplate('cinder_backup.pp') manifestdata += getManifestTemplate('cinder_backup.pp')
config['FIREWALL_SERVICE_NAME'] = "cinder" config['FIREWALL_SERVICE_NAME'] = "cinder"
config['FIREWALL_PORTS'] = "'3260', '8776'" config['FIREWALL_PORTS'] = "'3260', '8776'"
config['FIREWALL_CHAIN'] = "INPUT" config['FIREWALL_CHAIN'] = "INPUT"
if (config['CONFIG_NOVA_INSTALL'] == 'y' and config['CONFIG_VMWARE_BACKEND']=='n'): if (config['CONFIG_NOVA_INSTALL'] == 'y' and
for host in split_hosts(config['CONFIG_NOVA_COMPUTE_HOSTS']): config['CONFIG_VMWARE_BACKEND'] == 'n'):
for host in split_hosts(config['CONFIG_COMPUTE_HOSTS']):
config['FIREWALL_ALLOWED'] = "'%s'" % host config['FIREWALL_ALLOWED'] = "'%s'" % host
config['FIREWALL_SERVICE_ID'] = "cinder_%s" % host config['FIREWALL_SERVICE_ID'] = "cinder_%s" % host
manifestdata += getManifestTemplate("firewall.pp") manifestdata += getManifestTemplate("firewall.pp")

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures OpenStack Horizon Installs and configures OpenStack Horizon
""" """
@ -11,92 +13,80 @@ from packstack.installer import basedefs, output_messages
from packstack.installer import exceptions from packstack.installer import exceptions
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile)
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-HORIZON"
PLUGIN_NAME = "OS-Horizon"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller params = [
controller = controllerObject {"CMD_OPTION": "os-horizon-ssl",
logging.debug("Adding OpenStack Horizon configuration") "USAGE": "To set up Horizon communication over https set this to 'y'",
paramsList = [ "PROMPT": "Would you like to set up Horizon communication over https",
{"CMD_OPTION" : "os-horizon-host", "OPTION_LIST": ["y", "n"],
"USAGE" : "The IP address of the server on which to install Horizon", "VALIDATORS": [validators.validate_options],
"PROMPT" : "Enter the IP address of the Horizon server", "DEFAULT_VALUE": "n",
"OPTION_LIST" : [], "MASK_INPUT": False,
"VALIDATORS" : [validators.validate_ssh], "LOOSE_VALIDATION": True,
"DEFAULT_VALUE" : utils.get_localhost_ip(), "CONF_NAME": "CONFIG_HORIZON_SSL",
"MASK_INPUT" : False, "USE_DEFAULT": False,
"LOOSE_VALIDATION": True, "NEED_CONFIRM": False,
"CONF_NAME" : "CONFIG_HORIZON_HOST", "CONDITION": False},
"USE_DEFAULT" : False, ]
"NEED_CONFIRM" : False, group = {"GROUP_NAME": "OSHORIZON",
"CONDITION" : False }, "DESCRIPTION": "OpenStack Horizon Config parameters",
{"CMD_OPTION" : "os-horizon-ssl", "PRE_CONDITION": "CONFIG_HORIZON_INSTALL",
"USAGE" : "To set up Horizon communication over https set this to \"y\"", "PRE_CONDITION_MATCH": "y",
"PROMPT" : "Would you like to set up Horizon communication over https", "POST_CONDITION": False,
"OPTION_LIST" : ["y", "n"], "POST_CONDITION_MATCH": True}
"VALIDATORS" : [validators.validate_options], controller.addGroup(group, params)
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_HORIZON_SSL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "OSHORIZON", params = [
"DESCRIPTION" : "OpenStack Horizon Config parameters", {"CMD_OPTION": "os-ssl-cert",
"PRE_CONDITION" : "CONFIG_HORIZON_INSTALL", "USAGE": ("PEM encoded certificate to be used for ssl on the https "
"PRE_CONDITION_MATCH" : "y", "server, leave blank if one should be generated, this "
"POST_CONDITION" : False, "certificate should not require a passphrase"),
"POST_CONDITION_MATCH" : True} "PROMPT": ("Enter the path to a PEM encoded certificate to be used "
"on the https server, leave blank if one should be "
"generated, this certificate should not require "
"a passphrase"),
"OPTION_LIST": [],
"VALIDATORS": [],
"DEFAULT_VALUE": '',
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_SSL_CERT",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
controller.addGroup(groupDict, paramsList) {"CMD_OPTION": "os-ssl-key",
"USAGE": ("SSL keyfile corresponding to the certificate if one was "
paramsList = [ "entered"),
{"CMD_OPTION" : "os-ssl-cert", "PROMPT": ("Enter the SSL keyfile corresponding to the certificate "
"USAGE" : "PEM encoded certificate to be used for ssl on the https server, leave blank if one should be generated, this certificate should not require a passphrase", "if one was entered"),
"PROMPT" : "Enter the path to a PEM encoded certificate to be used on the https server, leave blank if one should be generated, this certificate should not require a passphrase", "OPTION_LIST": [],
"OPTION_LIST" : [], "VALIDATORS": [],
"VALIDATORS" : [], "DEFAULT_VALUE": "",
"DEFAULT_VALUE" : '', "MASK_INPUT": False,
"MASK_INPUT" : False, "LOOSE_VALIDATION": True,
"LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_SSL_KEY",
"CONF_NAME" : "CONFIG_SSL_CERT", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False }, ]
{"CMD_OPTION" : "os-ssl-key", group = {"GROUP_NAME": "OSSSL",
"USAGE" : "Keyfile corresponding to the certificate if one was entered", "DESCRIPTION": "SSL Config parameters",
"PROMPT" : "Enter the keyfile corresponding to the certificate if one was entered", "PRE_CONDITION": "CONFIG_HORIZON_SSL",
"OPTION_LIST" : [], "PRE_CONDITION_MATCH": "y",
"VALIDATORS" : [], "POST_CONDITION": False,
"DEFAULT_VALUE" : "", "POST_CONDITION_MATCH": True}
"MASK_INPUT" : False, controller.addGroup(group, params)
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_SSL_KEY",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "OSSSL",
"DESCRIPTION" : "SSL Config parameters",
"PRE_CONDITION" : "CONFIG_HORIZON_SSL",
"PRE_CONDITION_MATCH" : "y",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
@ -104,28 +94,31 @@ def initSequences(controller):
return return
steps = [ steps = [
{'title': 'Adding Horizon manifest entries', 'functions': [createmanifest]} {'title': 'Adding Horizon manifest entries',
'functions': [create_manifest]}
] ]
controller.addSequence("Installing OpenStack Horizon", [], [], steps) controller.addSequence("Installing OpenStack Horizon", [], [], steps)
def createmanifest(config): #-------------------------- step functions --------------------------
controller.CONF["CONFIG_HORIZON_SECRET_KEY"] = uuid.uuid4().hex
horizon_host = controller.CONF['CONFIG_HORIZON_HOST'] def create_manifest(config, messages):
config["CONFIG_HORIZON_SECRET_KEY"] = uuid.uuid4().hex
horizon_host = config['CONFIG_CONTROLLER_HOST']
manifestfile = "%s_horizon.pp" % horizon_host manifestfile = "%s_horizon.pp" % horizon_host
proto = "http" proto = "http"
controller.CONF["CONFIG_HORIZON_PORT"] = "'80'" config["CONFIG_HORIZON_PORT"] = "'80'"
sslmanifestdata = '' sslmanifestdata = ''
if controller.CONF["CONFIG_HORIZON_SSL"] == 'y': if config["CONFIG_HORIZON_SSL"] == 'y':
controller.CONF["CONFIG_HORIZON_PORT"] = "'443'" config["CONFIG_HORIZON_PORT"] = "'443'"
proto = "https" proto = "https"
sslmanifestdata += getManifestTemplate("https.pp") sslmanifestdata += getManifestTemplate("https.pp")
# Are we using the users cert/key files # Are we using the users cert/key files
if controller.CONF["CONFIG_SSL_CERT"]: if config["CONFIG_SSL_CERT"]:
ssl_cert = controller.CONF["CONFIG_SSL_CERT"] ssl_cert = config["CONFIG_SSL_CERT"]
ssl_key = controller.CONF["CONFIG_SSL_KEY"] ssl_key = config["CONFIG_SSL_KEY"]
if not os.path.exists(ssl_cert): if not os.path.exists(ssl_cert):
raise exceptions.ParamValidationError( raise exceptions.ParamValidationError(
@ -135,13 +128,13 @@ def createmanifest(config):
raise exceptions.ParamValidationError( raise exceptions.ParamValidationError(
"The file %s doesn't exist" % ssl_key) "The file %s doesn't exist" % ssl_key)
controller.addResource(horizon_host, ssl_cert, 'ssl_ps_server.crt') resources = config.setdefault('RESOURCES', {})
host_resources = resources.setdefault(horizon_host, [])
host_resources.append((ssl_cert, 'ssl_ps_server.crt'))
if ssl_key: if ssl_key:
controller.addResource( host_resources.append(ssl_key, 'ssl_ps_server.key')
horizon_host, ssl_key, 'ssl_ps_server.key'
)
else: else:
controller.MESSAGES.append( messages.append(
"%sNOTE%s : A certificate was generated to be used for ssl, " "%sNOTE%s : A certificate was generated to be used for ssl, "
"You should change the ssl certificate configured in " "You should change the ssl certificate configured in "
"/etc/httpd/conf.d/ssl.conf on %s to use a CA signed cert." "/etc/httpd/conf.d/ssl.conf on %s to use a CA signed cert."
@ -151,8 +144,8 @@ def createmanifest(config):
manifestdata += sslmanifestdata manifestdata += sslmanifestdata
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
msg = "To access the OpenStack Dashboard browse to %s://%s/dashboard .\n" \ msg = ("To access the OpenStack Dashboard browse to %s://%s/dashboard .\n"
"Please, find your login credentials stored in the keystonerc_admin" \ "Please, find your login credentials stored in the keystonerc_admin"
" in your home directory." % \ " in your home directory."
(proto, controller.CONF['CONFIG_HORIZON_HOST']) % (proto, config['CONFIG_CONTROLLER_HOST']))
controller.MESSAGES.append(msg) messages.append(msg)

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures Glance Installs and configures Glance
""" """
@ -11,68 +13,51 @@ from packstack.installer import utils
from packstack.installer.utils import split_hosts from packstack.installer.utils import split_hosts
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile)
# Controller object will be initialized from main flow #------------------ oVirt installer initialization ------------------
controller = None
# Plugin name
PLUGIN_NAME = "OS-Glance" PLUGIN_NAME = "OS-Glance"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller params = [
controller = controllerObject {"CMD_OPTION": "glance-db-passwd",
logging.debug("Adding OpenStack Glance configuration") "USAGE": "The password to use for the Glance to access DB",
paramsList = [ "PROMPT": "Enter the password for the Glance DB access",
{"CMD_OPTION" : "glance-host", "OPTION_LIST": [],
"USAGE" : "The IP address of the server on which to install Glance", "VALIDATORS": [validators.validate_not_empty],
"PROMPT" : "Enter the IP address of the Glance server", "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"OPTION_LIST" : [], "MASK_INPUT": True,
"VALIDATORS" : [validators.validate_ssh], "LOOSE_VALIDATION": False,
"DEFAULT_VALUE" : utils.get_localhost_ip(), "CONF_NAME": "CONFIG_GLANCE_DB_PW",
"MASK_INPUT" : False, "USE_DEFAULT": True,
"LOOSE_VALIDATION": True, "NEED_CONFIRM": True,
"CONF_NAME" : "CONFIG_GLANCE_HOST", "CONDITION": False},
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "glance-db-passwd",
"USAGE" : "The password to use for the Glance to access DB",
"PROMPT" : "Enter the password for the Glance DB access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_GLANCE_DB_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "glance-ks-passwd",
"USAGE" : "The password to use for the Glance to authenticate with Keystone",
"PROMPT" : "Enter the password for the Glance Keystone access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_GLANCE_KS_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "GLANCE", {"CMD_OPTION": "glance-ks-passwd",
"DESCRIPTION" : "Glance Config parameters", "USAGE": ("The password to use for the Glance to authenticate "
"PRE_CONDITION" : "CONFIG_GLANCE_INSTALL", "with Keystone"),
"PRE_CONDITION_MATCH" : "y", "PROMPT": "Enter the password for the Glance Keystone access",
"POST_CONDITION" : False, "OPTION_LIST": [],
"POST_CONDITION_MATCH" : True} "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
controller.addGroup(groupDict, paramsList) "MASK_INPUT": True,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_GLANCE_KS_PW",
"USE_DEFAULT": True,
"NEED_CONFIRM": True,
"CONDITION": False},
]
group = {"GROUP_NAME": "GLANCE",
"DESCRIPTION": "Glance Config parameters",
"PRE_CONDITION": "CONFIG_GLANCE_INSTALL",
"PRE_CONDITION_MATCH": "y",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
def initSequences(controller): def initSequences(controller):
@ -84,27 +69,34 @@ def initSequences(controller):
return return
glancesteps = [ glancesteps = [
{'title': 'Adding Glance Keystone manifest entries', 'functions':[createkeystonemanifest]}, {'title': 'Adding Glance Keystone manifest entries',
{'title': 'Adding Glance manifest entries', 'functions':[createmanifest]} 'functions': [create_keystone_manifest]},
{'title': 'Adding Glance manifest entries',
'functions': [create_manifest]}
] ]
controller.addSequence("Installing OpenStack Glance", [], [], glancesteps) controller.addSequence("Installing OpenStack Glance", [], [], glancesteps)
def createkeystonemanifest(config):
manifestfile = "%s_keystone.pp" % controller.CONF['CONFIG_KEYSTONE_HOST'] #-------------------------- step functions --------------------------
def create_keystone_manifest(config, messages):
manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("keystone_glance.pp") manifestdata = getManifestTemplate("keystone_glance.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def createmanifest(config):
manifestfile = "%s_glance.pp" % controller.CONF['CONFIG_GLANCE_HOST'] def create_manifest(config, messages):
manifestfile = "%s_glance.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("glance.pp") manifestdata = getManifestTemplate("glance.pp")
if config['CONFIG_CEILOMETER_INSTALL'] == 'y': if config['CONFIG_CEILOMETER_INSTALL'] == 'y':
manifestdata += getManifestTemplate(get_mq(config, "glance_ceilometer")) mq_template = get_mq(config, "glance_ceilometer")
manifestdata += getManifestTemplate(mq_template)
config['FIREWALL_SERVICE_NAME'] = "glance" config['FIREWALL_SERVICE_NAME'] = "glance"
config['FIREWALL_PORTS'] = "'9292'" config['FIREWALL_PORTS'] = "'9292'"
config['FIREWALL_CHAIN'] = "INPUT" config['FIREWALL_CHAIN'] = "INPUT"
if config['CONFIG_NOVA_INSTALL'] == 'y': if config['CONFIG_NOVA_INSTALL'] == 'y':
for host in split_hosts(config['CONFIG_NOVA_COMPUTE_HOSTS']): for host in split_hosts(config['CONFIG_COMPUTE_HOSTS']):
config['FIREWALL_ALLOWED'] = "'%s'" % host config['FIREWALL_ALLOWED'] = "'%s'" % host
config['FIREWALL_SERVICE_ID'] = "glance_%s" % host config['FIREWALL_SERVICE_ID'] = "glance_%s" % host
manifestdata += getManifestTemplate("firewall.pp") manifestdata += getManifestTemplate("firewall.pp")

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures heat Installs and configures heat
""" """
@ -14,216 +16,141 @@ from packstack.modules.ospluginutils import (getManifestTemplate,
manifestfiles, manifestfiles,
appendManifestFile) appendManifestFile)
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-HEAT"
PLUGIN_NAME = "OS-Heat"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controller):
def initConfig(controllerObject):
global controller
controller = controllerObject
logging.debug("Adding OpenStack Heat configuration")
parameters = [ parameters = [
{"CMD_OPTION" : "heat-host", {"CMD_OPTION": "os-heat-mysql-password",
"USAGE" : ('The IP address of the server on which ' "USAGE": ('The password used by Heat user to authenticate against '
'to install Heat service'), 'MySQL'),
"PROMPT" : 'Enter the IP address of the Heat service', "PROMPT": "Enter the password for the Heat MySQL user",
"OPTION_LIST" : [], "OPTION_LIST": [],
"VALIDATORS" : [validators.validate_ssh], "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE" : utils.get_localhost_ip(), "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT" : False, "MASK_INPUT": True,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_HEAT_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "heat-mysql-password",
"USAGE" : 'The password used by Heat user to authenticate against MySQL',
"PROMPT" : "Enter the password for the Heat MySQL user",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_HEAT_DB_PW", "CONF_NAME": "CONFIG_HEAT_DB_PW",
"USE_DEFAULT" : True, "USE_DEFAULT": True,
"NEED_CONFIRM" : True, "NEED_CONFIRM": True,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "heat-auth-encryption-key", {"CMD_OPTION": "heat-auth-encryption-key",
"USAGE" : "The encryption key to use for authentication info in database", "USAGE": ("The encryption key to use for authentication info "
"PROMPT" : "Enter the authentication key for Heat to use for authenticate info in database", "in database"),
"OPTION_LIST" : [], "PROMPT": ("Enter the authentication key for Heat to use for "
"VALIDATORS" : [validators.validate_not_empty], "authenticate info in database"),
"DEFAULT_VALUE" : uuid.uuid4().hex[:16], "OPTION_LIST": [],
"MASK_INPUT" : True, "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_HEAT_AUTH_ENC_KEY", "CONF_NAME": "CONFIG_HEAT_AUTH_ENC_KEY",
"USE_DEFAULT" : True, "USE_DEFAULT": True,
"NEED_CONFIRM" : True, "NEED_CONFIRM": True,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "heat-ks-passwd", {"CMD_OPTION": "os-heat-ks-passwd",
"USAGE" : "The password to use for the Heat to authenticate with Keystone", "USAGE": ("The password to use for the Heat to authenticate "
"PROMPT" : "Enter the password for the Heat Keystone access", "with Keystone"),
"OPTION_LIST" : [], "PROMPT": "Enter the password for the Heat Keystone access",
"VALIDATORS" : [validators.validate_not_empty], "OPTION_LIST": [],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16], "VALIDATORS": [validators.validate_not_empty],
"MASK_INPUT" : True, "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_HEAT_KS_PW", "CONF_NAME": "CONFIG_HEAT_KS_PW",
"USE_DEFAULT" : True, "USE_DEFAULT": True,
"NEED_CONFIRM" : True, "NEED_CONFIRM": True,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "os-heat-cloudwatch-install", {"CMD_OPTION": "os-heat-cloudwatch-install",
"USAGE" : ("Set to 'y' if you would like Packstack to " "USAGE": ("Set to 'y' if you would like Packstack to install Heat "
"install Heat CloudWatch API"), "CloudWatch API"),
"PROMPT" : "Should Packstack install Heat CloudWatch API", "PROMPT": "Should Packstack install Heat CloudWatch API",
"OPTION_LIST" : ["y", "n"], "OPTION_LIST": ["y", "n"],
"VALIDATORS" : [validators.validate_options], "VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE" : "n", "DEFAULT_VALUE": "n",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_HEAT_CLOUDWATCH_INSTALL", "CONF_NAME": "CONFIG_HEAT_CLOUDWATCH_INSTALL",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "os-heat-cfn-install", {"CMD_OPTION": "os-heat-cfn-install",
"USAGE" : ("Set to 'y' if you would like Packstack to " "USAGE": ("Set to 'y' if you would like Packstack to install Heat "
"install Heat CloudFormation API"), "CloudFormation API"),
"PROMPT" : "Should Packstack install Heat CloudFormation API", "PROMPT": "Should Packstack install Heat CloudFormation API",
"OPTION_LIST" : ["y", "n"], "OPTION_LIST": ["y", "n"],
"VALIDATORS" : [validators.validate_options], "VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE" : "n", "DEFAULT_VALUE": "n",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_HEAT_CFN_INSTALL", "CONF_NAME": "CONFIG_HEAT_CFN_INSTALL",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
]
group = {"GROUP_NAME" : "Heat",
"DESCRIPTION" : "Heat Config parameters",
"PRE_CONDITION" : "CONFIG_HEAT_INSTALL",
"PRE_CONDITION_MATCH" : "y",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, parameters)
parameters = [
{"CMD_OPTION" : "heat-api-cloudwatch-host",
"USAGE" : ('The IP address of the server on which '
'to install Heat CloudWatch API service'),
"PROMPT" : ('Enter the IP address of the Heat CloudWatch API '
'server'),
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_HEAT_CLOUDWATCH_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
] ]
group = {"GROUP_NAME": "Heat",
def check_cloudwatch(config): "DESCRIPTION": "Heat Config parameters",
return config["CONFIG_HEAT_INSTALL"] == 'y' and \ "PRE_CONDITION": "CONFIG_HEAT_INSTALL",
config["CONFIG_HEAT_CLOUDWATCH_INSTALL"] == 'y' "PRE_CONDITION_MATCH": "y",
"POST_CONDITION": False,
group = {"GROUP_NAME" : "Heat CloudWatch API",
"DESCRIPTION" : "Heat CloudWatch API config parameters",
"PRE_CONDITION" : check_cloudwatch,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, parameters)
parameters = [
{"CMD_OPTION" : "heat-api-cfn-host",
"USAGE" : ('The IP address of the server on which '
'to install Heat CloudFormation API service'),
"PROMPT" : ('Enter the IP address of the Heat CloudFormation '
'API server'),
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_HEAT_CFN_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
def check_cloudformation(config):
return config["CONFIG_HEAT_INSTALL"] == 'y' and \
config["CONFIG_HEAT_CFN_INSTALL"] == 'y'
group = {"GROUP_NAME" : "Heat CloudFormation API",
"DESCRIPTION" : "Heat CloudFormation API config parameters",
"PRE_CONDITION" : check_cloudformation,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH": True} "POST_CONDITION_MATCH": True}
controller.addGroup(group, parameters) controller.addGroup(group, parameters)
def initSequences(controller): def initSequences(controller):
if controller.CONF['CONFIG_HEAT_INSTALL'] != 'y': config = controller.CONF
if config['CONFIG_HEAT_INSTALL'] != 'y':
return return
steps = [{'title': 'Adding Heat manifest entries', steps = [
'functions': [create_manifest]}, {'title': 'Adding Heat manifest entries',
{'title': 'Adding Heat Keystone manifest entries', 'functions': [create_manifest]},
'functions':[create_keystone_manifest]}] {'title': 'Adding Heat Keystone manifest entries',
'functions': [create_keystone_manifest]}
]
if controller.CONF.get('CONFIG_HEAT_CLOUDWATCH_INSTALL', 'n') == 'y': if config.get('CONFIG_HEAT_CLOUDWATCH_INSTALL', 'n') == 'y':
steps.append({'title': 'Adding Heat CloudWatch API manifest entries', steps.append(
'functions': [create_cloudwatch_manifest]}) {'title': 'Adding Heat CloudWatch API manifest entries',
if controller.CONF.get('CONFIG_HEAT_CFN_INSTALL', 'n') == 'y': 'functions': [create_cloudwatch_manifest]})
steps.append({'title': 'Adding Heat CloudFormation API manifest entries', if config.get('CONFIG_HEAT_CFN_INSTALL', 'n') == 'y':
'functions': [create_cfn_manifest]}) steps.append(
{'title': 'Adding Heat CloudFormation API manifest entries',
'functions': [create_cfn_manifest]})
controller.addSequence("Installing Heat", [], [], steps) controller.addSequence("Installing Heat", [], [], steps)
def create_manifest(config): #-------------------------- step functions --------------------------
if config['CONFIG_HEAT_CLOUDWATCH_INSTALL'] == 'y':
config['CONFIG_HEAT_WATCH_HOST'] = config['CONFIG_HEAT_CLOUDWATCH_HOST']
else:
config['CONFIG_HEAT_WATCH_HOST'] = config['CONFIG_HEAT_HOST']
if config['CONFIG_HEAT_CFN_INSTALL'] == 'y':
config['CONFIG_HEAT_METADATA_HOST'] = config['CONFIG_HEAT_CFN_HOST']
else:
config['CONFIG_HEAT_METADATA_HOST'] = config['CONFIG_HEAT_HOST']
manifestfile = "%s_heat.pp" % controller.CONF['CONFIG_HEAT_HOST'] def create_manifest(config, messages):
manifestfile = "%s_heat.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate(get_mq(config, "heat")) manifestdata = getManifestTemplate(get_mq(config, "heat"))
manifestdata += getManifestTemplate("heat.pp") manifestdata += getManifestTemplate("heat.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def create_keystone_manifest(config): def create_keystone_manifest(config, messages):
manifestfile = "%s_keystone.pp" % controller.CONF['CONFIG_KEYSTONE_HOST'] manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("keystone_heat.pp") manifestdata = getManifestTemplate("keystone_heat.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def create_cloudwatch_manifest(config): def create_cloudwatch_manifest(config, messages):
manifestfile = "%s_heatcw.pp" % controller.CONF['CONFIG_HEAT_CLOUDWATCH_HOST'] manifestfile = "%s_heatcw.pp" % controller.CONF['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate(get_mq(config, "heat")) manifestdata = getManifestTemplate(get_mq(config, "heat"))
manifestdata += getManifestTemplate("heat_cloudwatch.pp") manifestdata += getManifestTemplate("heat_cloudwatch.pp")
appendManifestFile(manifestfile, manifestdata, marker='heat') appendManifestFile(manifestfile, manifestdata, marker='heat')
def create_cfn_manifest(config): def create_cfn_manifest(config, messages):
manifestfile = "%s_heatcnf.pp" % controller.CONF['CONFIG_HEAT_CFN_HOST'] manifestfile = "%s_heatcnf.pp" % controller.CONF['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate(get_mq(config, "heat")) manifestdata = getManifestTemplate(get_mq(config, "heat"))
manifestdata += getManifestTemplate("heat_cfn.pp") manifestdata += getManifestTemplate("heat_cfn.pp")
appendManifestFile(manifestfile, manifestdata, marker='heat') appendManifestFile(manifestfile, manifestdata, marker='heat')

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures Keystone Installs and configures Keystone
""" """
@ -9,122 +11,112 @@ from packstack.installer import validators
from packstack.installer import basedefs from packstack.installer import basedefs
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile from packstack.modules.ospluginutils import (getManifestTemplate,
from packstack.installer.utils import host_iter appendManifestFile)
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-Keystone" PLUGIN_NAME = "OS-Keystone"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller params = [
controller = controllerObject {"CMD_OPTION": "keystone-db-passwd",
logging.debug("Adding OpenStack Keystone configuration") "USAGE": "The password to use for the Keystone to access DB",
paramsList = [ "PROMPT": "Enter the password for the Keystone DB access",
{"CMD_OPTION" : "keystone-host", "OPTION_LIST": [],
"USAGE" : "The IP address of the server on which to install Keystone", "VALIDATORS": [validators.validate_not_empty],
"PROMPT" : "Enter the IP address of the Keystone server", "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"OPTION_LIST" : [], "MASK_INPUT": True,
"VALIDATORS" : [validators.validate_ssh], "LOOSE_VALIDATION": False,
"DEFAULT_VALUE" : utils.get_localhost_ip(), "CONF_NAME": "CONFIG_KEYSTONE_DB_PW",
"MASK_INPUT" : False, "USE_DEFAULT": True,
"LOOSE_VALIDATION": True, "NEED_CONFIRM": True,
"CONF_NAME" : "CONFIG_KEYSTONE_HOST", "CONDITION": False},
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "keystone-db-passwd",
"USAGE" : "The password to use for the Keystone to access DB",
"PROMPT" : "Enter the password for the Keystone DB access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_KEYSTONE_DB_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "keystone-admin-token",
"USAGE" : "The token to use for the Keystone service api",
"PROMPT" : "The token to use for the Keystone service api",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex,
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_KEYSTONE_ADMIN_TOKEN",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "keystone-admin-passwd",
"USAGE" : "The password to use for the Keystone admin user",
"PROMPT" : "Enter the password for the Keystone admin user",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_KEYSTONE_ADMIN_PW",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "keystone-demo-passwd",
"USAGE" : "The password to use for the Keystone demo user",
"PROMPT" : "Enter the password for the Keystone demo user",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_KEYSTONE_DEMO_PW",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "keystone-token-format",
"USAGE" : "Kestone token format. Use either UUID or PKI",
"PROMPT" : "Enter the Keystone token format.",
"OPTION_LIST" : ['UUID', 'PKI'],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : 'PKI',
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : 'CONFIG_KEYSTONE_TOKEN_FORMAT',
"USE_DEFAULT" : True,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "KEYSTONE", {"CMD_OPTION": "keystone-admin-token",
"DESCRIPTION" : "Keystone Config parameters", "USAGE": "The token to use for the Keystone service api",
"PRE_CONDITION" : lambda x: 'yes', "PROMPT": "The token to use for the Keystone service api",
"PRE_CONDITION_MATCH" : "yes", "OPTION_LIST": [],
"POST_CONDITION" : False, "VALIDATORS": [validators.validate_not_empty],
"POST_CONDITION_MATCH" : True} "DEFAULT_VALUE": uuid.uuid4().hex,
"MASK_INPUT": True,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_KEYSTONE_ADMIN_TOKEN",
"USE_DEFAULT": True,
"NEED_CONFIRM": False,
"CONDITION": False},
controller.addGroup(groupDict, paramsList) {"CMD_OPTION": "keystone-admin-passwd",
"USAGE": "The password to use for the Keystone admin user",
"PROMPT": "Enter the password for the Keystone admin user",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": True,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_KEYSTONE_ADMIN_PW",
"USE_DEFAULT": False,
"NEED_CONFIRM": True,
"CONDITION": False},
{"CMD_OPTION": "keystone-demo-passwd",
"USAGE": "The password to use for the Keystone demo user",
"PROMPT": "Enter the password for the Keystone demo user",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": True,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_KEYSTONE_DEMO_PW",
"USE_DEFAULT": False,
"NEED_CONFIRM": True,
"CONDITION": False},
{"CMD_OPTION": "keystone-token-format",
"USAGE": "Kestone token format. Use either UUID or PKI",
"PROMPT": "Enter the Keystone token format.",
"OPTION_LIST": ['UUID', 'PKI'],
"VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE": 'PKI',
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": 'CONFIG_KEYSTONE_TOKEN_FORMAT',
"USE_DEFAULT": True,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "KEYSTONE",
"DESCRIPTION": "Keystone Config parameters",
"PRE_CONDITION": lambda x: 'yes',
"PRE_CONDITION_MATCH": "yes",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
def initSequences(controller): def initSequences(controller):
keystonesteps = [ keystonesteps = [
{'title': 'Adding Keystone manifest entries', {'title': 'Adding Keystone manifest entries',
'functions': [create_manifest]}, 'functions': [create_manifest]},
] ]
controller.addSequence("Installing OpenStack Keystone", [], [], controller.addSequence("Installing OpenStack Keystone", [], [],
keystonesteps) keystonesteps)
def create_manifest(config):
manifestfile = "%s_keystone.pp" % config['CONFIG_KEYSTONE_HOST'] #-------------------------- step functions --------------------------
def create_manifest(config, messages):
manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("keystone.pp") manifestdata = getManifestTemplate("keystone.pp")
config['FIREWALL_ALLOWED'] = "'ALL'" config['FIREWALL_ALLOWED'] = "'ALL'"
config['FIREWALL_SERVICE_NAME'] = "keystone" config['FIREWALL_SERVICE_NAME'] = "keystone"
config['FIREWALL_SERVICE_ID'] = "keystone" config['FIREWALL_SERVICE_ID'] = "keystone"
config['FIREWALL_PORTS'] = "'5000', '35357'" config['FIREWALL_PORTS'] = "'5000', '35357'"
config['FIREWALL_CHAIN'] = "INPUT" config['FIREWALL_CHAIN'] = "INPUT"
manifestdata += getManifestTemplate("firewall.pp") manifestdata += getManifestTemplate("firewall.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures MySQL Installs and configures MySQL
""" """
@ -9,79 +11,79 @@ from packstack.installer import validators
from packstack.installer import utils from packstack.installer import utils
from packstack.installer.utils import split_hosts from packstack.installer.utils import split_hosts
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile)
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-MySQL"
PLUGIN_NAME = "MySQL"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller params = [
controller = controllerObject {"CMD_OPTION": "mysql-host",
logging.debug("Adding MySQL OpenStack configuration") "USAGE": ("The IP address of the server on which to install MySQL or "
paramsList = [ "IP address of DB server to use if MySQL installation was "
{"CMD_OPTION" : "mysql-host", "not selected"),
"USAGE" : "The IP address of the server on which to install MySQL", "PROMPT": "Enter the IP address of the MySQL server",
"PROMPT" : "Enter the IP address of the MySQL server", "OPTION_LIST": [],
"OPTION_LIST" : [], "VALIDATORS": [validators.validate_ssh],
"VALIDATORS" : [validators.validate_ssh], "DEFAULT_VALUE": utils.get_localhost_ip(),
"DEFAULT_VALUE" : utils.get_localhost_ip(), "MASK_INPUT": False,
"MASK_INPUT" : False, "LOOSE_VALIDATION": True,
"LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_MYSQL_HOST",
"CONF_NAME" : "CONFIG_MYSQL_HOST", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": 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" : [validators.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" : [validators.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" : True,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "MYSQL", {"CMD_OPTION": "mysql-user",
"DESCRIPTION" : "MySQL Config parameters", "USAGE": "Username for the MySQL admin user",
"PRE_CONDITION" : lambda x: 'yes', "PROMPT": "Enter the username for the MySQL admin user",
"PRE_CONDITION_MATCH" : "yes", "OPTION_LIST": [],
"POST_CONDITION" : False, "VALIDATORS": [validators.validate_not_empty],
"POST_CONDITION_MATCH" : True} "DEFAULT_VALUE": "root",
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_MYSQL_USER",
"USE_DEFAULT": True,
"NEED_CONFIRM": False,
"CONDITION": False},
controller.addGroup(groupDict, paramsList) {"CMD_OPTION": "mysql-pw",
"USAGE": "Password for the MySQL admin user",
"PROMPT": "Enter the password for the MySQL admin user",
"OPTION_LIST": [],
"VALIDATORS": [validators.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": True,
"CONDITION": False},
]
group = {"GROUP_NAME": "MYSQL",
"DESCRIPTION": "MySQL Config parameters",
"PRE_CONDITION": lambda x: 'yes',
"PRE_CONDITION_MATCH": "yes",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
def initSequences(controller): def initSequences(controller):
mysqlsteps = [ mysqlsteps = [
{'title': 'Adding MySQL manifest entries', {'title': 'Adding MySQL manifest entries',
'functions':[createmanifest]} 'functions': [create_manifest]}
] ]
controller.addSequence("Installing MySQL", [], [], mysqlsteps) controller.addSequence("Installing MySQL", [], [], mysqlsteps)
def createmanifest(config): #-------------------------- step functions --------------------------
def create_manifest(config, messages):
if config['CONFIG_MYSQL_INSTALL'] == 'y': if config['CONFIG_MYSQL_INSTALL'] == 'y':
install = True install = True
suffix = 'install' suffix = 'install'
@ -89,11 +91,7 @@ def createmanifest(config):
install = False install = False
suffix = 'noinstall' suffix = 'noinstall'
# In case we are not installing MySQL server, mysql* manifests have manifestfile = "%s_mysql.pp" % config['CONFIG_MYSQL_HOST']
# to be run from Keystone host
host = install and config['CONFIG_MYSQL_HOST'] \
or config['CONFIG_KEYSTONE_HOST']
manifestfile = "%s_mysql.pp" % host
manifestdata = [getManifestTemplate('mysql_%s.pp' % suffix)] manifestdata = [getManifestTemplate('mysql_%s.pp' % suffix)]
def append_for(module, suffix): def append_for(module, suffix):
@ -104,28 +102,12 @@ def createmanifest(config):
manifestdata.append(getManifestTemplate(template)) manifestdata.append(getManifestTemplate(template))
append_for("keystone", suffix) append_for("keystone", suffix)
hosts = set()
for mod in ['nova', 'cinder', 'glance', 'neutron', 'heat']: for mod in ['nova', 'cinder', 'glance', 'neutron', 'heat']:
if config['CONFIG_%s_INSTALL' % mod.upper()] == 'y': if config['CONFIG_%s_INSTALL' % mod.upper()] == 'y':
append_for(mod, suffix) append_for(mod, suffix)
# Check wich modules are enabled so we can allow their
# hosts on the firewall hosts = set([config['CONFIG_CONTROLLER_HOST']])
if mod != 'nova' and mod != 'neutron': hosts |= split_hosts(config['CONFIG_COMPUTE_HOSTS'])
hosts.add(config.get('CONFIG_%s_HOST' % mod.upper()).strip())
elif mod == 'neutron':
hosts.add(config.get('CONFIG_NEUTRON_SERVER_HOST').strip())
elif config['CONFIG_NOVA_INSTALL'] != 'n':
#In that remote case that we have lot's of nova hosts
hosts.add(config.get('CONFIG_NOVA_API_HOST').strip())
hosts.add(config.get('CONFIG_NOVA_CERT_HOST').strip())
hosts.add(config.get('CONFIG_NOVA_VNCPROXY_HOST').strip())
hosts.add(config.get('CONFIG_NOVA_CONDUCTOR_HOST').strip())
hosts.add(config.get('CONFIG_NOVA_SCHED_HOST').strip())
if config['CONFIG_NEUTRON_INSTALL'] != 'y':
dbhosts = split_hosts(config['CONFIG_NOVA_NETWORK_HOSTS'])
hosts |= dbhosts
for host in config.get('CONFIG_NOVA_COMPUTE_HOSTS').split(','):
hosts.add(host.strip())
config['FIREWALL_SERVICE_NAME'] = "mysql" config['FIREWALL_SERVICE_NAME'] = "mysql"
config['FIREWALL_PORTS'] = "'3306'" config['FIREWALL_PORTS'] = "'3306'"

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures Nagios Installs and configures Nagios
""" """
@ -10,72 +12,55 @@ from packstack.installer import basedefs, output_messages
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.common import filtered_hosts from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import gethostlist,\ from packstack.modules.ospluginutils import (getManifestTemplate,
getManifestTemplate,\ appendManifestFile)
appendManifestFile
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-Nagios" PLUGIN_NAME = "OS-Nagios"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller params = [
controller = controllerObject {"CMD_OPTION": "nagios-passwd",
logging.debug("Adding OpenStack Nagios configuration") "USAGE": "The password of the nagiosadmin user on the Nagios server",
paramsList = [ "PROMPT": "Enter the password for the nagiosadmin user",
{"CMD_OPTION" : "nagios-host", "OPTION_LIST": [],
"USAGE" : "The IP address of the server on which to install the Nagios server", "VALIDATORS": [validators.validate_not_empty],
"PROMPT" : "Enter the IP address of the Nagios server", "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"OPTION_LIST" : [], "MASK_INPUT": True,
"VALIDATORS" : [validators.validate_ssh], "LOOSE_VALIDATION": True,
"DEFAULT_VALUE" : utils.get_localhost_ip(), "CONF_NAME": "CONFIG_NAGIOS_PW",
"MASK_INPUT" : False, "USE_DEFAULT": False,
"LOOSE_VALIDATION": True, "NEED_CONFIRM": False,
"CONF_NAME" : "CONFIG_NAGIOS_HOST", "CONDITION": False},
"USE_DEFAULT" : False, ]
"NEED_CONFIRM" : False, group = {"GROUP_NAME": "NAGIOS",
"CONDITION" : False }, "DESCRIPTION": "Nagios Config parameters",
{"CMD_OPTION" : "nagios-passwd", "PRE_CONDITION": "CONFIG_NAGIOS_INSTALL",
"USAGE" : "The password of the nagiosadmin user on the Nagios server", "PRE_CONDITION_MATCH": "y",
"PROMPT" : "Enter the password for the nagiosadmin user", "POST_CONDITION": False,
"OPTION_LIST" : [], "POST_CONDITION_MATCH": True}
"VALIDATORS" : [validators.validate_not_empty], controller.addGroup(group, params)
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NAGIOS_PW",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "NAGIOS",
"DESCRIPTION" : "Nagios Config parameters",
"PRE_CONDITION" : "CONFIG_NAGIOS_INSTALL",
"PRE_CONDITION_MATCH" : "y",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
conf = controller.CONF if controller.CONF['CONFIG_NAGIOS_INSTALL'] != 'y':
if conf['CONFIG_NAGIOS_INSTALL'] != 'y':
return return
nagiossteps = [ nagiossteps = [
{'title': 'Adding Nagios server manifest entries', 'functions':[createmanifest]}, {'title': 'Adding Nagios server manifest entries',
{'title': 'Adding Nagios host manifest entries', 'functions':[createnrpemanifests]} 'functions': [create_manifest]},
{'title': 'Adding Nagios host manifest entries',
'functions': [create_nrpe_manifests]}
] ]
controller.addSequence("Installing Nagios", [], [], nagiossteps) controller.addSequence("Installing Nagios", [], [], nagiossteps)
#------------------------- helper functions -------------------------
def _serviceentry(**kwargs): def _serviceentry(**kwargs):
s = 'define service {\n' s = 'define service {\n'
for key in sorted(kwargs.keys()): for key in sorted(kwargs.keys()):
@ -83,16 +68,18 @@ def _serviceentry(**kwargs):
s += "\t}\n" s += "\t}\n"
return s return s
def _copy_script(**kwargs): def _copy_script(**kwargs):
# TODO : Replace all these shell templates with with python # TODO : Replace all these shell templates with with python
return ('file{"/usr/lib64/nagios/plugins/%(name)s":' return ('file{"/usr/lib64/nagios/plugins/%(name)s":'
'mode => 755, owner => "nagios", ' 'mode => 755, owner => "nagios", '
'seltype => "nagios_unconfined_plugin_exec_t", ' 'seltype => "nagios_unconfined_plugin_exec_t", '
'content => template("packstack/%(name)s.erb"),}\n' 'content => template("packstack/%(name)s.erb"),}\n'
'nagios_command {"%(name)s": ' 'nagios_command {"%(name)s": '
'command_line => "/usr/lib64/nagios/plugins/%(name)s",}\n' 'command_line => "/usr/lib64/nagios/plugins/%(name)s",}\n'
% kwargs) % kwargs)
def nagios_host(hostname, **kwargs): def nagios_host(hostname, **kwargs):
out = ("nagios_host { '%s': " % hostname) out = ("nagios_host { '%s': " % hostname)
for key, value in kwargs.items(): for key, value in kwargs.items():
@ -100,81 +87,104 @@ def nagios_host(hostname, **kwargs):
return "%s}\n" % out return "%s}\n" % out
def createmanifest(config): #-------------------------- step functions --------------------------
def create_manifest(config, messages):
manifest_entries = '' manifest_entries = ''
# I should be adding service entries with nagios_service but it appears to be broken # I should be adding service entries with nagios_service
# http://projects.puppetlabs.com/issues/3420 # but it appears to be broken http://projects.puppetlabs.com/issues/3420
service_entries = '' service_entries = ''
for hostname in gethostlist(config): for hostname in filtered_hosts(config):
manifest_entries += nagios_host(hostname, address=hostname, use='linux-server') manifest_entries += nagios_host(hostname, address=hostname,
use='linux-server')
service_entries += _serviceentry(name='load5-%s'%hostname, service_description='5 minute load average', service_entries += _serviceentry(
host_name=hostname, check_command="check_nrpe!load5", use="generic-service", name='load5-%s' % hostname,
normal_check_interval='5') service_description='5 minute load average',
host_name=hostname,
check_command="check_nrpe!load5",
use="generic-service",
normal_check_interval='5'
)
service_entries += _serviceentry(name='df_var-%s'%hostname, service_entries += _serviceentry(
service_description='Percent disk space used on /var', name='df_var-%s' % hostname,
host_name=hostname, service_description='Percent disk space used on /var',
check_command="check_nrpe!df_var", use="generic-service") host_name=hostname,
check_command="check_nrpe!df_var",
use="generic-service"
)
manifest_entries += _copy_script(name="keystone-user-list") manifest_entries += _copy_script(name="keystone-user-list")
service_entries += _serviceentry(name='keystone-user-list', service_entries += _serviceentry(
name='keystone-user-list',
service_description='number of keystone users', service_description='number of keystone users',
host_name=controller.CONF['CONFIG_NAGIOS_HOST'], host_name=config['CONFIG_CONTROLLER_HOST'],
check_command="keystone-user-list", use="generic-service", check_command="keystone-user-list",
normal_check_interval='5') use="generic-service",
normal_check_interval='5'
)
if controller.CONF['CONFIG_GLANCE_INSTALL'] == 'y': if config['CONFIG_GLANCE_INSTALL'] == 'y':
manifest_entries += _copy_script(name="glance-index") manifest_entries += _copy_script(name="glance-index")
service_entries += _serviceentry(name='glance-index', service_entries += _serviceentry(
name='glance-index',
service_description='number of glance images', service_description='number of glance images',
host_name=controller.CONF['CONFIG_NAGIOS_HOST'], host_name=config['CONFIG_CONTROLLER_HOST'],
check_command="glance-index", use="generic-service", check_command="glance-index", use="generic-service",
normal_check_interval='5') normal_check_interval='5'
)
if controller.CONF['CONFIG_NOVA_INSTALL'] == 'y': if config['CONFIG_NOVA_INSTALL'] == 'y':
manifest_entries += _copy_script(name="nova-list") manifest_entries += _copy_script(name="nova-list")
service_entries += _serviceentry(name='nova-list', service_entries += _serviceentry(
name='nova-list',
service_description='number of nova vm instances', service_description='number of nova vm instances',
host_name=controller.CONF['CONFIG_NAGIOS_HOST'], host_name=config['CONFIG_CONTROLLER_HOST'],
check_command="nova-list", use="generic-service", check_command="nova-list", use="generic-service",
normal_check_interval='5') normal_check_interval='5'
)
if controller.CONF['CONFIG_CINDER_INSTALL'] == 'y': if config['CONFIG_CINDER_INSTALL'] == 'y':
manifest_entries += _copy_script(name="cinder-list") manifest_entries += _copy_script(name="cinder-list")
service_entries += _serviceentry(name='cinder-list', service_entries += _serviceentry(
name='cinder-list',
service_description='number of cinder volumes', service_description='number of cinder volumes',
host_name=controller.CONF['CONFIG_NAGIOS_HOST'], host_name=config['CONFIG_CONTROLLER_HOST'],
check_command="cinder-list", use="generic-service", check_command="cinder-list", use="generic-service",
normal_check_interval='5') normal_check_interval='5'
)
if controller.CONF['CONFIG_SWIFT_INSTALL'] == 'y': if config['CONFIG_SWIFT_INSTALL'] == 'y':
manifest_entries += _copy_script(name="swift-list") manifest_entries += _copy_script(name="swift-list")
service_entries += _serviceentry(name='swift-list', service_entries += _serviceentry(
name='swift-list',
service_description='number of swift containers', service_description='number of swift containers',
host_name=controller.CONF['CONFIG_NAGIOS_HOST'], host_name=config['CONFIG_CONTROLLER_HOST'],
check_command="swift-list", use="generic-service", check_command="swift-list", use="generic-service",
normal_check_interval='5') normal_check_interval='5'
)
manifest_entries += ("file { '/etc/nagios/nagios_service.cfg': \n" manifest_entries += ("file { '/etc/nagios/nagios_service.cfg': \n"
"ensure => present, mode => 644,\n" "ensure => present, mode => 644,\n"
"owner => 'nagios', group => 'nagios',\n" "owner => 'nagios', group => 'nagios',\n"
"before => Service['nagios'],\n" "before => Service['nagios'],\n"
"content => '%s'}" % service_entries) "content => '%s'}" % service_entries)
controller.CONF['CONFIG_NAGIOS_MANIFEST_CONFIG'] = manifest_entries config['CONFIG_NAGIOS_MANIFEST_CONFIG'] = manifest_entries
manifestfile = "%s_nagios.pp" % controller.CONF['CONFIG_NAGIOS_HOST'] manifestfile = "%s_nagios.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("nagios_server.pp") manifestdata = getManifestTemplate("nagios_server.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def createnrpemanifests(config):
for hostname in filtered_hosts(controller.CONF): def create_nrpe_manifests(config, messages):
controller.CONF['CONFIG_NRPE_HOST'] = hostname for hostname in filtered_hosts(config):
config['CONFIG_NRPE_HOST'] = hostname
manifestfile = "%s_nagios_nrpe.pp" % hostname manifestfile = "%s_nagios_nrpe.pp" % hostname
manifestdata = getManifestTemplate("nagios_nrpe.pp") manifestdata = getManifestTemplate("nagios_nrpe.pp")
#Only the Nagios host is allowed to talk to nrpe # Only the Nagios host is allowed to talk to nrpe
config['FIREWALL_ALLOWED'] = "'%s'" % config['CONFIG_NAGIOS_HOST'] config['FIREWALL_ALLOWED'] = "'%s'" % config['CONFIG_CONTROLLER_HOST']
config['FIREWALL_SERVICE_NAME'] = "nagios-nrpe" config['FIREWALL_SERVICE_NAME'] = "nagios-nrpe"
config['FIREWALL_SERVICE_ID'] = "nagios_nrpe" config['FIREWALL_SERVICE_ID'] = "nagios_nrpe"
config['FIREWALL_PORTS'] = '5666' config['FIREWALL_PORTS'] = '5666'
@ -182,7 +192,7 @@ def createnrpemanifests(config):
manifestdata += getManifestTemplate("firewall.pp") manifestdata += getManifestTemplate("firewall.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
controller.MESSAGES.append("To use Nagios, browse to http://%s/nagios " messages.append("To use Nagios, browse to "
"username : nagiosadmin, password : %s" % "http://%(CONFIG_CONTROLLER_HOST)s/nagios "
(controller.CONF['CONFIG_NAGIOS_HOST'], "username: nagiosadmin, password: %(CONFIG_NAGIOS_PW)s"
controller.CONF['CONFIG_NAGIOS_PW'])) % config)

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures nova Installs and configures nova
""" """
@ -12,19 +14,17 @@ from packstack.installer import basedefs, processors, utils, validators
from packstack.installer.exceptions import ScriptRuntimeError from packstack.installer.exceptions import ScriptRuntimeError
from packstack.modules.shortcuts import get_mq from packstack.modules.shortcuts import get_mq
from packstack.modules.ospluginutils import NovaConfig, getManifestTemplate, appendManifestFile, manifestfiles from packstack.modules.ospluginutils import (NovaConfig, getManifestTemplate,
appendManifestFile, manifestfiles)
# Controller object will be initialized from main flow
controller = None
PLUGIN_NAME = "OS-NOVA" #------------------ oVirt installer initialization ------------------
logging.debug("plugin %s loaded", __name__) PLUGIN_NAME = "OS-Nova"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
def initConfig(controllerObject):
global controller
controller = controllerObject
def initConfig(controller):
if platform.linux_distribution()[0] == "Fedora": if platform.linux_distribution()[0] == "Fedora":
primary_netif = "em1" primary_netif = "em1"
secondary_netif = "em2" secondary_netif = "em2"
@ -33,387 +33,300 @@ def initConfig(controllerObject):
secondary_netif = "eth1" secondary_netif = "eth1"
nova_params = { nova_params = {
"NOVA" : [ "NOVA": [
{"CMD_OPTION" : "novaapi-host", {"CMD_OPTION": "nova-db-passwd",
"USAGE" : "The IP address of the server on which to install the Nova API service", "USAGE": "The password to use for the Nova to access DB",
"PROMPT" : "Enter the IP address of the Nova API service", "PROMPT": "Enter the password for the Nova DB access",
"OPTION_LIST" : [], "OPTION_LIST": [],
"VALIDATORS" : [validators.validate_ip, validators.validate_ssh], "VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE" : utils.get_localhost_ip(), "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT" : False, "MASK_INPUT": True,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NOVA_API_HOST", "CONF_NAME": "CONFIG_NOVA_DB_PW",
"USE_DEFAULT" : False, "USE_DEFAULT": True,
"NEED_CONFIRM" : False, "NEED_CONFIRM": True,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "novacert-host",
"USAGE" : "The IP address of the server on which to install the Nova Cert service", {"CMD_OPTION": "nova-ks-passwd",
"PROMPT" : "Enter the IP address of the Nova Cert service", "USAGE": ("The password to use for the Nova to authenticate "
"OPTION_LIST" : [], "with Keystone"),
"VALIDATORS" : [validators.validate_ssh], "PROMPT": "Enter the password for the Nova Keystone access",
"DEFAULT_VALUE" : utils.get_localhost_ip(), "OPTION_LIST": [],
"MASK_INPUT" : False, "VALIDATORS": [validators.validate_not_empty],
"LOOSE_VALIDATION": True, "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"CONF_NAME" : "CONFIG_NOVA_CERT_HOST", "MASK_INPUT": True,
"USE_DEFAULT" : False, "LOOSE_VALIDATION": False,
"NEED_CONFIRM" : False, "CONF_NAME": "CONFIG_NOVA_KS_PW",
"CONDITION" : False }, "USE_DEFAULT": True,
{"CMD_OPTION" : "novavncproxy-hosts", "NEED_CONFIRM": True,
"USAGE" : "The IP address of the server on which to install the Nova VNC proxy", "CONDITION": False},
"PROMPT" : "Enter the IP address of the Nova VNC proxy",
"OPTION_LIST" : [], {"CMD_OPTION": "novasched-cpu-allocation-ratio",
"VALIDATORS" : [validators.validate_ssh], "USAGE": ("The overcommitment ratio for virtual to physical CPUs."
"DEFAULT_VALUE" : utils.get_localhost_ip(), " Set to 1.0 to disable CPU overcommitment"),
"MASK_INPUT" : False, "PROMPT": "Enter the CPU overcommitment ratio. Set to 1.0 to "
"LOOSE_VALIDATION": True, "disable CPU overcommitment",
"CONF_NAME" : "CONFIG_NOVA_VNCPROXY_HOST", "OPTION_LIST": [],
"USE_DEFAULT" : False, "VALIDATORS": [validators.validate_float],
"NEED_CONFIRM" : False, "DEFAULT_VALUE": 16.0,
"CONDITION" : False }, "MASK_INPUT": False,
{"CMD_OPTION" : "novacompute-hosts", "LOOSE_VALIDATION": True,
"USAGE" : "A comma separated list of IP addresses on which to install the Nova Compute services", "CONF_NAME": "CONFIG_NOVA_SCHED_CPU_ALLOC_RATIO",
"PROMPT" : "Enter a comma separated list of IP addresses on which to install the Nova Compute services", "USE_DEFAULT": False,
"OPTION_LIST" : [], "NEED_CONFIRM": False,
"VALIDATORS" : [validators.validate_not_empty, validators.validate_multi_ssh], "CONDITION": False},
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False, {"CMD_OPTION": "novasched-ram-allocation-ratio",
"LOOSE_VALIDATION": True, "USAGE": ("The overcommitment ratio for virtual to physical RAM. "
"CONF_NAME" : "CONFIG_NOVA_COMPUTE_HOSTS", "Set to 1.0 to disable RAM overcommitment"),
"USE_DEFAULT" : False, "PROMPT": ("Enter the RAM overcommitment ratio. Set to 1.0 to "
"NEED_CONFIRM" : False, "disable RAM overcommitment"),
"CONDITION" : False }, "OPTION_LIST": [],
{"CMD_OPTION" : "novaconductor-host", "VALIDATORS": [validators.validate_float],
"USAGE" : "The IP address of the server on which to install the Nova Conductor service", "DEFAULT_VALUE": 1.5,
"PROMPT" : "Enter the IP address of the Nova Conductor service", "MASK_INPUT": False,
"OPTION_LIST" : [], "LOOSE_VALIDATION": True,
"VALIDATORS" : [validators.validate_ip, validators.validate_ssh], "CONF_NAME": "CONFIG_NOVA_SCHED_RAM_ALLOC_RATIO",
"DEFAULT_VALUE" : utils.get_localhost_ip(), "USE_DEFAULT": False,
"MASK_INPUT" : False, "NEED_CONFIRM": False,
"LOOSE_VALIDATION": True, "CONDITION": False},
"CONF_NAME" : "CONFIG_NOVA_CONDUCTOR_HOST", ],
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False, "NOVA_NETWORK": [
"CONDITION" : False }, {"CMD_OPTION": "novacompute-privif",
{"CMD_OPTION" : "nova-db-passwd", "USAGE": ("Private interface for Flat DHCP on the Nova compute "
"USAGE" : "The password to use for the Nova to access DB", "servers"),
"PROMPT" : "Enter the password for the Nova DB access", "PROMPT": ("Enter the Private interface for Flat DHCP on the Nova"
"OPTION_LIST" : [], " compute servers"),
"VALIDATORS" : [validators.validate_not_empty], "OPTION_LIST": [],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16], "VALIDATORS": [validators.validate_not_empty],
"MASK_INPUT" : True, "DEFAULT_VALUE": secondary_netif,
"LOOSE_VALIDATION": False, "MASK_INPUT": False,
"CONF_NAME" : "CONFIG_NOVA_DB_PW", "LOOSE_VALIDATION": True,
"USE_DEFAULT" : True, "CONF_NAME": "CONFIG_NOVA_COMPUTE_PRIVIF",
"NEED_CONFIRM" : True, "USE_DEFAULT": False,
"CONDITION" : False }, "NEED_CONFIRM": False,
{"CMD_OPTION" : "nova-ks-passwd", "CONDITION": False},
"USAGE" : "The password to use for the Nova to authenticate with Keystone",
"PROMPT" : "Enter the password for the Nova Keystone access", {"CMD_OPTION": "novanetwork-manager",
"OPTION_LIST" : [], "USAGE": "Nova network manager",
"VALIDATORS" : [validators.validate_not_empty], "PROMPT": "Enter the Nova network manager",
"DEFAULT_VALUE" : uuid.uuid4().hex[:16], "OPTION_LIST": [r'^nova\.network\.manager\.\w+Manager$'],
"MASK_INPUT" : True, "VALIDATORS": [validators.validate_regexp],
"LOOSE_VALIDATION": False, "DEFAULT_VALUE": "nova.network.manager.FlatDHCPManager",
"CONF_NAME" : "CONFIG_NOVA_KS_PW", "MASK_INPUT": False,
"USE_DEFAULT" : True, "LOOSE_VALIDATION": True,
"NEED_CONFIRM" : True, "CONF_NAME": "CONFIG_NOVA_NETWORK_MANAGER",
"CONDITION" : False }, "USE_DEFAULT": False,
{"CMD_OPTION" : "novasched-host", "NEED_CONFIRM": False,
"USAGE" : "The IP address of the server on which to install the Nova Scheduler service", "CONDITION": False},
"PROMPT" : "Enter the IP address of the Nova Scheduler service",
"OPTION_LIST" : [], {"CMD_OPTION": "novanetwork-pubif",
"VALIDATORS" : [validators.validate_ssh], "USAGE": "Public interface on the Nova network server",
"DEFAULT_VALUE" : utils.get_localhost_ip(), "PROMPT": "Enter the Public interface on the Nova network server",
"MASK_INPUT" : False, "OPTION_LIST": [],
"LOOSE_VALIDATION": True, "VALIDATORS": [validators.validate_not_empty],
"CONF_NAME" : "CONFIG_NOVA_SCHED_HOST", "DEFAULT_VALUE": primary_netif,
"USE_DEFAULT" : False, "MASK_INPUT": False,
"NEED_CONFIRM" : False, "LOOSE_VALIDATION": True,
"CONDITION" : False }, "CONF_NAME": "CONFIG_NOVA_NETWORK_PUBIF",
{"CMD_OPTION" : "novasched-cpu-allocation-ratio", "USE_DEFAULT": False,
"USAGE" : "The overcommitment ratio for virtual to physical CPUs. " "NEED_CONFIRM": False,
"Set to 1.0 to disable CPU overcommitment", "CONDITION": False},
"PROMPT" : "Enter the CPU overcommitment ratio. "
"Set to 1.0 to disable CPU overcommitment", {"CMD_OPTION": "novanetwork-privif",
"OPTION_LIST" : [], "USAGE": ("Private interface for network manager on the Nova "
"VALIDATORS" : [validators.validate_float], "network server"),
"DEFAULT_VALUE" : 16.0, "PROMPT": ("Enter the Private interface for network manager on "
"MASK_INPUT" : False, "the Nova network server"),
"LOOSE_VALIDATION": True, "OPTION_LIST": [],
"CONF_NAME" : "CONFIG_NOVA_SCHED_CPU_ALLOC_RATIO", "VALIDATORS": [validators.validate_not_empty],
"USE_DEFAULT" : False, "DEFAULT_VALUE": secondary_netif,
"NEED_CONFIRM" : False, "MASK_INPUT": False,
"CONDITION" : False }, "LOOSE_VALIDATION": True,
{"CMD_OPTION" : "novasched-ram-allocation-ratio", "CONF_NAME": "CONFIG_NOVA_NETWORK_PRIVIF",
"USAGE" : "The overcommitment ratio for virtual to physical RAM. " "USE_DEFAULT": False,
"Set to 1.0 to disable RAM overcommitment", "NEED_CONFIRM": False,
"PROMPT" : "Enter the RAM overcommitment ratio. " "CONDITION": False},
"Set to 1.0 to disable RAM overcommitment",
"OPTION_LIST" : [], {"CMD_OPTION": "novanetwork-fixed-range",
"VALIDATORS" : [validators.validate_float], "USAGE": "IP Range for network manager",
"DEFAULT_VALUE" : 1.5, "PROMPT": "Enter the IP Range for network manager",
"MASK_INPUT" : False, "OPTION_LIST": ["^[\:\.\da-fA-f]+(\/\d+){0,1}$"],
"LOOSE_VALIDATION": True, "PROCESSORS": [processors.process_cidr],
"CONF_NAME" : "CONFIG_NOVA_SCHED_RAM_ALLOC_RATIO", "VALIDATORS": [validators.validate_regexp],
"USE_DEFAULT" : False, "DEFAULT_VALUE": "192.168.32.0/22",
"NEED_CONFIRM" : False, "MASK_INPUT": False,
"CONDITION" : False }, "LOOSE_VALIDATION": True,
], "CONF_NAME": "CONFIG_NOVA_NETWORK_FIXEDRANGE",
"NOVA_NETWORK" : [ "USE_DEFAULT": False,
{"CMD_OPTION" : "novacompute-privif", "NEED_CONFIRM": False,
"USAGE" : "Private interface for Flat DHCP on the Nova compute servers", "CONDITION": False},
"PROMPT" : "Enter the Private interface for Flat DHCP on the Nova compute servers",
"OPTION_LIST" : [], {"CMD_OPTION": "novanetwork-floating-range",
"VALIDATORS" : [validators.validate_not_empty], "USAGE": "IP Range for Floating IP's",
"DEFAULT_VALUE" : secondary_netif, "PROMPT": "Enter the IP Range for Floating IP's",
"MASK_INPUT" : False, "OPTION_LIST": ["^[\:\.\da-fA-f]+(\/\d+){0,1}$"],
"LOOSE_VALIDATION": True, "PROCESSORS": [processors.process_cidr],
"CONF_NAME" : "CONFIG_NOVA_COMPUTE_PRIVIF", "VALIDATORS": [validators.validate_regexp],
"USE_DEFAULT" : False, "DEFAULT_VALUE": "10.3.4.0/22",
"NEED_CONFIRM" : False, "MASK_INPUT": False,
"CONDITION" : False }, "LOOSE_VALIDATION": True,
{"CMD_OPTION" : "novanetwork-hosts", "CONF_NAME": "CONFIG_NOVA_NETWORK_FLOATRANGE",
"USAGE" : "The list of IP addresses of the server on which to install the Nova Network service", "USE_DEFAULT": False,
"PROMPT" : "Enter list of IP addresses on which to install the Nova Network service", "NEED_CONFIRM": False,
"OPTION_LIST" : [], "CONDITION": False},
"VALIDATORS" : [validators.validate_multi_ip, validators.validate_multi_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(), {"CMD_OPTION": "novanetwork-default-floating-pool",
"MASK_INPUT" : False, "USAGE": ("Name of the default floating pool to which the "
"LOOSE_VALIDATION": True, "specified floating ranges are added to"),
"CONF_NAME" : "CONFIG_NOVA_NETWORK_HOSTS", "PROMPT": "What should the default floating pool be called?",
"USE_DEFAULT" : False, "OPTION_LIST": [],
"NEED_CONFIRM" : False, "VALIDATORS": [validators.validate_not_empty],
"CONDITION" : False }, "DEFAULT_VALUE": "nova",
{"CMD_OPTION" : "novanetwork-manager", "MASK_INPUT": False,
"USAGE" : "Nova network manager", "LOOSE_VALIDATION": False,
"PROMPT" : "Enter the Nova network manager", "CONF_NAME": "CONFIG_NOVA_NETWORK_DEFAULTFLOATINGPOOL",
"OPTION_LIST" : [r'^nova\.network\.manager\.\w+Manager$'], "USE_DEFAULT": False,
"VALIDATORS" : [validators.validate_regexp], "NEED_CONFIRM": False,
"DEFAULT_VALUE" : "nova.network.manager.FlatDHCPManager", "CONDITION": False},
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True, {"CMD_OPTION": "novanetwork-auto-assign-floating-ip",
"CONF_NAME" : "CONFIG_NOVA_NETWORK_MANAGER", "USAGE": "Automatically assign a floating IP to new instances",
"USE_DEFAULT" : False, "PROMPT": ("Should new instances automatically have a floating "
"NEED_CONFIRM" : False, "IP assigned?"),
"CONDITION" : False }, "OPTION_LIST": ["y", "n"],
{"CMD_OPTION" : "novanetwork-pubif", "VALIDATORS": [validators.validate_options],
"USAGE" : "Public interface on the Nova network server", "DEFAULT_VALUE": "n",
"PROMPT" : "Enter the Public interface on the Nova network server", "MASK_INPUT": False,
"OPTION_LIST" : [], "LOOSE_VALIDATION": False,
"VALIDATORS" : [validators.validate_not_empty], "CONF_NAME": "CONFIG_NOVA_NETWORK_AUTOASSIGNFLOATINGIP",
"DEFAULT_VALUE" : primary_netif, "USE_DEFAULT": False,
"MASK_INPUT" : False, "NEED_CONFIRM": False,
"LOOSE_VALIDATION": True, "CONDITION": False},
"CONF_NAME" : "CONFIG_NOVA_NETWORK_PUBIF", ],
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False, "NOVA_NETWORK_VLAN": [
"CONDITION" : False }, {"CMD_OPTION": "novanetwork-vlan-start",
{"CMD_OPTION" : "novanetwork-privif", "USAGE": "First VLAN for private networks",
"USAGE" : "Private interface for network manager on the Nova network server", "PROMPT": "Enter first VLAN for private networks",
"PROMPT" : "Enter the Private interface for network manager on the Nova network server", "OPTION_LIST": [],
"OPTION_LIST" : [], "VALIDATORS": [validators.validate_not_empty],
"VALIDATORS" : [validators.validate_not_empty], "DEFAULT_VALUE": 100,
"DEFAULT_VALUE" : secondary_netif, "MASK_INPUT": False,
"MASK_INPUT" : False, "LOOSE_VALIDATION": True,
"LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_VLAN_START",
"CONF_NAME" : "CONFIG_NOVA_NETWORK_PRIVIF", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False },
{"CMD_OPTION" : "novanetwork-fixed-range", {"CMD_OPTION": "novanetwork-num-networks",
"USAGE" : "IP Range for network manager", "USAGE": "Number of networks to support",
"PROMPT" : "Enter the IP Range for network manager", "PROMPT": "How many networks should be supported",
"OPTION_LIST" : ["^[\:\.\da-fA-f]+(\/\d+){0,1}$"], "OPTION_LIST": [],
"PROCESSORS" : [processors.process_cidr], "VALIDATORS": [validators.validate_not_empty],
"VALIDATORS" : [validators.validate_regexp], "DEFAULT_VALUE": 1,
"DEFAULT_VALUE" : "192.168.32.0/22", "MASK_INPUT": False,
"MASK_INPUT" : False, "LOOSE_VALIDATION": True,
"LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_NUMBER",
"CONF_NAME" : "CONFIG_NOVA_NETWORK_FIXEDRANGE", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False },
{"CMD_OPTION" : "novanetwork-floating-range", {"CMD_OPTION": "novanetwork-network-size",
"USAGE" : "IP Range for Floating IP's", "USAGE": "Number of addresses in each private subnet",
"PROMPT" : "Enter the IP Range for Floating IP's", "PROMPT": "How many addresses should be in each private subnet",
"OPTION_LIST" : ["^[\:\.\da-fA-f]+(\/\d+){0,1}$"], "OPTION_LIST": [],
"PROCESSORS" : [processors.process_cidr], "VALIDATORS": [validators.validate_not_empty],
"VALIDATORS" : [validators.validate_regexp], "DEFAULT_VALUE": 255,
"DEFAULT_VALUE" : "10.3.4.0/22", "MASK_INPUT": False,
"MASK_INPUT" : False, "LOOSE_VALIDATION": True,
"LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_NOVA_NETWORK_SIZE",
"CONF_NAME" : "CONFIG_NOVA_NETWORK_FLOATRANGE", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False }, ],
{"CMD_OPTION" : "novanetwork-default-floating-pool", }
"USAGE" : "Name of the default floating pool to which the specified floating ranges are added to",
"PROMPT" : "What should the default floating pool be called?",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "nova",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NOVA_NETWORK_DEFAULTFLOATINGPOOL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "novanetwork-auto-assign-floating-ip",
"USAGE" : "Automatically assign a floating IP to new instances",
"PROMPT" : "Should new instances automatically have a floating IP assigned?",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NOVA_NETWORK_AUTOASSIGNFLOATINGIP",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"NOVA_NETWORK_VLAN" : [
{"CMD_OPTION" : "novanetwork-vlan-start",
"USAGE" : "First VLAN for private networks",
"PROMPT" : "Enter first VLAN for private networks",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : 100,
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NOVA_NETWORK_VLAN_START",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "novanetwork-num-networks",
"USAGE" : "Number of networks to support",
"PROMPT" : "How many networks should be supported",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : 1,
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NOVA_NETWORK_NUMBER",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "novanetwork-network-size",
"USAGE" : "Number of addresses in each private subnet",
"PROMPT" : "How many addresses should be in each private subnet",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : 255,
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_NOVA_NETWORK_SIZE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
}
def use_nova_network(config): def use_nova_network(config):
return config['CONFIG_NOVA_INSTALL'] == 'y' and \ return (config['CONFIG_NOVA_INSTALL'] == 'y' and
config['CONFIG_NEUTRON_INSTALL'] != 'y' config['CONFIG_NEUTRON_INSTALL'] != 'y')
def use_nova_network_vlan(config): def use_nova_network_vlan(config):
manager = 'nova.network.manager.VlanManager' manager = 'nova.network.manager.VlanManager'
return config['CONFIG_NOVA_INSTALL'] == 'y' and \ return (config['CONFIG_NOVA_INSTALL'] == 'y' and
config['CONFIG_NEUTRON_INSTALL'] != 'y' and \ config['CONFIG_NEUTRON_INSTALL'] != 'y' and
config['CONFIG_NOVA_NETWORK_MANAGER'] == manager config['CONFIG_NOVA_NETWORK_MANAGER'] == manager)
nova_groups = [ nova_groups = [
{"GROUP_NAME" : "NOVA", {"GROUP_NAME": "NOVA",
"DESCRIPTION" : "Nova Options", "DESCRIPTION": "Nova Options",
"PRE_CONDITION" : "CONFIG_NOVA_INSTALL", "PRE_CONDITION": "CONFIG_NOVA_INSTALL",
"PRE_CONDITION_MATCH" : "y", "PRE_CONDITION_MATCH": "y",
"POST_CONDITION" : False, "POST_CONDITION": False,
"POST_CONDITION_MATCH" : True}, "POST_CONDITION_MATCH": True},
{"GROUP_NAME" : "NOVA_NETWORK",
"DESCRIPTION" : "Nova Network Options",
"PRE_CONDITION" : use_nova_network,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True},
{"GROUP_NAME" : "NOVA_NETWORK_VLAN",
"DESCRIPTION" : "Nova Network VLAN Options",
"PRE_CONDITION" : use_nova_network_vlan,
"PRE_CONDITION_MATCH" : True,
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True},
]
{"GROUP_NAME": "NOVA_NETWORK",
"DESCRIPTION": "Nova Network Options",
"PRE_CONDITION": use_nova_network,
"PRE_CONDITION_MATCH": True,
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True},
{"GROUP_NAME": "NOVA_NETWORK_VLAN",
"DESCRIPTION": "Nova Network VLAN Options",
"PRE_CONDITION": use_nova_network_vlan,
"PRE_CONDITION_MATCH": True,
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True},
]
for group in nova_groups: for group in nova_groups:
paramList = nova_params[group["GROUP_NAME"]] params = nova_params[group["GROUP_NAME"]]
controller.addGroup(group, paramList) controller.addGroup(group, params)
def initSequences(controller): def initSequences(controller):
if controller.CONF['CONFIG_NOVA_INSTALL'] != 'y': if controller.CONF['CONFIG_NOVA_INSTALL'] != 'y':
return return
novaapisteps = [ novaapisteps = [
{'title': 'Adding Nova API manifest entries', 'functions':[createapimanifest]}, {'title': 'Adding Nova API manifest entries',
{'title': 'Adding Nova Keystone manifest entries', 'functions':[createkeystonemanifest]}, 'functions': [create_api_manifest]},
{'title': 'Adding Nova Cert manifest entries', 'functions':[createcertmanifest]}, {'title': 'Adding Nova Keystone manifest entries',
{'title': 'Adding Nova Conductor manifest entries', 'functions':[createconductormanifest]}, 'functions': [create_keystone_manifest]},
{'title': 'Creating ssh keys for Nova migration', {'title': 'Adding Nova Cert manifest entries',
'functions':[create_ssh_keys]}, 'functions': [create_cert_manifest]},
{'title': 'Gathering ssh host keys for Nova migration', {'title': 'Adding Nova Conductor manifest entries',
'functions':[gather_host_keys]}, 'functions': [create_conductor_manifest]},
{'title': 'Adding Nova Compute manifest entries', 'functions':[createcomputemanifest]}, {'title': 'Creating ssh keys for Nova migration',
{'title': 'Adding Nova Scheduler manifest entries', 'functions':[createschedmanifest]}, 'functions': [create_ssh_keys]},
{'title': 'Adding Nova VNC Proxy manifest entries', 'functions':[createvncproxymanifest]}, {'title': 'Gathering ssh host keys for Nova migration',
{'title': 'Adding Nova Common manifest entries', 'functions':[createcommonmanifest]}, 'functions': [gather_host_keys]},
{'title': 'Adding Nova Compute manifest entries',
'functions': [create_compute_manifest]},
{'title': 'Adding Nova Scheduler manifest entries',
'functions': [create_sched_manifest]},
{'title': 'Adding Nova VNC Proxy manifest entries',
'functions': [create_vncproxy_manifest]},
{'title': 'Adding Nova Common manifest entries',
'functions': [create_common_manifest]},
] ]
if controller.CONF['CONFIG_NEUTRON_INSTALL'] == 'y': if controller.CONF['CONFIG_NEUTRON_INSTALL'] == 'y':
novaapisteps.append({'title': 'Adding Openstack Network-related Nova manifest entries', 'functions':[createneutronmanifest]}) novaapisteps.append(
{'title': 'Adding Openstack Network-related Nova manifest entries',
'functions': [create_neutron_manifest]}
)
else: else:
novaapisteps.append({'title': 'Adding Nova Network manifest entries', 'functions':[createnetworkmanifest]}) novaapisteps.append(
{'title': 'Adding Nova Network manifest entries',
controller.addSequence("Installing OpenStack Nova API", [], [], novaapisteps) 'functions': [create_network_manifest]}
)
controller.addSequence("Installing OpenStack Nova API", [], [],
novaapisteps)
def createapimanifest(config): #------------------------- helper functions -------------------------
# Since this step is running first, let's create necesary variables here
# and make them global
global compute_hosts, network_hosts
com_var = config.get("CONFIG_NOVA_COMPUTE_HOSTS", "")
compute_hosts = set([i.strip() for i in com_var.split(",") if i.strip()])
net_var = config.get("CONFIG_NOVA_NETWORK_HOSTS", "")
network_hosts = set([i.strip() for i in net_var.split(",") if i.strip()])
# This is a hack around us needing to generate the neutron metadata
# password, but the nova puppet plugin uses the existence of that
# password to determine whether or not to configure neutron metadata
# proxy support. So the nova_api.pp template needs unquoted 'undef'
# to disable metadata support if neutron is not being installed.
if controller.CONF['CONFIG_NEUTRON_INSTALL'] != 'y':
controller.CONF['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = 'undef'
else:
controller.CONF['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = \
"'%s'" % controller.CONF['CONFIG_NEUTRON_METADATA_PW']
manifestfile = "%s_api_nova.pp"%controller.CONF['CONFIG_NOVA_API_HOST']
manifestdata = getManifestTemplate("nova_api.pp")
appendManifestFile(manifestfile, manifestdata, 'novaapi')
def createkeystonemanifest(config):
manifestfile = "%s_keystone.pp"%controller.CONF['CONFIG_KEYSTONE_HOST']
manifestdata = getManifestTemplate("keystone_nova.pp")
appendManifestFile(manifestfile, manifestdata)
def createcertmanifest(config):
manifestfile = "%s_nova.pp"%controller.CONF['CONFIG_NOVA_CERT_HOST']
manifestdata = getManifestTemplate("nova_cert.pp")
appendManifestFile(manifestfile, manifestdata)
def createconductormanifest(config):
manifestfile = "%s_nova.pp"%controller.CONF['CONFIG_NOVA_CONDUCTOR_HOST']
manifestdata = getManifestTemplate("nova_conductor.pp")
appendManifestFile(manifestfile, manifestdata)
def check_ifcfg(host, device): def check_ifcfg(host, device):
""" """
@ -447,7 +360,9 @@ def bring_up_ifcfg(host, device):
raise ScriptRuntimeError(msg) raise ScriptRuntimeError(msg)
def create_ssh_keys(config): #-------------------------- step functions --------------------------
def create_ssh_keys(config, messages):
migration_key = os.path.join(basedefs.VAR_DIR, 'nova_migration_key') migration_key = os.path.join(basedefs.VAR_DIR, 'nova_migration_key')
# Generate key # Generate key
local = utils.ScriptRunner() local = utils.ScriptRunner()
@ -463,7 +378,8 @@ def create_ssh_keys(config):
config['NOVA_MIGRATION_KEY_PUBLIC'] = public.split()[1] config['NOVA_MIGRATION_KEY_PUBLIC'] = public.split()[1]
config['NOVA_MIGRATION_KEY_SECRET'] = secret config['NOVA_MIGRATION_KEY_SECRET'] = secret
def gather_host_keys(config):
def gather_host_keys(config, messages):
global compute_hosts global compute_hosts
for host in compute_hosts: for host in compute_hosts:
@ -472,7 +388,50 @@ def gather_host_keys(config):
retcode, hostkey = local.execute() retcode, hostkey = local.execute()
config['HOST_KEYS_%s' % host] = hostkey config['HOST_KEYS_%s' % host] = hostkey
def createcomputemanifest(config):
def create_api_manifest(config, messages):
# Since this step is running first, let's create necesary variables here
# and make them global
global compute_hosts, network_hosts
com_var = config.get("CONFIG_COMPUTE_HOSTS", "")
compute_hosts = set([i.strip() for i in com_var.split(",") if i.strip()])
net_var = config.get("CONFIG_NETWORK_HOSTS", "")
network_hosts = set([i.strip() for i in net_var.split(",") if i.strip()])
# This is a hack around us needing to generate the neutron metadata
# password, but the nova puppet plugin uses the existence of that
# password to determine whether or not to configure neutron metadata
# proxy support. So the nova_api.pp template needs unquoted 'undef'
# to disable metadata support if neutron is not being installed.
if config['CONFIG_NEUTRON_INSTALL'] != 'y':
config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = 'undef'
else:
config['CONFIG_NEUTRON_METADATA_PW_UNQUOTED'] = \
"'%s'" % config['CONFIG_NEUTRON_METADATA_PW']
manifestfile = "%s_api_nova.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("nova_api.pp")
appendManifestFile(manifestfile, manifestdata, 'novaapi')
def create_keystone_manifest(config, messages):
manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("keystone_nova.pp")
appendManifestFile(manifestfile, manifestdata)
def create_cert_manifest(config, messages):
manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("nova_cert.pp")
appendManifestFile(manifestfile, manifestdata)
def create_conductor_manifest(config, messages):
manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("nova_conductor.pp")
appendManifestFile(manifestfile, manifestdata)
def create_compute_manifest(config, messages):
global compute_hosts, network_hosts global compute_hosts, network_hosts
ssh_hostkeys = '' ssh_hostkeys = ''
@ -482,15 +441,16 @@ def createcomputemanifest(config):
except socket.herror: except socket.herror:
host_name, host_aliases, host_addrs = (host, [], []) host_name, host_aliases, host_addrs = (host, [], [])
for hostkey in config['HOST_KEYS_%s' %host].split('\n'): for hostkey in config['HOST_KEYS_%s' % host].split('\n'):
hostkey = hostkey.strip() hostkey = hostkey.strip()
if not hostkey: if not hostkey:
continue continue
_, host_key_type, host_key_data = hostkey.split() _, host_key_type, host_key_data = hostkey.split()
config['SSH_HOST_NAME'] = host_name config['SSH_HOST_NAME'] = host_name
config['SSH_HOST_ALIASES'] = ','.join('"%s"' % addr config['SSH_HOST_ALIASES'] = ','.join(
for addr in host_aliases + host_addrs) '"%s"' % addr for addr in host_aliases + host_addrs
)
config['SSH_HOST_KEY'] = host_key_data config['SSH_HOST_KEY'] = host_key_data
config['SSH_HOST_KEY_TYPE'] = host_key_type config['SSH_HOST_KEY_TYPE'] = host_key_type
ssh_hostkeys += getManifestTemplate("sshkey.pp") ssh_hostkeys += getManifestTemplate("sshkey.pp")
@ -503,35 +463,35 @@ def createcomputemanifest(config):
else: else:
manifestdata += getManifestTemplate("nova_compute_libvirt.pp") manifestdata += getManifestTemplate("nova_compute_libvirt.pp")
if (config['CONFIG_VMWARE_BACKEND'] != 'y' and if (config['CONFIG_VMWARE_BACKEND'] != 'y' and
config['CONFIG_CINDER_INSTALL'] == 'y' and config['CONFIG_CINDER_INSTALL'] == 'y' and
config['CONFIG_CINDER_BACKEND'] == 'gluster'): config['CONFIG_CINDER_BACKEND'] == 'gluster'):
manifestdata += getManifestTemplate("nova_gluster.pp") manifestdata += getManifestTemplate("nova_gluster.pp")
if (config['CONFIG_VMWARE_BACKEND'] != 'y' and if (config['CONFIG_VMWARE_BACKEND'] != 'y' and
config['CONFIG_CINDER_INSTALL'] == 'y' and config['CONFIG_CINDER_INSTALL'] == 'y' and
config['CONFIG_CINDER_BACKEND'] == 'nfs'): config['CONFIG_CINDER_BACKEND'] == 'nfs'):
manifestdata += getManifestTemplate("nova_nfs.pp") manifestdata += getManifestTemplate("nova_nfs.pp")
manifestfile = "%s_nova.pp" % host manifestfile = "%s_nova.pp" % host
nova_config_options = NovaConfig() nova_config_options = NovaConfig()
if config['CONFIG_NEUTRON_INSTALL'] != 'y': if config['CONFIG_NEUTRON_INSTALL'] != 'y':
if host not in network_hosts: if host not in network_hosts:
nova_config_options.addOption("DEFAULT/flat_interface", nova_config_options.addOption(
config['CONFIG_NOVA_COMPUTE_PRIVIF']) "DEFAULT/flat_interface",
config['CONFIG_NOVA_COMPUTE_PRIVIF']
)
check_ifcfg(host, config['CONFIG_NOVA_COMPUTE_PRIVIF']) check_ifcfg(host, config['CONFIG_NOVA_COMPUTE_PRIVIF'])
try: try:
bring_up_ifcfg(host, config['CONFIG_NOVA_COMPUTE_PRIVIF']) bring_up_ifcfg(host, config['CONFIG_NOVA_COMPUTE_PRIVIF'])
except ScriptRuntimeError as ex: except ScriptRuntimeError as ex:
# just warn user to do it by himself # just warn user to do it by himself
controller.MESSAGES.append(str(ex)) messages.append(str(ex))
if config['CONFIG_CEILOMETER_INSTALL'] == 'y': if config['CONFIG_CEILOMETER_INSTALL'] == 'y':
manifestdata += getManifestTemplate(get_mq(config, "nova_ceilometer")) mq_template = get_mq(config, "nova_ceilometer")
manifestdata += getManifestTemplate(mq_template)
manifestdata += getManifestTemplate("nova_ceilometer.pp") manifestdata += getManifestTemplate("nova_ceilometer.pp")
# According to the docs the only element that connects directly to nova compute config['FIREWALL_ALLOWED'] = "'%s'" % config['CONFIG_CONTROLLER_HOST']
# is nova scheduler
# http://docs.openstack.org/developer/nova/nova.concepts.html#concept-system-architecture
config['FIREWALL_ALLOWED'] = "'%s'" % (config['CONFIG_NOVA_SCHED_HOST'].strip())
config['FIREWALL_SERVICE_NAME'] = "nova compute" config['FIREWALL_SERVICE_NAME'] = "nova compute"
config['FIREWALL_SERVICE_ID'] = "nova_compute" config['FIREWALL_SERVICE_ID'] = "nova_compute"
config['FIREWALL_PORTS'] = "'5900-5999'" config['FIREWALL_PORTS'] = "'5900-5999'"
@ -543,7 +503,7 @@ def createcomputemanifest(config):
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def createnetworkmanifest(config): def create_network_manifest(config, messages):
global compute_hosts, network_hosts global compute_hosts, network_hosts
if config['CONFIG_NEUTRON_INSTALL'] == "y": if config['CONFIG_NEUTRON_INSTALL'] == "y":
return return
@ -554,7 +514,7 @@ def createnetworkmanifest(config):
('CONFIG_NOVA_NETWORK_NUMBER', 1)]: ('CONFIG_NOVA_NETWORK_NUMBER', 1)]:
config[key] = config.get(key, value) config[key] = config.get(key, value)
api_host = config['CONFIG_NOVA_API_HOST'] api_host = config['CONFIG_CONTROLLER_HOST']
multihost = len(network_hosts) > 1 multihost = len(network_hosts) > 1
config['CONFIG_NOVA_NETWORK_MULTIHOST'] = multihost and 'true' or 'false' config['CONFIG_NOVA_NETWORK_MULTIHOST'] = multihost and 'true' or 'false'
for host in network_hosts: for host in network_hosts:
@ -564,14 +524,14 @@ def createnetworkmanifest(config):
bring_up_ifcfg(host, config[i]) bring_up_ifcfg(host, config[i])
except ScriptRuntimeError as ex: except ScriptRuntimeError as ex:
# just warn user to do it by himself # just warn user to do it by himself
controller.MESSAGES.append(str(ex)) messages.append(str(ex))
key = 'CONFIG_NOVA_NETWORK_AUTOASSIGNFLOATINGIP' key = 'CONFIG_NOVA_NETWORK_AUTOASSIGNFLOATINGIP'
config[key] = config[key] == "y" config[key] = config[key] == "y"
# We need to explicitly set the network size # We need to explicitly set the network size
routing_prefix = config['CONFIG_NOVA_NETWORK_FIXEDRANGE'].split('/')[1] routing_prefix = config['CONFIG_NOVA_NETWORK_FIXEDRANGE'].split('/')[1]
net_size = 2**(32 - int(routing_prefix)) net_size = 2 ** (32 - int(routing_prefix))
config['CONFIG_NOVA_NETWORK_FIXEDSIZE'] = str(net_size) config['CONFIG_NOVA_NETWORK_FIXEDSIZE'] = str(net_size)
manifestfile = "%s_nova.pp" % host manifestfile = "%s_nova.pp" % host
@ -583,29 +543,24 @@ def createnetworkmanifest(config):
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def createschedmanifest(config): def create_sched_manifest(config, messages):
manifestfile = "%s_nova.pp"%controller.CONF['CONFIG_NOVA_SCHED_HOST'] manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("nova_sched.pp") manifestdata = getManifestTemplate("nova_sched.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def createvncproxymanifest(config): def create_vncproxy_manifest(config, messages):
manifestfile = "%s_nova.pp"%controller.CONF['CONFIG_NOVA_VNCPROXY_HOST'] manifestfile = "%s_nova.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("nova_vncproxy.pp") manifestdata = getManifestTemplate("nova_vncproxy.pp")
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def createcommonmanifest(config): def create_common_manifest(config, messages):
global compute_hosts, network_hosts global compute_hosts, network_hosts
network_type = (config['CONFIG_NEUTRON_INSTALL'] == "y" and network_type = (config['CONFIG_NEUTRON_INSTALL'] == "y" and
'neutron' or 'nova') 'neutron' or 'nova')
network_multi = len(network_hosts) > 1 network_multi = len(network_hosts) > 1
dirty = [config.get('CONFIG_NOVA_CONDUCTOR_HOST'), dbacces_hosts = set([config.get('CONFIG_CONTROLLER_HOST')])
config.get('CONFIG_NOVA_API_HOST'),
config.get('CONFIG_NOVA_CERT_HOST'),
config.get('CONFIG_NOVA_VNCPROXY_HOST'),
config.get('CONFIG_NOVA_SCHED_HOST')]
dbacces_hosts = set([i.strip() for i in dirty if i and i.strip()])
dbacces_hosts |= network_hosts dbacces_hosts |= network_hosts
for manifestfile, marker in manifestfiles.getFiles(): for manifestfile, marker in manifestfiles.getFiles():
@ -625,10 +580,10 @@ def createcommonmanifest(config):
# for nova-network in multihost mode each compute host is metadata # for nova-network in multihost mode each compute host is metadata
# host otherwise we use api host # host otherwise we use api host
if (network_type == 'nova' and network_multi and if (network_type == 'nova' and network_multi and
host in compute_hosts): host in compute_hosts):
metadata = host metadata = host
else: else:
metadata = config['CONFIG_NOVA_API_HOST'] metadata = config['CONFIG_CONTROLLER_HOST']
config['CONFIG_NOVA_METADATA_HOST'] = metadata config['CONFIG_NOVA_METADATA_HOST'] = metadata
data = getManifestTemplate(get_mq(config, "nova_common")) data = getManifestTemplate(get_mq(config, "nova_common"))
@ -636,11 +591,12 @@ def createcommonmanifest(config):
appendManifestFile(os.path.split(manifestfile)[1], data) appendManifestFile(os.path.split(manifestfile)[1], data)
def createneutronmanifest(config): def create_neutron_manifest(config, messages):
if controller.CONF['CONFIG_NEUTRON_INSTALL'] != "y": if config['CONFIG_NEUTRON_INSTALL'] != "y":
return return
controller.CONF['CONFIG_NOVA_LIBVIRT_VIF_DRIVER'] = 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver' virt_driver = 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver'
config['CONFIG_NOVA_LIBVIRT_VIF_DRIVER'] = virt_driver
for manifestfile, marker in manifestfiles.getFiles(): for manifestfile, marker in manifestfiles.getFiles():
if manifestfile.endswith("_nova.pp"): if manifestfile.endswith("_nova.pp"):

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures an OpenStack Client Installs and configures an OpenStack Client
""" """
@ -9,44 +11,24 @@ from packstack.installer import validators
from packstack.installer import basedefs, output_messages from packstack.installer import basedefs, output_messages
from packstack.installer import utils from packstack.installer import utils
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile)
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-CLIENT"
PLUGIN_NAME = "OS-Client"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller group = {"GROUP_NAME": "NOVACLIENT",
controller = controllerObject "DESCRIPTION": "NOVACLIENT Config parameters",
logging.debug("Adding OpenStack Client configuration") "PRE_CONDITION": "CONFIG_CLIENT_INSTALL",
paramsList = [ "PRE_CONDITION_MATCH": "y",
{"CMD_OPTION" : "osclient-host", "POST_CONDITION": False,
"USAGE" : "The IP address of the server on which to install the OpenStack client packages. An admin \"rc\" file will also be installed", "POST_CONDITION_MATCH": True}
"PROMPT" : "Enter the IP address of the client server", controller.addGroup(group, [])
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_OSCLIENT_HOST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "NOVACLIENT",
"DESCRIPTION" : "NOVACLIENT Config parameters",
"PRE_CONDITION" : "CONFIG_CLIENT_INSTALL",
"PRE_CONDITION_MATCH" : "y",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
@ -54,13 +36,17 @@ def initSequences(controller):
return return
osclientsteps = [ osclientsteps = [
{'title': 'Adding OpenStack Client manifest entries', 'functions':[createmanifest]} {'title': 'Adding OpenStack Client manifest entries',
'functions': [create_manifest]}
] ]
controller.addSequence("Installing OpenStack Client", [], [], osclientsteps) controller.addSequence("Installing OpenStack Client", [], [],
osclientsteps)
def createmanifest(config): #-------------------------- step functions --------------------------
client_host = config['CONFIG_OSCLIENT_HOST'].strip()
def create_manifest(config, messages):
client_host = config['CONFIG_CONTROLLER_HOST'].strip()
manifestfile = "%s_osclient.pp" % client_host manifestfile = "%s_osclient.pp" % client_host
server = utils.ScriptRunner(client_host) server = utils.ScriptRunner(client_host)
@ -83,9 +69,9 @@ def createmanifest(config):
msg = ("File %s/keystonerc_admin has been created on OpenStack client host" msg = ("File %s/keystonerc_admin has been created on OpenStack client host"
" %s. To use the command line tools you need to source the file.") " %s. To use the command line tools you need to source the file.")
controller.MESSAGES.append(msg % (root_home, client_host)) messages.append(msg % (root_home, client_host))
if no_root_allinone: if no_root_allinone:
msg = ("Copy of keystonerc_admin file has been created for non-root " msg = ("Copy of keystonerc_admin file has been created for non-root "
"user in %s.") "user in %s.")
controller.MESSAGES.append(msg % homedir) messages.append(msg % homedir)

View File

@ -1,50 +1,52 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures an OpenStack Client Installs and configures an OpenStack Client
""" """
import logging import logging
from packstack.installer import utils
from packstack.modules.common import filtered_hosts from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import (getManifestTemplate, from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile) appendManifestFile)
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-POSTSCRIPT"
logging.debug("plugin %s loaded", __name__) PLUGIN_NAME = "Postscript"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
def initConfig(controllerObject):
global controller
controller = controllerObject
logging.debug("Executing post run scripts")
groupDict = {"GROUP_NAME" : "POSTSCRIPT", def initConfig(controller):
"DESCRIPTION" : "POSTSCRIPT Config parameters", group = {"GROUP_NAME": "POSTSCRIPT",
"PRE_CONDITION" : lambda x: 'yes', "DESCRIPTION": "POSTSCRIPT Config parameters",
"PRE_CONDITION_MATCH" : "yes", "PRE_CONDITION": lambda x: 'yes',
"POST_CONDITION" : False, "PRE_CONDITION_MATCH": "yes",
"POST_CONDITION_MATCH" : True} "POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(groupDict, []) controller.addGroup(group, [])
def initSequences(controller): def initSequences(controller):
osclientsteps = [ postscript_steps = [
{'title': 'Adding post install manifest entries', 'functions':[createmanifest]} {'title': 'Adding post install manifest entries',
'functions': [create_manifest]}
] ]
controller.addSequence("Running post install scripts", [], [], osclientsteps) controller.addSequence("Running post install scripts", [], [],
postscript_steps)
def createmanifest(config): #-------------------------- step functions --------------------------
def create_manifest(config, messages):
for hostname in filtered_hosts(config): for hostname in filtered_hosts(config):
manifestfile = "%s_postscript.pp" % hostname manifestfile = "%s_postscript.pp" % hostname
manifestdata = getManifestTemplate("postscript.pp") manifestdata = getManifestTemplate("postscript.pp")
appendManifestFile(manifestfile, manifestdata, 'postscript') appendManifestFile(manifestfile, manifestdata, 'postscript')
if config.get("CONFIG_PROVISION_ALL_IN_ONE_OVS_BRIDGE") != 'n': if config.get("CONFIG_PROVISION_ALL_IN_ONE_OVS_BRIDGE") != 'n':
config['EXT_BRIDGE_VAR'] = config['CONFIG_NEUTRON_L3_EXT_BRIDGE'].replace('-','_') fmted = config['CONFIG_NEUTRON_L3_EXT_BRIDGE'].replace('-', '_')
config['EXT_BRIDGE_VAR'] = fmted
manifestdata = getManifestTemplate("persist_ovs_bridge.pp") manifestdata = getManifestTemplate("persist_ovs_bridge.pp")
appendManifestFile(manifestfile, manifestdata, 'postscript') appendManifestFile(manifestfile, manifestdata, 'postscript')

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Plugin responsible for setting OpenStack global options Plugin responsible for setting OpenStack global options
""" """
@ -16,310 +18,399 @@ from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile) appendManifestFile)
# Controller object will be initialized from main flow #------------------ oVirt installer initialization ------------------
controller = None
# Plugin name PLUGIN_NAME = "Prescript"
PLUGIN_NAME = "OS-PRESCRIPT" PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller default_ssh_key = os.path.join(os.environ["HOME"], ".ssh/*.pub")
controller = controllerObject default_ssh_key = (glob.glob(default_ssh_key) + [""])[0]
params = [
{"CMD_OPTION": "ssh-public-key",
"USAGE": ("Path to a Public key to install on servers. If a usable "
"key has not been installed on the remote servers the user "
"will be prompted for a password and this key will be "
"installed so the password will not be required again"),
"PROMPT": ("Enter the path to your ssh Public key to install "
"on servers"),
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_file, validators.validate_sshkey],
"PROCESSORS": [processors.process_ssh_key],
"DEFAULT_VALUE": default_ssh_key,
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_SSH_KEY",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
paramsList = [{"CMD_OPTION" : "ssh-public-key", {"CMD_OPTION": "mysql-install",
"USAGE" : "Path to a Public key to install on servers. If a usable key has not been installed on the remote servers the user will be prompted for a password and this key will be installed so the password will not be required again", "USAGE": "Set to 'y' if you would like Packstack to install MySQL",
"PROMPT" : "Enter the path to your ssh Public key to install on servers", "PROMPT": "Should Packstack install MySQL DB",
"OPTION_LIST" : [], "OPTION_LIST": ["y", "n"],
"VALIDATORS" : [validators.validate_file, "VALIDATORS": [validators.validate_options],
validators.validate_sshkey], "DEFAULT_VALUE": "y",
"PROCESSORS" : [processors.process_ssh_key], "MASK_INPUT": False,
"DEFAULT_VALUE" : (glob.glob(os.path.join(os.environ["HOME"], ".ssh/*.pub"))+[""])[0], "LOOSE_VALIDATION": False,
"MASK_INPUT" : False, "CONF_NAME": "CONFIG_MYSQL_INSTALL",
"LOOSE_VALIDATION": False, "USE_DEFAULT": False,
"CONF_NAME" : "CONFIG_SSH_KEY", "NEED_CONFIRM": False,
"USE_DEFAULT" : False, "CONDITION": False},
"NEED_CONFIRM" : False,
"CONDITION" : False }, {"CMD_OPTION": "os-glance-install",
{"CMD_OPTION" : "os-mysql-install", "USAGE": ("Set to 'y' if you would like Packstack to install "
"USAGE" : "Set to 'y' if you would like Packstack to install MySQL", "OpenStack Image Service (Glance)"),
"PROMPT" : "Should Packstack install MySQL DB", "PROMPT": "Should Packstack install OpenStack Image Service (Glance)",
"OPTION_LIST" : ["y", "n"], "OPTION_LIST": ["y", "n"],
"VALIDATORS" : [validators.validate_options], "VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE" : "y", "DEFAULT_VALUE": "y",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_MYSQL_INSTALL", "CONF_NAME": "CONFIG_GLANCE_INSTALL",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "os-glance-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Image Service (Glance)", {"CMD_OPTION": "os-cinder-install",
"PROMPT" : "Should Packstack install OpenStack Image Service (Glance)", "USAGE": ("Set to 'y' if you would like Packstack to install "
"OPTION_LIST" : ["y", "n"], "OpenStack Block Storage (Cinder)"),
"VALIDATORS" : [validators.validate_options], "PROMPT": ("Should Packstack install OpenStack Block Storage "
"DEFAULT_VALUE" : "y", "(Cinder) service"),
"MASK_INPUT" : False, "OPTION_LIST": ["y", "n"],
"LOOSE_VALIDATION": False, "VALIDATORS": [validators.validate_options],
"CONF_NAME" : "CONFIG_GLANCE_INSTALL", "DEFAULT_VALUE": "y",
"USE_DEFAULT" : False, "MASK_INPUT": False,
"NEED_CONFIRM" : False, "LOOSE_VALIDATION": False,
"CONDITION" : False }, "CONF_NAME": "CONFIG_CINDER_INSTALL",
{"CMD_OPTION" : "os-cinder-install", "USE_DEFAULT": False,
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Block Storage (Cinder)", "NEED_CONFIRM": False,
"PROMPT" : "Should Packstack install OpenStack Block Storage (Cinder) service", "CONDITION": False},
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options], {"CMD_OPTION": "os-nova-install",
"DEFAULT_VALUE" : "y", "USAGE": ("Set to 'y' if you would like Packstack to install "
"MASK_INPUT" : False, "OpenStack Compute (Nova)"),
"LOOSE_VALIDATION": False, "PROMPT": "Should Packstack install OpenStack Compute (Nova) service",
"CONF_NAME" : "CONFIG_CINDER_INSTALL", "OPTION_LIST": ["y", "n"],
"USE_DEFAULT" : False, "VALIDATORS": [validators.validate_options],
"NEED_CONFIRM" : False, "DEFAULT_VALUE": "y",
"CONDITION" : False }, "MASK_INPUT": False,
{"CMD_OPTION" : "os-nova-install", "LOOSE_VALIDATION": False,
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Compute (Nova)", "CONF_NAME": "CONFIG_NOVA_INSTALL",
"PROMPT" : "Should Packstack install OpenStack Compute (Nova) service", "USE_DEFAULT": False,
"OPTION_LIST" : ["y", "n"], "NEED_CONFIRM": False,
"VALIDATORS" : [validators.validate_options], "CONDITION": False},
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False, {"CMD_OPTION": "os-neutron-install",
"LOOSE_VALIDATION": False, "USAGE": ("Set to 'y' if you would like Packstack to install "
"CONF_NAME" : "CONFIG_NOVA_INSTALL", "OpenStack Networking (Neutron). Otherwise Nova Network "
"USE_DEFAULT" : False, "will be used."),
"NEED_CONFIRM" : False, "PROMPT": ("Should Packstack install OpenStack Networking (Neutron) "
"CONDITION" : False }, "service"),
{"CMD_OPTION" : "os-neutron-install", "OPTION_LIST": ["y", "n"],
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Networking (Neutron)", "VALIDATORS": [validators.validate_options],
"PROMPT" : "Should Packstack install OpenStack Networking (Neutron) service", "DEFAULT_VALUE": "y",
"OPTION_LIST" : ["y", "n"], "MASK_INPUT": False,
"VALIDATORS" : [validators.validate_options], "LOOSE_VALIDATION": False,
"DEFAULT_VALUE" : "y", "CONF_NAME": "CONFIG_NEUTRON_INSTALL",
"MASK_INPUT" : False, "USE_DEFAULT": False,
"LOOSE_VALIDATION": False, "NEED_CONFIRM": False,
"CONF_NAME" : "CONFIG_NEUTRON_INSTALL", "CONDITION": False},
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False, {"CMD_OPTION": "os-horizon-install",
"CONDITION" : False }, "USAGE": ("Set to 'y' if you would like Packstack to install "
{"CMD_OPTION" : "os-horizon-install", "OpenStack Dashboard (Horizon)"),
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Dashboard (Horizon)", "PROMPT": "Should Packstack install OpenStack Dashboard (Horizon)",
"PROMPT" : "Should Packstack install OpenStack Dashboard (Horizon)", "OPTION_LIST": ["y", "n"],
"OPTION_LIST" : ["y", "n"], "VALIDATORS": [validators.validate_options],
"VALIDATORS" : [validators.validate_options], "DEFAULT_VALUE": "y",
"DEFAULT_VALUE" : "y", "MASK_INPUT": False,
"MASK_INPUT" : False, "LOOSE_VALIDATION": False,
"LOOSE_VALIDATION": False, "CONF_NAME": "CONFIG_HORIZON_INSTALL",
"CONF_NAME" : "CONFIG_HORIZON_INSTALL", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-install", {"CMD_OPTION": "os-swift-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Object Storage (Swift)", "USAGE": ("Set to 'y' if you would like Packstack to install "
"PROMPT" : "Should Packstack install OpenStack Object Storage (Swift)", "OpenStack Object Storage (Swift)"),
"OPTION_LIST" : ["y", "n"], "PROMPT": "Should Packstack install OpenStack Object Storage (Swift)",
"VALIDATORS" : [validators.validate_options], "OPTION_LIST": ["y", "n"],
"DEFAULT_VALUE" : "y", "VALIDATORS": [validators.validate_options],
"MASK_INPUT" : False, "DEFAULT_VALUE": "y",
"LOOSE_VALIDATION": False, "MASK_INPUT": False,
"CONF_NAME" : "CONFIG_SWIFT_INSTALL", "LOOSE_VALIDATION": False,
"USE_DEFAULT" : False, "CONF_NAME": "CONFIG_SWIFT_INSTALL",
"NEED_CONFIRM" : False, "USE_DEFAULT": False,
"CONDITION" : False }, "NEED_CONFIRM": False,
{"CMD_OPTION" : "os-ceilometer-install", "CONDITION": False},
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Metering (Ceilometer)",
"PROMPT" : "Should Packstack install OpenStack Metering (Ceilometer)", {"CMD_OPTION": "os-ceilometer-install",
"OPTION_LIST" : ["y", "n"], "USAGE": ("Set to 'y' if you would like Packstack to install "
"VALIDATORS" : [validators.validate_options], "OpenStack Metering (Ceilometer)"),
"DEFAULT_VALUE" : "y", "PROMPT": "Should Packstack install OpenStack Metering (Ceilometer)",
"MASK_INPUT" : False, "OPTION_LIST": ["y", "n"],
"LOOSE_VALIDATION": False, "VALIDATORS": [validators.validate_options],
"CONF_NAME" : "CONFIG_CEILOMETER_INSTALL", "DEFAULT_VALUE": "y",
"USE_DEFAULT" : False, "MASK_INPUT": False,
"NEED_CONFIRM" : False, "LOOSE_VALIDATION": False,
"CONDITION" : False }, "CONF_NAME": "CONFIG_CEILOMETER_INSTALL",
{"CMD_OPTION" : "os-heat-install", "USE_DEFAULT": False,
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Orchestration (Heat)", "NEED_CONFIRM": False,
"PROMPT" : "Should Packstack install OpenStack Orchestration (Heat)", "CONDITION": False},
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options], {"CMD_OPTION": "os-heat-install",
"DEFAULT_VALUE" : "n", "USAGE": ("Set to 'y' if you would like Packstack to install "
"MASK_INPUT" : False, "OpenStack Orchestration (Heat)"),
"LOOSE_VALIDATION": False, "PROMPT": "Should Packstack install OpenStack Orchestration (Heat)",
"CONF_NAME" : "CONFIG_HEAT_INSTALL", "OPTION_LIST": ["y", "n"],
"USE_DEFAULT" : False, "VALIDATORS": [validators.validate_options],
"NEED_CONFIRM" : False, "DEFAULT_VALUE": "n",
"CONDITION" : False }, "MASK_INPUT": False,
{"CMD_OPTION" : "os-client-install", "LOOSE_VALIDATION": False,
"USAGE" : "Set to 'y' if you would like Packstack to install the OpenStack Client packages. An admin \"rc\" file will also be installed", "CONF_NAME": "CONFIG_HEAT_INSTALL",
"PROMPT" : "Should Packstack install OpenStack client tools", "USE_DEFAULT": False,
"OPTION_LIST" : ["y", "n"], "NEED_CONFIRM": False,
"VALIDATORS" : [validators.validate_options], "CONDITION": False},
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False, {"CMD_OPTION": "os-client-install",
"LOOSE_VALIDATION": False, "USAGE": ("Set to 'y' if you would like Packstack to install "
"CONF_NAME" : "CONFIG_CLIENT_INSTALL", "the OpenStack Client packages. An admin \"rc\" file will "
"USE_DEFAULT" : False, "also be installed"),
"NEED_CONFIRM" : False, "PROMPT": "Should Packstack install OpenStack client tools",
"CONDITION" : False }, "OPTION_LIST": ["y", "n"],
{"CMD_OPTION" : "ntp-servers", "VALIDATORS": [validators.validate_options],
"USAGE" : "Comma separated list of NTP servers. Leave plain if Packstack should not install ntpd on instances.", "DEFAULT_VALUE": "y",
"PROMPT" : "Enter a comma separated list of NTP server(s). Leave plain if Packstack should not install ntpd on instances.", "MASK_INPUT": False,
"OPTION_LIST" : [], "LOOSE_VALIDATION": False,
"DEFAULT_VALUE" : '', "CONF_NAME": "CONFIG_CLIENT_INSTALL",
"MASK_INPUT" : False, "USE_DEFAULT": False,
"LOOSE_VALIDATION": False, "NEED_CONFIRM": False,
"CONF_NAME" : "CONFIG_NTP_SERVERS", "CONDITION": False},
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False, {"CMD_OPTION": "ntp-servers",
"CONDITION" : False }, "USAGE": ("Comma separated list of NTP servers. Leave plain if "
{"CMD_OPTION" : "nagios-install", "Packstack should not install ntpd on instances."),
"USAGE" : "Set to 'y' if you would like Packstack to install Nagios to monitor OpenStack hosts", "PROMPT": ("Enter a comma separated list of NTP server(s). Leave "
"PROMPT" : "Should Packstack install Nagios to monitor OpenStack hosts", "plain if Packstack should not install ntpd "
"OPTION_LIST" : ["y", "n"], "on instances."),
"VALIDATORS" : [validators.validate_options], "OPTION_LIST": [],
"DEFAULT_VALUE" : 'y', "DEFAULT_VALUE": '',
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NAGIOS_INSTALL", "CONF_NAME": "CONFIG_NTP_SERVERS",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "exclude-servers",
"USAGE" : "Comma separated list of servers to be excluded from installation in case you are running Packstack the second time with the same answer file and don't want Packstack to touch these servers. Leave plain if you don't need to exclude any server.", {"CMD_OPTION": "nagios-install",
"PROMPT" : "Enter a comma separated list of server(s) to be excluded. Leave plain if you don't need to exclude any server.", "USAGE": ("Set to 'y' if you would like Packstack to install Nagios "
"OPTION_LIST" : [], "to monitor OpenStack hosts"),
"DEFAULT_VALUE" : '', "PROMPT": ("Should Packstack install Nagios to monitor OpenStack "
"MASK_INPUT" : False, "hosts"),
"LOOSE_VALIDATION": False, "OPTION_LIST": ["y", "n"],
"CONF_NAME" : "EXCLUDE_SERVERS", "VALIDATORS": [validators.validate_options],
"USE_DEFAULT" : False, "DEFAULT_VALUE": 'y',
"NEED_CONFIRM" : False, "MASK_INPUT": False,
"CONDITION" : False }, "LOOSE_VALIDATION": False,
{"CMD_OPTION" : "os-debug-mode", "CONF_NAME": "CONFIG_NAGIOS_INSTALL",
"USAGE" : ("Set to 'y' if you want to run " "USE_DEFAULT": False,
"OpenStack services in debug mode. " "NEED_CONFIRM": False,
"Otherwise set to 'n'."), "CONDITION": False},
"PROMPT" : ("Do you want to run OpenStack services"
" in debug mode"), {"CMD_OPTION": "exclude-servers",
"OPTION_LIST" : ["y", "n"], "USAGE": ("Comma separated list of servers to be excluded from "
"DEFAULT_VALUE" : "n", "installation in case you are running Packstack the second "
"VALIDATORS" : [validators.validate_options], "time with the same answer file and don't want Packstack "
"MASK_INPUT" : False, "to touch these servers. Leave plain if you don't need to "
"LOOSE_VALIDATION": False, "exclude any server."),
"CONF_NAME" : "CONFIG_DEBUG_MODE", "PROMPT": ("Enter a comma separated list of server(s) to be excluded."
"USE_DEFAULT" : False, " Leave plain if you don't need to exclude any server."),
"NEED_CONFIRM" : False, "OPTION_LIST": [],
"CONDITION" : False }, "DEFAULT_VALUE": '',
{"CMD_OPTION" : "os-vmware", "MASK_INPUT": False,
"USAGE" : ("Set to 'y' if you want to use " "LOOSE_VALIDATION": False,
"VMware vCenter as hypervisor and storage" "CONF_NAME": "EXCLUDE_SERVERS",
"Otherwise set to 'n'."), "USE_DEFAULT": False,
"PROMPT" : ("Do you want to use VMware vCenter as" "NEED_CONFIRM": False,
" hypervisor and datastore"), "CONDITION": False},
"OPTION_LIST" : ["y","n"],
"DEFAULT_VALUE" : "n", {"CMD_OPTION": "os-debug-mode",
"VALIDATORS" : [validators.validate_options], "USAGE": ("Set to 'y' if you want to run OpenStack services in debug "
"MASK_INPUT" : False, "mode. Otherwise set to 'n'."),
"LOOSE_VALIDATION": False, "PROMPT": "Do you want to run OpenStack services in debug mode",
"CONF_NAME" : "CONFIG_VMWARE_BACKEND", "OPTION_LIST": ["y", "n"],
"USE_DEFAULT" : False, "DEFAULT_VALUE": "n",
"NEED_CONFIRM" : False, "VALIDATORS": [validators.validate_options],
"CONDITION" : False }, "MASK_INPUT": False,
] "LOOSE_VALIDATION": False,
groupDict = { "GROUP_NAME" : "GLOBAL", "CONF_NAME": "CONFIG_DEBUG_MODE",
"DESCRIPTION" : "Global Options", "USE_DEFAULT": False,
"PRE_CONDITION" : lambda x: 'yes', "NEED_CONFIRM": False,
"PRE_CONDITION_MATCH" : "yes", "CONDITION": False},
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True} {"CONF_NAME": "CONFIG_CONTROLLER_HOST",
controller.addGroup(groupDict, paramsList) "CMD_OPTION": "os-controller-host",
"USAGE": ("The IP address of the server on which to install OpenStack"
" services specific to controller role such as API servers,"
" Horizon, etc."),
"PROMPT": "Enter the IP address of the controller host",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_ip,
validators.validate_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CONF_NAME": "CONFIG_COMPUTE_HOSTS",
"CMD_OPTION": "os-compute-hosts",
"USAGE": ("The list of IP addresses of the server on which to install"
" the Nova compute service"),
"PROMPT": ("Enter list of IP addresses on which to install compute "
"service"),
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_multi_ip,
validators.validate_multi_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CONF_NAME": "CONFIG_NETWORK_HOSTS",
"CMD_OPTION": "os-network-hosts",
"USAGE": ("The list of IP addresses of the server on which "
"to install the network service such as Nova "
"network or Neutron"),
"PROMPT": ("Enter list of IP addresses on which to install "
"network service"),
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_multi_ip,
validators.validate_multi_ssh],
"DEFAULT_VALUE": utils.get_localhost_ip(),
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "os-vmware",
"USAGE": ("Set to 'y' if you want to use VMware vCenter as hypervisor"
" and storage. Otherwise set to 'n'."),
"PROMPT": ("Do you want to use VMware vCenter as hypervisor and "
"datastore"),
"OPTION_LIST": ["y", "n"],
"DEFAULT_VALUE": "n",
"VALIDATORS": [validators.validate_options],
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_VMWARE_BACKEND",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "GLOBAL",
"DESCRIPTION": "Global Options",
"PRE_CONDITION": lambda x: 'yes',
"PRE_CONDITION_MATCH": "yes",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
def use_vcenter(config): def use_vcenter(config):
return (config['CONFIG_NOVA_INSTALL'] == 'y' and return (config['CONFIG_NOVA_INSTALL'] == 'y' and
config['CONFIG_VMWARE_BACKEND'] == 'y') config['CONFIG_VMWARE_BACKEND'] == 'y')
paramsList = [ params = [
{"CMD_OPTION" : "vcenter-host", {"CMD_OPTION": "vcenter-host",
"USAGE" : ("The IP address of the VMware vCenter server"), "USAGE": "The IP address of the VMware vCenter server",
"PROMPT" : ("Enter the IP address of the VMware vCenter server to use with Nova"), "PROMPT": ("Enter the IP address of the VMware vCenter server to use "
"OPTION_LIST" : [], "with Nova"),
"VALIDATORS" : [validators.validate_ip], "OPTION_LIST": [],
"DEFAULT_VALUE" : "", "VALIDATORS": [validators.validate_ip],
"MASK_INPUT" : False, "DEFAULT_VALUE": "",
"LOOSE_VALIDATION": True, "MASK_INPUT": False,
"CONF_NAME" : "CONFIG_VCENTER_HOST", "LOOSE_VALIDATION": True,
"USE_DEFAULT" : False, "CONF_NAME": "CONFIG_VCENTER_HOST",
"NEED_CONFIRM" : False, "USE_DEFAULT": False,
"CONDITION" : False }, "NEED_CONFIRM": False,
{"CMD_OPTION" : "vcenter-username", "CONDITION": False},
"USAGE" : ("The username to authenticate to VMware vCenter server"),
"PROMPT" : ("Enter the username to authenticate on VMware vCenter server"),
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_VCENTER_USER",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False,},
{"CMD_OPTION" : "vcenter-password",
"USAGE" : ("The password to authenticate to VMware vCenter server"),
"PROMPT" : ("Enter the password to authenticate on VMware vCenter server"),
"DEFAULT_VALUE" : "",
"MASK_INPUT" : True,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_VCENTER_PASSWORD",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False,},
{"CMD_OPTION" : "vcenter-cluster",
"USAGE" : ("The name of the vCenter cluster"),
"PROMPT" : ("Enter the name of the vCenter datastore"),
"DEFAULT_VALUE" : "",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_VCENTER_CLUSTER_NAME",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False,},
]
groupDict = {"GROUP_NAME" : "VMWARE", {"CMD_OPTION": "vcenter-username",
"DESCRIPTION" : "vCenter Config Parameters", "USAGE": "The username to authenticate to VMware vCenter server",
"PRE_CONDITION" : use_vcenter, "PROMPT": ("Enter the username to authenticate on VMware "
"PRE_CONDITION_MATCH" : True, "vCenter server"),
"POST_CONDITION" : False, "DEFAULT_VALUE": "",
"POST_CONDITION_MATCH" : True} "MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_VCENTER_USER",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "vcenter-password",
"USAGE": "The password to authenticate to VMware vCenter server",
"PROMPT": ("Enter the password to authenticate on VMware "
"vCenter server"),
"DEFAULT_VALUE": "",
"MASK_INPUT": True,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_VCENTER_PASSWORD",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "vcenter-cluster",
"USAGE": "The name of the vCenter cluster",
"PROMPT": "Enter the name of the vCenter datastore",
"DEFAULT_VALUE": "",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_VCENTER_CLUSTER_NAME",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "VMWARE",
"DESCRIPTION": "vCenter Config Parameters",
"PRE_CONDITION": use_vcenter,
"PRE_CONDITION_MATCH": True,
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
prescript_steps = [ prescript_steps = [
{'title': 'Setting up ssh keys', {'title': 'Setting up ssh keys',
'functions':[install_keys]}, 'functions': [install_keys]},
{'title': 'Discovering hosts\' details', {'title': 'Discovering hosts\' details',
'functions': [discover]}, 'functions': [discover]},
{'title': 'Adding pre install manifest entries', {'title': 'Adding pre install manifest entries',
'functions':[create_manifest]}, 'functions': [create_manifest]},
] ]
if controller.CONF['CONFIG_NTP_SERVERS']: if controller.CONF['CONFIG_NTP_SERVERS']:
prescript_steps.append({ prescript_steps.append(
'title': 'Installing time synchronization via NTP', {'title': 'Installing time synchronization via NTP',
'functions': [create_ntp_manifest], 'functions': [create_ntp_manifest]})
})
else: else:
controller.MESSAGES.append('Time synchronization installation ' controller.MESSAGES.append('Time synchronization installation was '
'was skipped. Please note that ' 'skipped. Please note that unsynchronized '
'unsynchronized time on server ' 'time on server instances might be problem '
'instances might be problem for ' 'for some OpenStack components.')
'some OpenStack components.')
controller.addSequence("Running pre install scripts", [], [], controller.addSequence("Running pre install scripts", [], [],
prescript_steps) prescript_steps)
def install_keys(config): #-------------------------- step functions --------------------------
def install_keys(config, messages):
with open(config["CONFIG_SSH_KEY"]) as fp: with open(config["CONFIG_SSH_KEY"]) as fp:
sshkeydata = fp.read().strip() sshkeydata = fp.read().strip()
for hostname in filtered_hosts(config): for hostname in filtered_hosts(config):
@ -337,7 +428,7 @@ def install_keys(config):
server.execute() server.execute()
def discover(config): def discover(config, messages):
""" """
Discovers details about hosts. Discovers details about hosts.
""" """
@ -382,7 +473,7 @@ def discover(config):
config['HOST_DETAILS'] = details config['HOST_DETAILS'] = details
def create_manifest(config): def create_manifest(config, messages):
key = 'CONFIG_DEBUG_MODE' key = 'CONFIG_DEBUG_MODE'
config[key] = config[key] == 'y' and 'true' or 'false' config[key] = config[key] == 'y' and 'true' or 'false'
@ -392,7 +483,7 @@ def create_manifest(config):
appendManifestFile(manifestfile, manifestdata) appendManifestFile(manifestfile, manifestdata)
def create_ntp_manifest(config): def create_ntp_manifest(config, messages):
srvlist = [i.strip() srvlist = [i.strip()
for i in config['CONFIG_NTP_SERVERS'].split(',') for i in config['CONFIG_NTP_SERVERS'].split(',')
if i.strip()] if i.strip()]

View File

@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures neutron Installs and configures neutron
""" """
import logging import logging
from packstack.installer import utils
from packstack.installer import validators from packstack.installer import validators
from packstack.modules.common import is_all_in_one from packstack.modules.common import is_all_in_one
@ -11,118 +14,111 @@ from packstack.modules.ospluginutils import (appendManifestFile,
getManifestTemplate) getManifestTemplate)
# Controller object will be initialized from main flow #------------------ oVirt installer initialization ------------------
controller = None
# Plugin name
PLUGIN_NAME = "OS-Provision" PLUGIN_NAME = "OS-Provision"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller
controller = controllerObject
logging.debug("Provisioning OpenStack resources for demo usage and testing")
def process_provision(param, process_args=None): def process_provision(param, process_args=None):
return param if is_all_in_one(controller.CONF) else 'n' return param if is_all_in_one(controller.CONF) else 'n'
conf_params = { conf_params = {
"PROVISION_INIT" : [ "PROVISION_INIT": [
{"CMD_OPTION" : "provision-demo", {"CMD_OPTION": "provision-demo",
"USAGE" : ("Whether to provision for demo usage and testing. Note " "USAGE": ("Whether to provision for demo usage and testing. Note "
"that provisioning is only supported for all-in-one " "that provisioning is only supported for all-in-one "
"installations."), "installations."),
"PROMPT" : "Would you like to provision for demo usage and testing?", "PROMPT": ("Would you like to provision for demo usage "
"OPTION_LIST" : ["y", "n"], "and testing"),
"VALIDATORS" : [validators.validate_options], "OPTION_LIST": ["y", "n"],
"PROCESSORS" : [process_provision], "VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE" : "y", "DEFAULT_VALUE": "y",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_PROVISION_DEMO", "CONF_NAME": "CONFIG_PROVISION_DEMO",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "provision-tempest",
"USAGE" : ("Whether to configure tempest for testing. Note "
"that provisioning is only supported for all-in-one "
"installations."),
"PROMPT" : "Would you like to configure Tempest (OpenStack test suite)?",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"PROCESSORS" : [process_provision],
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_PROVISION_TEMPEST",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"PROVISION_DEMO" : [
{"CMD_OPTION" : "provision-demo-floatrange",
"USAGE" : "The CIDR network address for the floating IP subnet",
"PROMPT" : "Enter the network address for the floating IP subnet:",
"OPTION_LIST" : False,
"VALIDATORS" : False,
"DEFAULT_VALUE" : "172.24.4.224/28",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_PROVISION_DEMO_FLOATRANGE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"TEMPEST_GIT_REFS" : [
{"CMD_OPTION" : "provision-tempest-repo-uri",
"USAGE" : "The uri of the tempest git repository to use",
"PROMPT" : "What is the uri of the Tempest git repository?",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "https://github.com/openstack/tempest.git",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_PROVISION_TEMPEST_REPO_URI",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "provision-tempest-repo-revision",
"USAGE" : "The revision of the tempest git repository to use",
"PROMPT" : "What revision, branch, or tag of the Tempest git repository should be used?",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : "master",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_PROVISION_TEMPEST_REPO_REVISION",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
"PROVISION_ALL_IN_ONE_OVS_BRIDGE" : [
{"CMD_OPTION" : "provision-all-in-one-ovs-bridge",
"USAGE" : "Whether to configure the ovs external bridge in an all-in-one deployment",
"PROMPT" : "Would you like to configure the external ovs bridge?",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_PROVISION_ALL_IN_ONE_OVS_BRIDGE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
],
}
def allow_provisioning(config): {"CMD_OPTION": "provision-tempest",
# Provisioning is currently supported only for all-in-one (due "USAGE": "Whether to configure tempest for testing",
# to a limitation with how the custom types for OpenStack "PROMPT": ("Would you like to configure Tempest (OpenStack test "
# resources are implemented). "suite). Note that provisioning is only supported for "
return is_all_in_one(config) "all-in-one installations."),
"OPTION_LIST": ["y", "n"],
"VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE": "n",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_PROVISION_TEMPEST",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
],
"PROVISION_DEMO": [
{"CMD_OPTION": "provision-demo-floatrange",
"USAGE": "The CIDR network address for the floating IP subnet",
"PROMPT": "Enter the network address for the floating IP subnet",
"OPTION_LIST": False,
"VALIDATORS": False,
"DEFAULT_VALUE": "172.24.4.224/28",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_PROVISION_DEMO_FLOATRANGE",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
],
"TEMPEST_GIT_REFS": [
{"CMD_OPTION": "provision-tempest-repo-uri",
"USAGE": "The uri of the tempest git repository to use",
"PROMPT": "What is the uri of the Tempest git repository?",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": "https://github.com/openstack/tempest.git",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_PROVISION_TEMPEST_REPO_URI",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "provision-tempest-repo-revision",
"USAGE": "The revision of the tempest git repository to use",
"PROMPT": ("What revision, branch, or tag of the Tempest git "
"repository should be used"),
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": "master",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_PROVISION_TEMPEST_REPO_REVISION",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
],
"PROVISION_ALL_IN_ONE_OVS_BRIDGE": [
{"CMD_OPTION": "provision-all-in-one-ovs-bridge",
"USAGE": ("Whether to configure the ovs external bridge in an "
"all-in-one deployment"),
"PROMPT": "Would you like to configure the external ovs bridge",
"OPTION_LIST": ["y", "n"],
"VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE": "n",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_PROVISION_ALL_IN_ONE_OVS_BRIDGE",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
],
}
def check_provisioning_demo(config): def check_provisioning_demo(config):
return (allow_provisioning(config) and return (allow_provisioning(config) and
@ -130,39 +126,42 @@ def initConfig(controllerObject):
config.get('CONFIG_PROVISION_TEMPEST', 'n') == 'y')) config.get('CONFIG_PROVISION_TEMPEST', 'n') == 'y'))
def check_provisioning_tempest(config): def check_provisioning_tempest(config):
return allow_provisioning(config) and \ return (allow_provisioning(config) and
config.get('CONFIG_PROVISION_TEMPEST', 'n') == 'y' config.get('CONFIG_PROVISION_TEMPEST', 'n') == 'y')
def allow_all_in_one_ovs_bridge(config): def allow_all_in_one_ovs_bridge(config):
return allow_provisioning(config) and \ return (allow_provisioning(config) and
config['CONFIG_NEUTRON_INSTALL'] == 'y' and \ config['CONFIG_NEUTRON_INSTALL'] == 'y' and
config['CONFIG_NEUTRON_L2_PLUGIN'] == 'openvswitch' config['CONFIG_NEUTRON_L2_PLUGIN'] == 'openvswitch')
conf_groups = [ conf_groups = [
{ "GROUP_NAME" : "PROVISION_INIT", {"GROUP_NAME": "PROVISION_INIT",
"DESCRIPTION" : "Provisioning demo config", "DESCRIPTION": "Provisioning demo config",
"PRE_CONDITION" : lambda x: 'yes', "PRE_CONDITION": lambda x: 'yes',
"PRE_CONDITION_MATCH" : "yes", "PRE_CONDITION_MATCH": "yes",
"POST_CONDITION" : False, "POST_CONDITION": False,
"POST_CONDITION_MATCH" : True }, "POST_CONDITION_MATCH": True},
{ "GROUP_NAME" : "PROVISION_DEMO",
"DESCRIPTION" : "Provisioning demo config", {"GROUP_NAME": "PROVISION_DEMO",
"PRE_CONDITION" : check_provisioning_demo, "DESCRIPTION": "Provisioning demo config",
"PRE_CONDITION_MATCH" : True, "PRE_CONDITION": allow_provisioning,
"POST_CONDITION" : False, "PRE_CONDITION_MATCH": True,
"POST_CONDITION_MATCH" : True }, "POST_CONDITION": False,
{ "GROUP_NAME" : "TEMPEST_GIT_REFS", "POST_CONDITION_MATCH": True},
"DESCRIPTION" : "Optional tempest git uri and branch",
"PRE_CONDITION" : check_provisioning_tempest, {"GROUP_NAME": "TEMPEST_GIT_REFS",
"PRE_CONDITION_MATCH" : True, "DESCRIPTION": "Optional tempest git uri and branch",
"POST_CONDITION" : False, "PRE_CONDITION": check_provisioning_tempest,
"POST_CONDITION_MATCH" : True }, "PRE_CONDITION_MATCH": True,
{ "GROUP_NAME" : "PROVISION_ALL_IN_ONE_OVS_BRIDGE", "POST_CONDITION": False,
"DESCRIPTION" : "Provisioning all-in-one ovs bridge config", "POST_CONDITION_MATCH": True},
"PRE_CONDITION" : allow_all_in_one_ovs_bridge,
"PRE_CONDITION_MATCH" : True, {"GROUP_NAME": "PROVISION_ALL_IN_ONE_OVS_BRIDGE",
"POST_CONDITION" : False, "DESCRIPTION": "Provisioning all-in-one ovs bridge config",
"POST_CONDITION_MATCH" : True }, "PRE_CONDITION": allow_all_in_one_ovs_bridge,
"PRE_CONDITION_MATCH": True,
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True},
] ]
for group in conf_groups: for group in conf_groups:
paramList = conf_params[group["GROUP_NAME"]] paramList = conf_params[group["GROUP_NAME"]]
@ -182,6 +181,30 @@ def initConfig(controllerObject):
controller.CONF[param.CONF_NAME] = value controller.CONF[param.CONF_NAME] = value
def initSequences(controller):
config = controller.CONF
provisioning_required = (
config['CONFIG_PROVISION_DEMO'] == 'y'
or
config['CONFIG_PROVISION_TEMPEST'] == 'y'
)
if not provisioning_required or not allow_provisioning(config):
return
marshall_conf_bool(config, 'CONFIG_PROVISION_TEMPEST')
marshall_conf_bool(config, 'CONFIG_PROVISION_ALL_IN_ONE_OVS_BRIDGE')
provision_steps = [
{'title': 'Adding Provisioning manifest entries',
'functions': [create_manifest]}
]
controller.addSequence("Provisioning for Demo and Testing Usage",
[], [], provision_steps)
#------------------------- helper functions -------------------------
def marshall_conf_bool(conf, key): def marshall_conf_bool(conf, key):
if conf[key] == 'y': if conf[key] == 'y':
conf[key] = 'true' conf[key] = 'true'
@ -189,34 +212,19 @@ def marshall_conf_bool(conf, key):
conf[key] = 'false' conf[key] = 'false'
def initSequences(controller): def allow_provisioning(config):
provisioning_required = ( # Provisioning is currently supported only for all-in-one (due
controller.CONF['CONFIG_PROVISION_DEMO'] == 'y' # to a limitation with how the custom types for OpenStack
or # resources are implemented).
controller.CONF['CONFIG_PROVISION_TEMPEST'] == 'y' return is_all_in_one(config)
)
if not provisioning_required:
return
marshall_conf_bool(controller.CONF, 'CONFIG_PROVISION_TEMPEST')
marshall_conf_bool(controller.CONF,
'CONFIG_PROVISION_ALL_IN_ONE_OVS_BRIDGE')
provision_steps = [
{
'title': 'Adding Provisioning manifest entries',
'functions': [create_manifest],
}
]
controller.addSequence("Provisioning for Demo and Testing Usage",
[], [], provision_steps)
def create_manifest(config): #-------------------------- step functions --------------------------
def create_manifest(config, messages):
# Using the neutron or nova api servers as the provisioning target # Using the neutron or nova api servers as the provisioning target
# will suffice for the all-in-one case. # will suffice for the all-in-one case.
if config['CONFIG_NEUTRON_INSTALL'] == "y": if config['CONFIG_NEUTRON_INSTALL'] != "y":
host = config['CONFIG_NEUTRON_SERVER_HOST']
else:
host = config['CONFIG_NOVA_API_HOST']
# The provisioning template requires the name of the external # The provisioning template requires the name of the external
# bridge but the value will be missing if neutron isn't # bridge but the value will be missing if neutron isn't
# configured to be installed. # configured to be installed.
@ -228,6 +236,6 @@ def create_manifest(config):
config['PROVISION_NEUTRON_AVAILABLE'] = config['CONFIG_NEUTRON_INSTALL'] config['PROVISION_NEUTRON_AVAILABLE'] = config['CONFIG_NEUTRON_INSTALL']
marshall_conf_bool(config, 'PROVISION_NEUTRON_AVAILABLE') marshall_conf_bool(config, 'PROVISION_NEUTRON_AVAILABLE')
manifest_file = '%s_provision.pp' % host manifest_file = '%s_provision.pp' % config['CONFIG_CONTROLLER_HOST']
manifest_data = getManifestTemplate("provision.pp") manifest_data = getManifestTemplate("provision.pp")
appendManifestFile(manifest_file, manifest_data) appendManifestFile(manifest_file, manifest_data)

View File

@ -3,6 +3,7 @@
""" """
Installs and configures puppet Installs and configures puppet
""" """
import sys import sys
import logging import logging
import os import os
@ -17,62 +18,117 @@ from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import manifestfiles from packstack.modules.ospluginutils import manifestfiles
from packstack.modules.puppet import scan_logfile, validate_logfile from packstack.modules.puppet import scan_logfile, validate_logfile
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OSPUPPET"
PLUGIN_NAME = "Puppet"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
PUPPET_DIR = os.environ.get('PACKSTACK_PUPPETDIR', '/usr/share/openstack-puppet/') PUPPET_DIR = os.environ.get('PACKSTACK_PUPPETDIR',
'/usr/share/openstack-puppet/')
MODULE_DIR = os.path.join(PUPPET_DIR, 'modules') MODULE_DIR = os.path.join(PUPPET_DIR, 'modules')
def initConfig(controllerObject): def initConfig(controller):
global controller group = {"GROUP_NAME": "PUPPET",
controller = controllerObject "DESCRIPTION": "Puppet Config parameters",
logging.debug("Adding OpenStack Puppet configuration") "PRE_CONDITION": lambda x: 'yes',
paramsList = [ "PRE_CONDITION_MATCH": "yes",
] "POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
groupDict = {"GROUP_NAME" : "PUPPET", controller.addGroup(group, [])
"DESCRIPTION" : "Puppet Config parameters",
"PRE_CONDITION" : lambda x: 'yes',
"PRE_CONDITION_MATCH" : "yes",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller): def initSequences(controller):
puppetpresteps = [ puppetpresteps = [
{'title': 'Clean Up', 'functions':[runCleanup]}, {'title': 'Clean Up', 'functions': [run_cleanup]},
] ]
controller.insertSequence("Clean Up", [], [], puppetpresteps, index=0) controller.insertSequence("Clean Up", [], [], puppetpresteps, index=0)
puppetsteps = [ puppetsteps = [
{'title': 'Installing Dependencies', {'title': 'Installing Dependencies',
'functions': [installdeps]}, 'functions': [install_deps]},
{'title': 'Copying Puppet modules and manifests', {'title': 'Copying Puppet modules and manifests',
'functions': [copyPuppetModules]}, 'functions': [copy_puppet_modules]},
{'title': 'Applying Puppet manifests', {'title': 'Applying Puppet manifests',
'functions': [applyPuppetManifest]}, 'functions': [apply_puppet_manifest]},
{'title': 'Finalizing', {'title': 'Finalizing',
'functions': [finalize]} 'functions': [finalize]}
] ]
controller.addSequence("Puppet", [], [], puppetsteps) controller.addSequence("Puppet", [], [], puppetsteps)
def runCleanup(config): #------------------------- helper functions -------------------------
def wait_for_puppet(currently_running, messages):
log_len = 0
twirl = ["-", "\\", "|", "/"]
while currently_running:
for hostname, finished_logfile in currently_running:
log_file = os.path.splitext(os.path.basename(finished_logfile))[0]
space_len = basedefs.SPACE_LEN - len(log_file)
if len(log_file) > log_len:
log_len = len(log_file)
if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
twirl = twirl[-1:] + twirl[:-1]
sys.stdout.write(("\rTesting if puppet apply is finished: %s"
% log_file).ljust(40 + log_len))
sys.stdout.write("[ %s ]" % twirl[0])
sys.stdout.flush()
try:
# Once a remote puppet run has finished, we retrieve the log
# file and check it for errors
local_server = utils.ScriptRunner()
log = os.path.join(basedefs.PUPPET_MANIFEST_DIR,
os.path.basename(finished_logfile))
log = log.replace(".finished", ".log")
local_server.append('scp -o StrictHostKeyChecking=no '
'-o UserKnownHostsFile=/dev/null '
'root@%s:%s %s'
% (hostname, finished_logfile, log))
# To not pollute logs we turn of logging of command execution
local_server.execute(log=False)
# If we got to this point the puppet apply has finished
currently_running.remove((hostname, finished_logfile))
# clean off the last "testing apply" msg
if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
sys.stdout.write(("\r").ljust(45 + log_len))
except ScriptRuntimeError:
# the test raises an exception if the file doesn't exist yet
# TO-DO: We need to start testing 'e' for unexpected exceptions
time.sleep(3)
continue
# check log file for relevant notices
messages.extend(scan_logfile(log))
# check the log file for errors
sys.stdout.write('\r')
try:
validate_logfile(log)
state = utils.state_message('%s:' % log_file, 'DONE', 'green')
sys.stdout.write('%s\n' % state)
sys.stdout.flush()
except PuppetError:
state = utils.state_message('%s:' % log_file, 'ERROR', 'red')
sys.stdout.write('%s\n' % state)
sys.stdout.flush()
raise
#-------------------------- step functions --------------------------
def run_cleanup(config, messages):
localserver = utils.ScriptRunner() localserver = utils.ScriptRunner()
localserver.append("rm -rf %s/*pp" % basedefs.PUPPET_MANIFEST_DIR) localserver.append("rm -rf %s/*pp" % basedefs.PUPPET_MANIFEST_DIR)
localserver.execute() localserver.execute()
def installdeps(config): def install_deps(config, messages):
deps = ["puppet", "openssh-clients", "tar", "nc"] deps = ["puppet", "openssh-clients", "tar", "nc"]
modules_pkg = 'openstack-puppet-modules' modules_pkg = 'openstack-puppet-modules'
@ -91,18 +147,19 @@ def installdeps(config):
for hostname in filtered_hosts(config): for hostname in filtered_hosts(config):
server = utils.ScriptRunner(hostname) server = utils.ScriptRunner(hostname)
for package in deps: for package in deps:
server.append("rpm -q --whatprovides %s || yum install -y %s" % (package, package)) server.append("rpm -q --whatprovides %s || yum install -y %s"
% (package, package))
server.execute() server.execute()
def copyPuppetModules(config): def copy_puppet_modules(config, messages):
os_modules = ' '.join(('apache', 'ceilometer', 'certmonger', 'cinder', os_modules = ' '.join(('apache', 'ceilometer', 'certmonger', 'cinder',
'concat', 'firewall', 'glance', 'heat', 'horizon', 'concat', 'firewall', 'glance', 'heat', 'horizon',
'inifile', 'keystone', 'memcached', 'mongodb', 'inifile', 'keystone', 'memcached', 'mongodb',
'mysql', 'neutron', 'nova', 'nssdb', 'openstack', 'mysql', 'neutron', 'nova', 'nssdb', 'openstack',
'packstack', 'qpid', 'rabbitmq', 'rsync', 'ssh', 'stdlib', 'packstack', 'qpid', 'rabbitmq', 'rsync', 'ssh',
'swift', 'sysctl', 'tempest', 'vcsrepo', 'vlan', 'stdlib', 'swift', 'sysctl', 'tempest', 'vcsrepo',
'vswitch', 'xinetd')) 'vlan', 'vswitch', 'xinetd'))
# write puppet manifest to disk # write puppet manifest to disk
manifestfiles.writeManifests() manifestfiles.writeManifests()
@ -115,80 +172,29 @@ def copyPuppetModules(config):
server.append("cd %s" % basedefs.PUPPET_MANIFEST_DIR) server.append("cd %s" % basedefs.PUPPET_MANIFEST_DIR)
server.append("tar --dereference -cpzf - ../manifests | " server.append("tar --dereference -cpzf - ../manifests | "
"ssh -o StrictHostKeyChecking=no " "ssh -o StrictHostKeyChecking=no "
"-o UserKnownHostsFile=/dev/null " "-o UserKnownHostsFile=/dev/null "
"root@%s tar -C %s -xpzf -" % (hostname, host_dir)) "root@%s tar -C %s -xpzf -" % (hostname, host_dir))
# copy resources # copy resources
for path, localname in controller.resources.get(hostname, []): resources = config.get('RESOURCES', {})
for path, localname in resources.get(hostname, []):
server.append("scp -o StrictHostKeyChecking=no " server.append("scp -o StrictHostKeyChecking=no "
"-o UserKnownHostsFile=/dev/null %s root@%s:%s/resources/%s" % "-o UserKnownHostsFile=/dev/null "
(path, hostname, host_dir, localname)) "%s root@%s:%s/resources/%s" %
(path, hostname, host_dir, localname))
# copy Puppet modules required by Packstack # copy Puppet modules required by Packstack
server.append("cd %s" % MODULE_DIR) server.append("cd %s" % MODULE_DIR)
server.append("tar --dereference -cpzf - %s | " server.append("tar --dereference -cpzf - %s | "
"ssh -o StrictHostKeyChecking=no " "ssh -o StrictHostKeyChecking=no "
"-o UserKnownHostsFile=/dev/null " "-o UserKnownHostsFile=/dev/null "
"root@%s tar -C %s -xpzf -" % "root@%s tar -C %s -xpzf -" %
(os_modules, hostname, os.path.join(host_dir, 'modules'))) (os_modules, hostname,
os.path.join(host_dir, 'modules')))
server.execute() server.execute()
def waitforpuppet(currently_running): def apply_puppet_manifest(config, messages):
global controller
log_len = 0
twirl = ["-","\\","|","/"]
while currently_running:
for hostname, finished_logfile in currently_running:
log_file = os.path.splitext(os.path.basename(finished_logfile))[0]
if len(log_file) > log_len:
log_len = len(log_file)
if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
twirl = twirl[-1:] + twirl[:-1]
sys.stdout.write(("\rTesting if puppet apply is finished: %s" % log_file).ljust(40 + log_len))
sys.stdout.write("[ %s ]" % twirl[0])
sys.stdout.flush()
try:
# Once a remote puppet run has finished, we retrieve the log
# file and check it for errors
local_server = utils.ScriptRunner()
log = os.path.join(basedefs.PUPPET_MANIFEST_DIR,
os.path.basename(finished_logfile).replace(".finished", ".log"))
local_server.append('scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@%s:%s %s' % (hostname, finished_logfile, log))
# To not pollute logs we turn of logging of command execution
local_server.execute(log=False)
# If we got to this point the puppet apply has finished
currently_running.remove((hostname, finished_logfile))
# clean off the last "testing apply" msg
if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
sys.stdout.write(('\r').ljust(45 + log_len))
except ScriptRuntimeError:
# the test raises an exception if the file doesn't exist yet
# TO-DO: We need to start testing 'e' for unexpected exceptions
time.sleep(3)
continue
# check log file for relevant notices
controller.MESSAGES.extend(scan_logfile(log))
# check the log file for errors
sys.stdout.write('\r')
try:
validate_logfile(log)
state = utils.state_message('%s:' % log_file, 'DONE', 'green')
sys.stdout.write('%s\n' % state)
sys.stdout.flush()
except PuppetError:
state = utils.state_message('%s:' % log_file, 'ERROR', 'red')
sys.stdout.write('%s\n' % state)
sys.stdout.flush()
raise
def applyPuppetManifest(config):
if config.get("DRY_RUN"): if config.get("DRY_RUN"):
return return
currently_running = [] currently_running = []
@ -201,8 +207,8 @@ def applyPuppetManifest(config):
for manifest, marker in manifestfiles.getFiles(): for manifest, marker in manifestfiles.getFiles():
# if the marker has changed then we don't want to proceed until # if the marker has changed then we don't want to proceed until
# all of the previous puppet runs have finished # all of the previous puppet runs have finished
if lastmarker != None and lastmarker != marker: if lastmarker is not None and lastmarker != marker:
waitforpuppet(currently_running) wait_for_puppet(currently_running, messages)
lastmarker = marker lastmarker = marker
for hostname in filtered_hosts(config): for hostname in filtered_hosts(config):
@ -220,22 +226,24 @@ def applyPuppetManifest(config):
running_logfile = "%s.running" % man_path running_logfile = "%s.running" % man_path
finished_logfile = "%s.finished" % man_path finished_logfile = "%s.finished" % man_path
currently_running.append((hostname, finished_logfile)) currently_running.append((hostname, finished_logfile))
# The apache puppet module doesn't work if we set FACTERLIB
# https://github.com/puppetlabs/puppetlabs-apache/pull/138
if not (manifest.endswith('_horizon.pp') or manifest.endswith('_nagios.pp')):
server.append("export FACTERLIB=$FACTERLIB:%s/facts" % host_dir)
server.append("touch %s" % running_logfile) server.append("touch %s" % running_logfile)
server.append("chmod 600 %s" % running_logfile) server.append("chmod 600 %s" % running_logfile)
server.append("export PACKSTACK_VAR_DIR=%s" % host_dir) server.append("export PACKSTACK_VAR_DIR=%s" % host_dir)
command = "( flock %s/ps.lock puppet apply %s --modulepath %s/modules %s > %s 2>&1 < /dev/null ; mv %s %s ) > /dev/null 2>&1 < /dev/null &" % (host_dir, loglevel, host_dir, man_path, running_logfile, running_logfile, finished_logfile) cmd = ("( flock %s/ps.lock "
server.append(command) "puppet apply %s --modulepath %s/modules %s > %s "
"2>&1 < /dev/null ; "
"mv %s %s ) > /dev/null 2>&1 < /dev/null &"
% (host_dir, loglevel, host_dir, man_path, running_logfile,
running_logfile, finished_logfile))
server.append(cmd)
server.execute(log=logcmd) server.execute(log=logcmd)
# wait for outstanding puppet runs befor exiting # wait for outstanding puppet runs befor exiting
waitforpuppet(currently_running) wait_for_puppet(currently_running, messages)
def finalize(config): def finalize(config, messages):
for hostname in filtered_hosts(config): for hostname in filtered_hosts(config):
server = utils.ScriptRunner(hostname) server = utils.ScriptRunner(hostname)
server.append("installed=$(rpm -q kernel --last | head -n1 | " server.append("installed=$(rpm -q kernel --last | head -n1 | "
@ -245,5 +253,5 @@ def finalize(config):
try: try:
rc, out = server.execute() rc, out = server.execute()
except ScriptRuntimeError: except ScriptRuntimeError:
controller.MESSAGES.append('Because of the kernel update the host ' messages.append('Because of the kernel update the host %s '
'%s requires reboot.' % hostname) 'requires reboot.' % hostname)

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
prepare server prepare server
""" """
@ -15,218 +17,215 @@ from packstack.installer import validators
from packstack.modules.common import filtered_hosts, is_all_in_one from packstack.modules.common import filtered_hosts, is_all_in_one
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-SERVERPREPARE" PLUGIN_NAME = "OS-SERVERPREPARE"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller
controller = controllerObject
logging.debug("Adding SERVERPREPARE KEY configuration")
conf_params = { conf_params = {
"SERVERPREPARE": [ "SERVERPREPARE": [
{"CMD_OPTION" : "use-epel", {"CMD_OPTION": "use-epel",
"USAGE" : "To subscribe each server to EPEL enter \"y\"", "USAGE": "To subscribe each server to EPEL enter \"y\"",
"PROMPT" : "To subscribe each server to EPEL enter \"y\"", "PROMPT": "To subscribe each server to EPEL enter \"y\"",
"OPTION_LIST" : ["y", "n"], "OPTION_LIST": ["y", "n"],
"VALIDATORS" : [validators.validate_options], "VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE" : "n", "DEFAULT_VALUE": "n",
"MASK_INPUT" : False, "MASK_INPUT": False,
"LOOSE_VALIDATION": True, "LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_USE_EPEL", "CONF_NAME": "CONFIG_USE_EPEL",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "additional-repo", {"CMD_OPTION": "additional-repo",
"USAGE" : "A comma separated list of URLs to any additional yum repositories to install", "USAGE": ("A comma separated list of URLs to any additional yum "
"PROMPT" : "Enter a comma separated list of URLs to any additional yum repositories to install", "repositories to install"),
"OPTION_LIST" : [], "PROMPT": ("Enter a comma separated list of URLs to any "
"DEFAULT_VALUE" : "", "additional yum repositories to install"),
"MASK_INPUT" : False, "OPTION_LIST": [],
"LOOSE_VALIDATION": True, "DEFAULT_VALUE": "",
"CONF_NAME" : "CONFIG_REPO", "MASK_INPUT": False,
"USE_DEFAULT" : False, "LOOSE_VALIDATION": True,
"NEED_CONFIRM" : False, "CONF_NAME": "CONFIG_REPO",
"CONDITION" : False }], "USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False}
],
"RHEL": [ "RHEL": [
{"CMD_OPTION" : "rh-username", {"CMD_OPTION": "rh-username",
"USAGE" : "To subscribe each server with Red Hat subscription manager, include this with CONFIG_RH_PW", "USAGE": ("To subscribe each server with Red Hat subscription "
"PROMPT" : "To subscribe each server to Red Hat enter a username here", "manager, include this with CONFIG_RH_PW"),
"OPTION_LIST" : [], "PROMPT": "To subscribe each server to Red Hat enter a username ",
"DEFAULT_VALUE" : "", "OPTION_LIST": [],
"MASK_INPUT" : False, "DEFAULT_VALUE": "",
"LOOSE_VALIDATION": True, "MASK_INPUT": False,
"CONF_NAME" : "CONFIG_RH_USER", "LOOSE_VALIDATION": True,
"USE_DEFAULT" : False, "CONF_NAME": "CONFIG_RH_USER",
"NEED_CONFIRM" : False, "USE_DEFAULT": False,
"CONDITION" : False }, "NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION" : "rh-password", {"CMD_OPTION": "rh-password",
"USAGE" : "To subscribe each server with Red Hat subscription manager, include this with CONFIG_RH_USER", "USAGE": ("To subscribe each server with Red Hat subscription "
"PROMPT" : "To subscribe each server to Red Hat enter your password here", "manager, include this with CONFIG_RH_USER"),
"OPTION_LIST" : [], "PROMPT": ("To subscribe each server to Red Hat enter your "
"DEFAULT_VALUE" : "", "password"),
"MASK_INPUT" : True, "OPTION_LIST": [],
"LOOSE_VALIDATION": True, "DEFAULT_VALUE": "",
"CONF_NAME" : "CONFIG_RH_PW", "MASK_INPUT": True,
"USE_DEFAULT" : False, "LOOSE_VALIDATION": True,
"NEED_CONFIRM" : False, "CONF_NAME": "CONFIG_RH_PW",
"CONDITION" : False }, "USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION" : "rh-beta-repo", {"CMD_OPTION": "rhn-satellite-server",
"USAGE" : "To subscribe each server to Red Hat Enterprise Linux 6 Server Beta channel (only needed for Preview versions of RHOS) enter \"y\"", "USAGE": ("To subscribe each server with RHN Satellite,fill "
"PROMPT" : "To subscribe each server to Red Hat Enterprise Linux 6 Server Beta channel (only needed for Preview versions of RHOS) enter \"y\"", "Satellite's URL here. Note that either satellite's "
"OPTION_LIST" : ["y", "n"], "username/password or activation key has "
"VALIDATORS" : [validators.validate_options], "to be provided"),
"DEFAULT_VALUE" : "n", "PROMPT": ("To subscribe each server with RHN Satellite enter "
"MASK_INPUT" : False, "RHN Satellite server URL"),
"LOOSE_VALIDATION": True, "OPTION_LIST": [],
"CONF_NAME" : "CONFIG_RH_BETA_REPO", "DEFAULT_VALUE": "",
"USE_DEFAULT" : False, "MASK_INPUT": False,
"NEED_CONFIRM" : False, "LOOSE_VALIDATION": False,
"CONDITION" : False }, "CONF_NAME": "CONFIG_SATELLITE_URL",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False}
],
{"CMD_OPTION" : "rhn-satellite-server", "SATELLITE": [
"USAGE" : ("To subscribe each server with RHN Satellite," {"CMD_OPTION": "rhn-satellite-username",
"fill Satellite's URL here. Note that either " "USAGE": "Username to access RHN Satellite",
"satellite's username/password or activation " "PROMPT": ("Enter RHN Satellite username or leave plain if you "
"key has to be provided"), "will use activation key instead"),
"PROMPT" : ("To subscribe each server with RHN Satellite " "OPTION_LIST": [],
"enter RHN Satellite server URL"), "DEFAULT_VALUE": "",
"OPTION_LIST" : [], "MASK_INPUT": False,
"DEFAULT_VALUE" : "", "LOOSE_VALIDATION": True,
"MASK_INPUT" : False, "CONF_NAME": "CONFIG_SATELLITE_USER",
"LOOSE_VALIDATION": False, "USE_DEFAULT": False,
"CONF_NAME" : "CONFIG_SATELLITE_URL", "NEED_CONFIRM": False,
"USE_DEFAULT" : False, "CONDITION": False},
"NEED_CONFIRM" : False,
"CONDITION" : False }],
"SATELLITE": [ {"CMD_OPTION": "rhn-satellite-password",
{"CMD_OPTION" : "rhn-satellite-username", "USAGE": "Password to access RHN Satellite",
"USAGE" : "Username to access RHN Satellite", "PROMPT": ("Enter RHN Satellite password or leave plain if you "
"PROMPT" : ("Enter RHN Satellite username or leave plain " "will use activation key instead"),
"if you will use activation key instead"), "OPTION_LIST": [],
"OPTION_LIST" : [], "DEFAULT_VALUE": "",
"DEFAULT_VALUE" : "", "MASK_INPUT": True,
"MASK_INPUT" : False, "LOOSE_VALIDATION": False,
"LOOSE_VALIDATION": True, "CONF_NAME": "CONFIG_SATELLITE_PW",
"CONF_NAME" : "CONFIG_SATELLITE_USER", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False },
{"CMD_OPTION" : "rhn-satellite-password", {"CMD_OPTION": "rhn-satellite-activation-key",
"USAGE" : "Password to access RHN Satellite", "USAGE": "Activation key for subscription to RHN Satellite",
"PROMPT" : ("Enter RHN Satellite password or leave plain " "PROMPT": ("Enter RHN Satellite activation key or leave plain if "
"if you will use activation key instead"), "you used username/password instead"),
"OPTION_LIST" : [], "OPTION_LIST": [],
"DEFAULT_VALUE" : "", "DEFAULT_VALUE": "",
"MASK_INPUT" : True, "MASK_INPUT": True,
"LOOSE_VALIDATION": False, "LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_SATELLITE_PW", "CONF_NAME": "CONFIG_SATELLITE_AKEY",
"USE_DEFAULT" : False, "USE_DEFAULT": False,
"NEED_CONFIRM" : False, "NEED_CONFIRM": False,
"CONDITION" : False }, "CONDITION": False},
{"CMD_OPTION" : "rhn-satellite-activation-key", {"CMD_OPTION": "rhn-satellite-cacert",
"USAGE" : "Activation key for subscription to RHN Satellite", "USAGE": "Specify a path or URL to a SSL CA certificate to use",
"PROMPT" : ("Enter RHN Satellite activation key or leave plain " "PROMPT": "Specify a path or URL to a SSL CA certificate to use",
"if you used username/password instead"), "OPTION_LIST": [],
"OPTION_LIST" : [], "DEFAULT_VALUE": "",
"DEFAULT_VALUE" : "", "MASK_INPUT": True,
"MASK_INPUT" : True, "LOOSE_VALIDATION": False,
"LOOSE_VALIDATION": False, "CONF_NAME": "CONFIG_SATELLITE_CACERT",
"CONF_NAME" : "CONFIG_SATELLITE_AKEY", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False },
{"CMD_OPTION" : "rhn-satellite-cacert", {"CMD_OPTION": "rhn-satellite-profile",
"USAGE" : "Specify a path or URL to a SSL CA certificate to use", "USAGE": ("If required specify the profile name that should be "
"PROMPT" : "Specify a path or URL to a SSL CA certificate to use", "used as an identifier for the system "
"OPTION_LIST" : [], "in RHN Satellite"),
"DEFAULT_VALUE" : "", "PROMPT": ("If required specify the profile name that should be "
"MASK_INPUT" : True, "used as an identifier for the system "
"LOOSE_VALIDATION": False, "in RHN Satellite"),
"CONF_NAME" : "CONFIG_SATELLITE_CACERT", "OPTION_LIST": [],
"USE_DEFAULT" : False, "DEFAULT_VALUE": "",
"NEED_CONFIRM" : False, "MASK_INPUT": True,
"CONDITION" : False }, "LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_SATELLITE_PROFILE",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION" : "rhn-satellite-profile", {"CMD_OPTION": "rhn-satellite-flags",
"USAGE" : ("If required specify the profile name that should " "USAGE": ("Comma separated list of flags passed to rhnreg_ks. "
"be used as an identifier for the system in RHN " "Valid flags are: novirtinfo, norhnsd, nopackages"),
"Satellite"), "PROMPT": ("Enter comma separated list of flags passed "
"PROMPT" : ("If required specify the profile name that should " "to rhnreg_ks"),
"be used as an identifier for the system in RHN " "OPTION_LIST": ['novirtinfo', 'norhnsd', 'nopackages'],
"Satellite"), "VALIDATORS": [validators.validate_multi_options],
"OPTION_LIST" : [], "DEFAULT_VALUE": "",
"DEFAULT_VALUE" : "", "MASK_INPUT": True,
"MASK_INPUT" : True, "LOOSE_VALIDATION": False,
"LOOSE_VALIDATION": False, "CONF_NAME": "CONFIG_SATELLITE_FLAGS",
"CONF_NAME" : "CONFIG_SATELLITE_PROFILE", "USE_DEFAULT": False,
"USE_DEFAULT" : False, "NEED_CONFIRM": False,
"NEED_CONFIRM" : False, "CONDITION": False},
"CONDITION" : False },
{"CMD_OPTION" : "rhn-satellite-flags", {"CMD_OPTION": "rhn-satellite-proxy-host",
"USAGE" : ("Comma separated list of flags passed to rhnreg_ks. Valid " "USAGE": "Specify a HTTP proxy to use with RHN Satellite",
"flags are: novirtinfo, norhnsd, nopackages"), "PROMPT": "Specify a HTTP proxy to use with RHN Satellite",
"PROMPT" : "Enter comma separated list of flags passed to rhnreg_ks", "OPTION_LIST": [],
"OPTION_LIST" : ['novirtinfo', 'norhnsd', 'nopackages'], "DEFAULT_VALUE": "",
"VALIDATORS" : [validators.validate_multi_options], "MASK_INPUT": True,
"DEFAULT_VALUE" : "", "LOOSE_VALIDATION": False,
"MASK_INPUT" : True, "CONF_NAME": "CONFIG_SATELLITE_PROXY",
"LOOSE_VALIDATION": False, "USE_DEFAULT": False,
"CONF_NAME" : "CONFIG_SATELLITE_FLAGS", "NEED_CONFIRM": False,
"USE_DEFAULT" : False, "CONDITION": False}
"NEED_CONFIRM" : False, ],
"CONDITION" : False },
{"CMD_OPTION" : "rhn-satellite-proxy-host", "SATELLITE_PROXY": [
"USAGE" : "Specify a HTTP proxy to use with RHN Satellite", {"CMD_OPTION": "rhn-satellite-proxy-username",
"PROMPT" : "Specify a HTTP proxy to use with RHN Satellite", "USAGE": ("Specify a username to use with an authenticated "
"OPTION_LIST" : [], "HTTP proxy"),
"DEFAULT_VALUE" : "", "PROMPT": ("Specify a username to use with an authenticated "
"MASK_INPUT" : True, "HTTP proxy"),
"LOOSE_VALIDATION": False, "OPTION_LIST": [],
"CONF_NAME" : "CONFIG_SATELLITE_PROXY", "DEFAULT_VALUE": "",
"USE_DEFAULT" : False, "MASK_INPUT": True,
"NEED_CONFIRM" : False, "LOOSE_VALIDATION": False,
"CONDITION" : False }], "CONF_NAME": "CONFIG_SATELLITE_PROXY_USER",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
"SATELLITE_PROXY": [ {"CMD_OPTION": "rhn-satellite-proxy-password",
{"CMD_OPTION" : "rhn-satellite-proxy-username", "USAGE": ("Specify a password to use with an authenticated "
"USAGE" : "Specify a username to use with an authenticated HTTP proxy", "HTTP proxy."),
"PROMPT" : "Specify a username to use with an authenticated HTTP proxy", "PROMPT": ("Specify a password to use with an authenticated "
"OPTION_LIST" : [], "HTTP proxy."),
"DEFAULT_VALUE" : "", "OPTION_LIST": [],
"MASK_INPUT" : True, "DEFAULT_VALUE": "",
"LOOSE_VALIDATION": False, "MASK_INPUT": True,
"CONF_NAME" : "CONFIG_SATELLITE_PROXY_USER", "LOOSE_VALIDATION": False,
"USE_DEFAULT" : False, "CONF_NAME": "CONFIG_SATELLITE_PROXY_PW",
"NEED_CONFIRM" : False, "USE_DEFAULT": False,
"CONDITION" : False }, "NEED_CONFIRM": False,
"CONDITION": False}
{"CMD_OPTION" : "rhn-satellite-proxy-password", ]
"USAGE" : "Specify a password to use with an authenticated HTTP proxy.", }
"PROMPT" : "Specify a password to use with an authenticated HTTP proxy.",
"OPTION_LIST" : [],
"DEFAULT_VALUE" : "",
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_SATELLITE_PROXY_PW",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False }]}
def filled_satellite(config): def filled_satellite(config):
return bool(config.get('CONFIG_SATELLITE_URL')) return bool(config.get('CONFIG_SATELLITE_URL'))
@ -235,42 +234,51 @@ def initConfig(controllerObject):
return bool(config.get('CONFIG_SATELLITE_PROXY')) return bool(config.get('CONFIG_SATELLITE_PROXY'))
conf_groups = [ conf_groups = [
{"GROUP_NAME" : "SERVERPREPARE", {"GROUP_NAME": "SERVERPREPARE",
"DESCRIPTION" : "Server Prepare Configs ", "DESCRIPTION": "Server Prepare Configs ",
"PRE_CONDITION" : lambda x: 'yes', "PRE_CONDITION": lambda x: 'yes',
"PRE_CONDITION_MATCH" : "yes", "PRE_CONDITION_MATCH": "yes",
"POST_CONDITION" : False, "POST_CONDITION": False,
"POST_CONDITION_MATCH" : True}, "POST_CONDITION_MATCH": True},
] ]
if ((is_all_in_one(controller.CONF) and is_rhel()) or config = controller.CONF
not is_all_in_one(controller.CONF)): if (is_all_in_one(config) and is_rhel()) or not is_all_in_one(config):
conf_groups.append({"GROUP_NAME" : "RHEL", conf_groups.append({"GROUP_NAME": "RHEL",
"DESCRIPTION" : "RHEL config", "DESCRIPTION": "RHEL config",
"PRE_CONDITION" : lambda x: 'yes', "PRE_CONDITION": lambda x: 'yes',
"PRE_CONDITION_MATCH" : "yes", "PRE_CONDITION_MATCH": "yes",
"POST_CONDITION" : False, "POST_CONDITION": False,
"POST_CONDITION_MATCH" : True}) "POST_CONDITION_MATCH": True})
conf_groups.append({"GROUP_NAME" : "SATELLITE", conf_groups.append({"GROUP_NAME": "SATELLITE",
"DESCRIPTION" : "RHN Satellite config", "DESCRIPTION": "RHN Satellite config",
"PRE_CONDITION" : filled_satellite, "PRE_CONDITION": filled_satellite,
"PRE_CONDITION_MATCH" : True, "PRE_CONDITION_MATCH": True,
"POST_CONDITION" : False, "POST_CONDITION": False,
"POST_CONDITION_MATCH" : True}) "POST_CONDITION_MATCH": True})
conf_groups.append({"GROUP_NAME" : "SATELLITE_PROXY", conf_groups.append({"GROUP_NAME": "SATELLITE_PROXY",
"DESCRIPTION" : "RHN Satellite proxy config", "DESCRIPTION": "RHN Satellite proxy config",
"PRE_CONDITION" : filled_satellite_proxy, "PRE_CONDITION": filled_satellite_proxy,
"PRE_CONDITION_MATCH" : True, "PRE_CONDITION_MATCH": True,
"POST_CONDITION" : False, "POST_CONDITION": False,
"POST_CONDITION_MATCH" : True}) "POST_CONDITION_MATCH": True})
for group in conf_groups: for group in conf_groups:
paramList = conf_params[group["GROUP_NAME"]] params = conf_params[group["GROUP_NAME"]]
controller.addGroup(group, paramList) controller.addGroup(group, params)
def initSequences(controller):
preparesteps = [
{'title': 'Preparing servers', 'functions': [server_prep]}
]
controller.addSequence("Preparing servers", [], [], preparesteps)
#------------------------- helper functions -------------------------
def is_rhel(): def is_rhel():
return 'Red Hat Enterprise Linux' in platform.linux_distribution()[0] return 'Red Hat Enterprise Linux' in platform.linux_distribution()[0]
@ -290,9 +298,8 @@ def run_rhn_reg(host, server_url, username=None, password=None,
server = utils.ScriptRunner(host) server = utils.ScriptRunner(host)
# check satellite server url # check satellite server url
server_url = server_url.rstrip('/').endswith('/XMLRPC') \ server_url = (server_url.rstrip('/').endswith('/XMLRPC')
and server_url \ and server_url or '%s/XMLRPC' % server_url)
or '%s/XMLRPC' % server_url
cmd.extend(['--serverUrl', server_url]) cmd.extend(['--serverUrl', server_url])
if activation_key: if activation_key:
@ -339,7 +346,7 @@ def run_rhn_reg(host, server_url, username=None, password=None,
server.execute(mask_list=mask) server.execute(mask_list=mask)
def run_rhsm_reg(host, username, password, beta): def run_rhsm_reg(host, username, password):
""" """
Registers given host to Red Hat Repositories via subscription manager. Registers given host to Red Hat Repositories via subscription manager.
""" """
@ -347,8 +354,8 @@ def run_rhsm_reg(host, username, password, beta):
# register host # register host
cmd = ('subscription-manager register --username=\"%s\" ' cmd = ('subscription-manager register --username=\"%s\" '
'--password=\"%s\" --autosubscribe || true') '--password=\"%s\" --autosubscribe || true')
server.append(cmd % (username, password.replace('"','\\"'))) server.append(cmd % (username, password.replace('"', '\\"')))
# subscribe to required channel # subscribe to required channel
cmd = ('subscription-manager list --consumed | grep -i openstack || ' cmd = ('subscription-manager list --consumed | grep -i openstack || '
@ -357,12 +364,12 @@ def run_rhsm_reg(host, username, password, beta):
"grep -e 'Red Hat OpenStack' -m 1 -A 2 | grep 'Pool Id' | " "grep -e 'Red Hat OpenStack' -m 1 -A 2 | grep 'Pool Id' | "
"awk '{print $3}')") "awk '{print $3}')")
server.append(cmd % pool) server.append(cmd % pool)
server.append("subscription-manager repos --enable rhel-6-server-optional-rpms") server.append("subscription-manager repos "
"--enable rhel-6-server-optional-rpms")
server.append("yum clean all") server.append("yum clean all")
server.append("rpm -q --whatprovides yum-utils || yum install -y yum-utils") server.append("rpm -q --whatprovides yum-utils || "
if beta: "yum install -y yum-utils")
server.append("yum-config-manager --enable rhel-6-server-beta-rpms")
server.append("yum clean metadata") server.append("yum clean metadata")
server.execute(mask_list=[password]) server.execute(mask_list=[password])
@ -409,7 +416,8 @@ def manage_epel(host, config):
server.append('yum-config-manager --%(cmd)s epel' % locals()) server.append('yum-config-manager --%(cmd)s epel' % locals())
rc, out = server.execute() rc, out = server.execute()
# yum-config-manager returns 0 always, but returns current setup if succeeds # yum-config-manager returns 0 always, but returns current setup
# if succeeds
match = re.search('enabled\s*\=\s*%(enabled)s' % locals(), out) match = re.search('enabled\s*\=\s*%(enabled)s' % locals(), out)
if match: if match:
return return
@ -428,7 +436,6 @@ def manage_epel(host, config):
logger.warn(msg % host) logger.warn(msg % host)
def manage_rdo(host, config): def manage_rdo(host, config):
""" """
Installs and enables RDO repo on host in case it is installed locally. Installs and enables RDO repo on host in case it is installed locally.
@ -457,7 +464,8 @@ def manage_rdo(host, config):
reponame = 'openstack-%s' % version reponame = 'openstack-%s' % version
server.clear() server.clear()
server.append('yum-config-manager --enable %(reponame)s' % locals()) server.append('yum-config-manager --enable %(reponame)s' % locals())
# yum-config-manager returns 0 always, but returns current setup if succeeds # yum-config-manager returns 0 always, but returns current setup
# if succeeds
rc, out = server.execute() rc, out = server.execute()
match = re.search('enabled\s*=\s*(1|True)', out) match = re.search('enabled\s*=\s*(1|True)', out)
if not match: if not match:
@ -467,14 +475,9 @@ def manage_rdo(host, config):
raise exceptions.ScriptRuntimeError(msg) raise exceptions.ScriptRuntimeError(msg)
def initSequences(controller): #-------------------------- step functions --------------------------
preparesteps = [
{'title': 'Preparing servers', 'functions':[serverprep]}
]
controller.addSequence("Preparing servers", [], [], preparesteps)
def server_prep(config, messages):
def serverprep(config):
rh_username = None rh_username = None
sat_url = None sat_url = None
if is_rhel(): if is_rhel():
@ -489,21 +492,22 @@ def serverprep(config):
sat_flags = [i.strip() for i in flag_list if i.strip()] sat_flags = [i.strip() for i in flag_list if i.strip()]
sat_proxy_user = config.get("CONFIG_SATELLITE_PROXY_USER", '') sat_proxy_user = config.get("CONFIG_SATELLITE_PROXY_USER", '')
sat_proxy_pass = config.get("CONFIG_SATELLITE_PROXY_PW", '') sat_proxy_pass = config.get("CONFIG_SATELLITE_PROXY_PW", '')
sat_args = {'username': config["CONFIG_SATELLITE_USER"].strip(), sat_args = {
'password': config["CONFIG_SATELLITE_PW"].strip(), 'username': config["CONFIG_SATELLITE_USER"].strip(),
'cacert': config["CONFIG_SATELLITE_CACERT"].strip(), 'password': config["CONFIG_SATELLITE_PW"].strip(),
'activation_key': config["CONFIG_SATELLITE_AKEY"].strip(), 'cacert': config["CONFIG_SATELLITE_CACERT"].strip(),
'profile_name': config["CONFIG_SATELLITE_PROFILE"].strip(), 'activation_key': config["CONFIG_SATELLITE_AKEY"].strip(),
'proxy_host': config["CONFIG_SATELLITE_PROXY"].strip(), 'profile_name': config["CONFIG_SATELLITE_PROFILE"].strip(),
'proxy_user': sat_proxy_user.strip(), 'proxy_host': config["CONFIG_SATELLITE_PROXY"].strip(),
'proxy_pass': sat_proxy_pass.strip(), 'proxy_user': sat_proxy_user.strip(),
'flags': sat_flags} 'proxy_pass': sat_proxy_pass.strip(),
'flags': sat_flags
}
for hostname in filtered_hosts(config): for hostname in filtered_hosts(config):
# Subscribe to Red Hat Repositories if configured # Subscribe to Red Hat Repositories if configured
if rh_username: if rh_username:
run_rhsm_reg(hostname, rh_username, rh_password, run_rhsm_reg(hostname, rh_username, rh_password)
config["CONFIG_RH_BETA_REPO"] == 'y')
# Subscribe to RHN Satellite if configured # Subscribe to RHN Satellite if configured
if sat_url and hostname not in sat_registered: if sat_url and hostname not in sat_registered:
@ -524,8 +528,8 @@ def serverprep(config):
server.clear() server.clear()
server.append('yum install -y yum-plugin-priorities || true') server.append('yum install -y yum-plugin-priorities || true')
server.append('rpm -q epel-release && yum-config-manager ' server.append('rpm -q epel-release && yum-config-manager '
'--setopt="%(reponame)s.priority=1" ' '--setopt="%(reponame)s.priority=1" '
'--save %(reponame)s' % locals()) '--save %(reponame)s' % locals())
# Add yum repositories if configured # Add yum repositories if configured
CONFIG_REPO = config["CONFIG_REPO"].strip() CONFIG_REPO = config["CONFIG_REPO"].strip()
@ -533,8 +537,8 @@ def serverprep(config):
for i, repourl in enumerate(CONFIG_REPO.split(',')): for i, repourl in enumerate(CONFIG_REPO.split(',')):
reponame = 'packstack_%d' % i reponame = 'packstack_%d' % i
server.append('echo "[%(reponame)s]\nname=%(reponame)s\n' server.append('echo "[%(reponame)s]\nname=%(reponame)s\n'
'baseurl=%(repourl)s\nenabled=1\n' 'baseurl=%(repourl)s\nenabled=1\n'
'priority=1\ngpgcheck=0"' 'priority=1\ngpgcheck=0"'
' > /etc/yum.repos.d/%(reponame)s.repo' ' > /etc/yum.repos.d/%(reponame)s.repo'
% locals()) % locals())

View File

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
Installs and configures an OpenStack Swift Installs and configures an OpenStack Swift
""" """
@ -13,136 +15,150 @@ from packstack.installer import basedefs
from packstack.installer import utils from packstack.installer import utils
from packstack.installer.utils import split_hosts from packstack.installer.utils import split_hosts
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile, manifestfiles from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile, manifestfiles)
# Controller object will be initialized from main flow
controller = None
# Plugin name #------------------ oVirt installer initialization ------------------
PLUGIN_NAME = "OS-SWIFT"
PLUGIN_NAME = "OS-Swift"
PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject): def initConfig(controller):
global controller params = [
controller = controllerObject {"CMD_OPTION": "os-swift-ks-passwd",
logging.debug("Adding OpenStack Swift configuration") "USAGE": ("The password to use for the Swift to authenticate "
paramsList = [ "with Keystone"),
{"CMD_OPTION" : "os-swift-proxy", "PROMPT": "Enter the password for the Swift Keystone access",
"USAGE" : "The IP address on which to install the Swift proxy service (currently only single proxy is supported)", "OPTION_LIST": [],
"PROMPT" : "Enter the IP address of the Swift proxy service", "VALIDATORS": [validators.validate_not_empty],
"OPTION_LIST" : [], "DEFAULT_VALUE": uuid.uuid4().hex[:16],
"VALIDATORS" : [validators.validate_multi_ip, validators.validate_multi_ssh], "MASK_INPUT": True,
"DEFAULT_VALUE" : utils.get_localhost_ip(), "LOOSE_VALIDATION": False,
"MASK_INPUT" : False, "CONF_NAME": "CONFIG_SWIFT_KS_PW",
"LOOSE_VALIDATION": True, "USE_DEFAULT": True,
"CONF_NAME" : "CONFIG_SWIFT_PROXY_HOSTS", "NEED_CONFIRM": True,
"USE_DEFAULT" : False, "CONDITION": False},
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-ks-passwd",
"USAGE" : "The password to use for the Swift to authenticate with Keystone",
"PROMPT" : "Enter the password for the Swift Keystone access",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_SWIFT_KS_PW",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-storage",
"USAGE" : "A comma separated list of IP addresses on which to install the Swift Storage services, each entry should take the format <ipaddress>[/dev], for example 127.0.0.1/vdb will install /dev/vdb on 127.0.0.1 as a swift storage device(packstack does not create the filesystem, you must do this first), if /dev is omitted Packstack will create a loopback device for a test setup",
"PROMPT" : "Enter the Swift Storage servers e.g. host/dev,host/dev",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty, validate_storage],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_SWIFT_STORAGE_HOSTS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-storage-zones",
"USAGE" : "Number of swift storage zones, this number MUST be no bigger than the number of storage devices configured",
"PROMPT" : "Enter the number of swift storage zones, MUST be no bigger than the number of storage devices configured",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_integer],
"DEFAULT_VALUE" : "1",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_SWIFT_STORAGE_ZONES",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-storage-replicas",
"USAGE" : "Number of swift storage replicas, this number MUST be no bigger than the number of storage zones configured",
"PROMPT" : "Enter the number of swift storage replicas, MUST be no bigger than the number of storage zones configured",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_integer],
"DEFAULT_VALUE" : "1",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_SWIFT_STORAGE_REPLICAS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-storage-fstype",
"USAGE" : "FileSystem type for storage nodes",
"PROMPT" : "Enter FileSystem type for storage nodes",
"OPTION_LIST" : ['xfs','ext4'],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "ext4",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_SWIFT_STORAGE_FSTYPE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-hash",
"USAGE" : "Shared secret for Swift",
"PROMPT" : "Enter hash for Swift shared secret",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_not_empty],
"DEFAULT_VALUE" : uuid.uuid4().hex[:16],
"MASK_INPUT" : True,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_SWIFT_HASH",
"USE_DEFAULT" : True,
"NEED_CONFIRM" : True,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-storage-size",
"USAGE" : "Size of the swift loopback file storage device",
"PROMPT" : "Enter the size of the storage device (eg. 2G, 2000M, 2000000K)",
"OPTION_LIST" : [],
"VALIDATORS" : [validate_storage_size],
"DEFAULT_VALUE" : "2G",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_SWIFT_STORAGE_SIZE",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
] {"CMD_OPTION": "os-swift-storages",
"USAGE": ("A comma separated list of devices which to use as Swift "
"Storage device. Each entry should take the format "
"/path/to/dev, for example /dev/vdb will install /dev/vdb "
"as Swift storage device (packstack does not create "
"the filesystem, you must do this first). If value is "
"omitted Packstack will create a loopback device for test "
"setup"),
"PROMPT": "Enter the Swift Storage devices e.g. /path/to/dev",
"OPTION_LIST": [],
"VALIDATORS": [],
"DEFAULT_VALUE": '',
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_SWIFT_STORAGES",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
groupDict = { "GROUP_NAME" : "OSSWIFT", {"CMD_OPTION": "os-swift-storage-zones",
"DESCRIPTION" : "OpenStack Swift Config parameters", "USAGE": ("Number of swift storage zones, this number MUST be "
"PRE_CONDITION" : "CONFIG_SWIFT_INSTALL", "no bigger than the number of storage devices configured"),
"PRE_CONDITION_MATCH" : "y", "PROMPT": ("Enter the number of swift storage zones, MUST be no "
"POST_CONDITION" : False, "bigger than the number of storage devices configured"),
"POST_CONDITION_MATCH" : True} "OPTION_LIST": [],
"VALIDATORS": [validators.validate_integer],
"DEFAULT_VALUE": "1",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_SWIFT_STORAGE_ZONES",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "os-swift-storage-replicas",
"USAGE": ("Number of swift storage replicas, this number MUST be "
"no bigger than the number of storage zones configured"),
"PROMPT": ("Enter the number of swift storage replicas, MUST be no "
"bigger than the number of storage zones configured"),
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_integer],
"DEFAULT_VALUE": "1",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_SWIFT_STORAGE_REPLICAS",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "os-swift-storage-fstype",
"USAGE": "FileSystem type for storage nodes",
"PROMPT": "Enter FileSystem type for storage nodes",
"OPTION_LIST": ['xfs', 'ext4'],
"VALIDATORS": [validators.validate_options],
"DEFAULT_VALUE": "ext4",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_SWIFT_STORAGE_FSTYPE",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "os-swift-hash",
"USAGE": "Shared secret for Swift",
"PROMPT": "Enter hash for Swift shared secret",
"OPTION_LIST": [],
"VALIDATORS": [validators.validate_not_empty],
"DEFAULT_VALUE": uuid.uuid4().hex[:16],
"MASK_INPUT": True,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_SWIFT_HASH",
"USE_DEFAULT": True,
"NEED_CONFIRM": True,
"CONDITION": False},
{"CMD_OPTION": "os-swift-storage-size",
"USAGE": "Size of the swift loopback file storage device",
"PROMPT": ("Enter the size of the storage device (eg. 2G, 2000M, "
"2000000K)"),
"OPTION_LIST": [],
"VALIDATORS": [validate_storage_size],
"DEFAULT_VALUE": "2G",
"MASK_INPUT": False,
"LOOSE_VALIDATION": True,
"CONF_NAME": "CONFIG_SWIFT_STORAGE_SIZE",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
]
group = {"GROUP_NAME": "OSSWIFT",
"DESCRIPTION": "OpenStack Swift Config parameters",
"PRE_CONDITION": "CONFIG_SWIFT_INSTALL",
"PRE_CONDITION_MATCH": "y",
"POST_CONDITION": False,
"POST_CONDITION_MATCH": True}
controller.addGroup(group, params)
controller.addGroup(groupDict, paramsList) def initSequences(controller):
if controller.CONF['CONFIG_SWIFT_INSTALL'] != 'y':
return
steps = [
{'title': 'Adding Swift Keystone manifest entries',
'functions': [create_keystone_manifest]},
{'title': 'Adding Swift builder manifest entries',
'functions': [create_builder_manifest]},
{'title': 'Adding Swift proxy manifest entries',
'functions': [create_proxy_manifest]},
{'title': 'Adding Swift storage manifest entries',
'functions': [create_storage_manifest]},
{'title': 'Adding Swift common manifest entries',
'functions': [create_common_manifest]},
]
controller.addSequence("Installing OpenStack Swift", [], [], steps)
def validate_storage(param, options=None): #------------------------- helper functions -------------------------
for host in param.split(','):
host = host.split('/', 1)[0]
validators.validate_ip(host.strip(), options)
def validate_storage_size(param, options=None): def validate_storage_size(param, options=None):
match = re.match(r'\d+G|\d+M|\d+K', param, re.IGNORECASE) match = re.match(r'\d+G|\d+M|\d+K', param, re.IGNORECASE)
@ -150,78 +166,28 @@ def validate_storage_size(param, options=None):
msg = 'Storage size not have a valid value (eg. 1G, 1000M, 1000000K)' msg = 'Storage size not have a valid value (eg. 1G, 1000M, 1000000K)'
raise ParamValidationError(msg) raise ParamValidationError(msg)
def initSequences(controller):
if controller.CONF['CONFIG_SWIFT_INSTALL'] != 'y':
return
steps = [ def parse_devices(config):
{'title': 'Adding Swift Keystone manifest entries', 'functions':[createkeystonemanifest]},
{'title': 'Adding Swift builder manifest entries', 'functions':[createbuildermanifest]},
{'title': 'Adding Swift proxy manifest entries', 'functions':[createproxymanifest]},
{'title': 'Adding Swift storage manifest entries', 'functions':[createstoragemanifest]},
{'title': 'Adding Swift common manifest entries', 'functions':[createcommonmanifest]},
]
controller.addSequence("Installing OpenStack Swift", [], [], steps)
def createkeystonemanifest(config):
manifestfile = "%s_keystone.pp"%controller.CONF['CONFIG_KEYSTONE_HOST']
controller.CONF['CONFIG_SWIFT_PROXY'] = controller.CONF['CONFIG_SWIFT_PROXY_HOSTS'].split(',')[0]
manifestdata = getManifestTemplate("keystone_swift.pp")
appendManifestFile(manifestfile, manifestdata)
devices = []
def parse_devices(config_swift_storage_hosts):
""" """
Returns dict containing information about Swift storage devices. Returns dict containing information about Swift storage devices.
""" """
devices = []
device_number = 0 device_number = 0
num_zones = int(controller.CONF["CONFIG_SWIFT_STORAGE_ZONES"]) num_zones = int(config["CONFIG_SWIFT_STORAGE_ZONES"])
for host in config_swift_storage_hosts.split(","): for device in config["CONFIG_SWIFT_STORAGES"].split(","):
host = host.strip() device = device.strip()
if not device:
continue
device_number += 1 device_number += 1
device = None
if '/' in host:
host, device = map(lambda x: x.strip(), host.split('/', 1))
zone = str((device_number % num_zones) + 1) zone = str((device_number % num_zones) + 1)
devices.append({'host': host, 'device': device, 'zone': zone, devices.append({'device': device, 'zone': zone,
'device_name': 'device%s' % device_number}) 'device_name': 'device%s' % device_number})
if not devices:
devices.append({'device': None, 'zone': 1,
'device_name': 'swiftloopback'})
return devices return devices
# The ring file should be built and distributed befor the storage services
# come up. Specifically the replicator crashes if the ring isn't present
def createbuildermanifest(config):
# TODO : put this on the proxy server, will need to change this later
controller.CONF['CONFIG_SWIFT_BUILDER_HOST'] = controller.CONF['CONFIG_SWIFT_PROXY_HOSTS'].split(',')[0]
manifestfile = "%s_ring_swift.pp"%controller.CONF['CONFIG_SWIFT_BUILDER_HOST']
manifestdata = getManifestTemplate("swift_builder.pp")
# Add each device to the ring
devicename = 0
for device in parse_devices(controller.CONF["CONFIG_SWIFT_STORAGE_HOSTS"]):
host = device['host']
devicename = device['device_name']
zone = device['zone']
manifestdata = manifestdata + '\n@@ring_object_device { "%s:6000/%s":\n zone => %s,\n weight => 10, }'%(host, devicename, zone)
manifestdata = manifestdata + '\n@@ring_container_device { "%s:6001/%s":\n zone => %s,\n weight => 10, }'%(host, devicename, zone)
manifestdata = manifestdata + '\n@@ring_account_device { "%s:6002/%s":\n zone => %s,\n weight => 10, }'%(host, devicename, zone)
appendManifestFile(manifestfile, manifestdata, 'swiftbuilder')
def createproxymanifest(config):
manifestfile = "%s_swift.pp"%controller.CONF['CONFIG_SWIFT_PROXY_HOSTS']
manifestdata = getManifestTemplate("swift_proxy.pp")
# If the proxy server is also a storage server then swift::ringsync will be included for the storage server
if controller.CONF['CONFIG_SWIFT_PROXY_HOSTS'] not in [h['host'] for h in devices]:
manifestdata += 'swift::ringsync{["account","container","object"]:\n ring_server => "%s"\n}'%controller.CONF['CONFIG_SWIFT_BUILDER_HOST']
appendManifestFile(manifestfile, manifestdata)
def check_device(host, device): def check_device(host, device):
""" """
Raises ScriptRuntimeError if given device is not mounted on given Raises ScriptRuntimeError if given device is not mounted on given
@ -230,62 +196,102 @@ def check_device(host, device):
server = utils.ScriptRunner(host) server = utils.ScriptRunner(host)
# the device MUST exist # the device MUST exist
cmd = 'ls -l /dev/%s' cmd = 'ls -l %s'
server.append(cmd % device) server.append(cmd % device)
# if it is not mounted then we can use it # if it is not mounted then we can use it
cmd = 'grep "/dev/%s " /proc/self/mounts || exit 0' cmd = 'grep "%s " /proc/self/mounts || exit 0'
server.append(cmd % device) server.append(cmd % device)
# if it is mounted then the mount point has to be in /srv/node # if it is mounted then the mount point has to be in /srv/node
cmd = 'grep "/dev/%s /srv/node" /proc/self/mounts && exit 0' cmd = 'grep "%s /srv/node" /proc/self/mounts && exit 0'
server.append(cmd % device) server.append(cmd % device)
# if we got here without exiting then we can't use this device # if we got here without exiting then we can't use this device
server.append('exit 1') server.append('exit 1')
server.execute() server.execute()
return False
def get_storage_size(size):
def get_storage_size(config):
ranges = {'G': 1048576, 'M': 1024, 'K': 1} ranges = {'G': 1048576, 'M': 1024, 'K': 1}
size.strip() size = config['CONFIG_SWIFT_STORAGE_SIZE'].strip()
for measure in ['G', 'M', 'K']: for measure in ['G', 'M', 'K']:
if re.match('\d+' + measure, size, re.IGNORECASE): if re.match('\d+' + measure, size, re.IGNORECASE):
intsize = int(size.rstrip(measure)) * ranges[measure] intsize = int(size.rstrip(measure)) * ranges[measure]
return intsize return intsize
def createstoragemanifest(config):
# this need to happen once per storage host #-------------------------- step functions --------------------------
for host in set([device['host'] for device in devices]):
controller.CONF["CONFIG_SWIFT_STORAGE_CURRENT"] = host def create_keystone_manifest(config, messages):
manifestfile = "%s_swift.pp"%host # parse devices in first step
manifestdata = getManifestTemplate("swift_storage.pp") global devices
appendManifestFile(manifestfile, manifestdata) devices = parse_devices(config)
manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("keystone_swift.pp")
appendManifestFile(manifestfile, manifestdata)
def create_builder_manifest(config, messages):
global devices
# The ring file should be built and distributed before the storage services
# come up. Specifically the replicator crashes if the ring isn't present
def device_def(dev_type, host, dev_port, devicename, zone):
fmt = ('\n@@%s { "%s:%s/%s":\n'
' zone => %s,\n'
' weight => 10, }\n')
return fmt % (dev_type, host, dev_port, devicename, zone)
manifestfile = "%s_ring_swift.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("swift_builder.pp")
# Add each device to the ring
devicename = 0
for device in devices:
host = config['CONFIG_CONTROLLER_HOST']
devicename = device['device_name']
zone = device['zone']
for dev_type, dev_port in [('ring_object_device', 6000),
('ring_container_device', 6001),
('ring_account_device', 6002)]:
manifestdata += device_def(dev_type, host, dev_port, devicename,
zone)
appendManifestFile(manifestfile, manifestdata, 'swiftbuilder')
def create_proxy_manifest(config, messages):
manifestfile = "%s_swift.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("swift_proxy.pp")
appendManifestFile(manifestfile, manifestdata)
def create_storage_manifest(config, messages):
global devices
manifestfile = "%s_swift.pp" % config['CONFIG_CONTROLLER_HOST']
manifestdata = getManifestTemplate("swift_storage.pp")
# this need to happen once per storage device # this need to happen once per storage device
for device in devices: for device in devices:
host = device['host'] host = config['CONFIG_CONTROLLER_HOST']
devicename = device['device_name'] devicename = device['device_name']
device = device['device'] device = device['device']
fstype = config["CONFIG_SWIFT_STORAGE_FSTYPE"]
if device: if device:
check_device(host, device) check_device(host, device)
manifestdata += ('\nswift::storage::%s { "%s":\n'
manifestfile = "%s_swift.pp"%host ' device => "%s",\n}\n'
if device: % (fstype, devicename, device))
manifestdata = "\n" + 'swift::storage::%s{"%s":\n device => "/dev/%s",\n}'% (controller.CONF["CONFIG_SWIFT_STORAGE_FSTYPE"], devicename, device)
else: else:
config['SWIFT_STORAGE_SEEK'] = get_storage_size(config['CONFIG_SWIFT_STORAGE_SIZE']) # create loopback device if none was specified
controller.CONF["SWIFT_STORAGE_DEVICES"] = "'%s'"%devicename config['CONFIG_SWIFT_STORAGE_SEEK'] = get_storage_size(config)
manifestdata = "\n" + getManifestTemplate("swift_loopback.pp") manifestdata += "\n" + getManifestTemplate("swift_loopback.pp")
appendManifestFile(manifestfile, manifestdata)
# set allowed hosts for firewall # set allowed hosts for firewall
swift_hosts = get_swift_hosts(config) hosts = set([config['CONFIG_CONTROLLER_HOST']])
hosts = swift_hosts.copy()
manifestdata = ""
if config['CONFIG_NOVA_INSTALL'] == 'y': if config['CONFIG_NOVA_INSTALL'] == 'y':
hosts |= split_hosts(config['CONFIG_NOVA_COMPUTE_HOSTS']) hosts |= split_hosts(config['CONFIG_COMPUTE_HOSTS'])
config['FIREWALL_SERVICE_NAME'] = "swift storage and rsync" config['FIREWALL_SERVICE_NAME'] = "swift storage and rsync"
config['FIREWALL_PORTS'] = "'6000', '6001', '6002', '873'" config['FIREWALL_PORTS'] = "'6000', '6001', '6002', '873'"
@ -296,22 +302,11 @@ def createstoragemanifest(config):
config['FIREWALL_SERVICE_ID'] = "swift_storage_and_rsync_%s" % host config['FIREWALL_SERVICE_ID'] = "swift_storage_and_rsync_%s" % host
manifestdata += getManifestTemplate("firewall.pp") manifestdata += getManifestTemplate("firewall.pp")
for host in swift_hosts: appendManifestFile(manifestfile, manifestdata)
manifestfile = "%s_swift.pp" % host
appendManifestFile(manifestfile, manifestdata)
def createcommonmanifest(config): def create_common_manifest(config, messages):
for manifestfile, marker in manifestfiles.getFiles(): for manifestfile, marker in manifestfiles.getFiles():
if manifestfile.endswith("_swift.pp"): if manifestfile.endswith("_swift.pp"):
data = getManifestTemplate("swift_common.pp") data = getManifestTemplate("swift_common.pp")
appendManifestFile(os.path.split(manifestfile)[1], data) appendManifestFile(os.path.split(manifestfile)[1], data)
def get_swift_hosts(config):
"""Get a set of all the Swift hosts"""
hosts = split_hosts(config['CONFIG_SWIFT_STORAGE_HOSTS'])
# remove "/device" from the storage host names
hosts = set(host.split('/', 1)[0] for host in hosts)
hosts |= split_hosts(config['CONFIG_SWIFT_PROXY_HOSTS'])
return hosts

View File

@ -1,4 +1,4 @@
$amqp = '%(CONFIG_AMQP_SERVER)s' $amqp = '%(CONFIG_AMQP_BACKEND)s'
case $amqp { case $amqp {
'qpid': { 'qpid': {
enable_qpid {"qpid": enable_qpid {"qpid":

View File

@ -6,7 +6,7 @@ class { 'ceilometer::collector':
} }
class { 'ceilometer::agent::auth': class { 'ceilometer::agent::auth':
auth_url => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', auth_url => 'http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0',
auth_password => '%(CONFIG_CEILOMETER_KS_PW)s', auth_password => '%(CONFIG_CEILOMETER_KS_PW)s',
} }
@ -20,6 +20,6 @@ class { 'ceilometer::alarm::evaluator':
} }
class { 'ceilometer::api': class { 'ceilometer::api':
keystone_host => '%(CONFIG_KEYSTONE_HOST)s', keystone_host => '%(CONFIG_CONTROLLER_HOST)s',
keystone_password => '%(CONFIG_CEILOMETER_KS_PW)s', keystone_password => '%(CONFIG_CEILOMETER_KS_PW)s',
} }

View File

@ -1,5 +1,5 @@
cinder_config { cinder_config {
"DEFAULT/glance_host": value => "%(CONFIG_GLANCE_HOST)s"; "DEFAULT/glance_host": value => "%(CONFIG_CONTROLLER_HOST)s";
} }
package {'python-keystone': package {'python-keystone':
@ -10,7 +10,7 @@ class {'cinder::api':
keystone_password => '%(CONFIG_CINDER_KS_PW)s', keystone_password => '%(CONFIG_CINDER_KS_PW)s',
keystone_tenant => "services", keystone_tenant => "services",
keystone_user => "cinder", keystone_user => "cinder",
keystone_auth_host => "%(CONFIG_KEYSTONE_HOST)s", keystone_auth_host => "%(CONFIG_CONTROLLER_HOST)s",
} }
class {'cinder::scheduler': class {'cinder::scheduler':
@ -20,5 +20,5 @@ class {'cinder::volume':
} }
class {'cinder::volume::iscsi': class {'cinder::volume::iscsi':
iscsi_ip_address => '%(CONFIG_CINDER_HOST)s' iscsi_ip_address => '%(CONFIG_CONTROLLER_HOST)s'
} }

View File

@ -2,7 +2,7 @@ class {'cinder::backup':
} }
class {'cinder::backup::swift': class {'cinder::backup::swift':
backup_swift_url => 'http://%(CONFIG_SWIFT_PROXY)s:8080/v1/AUTH_' backup_swift_url => 'http://%(CONFIG_CONTROLLER_HOST)s:8080/v1/AUTH_'
} }
Class['cinder::api'] ~> Service['cinder-backup'] Class['cinder::api'] ~> Service['cinder-backup']

View File

@ -1,6 +1,6 @@
class {"glance::api": class {"glance::api":
auth_host => "%(CONFIG_KEYSTONE_HOST)s", auth_host => "%(CONFIG_CONTROLLER_HOST)s",
keystone_tenant => "services", keystone_tenant => "services",
keystone_user => "glance", keystone_user => "glance",
keystone_password => "%(CONFIG_GLANCE_KS_PW)s", keystone_password => "%(CONFIG_GLANCE_KS_PW)s",
@ -13,7 +13,7 @@ class {"glance::api":
class { 'glance::backend::file': } class { 'glance::backend::file': }
class {"glance::registry": class {"glance::registry":
auth_host => "%(CONFIG_KEYSTONE_HOST)s", auth_host => "%(CONFIG_CONTROLLER_HOST)s",
keystone_tenant => "services", keystone_tenant => "services",
keystone_user => "glance", keystone_user => "glance",
keystone_password => "%(CONFIG_GLANCE_KS_PW)s", keystone_password => "%(CONFIG_GLANCE_KS_PW)s",

View File

@ -1,9 +1,10 @@
class { 'heat::api': class { 'heat::api':
} }
class { 'heat::engine': class { 'heat::engine':
heat_metadata_server_url => 'http://%(CONFIG_HEAT_METADATA_HOST)s:8000', heat_metadata_server_url => 'http://%(CONFIG_CONTROLLER_HOST)s:8000',
heat_waitcondition_server_url => 'http://%(CONFIG_HEAT_METADATA_HOST)s:8000/v1/waitcondition', heat_waitcondition_server_url => 'http://%(CONFIG_CONTROLLER_HOST)s:8000/v1/waitcondition',
heat_watch_server_url => 'http://%(CONFIG_HEAT_WATCH_HOST)s:8003', heat_watch_server_url => 'http://%(CONFIG_CONTROLLER_HOST)s:8003',
auth_encryption_key => '%(CONFIG_HEAT_AUTH_ENC_KEY)s', auth_encryption_key => '%(CONFIG_HEAT_AUTH_ENC_KEY)s',
} }

View File

@ -1,2 +1,3 @@
class { 'heat::api_cfn': class { 'heat::api_cfn':
} }

View File

@ -1,2 +1,3 @@
class { 'heat::api_cloudwatch': class { 'heat::api_cloudwatch':
} }

View File

@ -1,7 +1,7 @@
class { 'heat': class { 'heat':
keystone_host => '%(CONFIG_KEYSTONE_HOST)s', keystone_host => '%(CONFIG_CONTROLLER_HOST)s',
keystone_password => '%(CONFIG_HEAT_KS_PW)s', keystone_password => '%(CONFIG_HEAT_KS_PW)s',
auth_uri => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', auth_uri => 'http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0',
rpc_backend => 'heat.openstack.common.rpc.impl_qpid', rpc_backend => 'heat.openstack.common.rpc.impl_qpid',
qpid_hostname => '%(CONFIG_AMQP_HOST)s', qpid_hostname => '%(CONFIG_AMQP_HOST)s',
qpid_username => '%(CONFIG_AMQP_AUTH_USER)s', qpid_username => '%(CONFIG_AMQP_AUTH_USER)s',

View File

@ -1,7 +1,7 @@
class { 'heat': class { 'heat':
keystone_host => '%(CONFIG_KEYSTONE_HOST)s', keystone_host => '%(CONFIG_CONTROLLER_HOST)s',
keystone_password => '%(CONFIG_HEAT_KS_PW)s', keystone_password => '%(CONFIG_HEAT_KS_PW)s',
auth_uri => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', auth_uri => 'http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0',
rpc_backend => 'heat.openstack.common.rpc.impl_kombu', rpc_backend => 'heat.openstack.common.rpc.impl_kombu',
rabbit_host => '%(CONFIG_AMQP_HOST)s', rabbit_host => '%(CONFIG_AMQP_HOST)s',
rabbit_userid => '%(CONFIG_AMQP_AUTH_USER)s', rabbit_userid => '%(CONFIG_AMQP_AUTH_USER)s',

View File

@ -9,9 +9,9 @@ package {$horizon_packages:
class {'horizon': class {'horizon':
secret_key => '%(CONFIG_HORIZON_SECRET_KEY)s', secret_key => '%(CONFIG_HORIZON_SECRET_KEY)s',
keystone_host => '%(CONFIG_KEYSTONE_HOST)s', keystone_host => '%(CONFIG_CONTROLLER_HOST)s',
keystone_default_role => '_member_', keystone_default_role => '_member_',
fqdn => ['%(CONFIG_HORIZON_HOST)s', "$::fqdn", 'localhost'], fqdn => ['%(CONFIG_CONTROLLER_HOST)s', "$::fqdn", 'localhost'],
can_set_mount_point => 'False', can_set_mount_point => 'False',
help_url =>'http://docs.openstack.org', help_url =>'http://docs.openstack.org',
django_debug => %(CONFIG_DEBUG_MODE)s ? {true => 'True', false => 'False'}, django_debug => %(CONFIG_DEBUG_MODE)s ? {true => 'True', false => 'False'},

View File

@ -14,9 +14,9 @@ class {"keystone::roles::admin":
} }
class {"keystone::endpoint": class {"keystone::endpoint":
public_address => "%(CONFIG_KEYSTONE_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_KEYSTONE_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_KEYSTONE_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
} }
# Run token flush every minute (without output so we won't spam admins) # Run token flush every minute (without output so we won't spam admins)

View File

@ -1,7 +1,7 @@
class { 'ceilometer::keystone::auth': class { 'ceilometer::keystone::auth':
password => '%(CONFIG_CEILOMETER_KS_PW)s', password => '%(CONFIG_CEILOMETER_KS_PW)s',
public_address => "%(CONFIG_CEILOMETER_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_CEILOMETER_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_CEILOMETER_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
} }

View File

@ -1,9 +1,9 @@
class {"cinder::keystone::auth": class {"cinder::keystone::auth":
password => "%(CONFIG_CINDER_KS_PW)s", password => "%(CONFIG_CINDER_KS_PW)s",
public_address => "%(CONFIG_CINDER_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_CINDER_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_CINDER_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
} }
keystone_service { "${cinder::keystone::auth::auth_name}_v2": keystone_service { "${cinder::keystone::auth::auth_name}_v2":

View File

@ -1,7 +1,7 @@
class {"glance::keystone::auth": class {"glance::keystone::auth":
password => "%(CONFIG_GLANCE_KS_PW)s", password => "%(CONFIG_GLANCE_KS_PW)s",
public_address => "%(CONFIG_GLANCE_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_GLANCE_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_GLANCE_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
} }

View File

@ -1,17 +1,17 @@
# heat::keystone::auth # heat::keystone::auth
class {"heat::keystone::auth": class {"heat::keystone::auth":
password => "%(CONFIG_HEAT_KS_PW)s", password => "%(CONFIG_HEAT_KS_PW)s",
public_address => "%(CONFIG_HEAT_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_HEAT_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_HEAT_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
} }
if '%(CONFIG_HEAT_CFN_INSTALL)s' == 'y' { if '%(CONFIG_HEAT_CFN_INSTALL)s' == 'y' {
# heat::keystone::cfn # heat::keystone::cfn
class {"heat::keystone::auth_cfn": class {"heat::keystone::auth_cfn":
password => "%(CONFIG_HEAT_KS_PW)s", password => "%(CONFIG_HEAT_KS_PW)s",
public_address => "%(CONFIG_HEAT_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_HEAT_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_HEAT_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
} }
} }

View File

@ -1,7 +1,7 @@
class {"neutron::keystone::auth": class {"neutron::keystone::auth":
password => "%(CONFIG_NEUTRON_KS_PW)s", password => "%(CONFIG_NEUTRON_KS_PW)s",
public_address => "%(CONFIG_NEUTRON_SERVER_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_NEUTRON_SERVER_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_NEUTRON_SERVER_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
} }

View File

@ -1,8 +1,8 @@
class {"nova::keystone::auth": class {"nova::keystone::auth":
password => "%(CONFIG_NOVA_KS_PW)s", password => "%(CONFIG_NOVA_KS_PW)s",
public_address => "%(CONFIG_NOVA_API_HOST)s", public_address => "%(CONFIG_CONTROLLER_HOST)s",
admin_address => "%(CONFIG_NOVA_API_HOST)s", admin_address => "%(CONFIG_CONTROLLER_HOST)s",
internal_address => "%(CONFIG_NOVA_API_HOST)s", internal_address => "%(CONFIG_CONTROLLER_HOST)s",
cinder => true, cinder => true,
} }

View File

@ -1,4 +1,4 @@
class { 'swift::keystone::auth': class { 'swift::keystone::auth':
public_address => '%(CONFIG_SWIFT_PROXY)s', public_address => '%(CONFIG_CONTROLLER_HOST)s',
password => '%(CONFIG_SWIFT_KS_PW)s', password => '%(CONFIG_SWIFT_KS_PW)s',
} }

View File

@ -15,7 +15,7 @@ class nagios_configs(){
file_line{'allowed_hosts': file_line{'allowed_hosts':
path => '/etc/nagios/nrpe.cfg', path => '/etc/nagios/nrpe.cfg',
match => 'allowed_hosts=', match => 'allowed_hosts=',
line => 'allowed_hosts=%(CONFIG_NAGIOS_HOST)s', line => 'allowed_hosts=%(CONFIG_CONTROLLER_HOST)s',
} }
# 5 minute load average # 5 minute load average
@ -41,5 +41,3 @@ service{'nrpe':
enable => true, enable => true,
hasstatus => true, hasstatus => true,
} }

View File

@ -46,7 +46,7 @@ class nagios_configs(){
content => "export OS_USERNAME=admin content => "export OS_USERNAME=admin
export OS_TENANT_NAME=admin export OS_TENANT_NAME=admin
export OS_PASSWORD=%(CONFIG_KEYSTONE_ADMIN_PW)s export OS_PASSWORD=%(CONFIG_KEYSTONE_ADMIN_PW)s
export OS_AUTH_URL=http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0/ ",} export OS_AUTH_URL=http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0/ ",}
%(CONFIG_NAGIOS_MANIFEST_CONFIG)s %(CONFIG_NAGIOS_MANIFEST_CONFIG)s
} }

View File

@ -2,7 +2,7 @@ class { 'neutron::server':
sql_connection => $neutron_sql_connection, sql_connection => $neutron_sql_connection,
connection => $neutron_sql_connection, connection => $neutron_sql_connection,
auth_password => $neutron_user_password, auth_password => $neutron_user_password,
auth_host => '%(CONFIG_KEYSTONE_HOST)s', auth_host => '%(CONFIG_CONTROLLER_HOST)s',
enabled => true, enabled => true,
} }

View File

@ -1,6 +1,6 @@
class {'neutron::agents::metadata': class {'neutron::agents::metadata':
auth_password => '%(CONFIG_NEUTRON_KS_PW)s', auth_password => '%(CONFIG_NEUTRON_KS_PW)s',
auth_url => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', auth_url => 'http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0',
shared_secret => '%(CONFIG_NEUTRON_METADATA_PW)s', shared_secret => '%(CONFIG_NEUTRON_METADATA_PW)s',
metadata_ip => '%(CONFIG_NOVA_API_HOST)s', metadata_ip => '%(CONFIG_CONTROLLER_HOST)s',
} }

View File

@ -3,7 +3,6 @@ class { 'neutron::server::notifications':
nova_admin_username => 'nova', nova_admin_username => 'nova',
nova_admin_password => '%(CONFIG_NOVA_KS_PW)s', nova_admin_password => '%(CONFIG_NOVA_KS_PW)s',
nova_admin_tenant_name => 'services', nova_admin_tenant_name => 'services',
nova_url => 'http://%(CONFIG_NOVA_API_HOST)s:8774/v2', nova_url => 'http://%(CONFIG_CONTROLLER_HOST)s:8774/v2',
nova_admin_auth_url => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', nova_admin_auth_url => 'http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0',
} }

View File

@ -2,7 +2,7 @@
require 'keystone::python' require 'keystone::python'
class {"nova::api": class {"nova::api":
enabled => true, enabled => true,
auth_host => "%(CONFIG_KEYSTONE_HOST)s", auth_host => "%(CONFIG_CONTROLLER_HOST)s",
admin_password => "%(CONFIG_NOVA_KS_PW)s", admin_password => "%(CONFIG_NOVA_KS_PW)s",
neutron_metadata_proxy_shared_secret => %(CONFIG_NEUTRON_METADATA_PW_UNQUOTED)s neutron_metadata_proxy_shared_secret => %(CONFIG_NEUTRON_METADATA_PW_UNQUOTED)s
} }

View File

@ -1,6 +1,6 @@
class { 'ceilometer::agent::auth': class { 'ceilometer::agent::auth':
auth_url => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', auth_url => 'http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0',
auth_password => '%(CONFIG_CEILOMETER_KS_PW)s', auth_password => '%(CONFIG_CEILOMETER_KS_PW)s',
} }

View File

@ -5,7 +5,5 @@ Firewall <| |> -> Class['nova']
nova_config{ nova_config{
"DEFAULT/sql_connection": value => "%(CONFIG_NOVA_SQL_CONN)s"; "DEFAULT/sql_connection": value => "%(CONFIG_NOVA_SQL_CONN)s";
"DEFAULT/metadata_host": value => "%(CONFIG_NOVA_METADATA_HOST)s"; "DEFAULT/metadata_host": value => "%(CONFIG_CONTROLLER_HOST)s";
} }

View File

@ -1,6 +1,6 @@
class { "nova": class { "nova":
glance_api_servers => "%(CONFIG_GLANCE_HOST)s:9292", glance_api_servers => "%(CONFIG_CONTROLLER_HOST)s:9292",
qpid_hostname => "%(CONFIG_AMQP_HOST)s", qpid_hostname => "%(CONFIG_AMQP_HOST)s",
qpid_username => '%(CONFIG_AMQP_AUTH_USER)s', qpid_username => '%(CONFIG_AMQP_AUTH_USER)s',
qpid_password => '%(CONFIG_AMQP_AUTH_PASSWORD)s', qpid_password => '%(CONFIG_AMQP_AUTH_PASSWORD)s',

View File

@ -1,6 +1,6 @@
class { "nova": class { "nova":
glance_api_servers => "%(CONFIG_GLANCE_HOST)s:9292", glance_api_servers => "%(CONFIG_CONTROLLER_HOST)s:9292",
rabbit_host => "%(CONFIG_AMQP_HOST)s", rabbit_host => "%(CONFIG_AMQP_HOST)s",
rabbit_port => '%(CONFIG_AMQP_CLIENTS_PORT)s', rabbit_port => '%(CONFIG_AMQP_CLIENTS_PORT)s',
rabbit_userid => '%(CONFIG_AMQP_AUTH_USER)s', rabbit_userid => '%(CONFIG_AMQP_AUTH_USER)s',

View File

@ -26,7 +26,7 @@ nova_config{
class {"nova::compute": class {"nova::compute":
enabled => true, enabled => true,
vncproxy_host => "%(CONFIG_NOVA_VNCPROXY_HOST)s", vncproxy_host => "%(CONFIG_CONTROLLER_HOST)s",
vncserver_proxyclient_address => "%(CONFIG_NOVA_COMPUTE_HOST)s", vncserver_proxyclient_address => "%(CONFIG_NOVA_COMPUTE_HOST)s",
} }

View File

@ -2,9 +2,9 @@
class {"nova::network::neutron": class {"nova::network::neutron":
neutron_admin_password => "%(CONFIG_NEUTRON_KS_PW)s", neutron_admin_password => "%(CONFIG_NEUTRON_KS_PW)s",
neutron_auth_strategy => "keystone", neutron_auth_strategy => "keystone",
neutron_url => "http://%(CONFIG_NEUTRON_SERVER_HOST)s:9696", neutron_url => "http://%(CONFIG_CONTROLLER_HOST)s:9696",
neutron_admin_tenant_name => "services", neutron_admin_tenant_name => "services",
neutron_admin_auth_url => "http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0", neutron_admin_auth_url => "http://%(CONFIG_CONTROLLER_HOST)s:35357/v2.0",
} }
class {"nova::compute::neutron": class {"nova::compute::neutron":

View File

@ -8,7 +8,7 @@ package { $clientlibs: }
$rcadmin_content = "export OS_USERNAME=admin $rcadmin_content = "export OS_USERNAME=admin
export OS_TENANT_NAME=admin export OS_TENANT_NAME=admin
export OS_PASSWORD=%(CONFIG_KEYSTONE_ADMIN_PW)s export OS_PASSWORD=%(CONFIG_KEYSTONE_ADMIN_PW)s
export OS_AUTH_URL=http://%(CONFIG_KEYSTONE_HOST)s:5000/v2.0/ export OS_AUTH_URL=http://%(CONFIG_CONTROLLER_HOST)s:5000/v2.0/
export PS1='[\\u@\\h \\W(keystone_admin)]\\$ ' export PS1='[\\u@\\h \\W(keystone_admin)]\\$ '
" "
@ -25,7 +25,7 @@ if '%(CONFIG_PROVISION_DEMO)s' == 'y' {
content => "export OS_USERNAME=demo content => "export OS_USERNAME=demo
export OS_TENANT_NAME=demo export OS_TENANT_NAME=demo
export OS_PASSWORD=%(CONFIG_KEYSTONE_DEMO_PW)s export OS_PASSWORD=%(CONFIG_KEYSTONE_DEMO_PW)s
export OS_AUTH_URL=http://%(CONFIG_KEYSTONE_HOST)s:5000/v2.0/ export OS_AUTH_URL=http://%(CONFIG_CONTROLLER_HOST)s:5000/v2.0/
export PS1='[\\u@\\h \\W(keystone_demo)]\\$ ' export PS1='[\\u@\\h \\W(keystone_demo)]\\$ '
", ",
} }

View File

@ -8,11 +8,7 @@ class { 'swift::ringbuilder':
# sets up an rsync db that can be used to sync the ring DB # sets up an rsync db that can be used to sync the ring DB
class { 'swift::ringserver': class { 'swift::ringserver':
local_net_ip => "%(CONFIG_SWIFT_BUILDER_HOST)s", local_net_ip => "%(CONFIG_CONTROLLER_HOST)s",
}
@@swift::ringsync { ['account', 'object', 'container']:
ring_server => $swift_local_net_ip
} }
if ($::selinux != "false"){ if ($::selinux != "false"){

View File

@ -1,10 +1,8 @@
swift::storage::loopback { [%(SWIFT_STORAGE_DEVICES)s]: swift::storage::loopback { 'swift_loopback':
base_dir => '/srv/loopback-device', base_dir => '/srv/loopback-device',
mnt_base_dir => '/srv/node', mnt_base_dir => '/srv/node',
require => Class['swift'], require => Class['swift'],
fstype => '%(CONFIG_SWIFT_STORAGE_FSTYPE)s', fstype => '%(CONFIG_SWIFT_STORAGE_FSTYPE)s',
seek => '%(SWIFT_STORAGE_SEEK)s', seek => '%(CONFIG_SWIFT_STORAGE_SEEK)s',
} }

View File

@ -5,7 +5,7 @@ class { 'memcached':
} }
class { 'swift::proxy': class { 'swift::proxy':
proxy_local_net_ip => '%(CONFIG_SWIFT_PROXY)s', proxy_local_net_ip => '%(CONFIG_CONTROLLER_HOST)s',
pipeline => [ pipeline => [
'bulk', 'bulk',
'catch_errors', 'catch_errors',
@ -62,7 +62,7 @@ class { 'swift::proxy::authtoken':
admin_tenant_name => 'services', admin_tenant_name => 'services',
admin_password => '%(CONFIG_SWIFT_KS_PW)s', admin_password => '%(CONFIG_SWIFT_KS_PW)s',
# assume that the controller host is the swift api server # assume that the controller host is the swift api server
auth_host => '%(CONFIG_KEYSTONE_HOST)s', auth_host => '%(CONFIG_CONTROLLER_HOST)s',
} }
firewall { '001 swift proxy incoming': firewall { '001 swift proxy incoming':

View File

@ -1,7 +1,7 @@
# install all swift storage servers together # install all swift storage servers together
class { 'swift::storage::all': class { 'swift::storage::all':
storage_local_net_ip => '%(CONFIG_SWIFT_STORAGE_CURRENT)s', storage_local_net_ip => '%(CONFIG_CONTROLLER_HOST)s',
allow_versions => true, allow_versions => true,
require => Class['swift'], require => Class['swift'],
} }
@ -15,10 +15,8 @@ if(!defined(File['/srv/node'])) {
} }
} }
swift::ringsync{["account","container","object"]: swift::ringsync{ ["account", "container", "object"]:
ring_server => '%(CONFIG_SWIFT_BUILDER_HOST)s', ring_server => '%(CONFIG_CONTROLLER_HOST)s',
before => Class['swift::storage::all'], before => Class['swift::storage::all'],
require => Class['swift'], require => Class['swift'],
} }

View File

@ -39,7 +39,7 @@ class StepTestCase(PackstackTestCaseMixin, TestCase):
""" """
Test packstack.instaler.core.sequences.Step run. Test packstack.instaler.core.sequences.Step run.
""" """
def func(config): def func(config, messages):
if 'test' not in config: if 'test' not in config:
raise AssertionError('Missing config value.') raise AssertionError('Missing config value.')
@ -59,11 +59,11 @@ class SequenceTestCase(PackstackTestCaseMixin, TestCase):
self._stdout = sys.stdout self._stdout = sys.stdout
sys.stdout = StringIO.StringIO() sys.stdout = StringIO.StringIO()
self.steps = [{'name': '1', 'function': lambda x: True, self.steps = [{'name': '1', 'function': lambda x, y: True,
'title': 'Step 1'}, 'title': 'Step 1'},
{'name': '2', 'function': lambda x: True, {'name': '2', 'function': lambda x, y: True,
'title': 'Step 2'}, 'title': 'Step 2'},
{'name': '3', 'function': lambda x: True, {'name': '3', 'function': lambda x, y: True,
'title': 'Step 3'}] 'title': 'Step 3'}]
self.seq = Sequence('test', self.steps, condition='test', self.seq = Sequence('test', self.steps, condition='test',

View File

@ -18,8 +18,7 @@ downloadcache = ~/cache/pip
[testenv:pep8] [testenv:pep8]
deps=pep8==1.2 deps=pep8==1.2
commands = pep8 --exclude=*.pyc --repeat --show-source \ commands = pep8 --exclude=*.pyc --repeat --show-source \
packstack/modules tests setup.py packstack/installer/utils \ packstack/modules packstack/plugins tests setup.py
packstack/installer/processors.py
[testenv:cover] [testenv:cover]