Small cleanups.

This commit is contained in:
Joshua Harlow
2012-02-01 14:35:16 -08:00
parent 1a2b6c416c
commit 9f1eda617f
11 changed files with 33 additions and 80 deletions

View File

@@ -25,7 +25,6 @@ from devstack import utils
from devstack.runners import fork from devstack.runners import fork
LOG = logging.getLogger("devstack.component") LOG = logging.getLogger("devstack.component")
#how we actually setup and unsetup python #how we actually setup and unsetup python
@@ -166,8 +165,7 @@ class PkgInstallComponent(ComponentBase):
def configure(self): def configure(self):
self.tracewriter.make_dir(self.cfgdir) self.tracewriter.make_dir(self.cfgdir)
files_configured = self._configure_files() return self._configure_files()
return files_configured
class PythonInstallComponent(PkgInstallComponent): class PythonInstallComponent(PkgInstallComponent):
@@ -298,13 +296,13 @@ class PythonUninstallComponent(PkgUninstallComponent):
def _uninstall_pips(self): def _uninstall_pips(self):
pips = self.tracereader.pips_installed() pips = self.tracereader.pips_installed()
if pips: if pips:
LOG.info("Uninstalling %s pips" % (len(pips))) LOG.info("Uninstalling %s pips." % (len(pips)))
pip.uninstall(pips, self.distro) pip.uninstall(pips, self.distro)
def _uninstall_python(self): def _uninstall_python(self):
pylisting = self.tracereader.py_listing() pylisting = self.tracereader.py_listing()
if pylisting: if pylisting:
LOG.info("Uninstalling %s python setups" % (len(pylisting))) LOG.info("Uninstalling %s python setups." % (len(pylisting)))
for entry in pylisting: for entry in pylisting:
where = entry.get('where') where = entry.get('where')
sh.execute(*PY_UNINSTALL, cwd=where, run_as_root=True) sh.execute(*PY_UNINSTALL, cwd=where, run_as_root=True)
@@ -338,13 +336,6 @@ class ProgramRuntime(ComponentBase):
raise NotImplementedError("Can not yet stop %s mode" % (stop_mode)) raise NotImplementedError("Can not yet stop %s mode" % (stop_mode))
return ProgramRuntime.STOPPER_CLS_MAPPING.get(stop_mode) return ProgramRuntime.STOPPER_CLS_MAPPING.get(stop_mode)
def _was_installed(self):
if not self.check_installed_pkgs:
return True
if self.tracereader.packages_installed():
return True
return False
def _get_apps_to_start(self): def _get_apps_to_start(self):
return list() return list()
@@ -363,10 +354,6 @@ class ProgramRuntime(ComponentBase):
pass pass
def start(self): def start(self):
#ensure it was installed
if not self._was_installed():
msg = "Can not start %s since it was not installed" % (self.component_name)
raise excp.StartException(msg)
#select how we are going to start it #select how we are going to start it
startercls = self._getstartercls(self.run_type) startercls = self._getstartercls(self.run_type)
starter = startercls() starter = startercls()
@@ -387,8 +374,8 @@ class ProgramRuntime(ComponentBase):
for opt in program_opts: for opt in program_opts:
adjusted_opts.append(utils.param_replace(opt, params)) adjusted_opts.append(utils.param_replace(opt, params))
program_opts = adjusted_opts program_opts = adjusted_opts
LOG.info("Starting [%s] with options [%s]" % (app_name, ", ".join(program_opts)))
#start it with the given settings #start it with the given settings
LOG.info("Starting [%s] with options [%s]" % (app_name, ", ".join(program_opts)))
fn = starter.start(app_name, app_pth, *program_opts, app_dir=app_dir, \ fn = starter.start(app_name, app_pth, *program_opts, app_dir=app_dir, \
trace_dir=self.tracedir) trace_dir=self.tracedir)
if fn: if fn:
@@ -401,10 +388,6 @@ class ProgramRuntime(ComponentBase):
return fns return fns
def stop(self): def stop(self):
#ensure it was installed
if not self._was_installed():
msg = "Can not stop %s since it was not installed" % (self.component_name)
raise excp.StopException(msg)
#we can only stop what has a started trace #we can only stop what has a started trace
start_traces = self.starttracereader.apps_started() start_traces = self.starttracereader.apps_started()
killedam = 0 killedam = 0
@@ -453,16 +436,6 @@ class PythonRuntime(ProgramRuntime):
def __init__(self, component_name, *args, **kargs): def __init__(self, component_name, *args, **kargs):
ProgramRuntime.__init__(self, component_name, *args, **kargs) ProgramRuntime.__init__(self, component_name, *args, **kargs)
def _was_installed(self):
parent_result = ProgramRuntime._was_installed(self)
if not parent_result:
return False
python_installed = self.tracereader.py_listing()
if not python_installed:
return False
else:
return True
class EmptyRuntime(ComponentBase): class EmptyRuntime(ComponentBase):
def __init__(self, component_name, *args, **kargs): def __init__(self, component_name, *args, **kargs):

View File

@@ -111,7 +111,7 @@ class DBUninstaller(comp.PkgUninstallComponent):
utils.execute_template(*cmds, params=params, shell=True) utils.execute_template(*cmds, params=params, shell=True)
except IOError: except IOError:
LOG.warn(("Could not reset the database password. You might have to manually " LOG.warn(("Could not reset the database password. You might have to manually "
"reset the password to \"%s\" before the next install") % (RESET_BASE_PW), exc_info=True) "reset the password to \"%s\" before the next install.") % (RESET_BASE_PW), exc_info=True)
LOG.info("To aid in this check out: [%s]", " or ".join(SQL_RESET_PW_LINKS)) LOG.info("To aid in this check out: [%s]", " or ".join(SQL_RESET_PW_LINKS))
@@ -204,10 +204,6 @@ class DBRuntime(comp.EmptyRuntime):
self.tracereader = tr.TraceReader(self.tracedir, tr.IN_TRACE) self.tracereader = tr.TraceReader(self.tracedir, tr.IN_TRACE)
def _get_run_actions(self, act, exception_cls): def _get_run_actions(self, act, exception_cls):
pkgsinstalled = self.tracereader.packages_installed()
if not pkgsinstalled:
msg = "Can not %s %s since it was not installed" % (act, TYPE)
raise exception_cls(msg)
dbtype = self.cfg.get("db", "type") dbtype = self.cfg.get("db", "type")
type_actions = DB_ACTIONS.get(dbtype) type_actions = DB_ACTIONS.get(dbtype)
if type_actions is None: if type_actions is None:
@@ -238,9 +234,9 @@ class DBRuntime(comp.EmptyRuntime):
return 0 return 0
def restart(self): def restart(self):
LOG.info("Restarting your database.")
restartcmd = self._get_run_actions('restart', excp.RestartException) restartcmd = self._get_run_actions('restart', excp.RestartException)
sh.execute(*restartcmd, run_as_root=True) sh.execute(*restartcmd, run_as_root=True)
#this seems needed?
LOG.info("Please wait %s seconds while it restarts." % START_WAIT_TIME) LOG.info("Please wait %s seconds while it restarts." % START_WAIT_TIME)
time.sleep(START_WAIT_TIME) time.sleep(START_WAIT_TIME)
return 1 return 1

View File

@@ -110,7 +110,7 @@ class GlanceInstaller(comp.PythonInstallComponent):
return parent_result return parent_result
def _setup_db(self): def _setup_db(self):
LOG.info("Fixing up database named %s", DB_NAME) LOG.info("Fixing up database named %s.", DB_NAME)
db.drop_db(self.cfg, DB_NAME) db.drop_db(self.cfg, DB_NAME)
db.create_db(self.cfg, DB_NAME) db.create_db(self.cfg, DB_NAME)
@@ -134,17 +134,17 @@ class GlanceInstaller(comp.PythonInstallComponent):
if config.get('default_store', CFG_SECTION) == 'file': if config.get('default_store', CFG_SECTION) == 'file':
file_dir = config.get('filesystem_store_datadir', CFG_SECTION) file_dir = config.get('filesystem_store_datadir', CFG_SECTION)
if file_dir: if file_dir:
LOG.info("Ensuring file system store directory %s exists and is empty" % (file_dir)) LOG.info("Ensuring file system store directory %s exists and is empty." % (file_dir))
#delete existing images #delete existing images
#and recreate the image directory #and recreate the image directory
sh.deldir(file_dir) sh.deldir(file_dir)
self.tracewriter.make_dir(file_dir) self.tracewriter.make_dir(file_dir)
log_filename = config.get('log_file', CFG_SECTION) log_filename = config.get('log_file', CFG_SECTION)
if log_filename: if log_filename:
LOG.info("Ensuring log file %s exists and is empty" % (log_filename)) LOG.info("Ensuring log file %s exists and is empty." % (log_filename))
log_dir = sh.dirname(log_filename) log_dir = sh.dirname(log_filename)
if log_dir: if log_dir:
LOG.info("Ensuring log directory %s exists" % (log_dir)) LOG.info("Ensuring log directory %s exists." % (log_dir))
self.tracewriter.make_dir(log_dir) self.tracewriter.make_dir(log_dir)
#destroy then recreate it (the log file) #destroy then recreate it (the log file)
sh.unlink(log_filename) sh.unlink(log_filename)
@@ -153,7 +153,7 @@ class GlanceInstaller(comp.PythonInstallComponent):
if config.getboolean('delayed_delete', CFG_SECTION): if config.getboolean('delayed_delete', CFG_SECTION):
data_dir = config.get('scrubber_datadir', CFG_SECTION) data_dir = config.get('scrubber_datadir', CFG_SECTION)
if data_dir: if data_dir:
LOG.info("Ensuring scrubber data dir %s exists and is empty" % (data_dir)) LOG.info("Ensuring scrubber data dir %s exists and is empty." % (data_dir))
#destroy then recreate the scrubber data directory #destroy then recreate the scrubber data directory
sh.deldir(data_dir) sh.deldir(data_dir)
self.tracewriter.make_dir(data_dir) self.tracewriter.make_dir(data_dir)
@@ -205,6 +205,7 @@ class GlanceRuntime(comp.PythonRuntime):
if NO_IMG_START not in self.component_opts: if NO_IMG_START not in self.component_opts:
#install any images that need activating... #install any images that need activating...
# TODO: make this less cheesy - need to wait till glance goes online # TODO: make this less cheesy - need to wait till glance goes online
LOG.info("Waiting %s seconds so that glance can start up before image install." % (WAIT_ONLINE_TO))
time.sleep(WAIT_ONLINE_TO) time.sleep(WAIT_ONLINE_TO)
creator.ImageCreationService(self.cfg).install() creator.ImageCreationService(self.cfg).install()

View File

@@ -109,12 +109,11 @@ class HorizonInstaller(comp.PythonInstallComponent):
#create an empty directory that apache uses as docroot #create an empty directory that apache uses as docroot
black_dir = sh.joinpths(self.appdir, BLACKHOLE_DIR) black_dir = sh.joinpths(self.appdir, BLACKHOLE_DIR)
self.tracewriter.make_dir(black_dir) self.tracewriter.make_dir(black_dir)
return black_dir
def _sync_db(self): def _sync_db(self):
#Initialize the horizon database (it stores sessions and notices shown to users). #Initialize the horizon database (it stores sessions and notices shown to users).
#The user system is external (keystone). #The user system is external (keystone).
LOG.info("Initializing the horizon database") LOG.info("Initializing the horizon database.")
sh.execute(*DB_SYNC_CMD, cwd=self.dash_dir) sh.execute(*DB_SYNC_CMD, cwd=self.dash_dir)
def _fake_quantum(self): def _fake_quantum(self):
@@ -166,7 +165,7 @@ class HorizonInstaller(comp.PythonInstallComponent):
if config_fn == HORIZON_APACHE_CONF: if config_fn == HORIZON_APACHE_CONF:
(user, group) = self._get_apache_user_group() (user, group) = self._get_apache_user_group()
if user in BAD_APACHE_USERS: if user in BAD_APACHE_USERS:
LOG.warn("You may want to adjust your configuration, user=%s,group=%s will typically not work with apache", user, group) LOG.warn("You may want to adjust your configuration, (user=%s, group=%s) will typically not work with apache!", user, group)
mp['USER'] = user mp['USER'] = user
mp['GROUP'] = group mp['GROUP'] = group
mp['HORIZON_DIR'] = self.appdir mp['HORIZON_DIR'] = self.appdir

View File

@@ -98,7 +98,7 @@ class KeystoneInstaller(comp.PythonInstallComponent):
return parent_result return parent_result
def _sync_db(self): def _sync_db(self):
LOG.info("Syncing keystone to database named %s", DB_NAME) LOG.info("Syncing keystone to database named %s.", DB_NAME)
params = dict() params = dict()
#it seems like this command only works if fully specified #it seems like this command only works if fully specified
#probably a bug #probably a bug
@@ -115,7 +115,7 @@ class KeystoneInstaller(comp.PythonInstallComponent):
db.create_db(self.cfg, DB_NAME) db.create_db(self.cfg, DB_NAME)
def _setup_data(self): def _setup_data(self):
LOG.info("Configuring data setup template %s", MANAGE_DATA_CONF) LOG.info("Configuring data setup template %s.", MANAGE_DATA_CONF)
(src_fn, contents) = utils.load_template(self.component_name, MANAGE_DATA_CONF) (src_fn, contents) = utils.load_template(self.component_name, MANAGE_DATA_CONF)
params = self._get_param_map(MANAGE_DATA_CONF) params = self._get_param_map(MANAGE_DATA_CONF)
contents = utils.param_replace(contents, params, True) contents = utils.param_replace(contents, params, True)
@@ -141,10 +141,10 @@ class KeystoneInstaller(comp.PythonInstallComponent):
config.readfp(stream) config.readfp(stream)
log_filename = config.get('log_file', CFG_SECTION) log_filename = config.get('log_file', CFG_SECTION)
if log_filename: if log_filename:
LOG.info("Ensuring log file %s exists and is empty" % (log_filename)) LOG.info("Ensuring log file %s exists and is empty." % (log_filename))
log_dir = sh.dirname(log_filename) log_dir = sh.dirname(log_filename)
if log_dir: if log_dir:
LOG.info("Ensuring log directory %s exists" % (log_dir)) LOG.info("Ensuring log directory %s exists." % (log_dir))
self.tracewriter.make_dir(log_dir) self.tracewriter.make_dir(log_dir)
#destroy then recreate it (the log file) #destroy then recreate it (the log file)
sh.unlink(log_filename) sh.unlink(log_filename)

View File

@@ -161,7 +161,7 @@ class QuantumInstaller(comp.PkgInstallComponent):
def _setup_bridge(self): def _setup_bridge(self):
bridge = self.cfg.get("quantum", "ovs_bridge") bridge = self.cfg.get("quantum", "ovs_bridge")
if bridge: if bridge:
LOG.info("Fixing up ovs bridge named %s", bridge) LOG.info("Fixing up ovs bridge named %s.", bridge)
external_id = self.cfg.get("quantum", 'ovs_bridge_external_name') external_id = self.cfg.get("quantum", 'ovs_bridge_external_name')
if not external_id: if not external_id:
external_id = bridge external_id = bridge

View File

@@ -99,10 +99,6 @@ class RabbitRuntime(comp.EmptyRuntime):
return 0 return 0
def status(self): def status(self):
pkgsinstalled = self.tracereader.packages_installed()
if not pkgsinstalled:
msg = "Can not check the status of %s since it was not installed" % (TYPE)
raise excp.StatusException(msg)
#this has got to be the worst status output #this has got to be the worst status output
#i have ever seen (its like a weird mix json+crap) #i have ever seen (its like a weird mix json+crap)
(sysout, _) = sh.execute(*STATUS_CMD, (sysout, _) = sh.execute(*STATUS_CMD,
@@ -127,7 +123,7 @@ class RabbitRuntime(comp.EmptyRuntime):
stdout_fh=f, stderr_fh=f) stdout_fh=f, stderr_fh=f)
def restart(self): def restart(self):
LOG.info("Restarting rabbitmq") LOG.info("Restarting rabbit-mq.")
self._run_cmd(RESTART_CMD) self._run_cmd(RESTART_CMD)
LOG.info("Please wait %s seconds while it starts up." % (WAIT_ON_TIME)) LOG.info("Please wait %s seconds while it starts up." % (WAIT_ON_TIME))
time.sleep(WAIT_ON_TIME) time.sleep(WAIT_ON_TIME)

View File

@@ -23,8 +23,6 @@ from devstack import shell as sh
LOG = logging.getLogger("devstack.downloader") LOG = logging.getLogger("devstack.downloader")
EXT_REG = re.compile(r"^(.*?)\.git\s*$", re.IGNORECASE) EXT_REG = re.compile(r"^(.*?)\.git\s*$", re.IGNORECASE)
# What the git master string is
GIT_MASTER_BRANCH = "master" GIT_MASTER_BRANCH = "master"

View File

@@ -74,13 +74,13 @@ class YumPackager(pack.Packager):
tgt = RHEL_WEBOB_LINK.get("tgt") tgt = RHEL_WEBOB_LINK.get("tgt")
src = RHEL_WEBOB_LINK.get("src") src = RHEL_WEBOB_LINK.get("src")
if not sh.islink(tgt): if not sh.islink(tgt):
#This is actually a feature, EPEL must not conflict with RHEL, so python-webob1.0 installs newer version in parallel. # This is actually a feature, EPEL must not conflict with RHEL, so python-webob1.0 installs newer version in parallel.
# #
#This of course doesn't work when running from git like devstack does.... # This of course doesn't work when running from git like devstack does....
# #
#$ cat /usr/share/doc/python-webob1.0-1.0.8/README.Fedora # $ cat /usr/share/doc/python-webob1.0-1.0.8/README.Fedora
# #
# To use version 1.0.8 of python WebOB it is nescesary # To use version 1.0.8 of python WebOB it is necessary
# to explicitly load it so as not to get the system version # to explicitly load it so as not to get the system version
# of WebOb. # of WebOb.
# #
@@ -101,19 +101,18 @@ class YumPackager(pack.Packager):
def install_batch(self, pkgs): def install_batch(self, pkgs):
pkg_names = sorted(pkgs.keys()) pkg_names = sorted(pkgs.keys())
pkg_full_names = list() pkg_full_names = []
for name in pkg_names: for name in pkg_names:
info = pkgs.get(name) or {} info = pkgs.get(name) or {}
if self._install_special(name, info): if self._install_special(name, info):
continue continue
full_pkg_name = self._format_pkg_name(name, info.get("version")) full_pkg_name = self._format_pkg_name(name, info.get("version"))
if full_pkg_name: pkg_full_names.append(full_pkg_name)
pkg_full_names.append(full_pkg_name)
if pkg_full_names: if pkg_full_names:
cmd = YUM_CMD + YUM_INSTALL + pkg_full_names cmd = YUM_CMD + YUM_INSTALL + pkg_full_names
self._execute_yum(cmd) self._execute_yum(cmd)
def remove_batch(self, pkgs): def _remove_batch(self, pkgs):
pkg_names = sorted(pkgs.keys()) pkg_names = sorted(pkgs.keys())
pkg_full_names = [] pkg_full_names = []
which_removed = [] which_removed = []
@@ -126,9 +125,8 @@ class YumPackager(pack.Packager):
which_removed.append(name) which_removed.append(name)
continue continue
full_pkg_name = self._format_pkg_name(name, info.get("version")) full_pkg_name = self._format_pkg_name(name, info.get("version"))
if full_pkg_name: pkg_full_names.append(full_pkg_name)
pkg_full_names.append(full_pkg_name) which_removed.append(name)
which_removed.append(name)
if pkg_full_names: if pkg_full_names:
cmd = YUM_CMD + YUM_REMOVE + pkg_full_names cmd = YUM_CMD + YUM_REMOVE + pkg_full_names
self._execute_yum(cmd) self._execute_yum(cmd)

View File

@@ -21,8 +21,6 @@ from devstack import shell as sh
from devstack import settings from devstack import settings
LOG = logging.getLogger("devstack.pip") LOG = logging.getLogger("devstack.pip")
PIP_UNINSTALL_CMD_OPTS = ['-y', '-q'] PIP_UNINSTALL_CMD_OPTS = ['-y', '-q']
PIP_INSTALL_CMD_OPTS = ['-q'] PIP_INSTALL_CMD_OPTS = ['-q']

View File

@@ -346,9 +346,8 @@ def center_text(text, fill, max_len):
def _welcome_slang(): def _welcome_slang():
potentials = list() potentials = list()
potentials.append("And now for something completely different.") potentials.append("And now for something completely different")
msg = random.choice(potentials).strip("\n\r") return random.choice(potentials).strip("\n\r")
return msg
def color_text(text, color, bold=False): def color_text(text, color, bold=False):
@@ -368,6 +367,7 @@ def _color_blob(text, text_color):
def _goodbye_header(worked): def _goodbye_header(worked):
#cowsay headers
potentials_oks = list() potentials_oks = list()
potentials_oks.append(r''' potentials_oks.append(r'''
___________ ___________
@@ -492,13 +492,7 @@ def parse_components(components):
def welcome(ident): def welcome(ident):
ver_str = version.version_string() lower = "| %s %s |" % (ident, version.version_string())
lower = "|"
if ident:
lower += ident
lower += " "
lower += ver_str
lower += "|"
welcome_header = _get_welcome_stack() welcome_header = _get_welcome_stack()
max_line_len = len(max(welcome_header.splitlines(), key=len)) max_line_len = len(max(welcome_header.splitlines(), key=len))
footer = color_text(settings.PROG_NICE_NAME, 'green') footer = color_text(settings.PROG_NICE_NAME, 'green')