Adding RHEL6 distro specifics
This commit is contained in:
parent
3ebe2e4858
commit
f92caf2bb3
@ -36,7 +36,7 @@ LOG = logging.getLogger("devstack.component")
|
||||
PY_INSTALL = ['python', 'setup.py', 'develop']
|
||||
PY_UNINSTALL = ['python', 'setup.py', 'develop', '--uninstall']
|
||||
|
||||
# Runtime status constants (return by runtime status)
|
||||
# Runtime status constants (return by runtime status)
|
||||
# TODO: move...
|
||||
STATUS_UNKNOWN = "unknown"
|
||||
STATUS_STARTED = "started"
|
||||
@ -65,6 +65,7 @@ class ComponentBase(object):
|
||||
|
||||
self.active_subsystems = active_subsystems
|
||||
self.instances = all_instances
|
||||
self.component_name = name
|
||||
|
||||
# The runner has a reference to us, so use a weakref here to
|
||||
# avoid breaking garbage collection.
|
||||
@ -75,10 +76,7 @@ class ComponentBase(object):
|
||||
self.pw_gen = runner.pw_gen
|
||||
self.packager = runner.pkg_manager
|
||||
self.distro = runner.distro
|
||||
|
||||
# What this component is called
|
||||
self.component_name = name
|
||||
|
||||
|
||||
# Required component directories
|
||||
self.component_dir = component_dir
|
||||
self.trace_dir = sh.joinpths(self.component_dir,
|
||||
@ -157,7 +155,7 @@ class PkgInstallComponent(ComponentBase):
|
||||
if name in self.subsystems:
|
||||
# Todo handle duplicates/version differences?
|
||||
LOG.debug("Extending package list with packages for subsystem %s" % (name))
|
||||
subsystem_pkgs = self.subsystems[name].get('packages', list())
|
||||
subsystem_pkgs = self.subsystems[name].get('packages', list())
|
||||
pkg_list.extend(subsystem_pkgs)
|
||||
return pkg_list
|
||||
|
||||
@ -266,7 +264,7 @@ class PythonInstallComponent(PkgInstallComponent):
|
||||
if name in self.subsystems:
|
||||
# Todo handle duplicates/version differences?
|
||||
LOG.debug("Extending pip list with pips for subsystem %s" % (name))
|
||||
subsystem_pips = self.subsystems[name].get('pips', list())
|
||||
subsystem_pips = self.subsystems[name].get('pips', list())
|
||||
pip_list.extend(subsystem_pips)
|
||||
return pip_list
|
||||
|
||||
@ -275,9 +273,9 @@ class PythonInstallComponent(PkgInstallComponent):
|
||||
if pips:
|
||||
pip_names = set([p['name'] for p in pips])
|
||||
LOG.info("Setting up %s pips (%s)", len(pip_names), ", ".join(pip_names))
|
||||
for info in pips:
|
||||
self.tracewriter.pip_installed(info)
|
||||
pip.install(info, self.distro)
|
||||
for p in pips:
|
||||
self.tracewriter.pip_installed(p)
|
||||
pip.install(p, self.distro)
|
||||
|
||||
def _install_python_setups(self):
|
||||
pydirs = self._get_python_directories()
|
||||
|
@ -23,24 +23,22 @@ from devstack import utils
|
||||
|
||||
LOG = logging.getLogger("devstack.components.db")
|
||||
|
||||
#used for special setups
|
||||
MYSQL = 'mysql'
|
||||
START_WAIT_TIME = settings.WAIT_ALIVE_SECS
|
||||
|
||||
#need to reset pw to blank since this distributions don't seem to
|
||||
#always reset it when u uninstall the db
|
||||
# Need to reset pw to blank since this distributions don't seem to
|
||||
# always reset it when u uninstall the db
|
||||
RESET_BASE_PW = ''
|
||||
|
||||
#links about how to reset if it fails
|
||||
# Links about how to reset if it fails
|
||||
SQL_RESET_PW_LINKS = [
|
||||
'https://help.ubuntu.com/community/MysqlPasswordReset',
|
||||
'http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html',
|
||||
]
|
||||
|
||||
#used as a generic error message
|
||||
# Used as a generic error message
|
||||
BASE_ERROR = 'Currently we do not know how to [%s] for database type [%s]'
|
||||
|
||||
#config keys we warm up so u won't be prompted later
|
||||
# PW keys we warm up so u won't be prompted later
|
||||
WARMUP_PWS = ['sql']
|
||||
|
||||
|
||||
@ -55,7 +53,7 @@ class DBUninstaller(comp.PkgUninstallComponent):
|
||||
|
||||
def pre_uninstall(self):
|
||||
dbtype = self.cfg.get("db", "type")
|
||||
dbactions = self.distro.commands[dbtype]
|
||||
dbactions = self.distro.get_command(dbtype, quiet=True)
|
||||
try:
|
||||
if dbactions:
|
||||
LOG.info(("Attempting to reset your db password to \"%s\" so"
|
||||
@ -83,8 +81,8 @@ class DBInstaller(comp.PkgInstallComponent):
|
||||
self.runtime = DBRuntime(*args, **kargs)
|
||||
|
||||
def _get_param_map(self, config_fn):
|
||||
#this dictionary will be used for parameter replacement
|
||||
#in pre-install and post-install sections
|
||||
# This dictionary will be used for parameter replacement
|
||||
# In pre-install and post-install sections
|
||||
host_ip = self.cfg.get('host', 'ip')
|
||||
out = {
|
||||
'PASSWORD': self.pw_gen.get_password("sql"),
|
||||
@ -100,38 +98,19 @@ class DBInstaller(comp.PkgInstallComponent):
|
||||
self.pw_gen.get_password(pw_key)
|
||||
|
||||
def _configure_db_confs(self):
|
||||
dbtype = self.cfg.get("db", "type")
|
||||
#TODO: use separate classes in devstack.distros.$distro.db and
|
||||
# specify them in the yaml file
|
||||
if self.distro.name == settings.RHEL6 and dbtype == MYSQL:
|
||||
LOG.info("Fixing up %s mysql configs." % (settings.RHEL6))
|
||||
fc = sh.load_file('/etc/my.cnf')
|
||||
lines = fc.splitlines()
|
||||
new_lines = list()
|
||||
for line in lines:
|
||||
if line.startswith('skip-grant-tables'):
|
||||
line = '#' + line
|
||||
new_lines.append(line)
|
||||
fc = utils.joinlinesep(*new_lines)
|
||||
with sh.Rooted(True):
|
||||
sh.write_file('/etc/my.cnf', fc)
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
'Do not know how to configure db confs for %s' %
|
||||
self.distro.name
|
||||
)
|
||||
pass
|
||||
|
||||
def post_install(self):
|
||||
comp.PkgInstallComponent.post_install(self)
|
||||
|
||||
#fix up the db configs
|
||||
# Fix up the db configs
|
||||
self._configure_db_confs()
|
||||
|
||||
#extra actions to ensure we are granted access
|
||||
# Extra actions to ensure we are granted access
|
||||
dbtype = self.cfg.get("db", "type")
|
||||
dbactions = self.distro.commands[dbtype]
|
||||
dbactions = self.distro.get_command(dbtype, quiet=True)
|
||||
|
||||
#set your password
|
||||
# Set your password
|
||||
try:
|
||||
if dbactions:
|
||||
pwd_cmd = dbactions.get('set_pwd')
|
||||
@ -151,7 +130,7 @@ class DBInstaller(comp.PkgInstallComponent):
|
||||
LOG.warn(("Couldn't set your db password. It might have already been "
|
||||
"set by a previous process."))
|
||||
|
||||
#ensure access granted
|
||||
# Ensure access granted
|
||||
if dbactions:
|
||||
grant_cmd = dbactions.get('grant_all')
|
||||
if grant_cmd:
|
||||
|
@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OneiricDBInstaller(db.DBInstaller):
|
||||
|
||||
|
||||
def _configure_db_confs(self):
|
||||
LOG.info("Fixing up %s mysql configs.", self.distro.name)
|
||||
fc = sh.load_file('/etc/mysql/my.cnf')
|
||||
|
42
devstack/distros/rhel6.py
Normal file
42
devstack/distros/rhel6.py
Normal file
@ -0,0 +1,42 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
|
||||
# Copyright (C) 2012 Dreamhost Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Platform-specific logic for RHEL6 components.
|
||||
"""
|
||||
|
||||
from devstack.components import db
|
||||
from devstack import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Rhel6DBInstaller(db.DBInstaller):
|
||||
|
||||
def _configure_db_confs(self):
|
||||
dbtype = self.cfg.get("db", "type")
|
||||
if dbtype == 'mysql':
|
||||
LOG.info("Fixing up mysql configs.")
|
||||
fc = sh.load_file('/etc/my.cnf')
|
||||
lines = fc.splitlines()
|
||||
new_lines = list()
|
||||
for line in lines:
|
||||
if line.startswith('skip-grant-tables'):
|
||||
line = '#' + line
|
||||
new_lines.append(line)
|
||||
fc = utils.joinlinesep(*new_lines)
|
||||
with sh.Rooted(True):
|
||||
sh.write_file('/etc/my.cnf', fc)
|
@ -87,7 +87,7 @@ class AptPackager(pack.Packager):
|
||||
if self._pkg_install_special(name, pkg):
|
||||
return
|
||||
else:
|
||||
pkg_full = self._format_pkg(name, pkg.get("version"))
|
||||
pkg_full = self._format_pkg(name, pkg.get("version"))
|
||||
cmd = APT_GET + APT_INSTALL + [pkg_full]
|
||||
self._execute_apt(cmd)
|
||||
|
||||
|
@ -183,7 +183,7 @@ class ActionRunner(object):
|
||||
% (fn, e))
|
||||
raise excp.ConfigException(msg)
|
||||
return persona
|
||||
|
||||
|
||||
def _construct_instances(self, persona, action, root_dir):
|
||||
components = persona['components'] # Required
|
||||
subsystems = persona.get('subsystems') or dict() # Not required
|
||||
@ -207,19 +207,19 @@ class ActionRunner(object):
|
||||
LOG.debug("Using arg list %s", cls_args)
|
||||
instances[c] = cls(*cls_args, **cls_kvs)
|
||||
return instances
|
||||
|
||||
|
||||
def _verify_components(self, component_order, instances):
|
||||
LOG.info("Verifying that the components are ready to rock-n-roll.")
|
||||
for c in component_order:
|
||||
instance = instances[c]
|
||||
instance.verify()
|
||||
|
||||
|
||||
def _warm_components(self, component_order, instances):
|
||||
LOG.info("Warming up your component configurations (ie so you won't be prompted later)")
|
||||
for c in component_order:
|
||||
instance = instances[c]
|
||||
instance.warm_configs()
|
||||
|
||||
|
||||
def _write_rc_file(self, root_dir):
|
||||
writer = env_rc.RcWriter(self.cfg, self.pw_gen, root_dir)
|
||||
if not sh.isfile(settings.OSRC_FN):
|
||||
@ -229,7 +229,7 @@ class ActionRunner(object):
|
||||
LOG.info("Updating a file at [%s] that contains your environment settings." % (settings.OSRC_FN))
|
||||
am_upd = writer.update(settings.OSRC_FN)
|
||||
LOG.info("Updated [%s] settings in rc file [%s]" % (am_upd, settings.OSRC_FN))
|
||||
|
||||
|
||||
def _run_instances(self, action, component_order, instances):
|
||||
for (start_msg, functor, end_msg) in ACTION_MP[action]:
|
||||
for c in component_order:
|
||||
@ -260,16 +260,19 @@ class ActionRunner(object):
|
||||
% (preq_action, ", ".join(checks_passed_components)))
|
||||
self._run_action(persona, preq_action, root_dir)
|
||||
component_order = self._apply_reverse(action, persona['components'])
|
||||
LOG.info("Activating components [%s] (in that order) for action [%s]" %
|
||||
LOG.info("Activating components [%s] (in that order) for action [%s]" %
|
||||
("->".join(component_order), action))
|
||||
self._verify_components(component_order, instances)
|
||||
self._warm_components(component_order, instances)
|
||||
if action in RC_FILE_MAKE_ACTIONS:
|
||||
self._write_rc_file(root_dir)
|
||||
self._run_instances(action, component_order, instances)
|
||||
|
||||
def run(self, persona_fn, root_dir):
|
||||
persona = self._load_persona(persona_fn)
|
||||
|
||||
def _setup_root(self, root_dir):
|
||||
if not sh.isdir(root_dir):
|
||||
sh.mkdir(root_dir)
|
||||
|
||||
def run(self, persona_fn, root_dir):
|
||||
persona = self._load_persona(persona_fn)
|
||||
self._setup_root(root_dir)
|
||||
self._run_action(persona, self.action, root_dir)
|
||||
|
Loading…
Reference in New Issue
Block a user