More cleanups + melange actions.
This commit is contained in:
parent
f629e703d1
commit
6b91feff76
@ -117,7 +117,6 @@ class PkgInstallComponent(ComponentBase):
|
||||
pkgnames = sorted(pkgs.keys())
|
||||
LOG.info("Installing packages (%s)." % (", ".join(pkgnames)))
|
||||
self.packager.install_batch(pkgs)
|
||||
#add trace used to remove the pkgs
|
||||
for name in pkgnames:
|
||||
self.tracewriter.package_install(name, pkgs.get(name))
|
||||
return self.tracedir
|
||||
@ -127,14 +126,12 @@ class PkgInstallComponent(ComponentBase):
|
||||
if pkgs:
|
||||
mp = self._get_param_map(None)
|
||||
self.packager.pre_install(pkgs, mp)
|
||||
return self.tracedir
|
||||
|
||||
def post_install(self):
|
||||
pkgs = self._get_pkgs_expanded()
|
||||
if pkgs:
|
||||
mp = self._get_param_map(None)
|
||||
self.packager.post_install(pkgs, mp)
|
||||
return self.tracedir
|
||||
|
||||
def _get_config_files(self):
|
||||
return list()
|
||||
|
@ -156,7 +156,7 @@ class DBInstaller(comp.PkgInstallComponent):
|
||||
return list(REQ_PKGS)
|
||||
|
||||
def post_install(self):
|
||||
parent_result = comp.PkgInstallComponent.post_install(self)
|
||||
comp.PkgInstallComponent.post_install(self)
|
||||
|
||||
#fix up the db configs
|
||||
self._configure_db_confs()
|
||||
@ -205,8 +205,6 @@ class DBInstaller(comp.PkgInstallComponent):
|
||||
#since python escapes this to much...
|
||||
utils.execute_template(*cmds, params=params, shell=True)
|
||||
|
||||
return parent_result
|
||||
|
||||
|
||||
class DBRuntime(comp.EmptyRuntime):
|
||||
def __init__(self, *args, **kargs):
|
||||
|
@ -105,9 +105,8 @@ class GlanceInstaller(comp.PythonInstallComponent):
|
||||
return list(REQ_PKGS)
|
||||
|
||||
def post_install(self):
|
||||
parent_result = comp.PythonInstallComponent.post_install(self)
|
||||
comp.PythonInstallComponent.post_install(self)
|
||||
self._setup_db()
|
||||
return parent_result
|
||||
|
||||
def _setup_db(self):
|
||||
LOG.info("Fixing up database named %s.", DB_NAME)
|
||||
|
@ -142,12 +142,11 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
||||
sh.chown_r(path, uid, gid)
|
||||
|
||||
def post_install(self):
|
||||
parent_result = comp.PythonInstallComponent.post_install(self)
|
||||
comp.PythonInstallComponent.post_install(self)
|
||||
self._fake_quantum()
|
||||
self._sync_db()
|
||||
self._setup_blackhole()
|
||||
self._ensure_db_access()
|
||||
return parent_result
|
||||
|
||||
def _get_apache_user_group(self):
|
||||
user = self.cfg.get('horizon', 'apache_user')
|
||||
|
@ -94,11 +94,10 @@ class KeystoneInstaller(comp.PythonInstallComponent):
|
||||
return {sh.joinpths(self.cfgdir, ROOT_CONF): '/etc/keystone/keystone.conf'}
|
||||
|
||||
def post_install(self):
|
||||
parent_result = comp.PythonInstallComponent.post_install(self)
|
||||
comp.PythonInstallComponent.post_install(self)
|
||||
self._setup_db()
|
||||
self._sync_db()
|
||||
self._setup_data()
|
||||
return parent_result
|
||||
|
||||
def _sync_db(self):
|
||||
LOG.info("Syncing keystone to database named %s.", DB_NAME)
|
||||
|
@ -14,6 +14,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import io
|
||||
|
||||
from devstack import cfg
|
||||
from devstack import component as comp
|
||||
from devstack import log as logging
|
||||
from devstack import settings
|
||||
@ -28,6 +31,24 @@ TYPE = settings.MELANGE
|
||||
#the pkg json files melange requires for installation
|
||||
REQ_PKGS = ['general.json']
|
||||
|
||||
#this db will be dropped then created
|
||||
DB_NAME = 'melange'
|
||||
|
||||
#subdirs of the checkout/download
|
||||
BIN_DIR = 'bin'
|
||||
|
||||
#configs
|
||||
ROOT_CONF = 'melange.conf.sample'
|
||||
ROOT_CONF_REAL_NAME = 'melange.conf'
|
||||
CONFIGS = [ROOT_CONF]
|
||||
CFG_LOC = ['etc', 'melange']
|
||||
|
||||
#how we sync melange with the db
|
||||
DB_SYNC_CMD = [
|
||||
{'cmd': ['%BINDIR%/melange-manage', '--config-file', '%CFGFILE%',
|
||||
'db_sync']},
|
||||
]
|
||||
|
||||
|
||||
class MelangeUninstaller(comp.PythonUninstallComponent):
|
||||
def __init__(self, *args, **kargs):
|
||||
@ -37,6 +58,7 @@ class MelangeUninstaller(comp.PythonUninstallComponent):
|
||||
class MelangeInstaller(comp.PythonInstallComponent):
|
||||
def __init__(self, *args, **kargs):
|
||||
comp.PythonInstallComponent.__init__(self, TYPE, *args, **kargs)
|
||||
self.bindir = sh.joinpths(self.appdir, BIN_DIR)
|
||||
|
||||
def _get_download_locations(self):
|
||||
places = list()
|
||||
@ -46,9 +68,63 @@ class MelangeInstaller(comp.PythonInstallComponent):
|
||||
})
|
||||
return places
|
||||
|
||||
def _setup_db(self):
|
||||
LOG.info("Fixing up database named %s.", DB_NAME)
|
||||
db.drop_db(self.cfg, DB_NAME)
|
||||
db.create_db(self.cfg, DB_NAME)
|
||||
|
||||
def _get_pkgs(self):
|
||||
return list(REQ_PKGS)
|
||||
|
||||
def post_install(self):
|
||||
comp.PythonInstallComponent.post_install(self)
|
||||
self._setup_db()
|
||||
self._sync_db()
|
||||
|
||||
def _sync_db(self):
|
||||
LOG.info("Syncing the database with melange.")
|
||||
mp = dict()
|
||||
mp['BINDIR'] = self.bindir
|
||||
cfg_loc = [self.appdir] + CFG_LOC + [ROOT_CONF_REAL_NAME]
|
||||
mp['CFGFILE'] = sh.joinpths(*cfg_loc)
|
||||
utils.execute_template(*DB_SYNC_CMD, params=mp)
|
||||
|
||||
def _get_config_files(self):
|
||||
return list(CONFIGS)
|
||||
|
||||
def _config_adjust(self, contents, config_fn):
|
||||
if config_fn == ROOT_CONF:
|
||||
newcontents = contents
|
||||
with io.BytesIO(contents) as stream:
|
||||
config = cfg.IgnoreMissingConfigParser()
|
||||
config.readfp(stream)
|
||||
db_dsn = self.cfg.get_dbdsn(DB_NAME)
|
||||
config.set('DEFAULT', 'sql_connection', db_dsn)
|
||||
with io.BytesIO() as outputstream:
|
||||
config.write(outputstream)
|
||||
outputstream.flush()
|
||||
new_data = ['# Adjusted %s' % (config_fn), outputstream.getvalue()]
|
||||
#TODO can we write to contents here directly?
|
||||
newcontents = utils.joinlinesep(*new_data)
|
||||
contents = newcontents
|
||||
return contents
|
||||
|
||||
def _get_source_config(self, config_fn):
|
||||
if config_fn == ROOT_CONF:
|
||||
src_loc = [self.appdir] + CFG_LOC + [config_fn]
|
||||
srcfn = sh.joinpths(*src_loc)
|
||||
contents = sh.load_file(srcfn)
|
||||
return (srcfn, contents)
|
||||
else:
|
||||
return comp.PkgInstallComponent._get_source_config(self, config_fn)
|
||||
|
||||
def _get_target_config_name(self, config_fn):
|
||||
if config_fn == ROOT_CONF:
|
||||
tgt_loc = [self.appdir] + CFG_LOC + [ROOT_CONF_REAL_NAME]
|
||||
return sh.joinpths(*tgt_loc)
|
||||
else:
|
||||
return comp.PkgInstallComponent._get_target_config_name(self, config_fn)
|
||||
|
||||
|
||||
class MelangeRuntime(comp.EmptyRuntime):
|
||||
def __init__(self, *args, **kargs):
|
||||
|
@ -247,7 +247,7 @@ class NovaInstaller(comp.PythonInstallComponent):
|
||||
utils.execute_template(*DB_SYNC_CMD, params=mp, tracewriter=self.tracewriter)
|
||||
|
||||
def post_install(self):
|
||||
parent_result = comp.PkgInstallComponent.post_install(self)
|
||||
comp.PkgInstallComponent.post_install(self)
|
||||
#extra actions to do nova setup
|
||||
self._setup_db()
|
||||
self._sync_db()
|
||||
@ -257,7 +257,6 @@ class NovaInstaller(comp.PythonInstallComponent):
|
||||
# yes, either no subcomponents were specifically requested or it's
|
||||
# in the set that was requested
|
||||
self._setup_vol_groups()
|
||||
return parent_result
|
||||
|
||||
def _setup_db(self):
|
||||
LOG.info("Fixing up database named %s.", DB_NAME)
|
||||
|
@ -182,12 +182,11 @@ class QuantumInstaller(comp.PkgInstallComponent):
|
||||
#TODO maybe have a trace that says we did this so that we can remove it on uninstall?
|
||||
|
||||
def post_install(self):
|
||||
parent_result = comp.PkgInstallComponent.post_install(self)
|
||||
comp.PkgInstallComponent.post_install(self)
|
||||
if self.q_vswitch_service and settings.DB in self.instances:
|
||||
self._setup_db()
|
||||
if self.q_vswitch_agent:
|
||||
self._setup_bridge()
|
||||
return parent_result
|
||||
|
||||
def _setup_db(self):
|
||||
LOG.info("Fixing up database named %s.", DB_NAME)
|
||||
|
@ -83,9 +83,8 @@ class RabbitInstaller(comp.PkgInstallComponent):
|
||||
self.runtime.restart()
|
||||
|
||||
def post_install(self):
|
||||
parent_result = comp.PkgInstallComponent.post_install(self)
|
||||
comp.PkgInstallComponent.post_install(self)
|
||||
self._setup_pw()
|
||||
return parent_result
|
||||
|
||||
def _get_pkgs(self):
|
||||
return list(REQ_PKGS)
|
||||
|
@ -159,9 +159,9 @@ def _install(component_name, instance):
|
||||
LOG.info("Pre-installing %s." % (component_name))
|
||||
instance.pre_install()
|
||||
LOG.info("Installing %s." % (component_name))
|
||||
instance.install()
|
||||
trace = instance.install()
|
||||
LOG.info("Post-installing %s." % (component_name))
|
||||
trace = instance.post_install()
|
||||
instance.post_install()
|
||||
if trace:
|
||||
LOG.info("Finished install of %s - check %s for traces of what happened." % (component_name, trace))
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user