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

@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
"""
Installs and configures Glance
"""
@@ -11,68 +13,51 @@ from packstack.installer import utils
from packstack.installer.utils import split_hosts
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
controller = None
#------------------ oVirt installer initialization ------------------
# Plugin name
PLUGIN_NAME = "OS-Glance"
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 Glance configuration")
paramsList = [
{"CMD_OPTION" : "glance-host",
"USAGE" : "The IP address of the server on which to install Glance",
"PROMPT" : "Enter the IP address of the Glance server",
"OPTION_LIST" : [],
"VALIDATORS" : [validators.validate_ssh],
"DEFAULT_VALUE" : utils.get_localhost_ip(),
"MASK_INPUT" : False,
"LOOSE_VALIDATION": True,
"CONF_NAME" : "CONFIG_GLANCE_HOST",
"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 },
]
def initConfig(controller):
params = [
{"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},
groupDict = { "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(groupDict, paramsList)
{"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},
]
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):
@@ -84,27 +69,34 @@ def initSequences(controller):
return
glancesteps = [
{'title': 'Adding Glance Keystone manifest entries', 'functions':[createkeystonemanifest]},
{'title': 'Adding Glance manifest entries', 'functions':[createmanifest]}
{'title': 'Adding Glance Keystone manifest entries',
'functions': [create_keystone_manifest]},
{'title': 'Adding Glance manifest entries',
'functions': [create_manifest]}
]
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")
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")
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_PORTS'] = "'9292'"
config['FIREWALL_CHAIN'] = "INPUT"
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_SERVICE_ID'] = "glance_%s" % host
manifestdata += getManifestTemplate("firewall.pp")