Merge pull request #144 from harlowja/master

Bunch of string cleanups.
This commit is contained in:
Joshua Harlow 2012-03-27 18:06:02 -07:00
commit 492af315ed
11 changed files with 81 additions and 78 deletions

View File

@ -139,7 +139,7 @@ class PackageBasedComponentMixin(object):
def get_packager(self, pkg_info):
if self.PACKAGER_KEY_NAME in pkg_info:
packager_name = pkg_info[self.PACKAGER_KEY_NAME]
LOG.debug('Loading custom package manager %s', packager_name)
LOG.debug('Loading custom package manager %r', packager_name)
packager = importer.import_entry_point(packager_name)(self.distro)
else:
LOG.debug('Using default package manager')
@ -173,13 +173,13 @@ class PkgInstallComponent(ComponentBase, PackageBasedComponentMixin):
(cfg_section, cfg_key) = branch_tuple
branch = self.cfg.get(cfg_section, cfg_key)
if not branch:
msg = "No branch entry found at config location [%s]" % \
msg = "No branch entry found at config location %r" % \
(cfg_helpers.make_id(cfg_section, cfg_key))
raise excp.ConfigException(msg)
(cfg_section, cfg_key) = uri_tuple
uri = self.cfg.get(cfg_section, cfg_key)
if not uri:
msg = "No uri entry found at config location [%s]" % \
msg = "No uri entry found at config location %r" % \
(cfg_helpers.make_id(cfg_section, cfg_key))
raise excp.ConfigException(msg)
# Activate da download!
@ -213,14 +213,14 @@ class PkgInstallComponent(ComponentBase, PackageBasedComponentMixin):
if name in self.subsystem_info:
# Todo handle duplicates/version differences?
LOG.debug(
"Extending package list with packages for subsystem %s",
"Extending package list with packages for subsystem %r",
name)
subsystem_pkgs = self.subsystem_info[name].get('packages', [])
pkg_list.extend(subsystem_pkgs)
return pkg_list
def install(self):
LOG.debug('Preparing to install packages for %s',
LOG.debug('Preparing to install packages for %r',
self.component_name)
pkgs = self._get_packages()
if pkgs:
@ -234,7 +234,7 @@ class PkgInstallComponent(ComponentBase, PackageBasedComponentMixin):
packager.install(p)
p_bar.update(i + 1)
else:
LOG.info('No packages to install for %s',
LOG.info('No packages to install for %r',
self.component_name)
return self.trace_dir
@ -284,14 +284,14 @@ class PkgInstallComponent(ComponentBase, PackageBasedComponentMixin):
parameters = self._get_param_map(fn)
tgt_fn = self._get_target_config_name(fn)
self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(tgt_fn)))
LOG.info("Configuring file %s", fn)
LOG.info("Configuring file %r", fn)
(source_fn, contents) = self._get_source_config(fn)
LOG.debug("Replacing parameters in file %s", source_fn)
LOG.debug("Replacing parameters in file %r", source_fn)
LOG.debug("Replacements = %s", parameters)
contents = utils.param_replace(contents, parameters)
LOG.debug("Applying side-effects of param replacement for template %s", source_fn)
LOG.debug("Applying side-effects of param replacement for template %r", source_fn)
contents = self._config_adjust(contents, fn)
LOG.info("Writing configuration file %s", tgt_fn)
LOG.info("Writing configuration file %r", tgt_fn)
self.tracewriter.cfg_file_written(sh.write_file(tgt_fn,
contents))
return len(configs)
@ -306,11 +306,11 @@ class PkgInstallComponent(ComponentBase, PackageBasedComponentMixin):
for source in link_srcs:
link = links.get(source)
try:
LOG.info("Symlinking %s => %s", link, source)
LOG.info("Symlinking %r => %r", link, source)
self.tracewriter.dirs_made(*sh.symlink(source, link))
self.tracewriter.symlink_made(link)
except OSError as e:
LOG.warn("Symlink (%s => %s) error (%s)", link, source, e)
LOG.warn("Symlink (%r => %r) error (%s)", link, source, e)
return len(links)
def configure(self):
@ -334,7 +334,7 @@ class PythonInstallComponent(PkgInstallComponent):
for name in self.desired_subsystems:
if name in self.subsystem_info:
# Todo handle duplicates/version differences?
LOG.debug("Extending pip list with pips for subsystem %s" % (name))
LOG.debug("Extending pip list with pips for subsystem %r" % (name))
subsystem_pips = self.subsystem_info[name].get('pips', list())
pip_list.extend(subsystem_pips)
return pip_list
@ -468,12 +468,12 @@ class PkgUninstallComponent(ComponentBase, PackageBasedComponentMixin):
places = set()
for (pth_loc, _) in self.tracereader.download_locations():
places.add(pth_loc)
LOG.info("Keeping %s download directories [%s]",
len(places), ",".join(sorted(places)))
LOG.info("Keeping %s download directories (%s)",
len(places), ", ".join(sorted(places)))
for download_place in places:
dirsmade = sh.remove_parents(download_place, dirsmade)
for dirname in dirsmade:
LOG.info("Removing created directory (%s)", dirname)
LOG.info("Removing created directory %r", dirname)
sh.deldir(dirname, run_as_root=True)
@ -546,10 +546,10 @@ class ProgramRuntime(ComponentBase):
self._get_param_map(app_name),
)
# Configure it with the given settings
LOG.debug("Configuring runner for program [%s]", app_name)
LOG.debug("Configuring runner for program %r", app_name)
cfg_am = instance.configure(app_name,
(app_pth, app_dir, program_opts))
LOG.debug("Configured %s files for runner for program [%s]",
LOG.debug("Configured %s files for runner for program %r",
cfg_am, app_name)
tot_am += cfg_am
return tot_am
@ -569,12 +569,12 @@ class ProgramRuntime(ComponentBase):
self._get_param_map(app_name),
)
# Start it with the given settings
LOG.debug("Starting [%s] with options [%s]",
LOG.debug("Starting %r with options (%s)",
app_name, ", ".join(program_opts))
info_fn = instance.start(app_name,
(app_pth, app_dir, program_opts),
)
LOG.debug("Started [%s] details are in [%s]", app_name, info_fn)
LOG.info("Started %r details are in %r", app_name, info_fn)
# This trace is used to locate details about what to stop
self.tracewriter.started_info(app_name, info_fn)
am_started += 1
@ -611,7 +611,7 @@ class ProgramRuntime(ComponentBase):
to_kill = self._locate_killers()
for (app_name, killer) in to_kill:
killer.stop(app_name)
LOG.debug("Deleting start trace file [%s]",
LOG.debug("Deleting start trace file %r",
self.tracereader.filename())
sh.unlink(self.tracereader.filename())
return len(to_kill)

View File

@ -104,7 +104,7 @@ class GlanceInstaller(GlanceMixin, comp.PythonInstallComponent):
self._setup_db()
def _setup_db(self):
LOG.info("Fixing up database named %s.", DB_NAME)
LOG.info("Fixing up database named %r", DB_NAME)
db.drop_db(self.cfg, self.pw_gen, self.distro, DB_NAME)
db.create_db(self.cfg, self.pw_gen, self.distro, DB_NAME)

View File

@ -121,7 +121,7 @@ class KeystoneInstaller(comp.PythonInstallComponent):
return list(CONFIGS)
def _setup_db(self):
LOG.info("Fixing up database named %s.", DB_NAME)
LOG.info("Fixing up database named %r", DB_NAME)
db.drop_db(self.cfg, self.pw_gen, self.distro, DB_NAME)
db.create_db(self.cfg, self.pw_gen, self.distro, DB_NAME)

View File

@ -75,7 +75,7 @@ class MelangeInstaller(comp.PythonInstallComponent):
return places
def _setup_db(self):
LOG.info("Fixing up database named %s.", DB_NAME)
LOG.info("Fixing up database named %r", DB_NAME)
db.drop_db(self.cfg, self.pw_gen, self.distro, DB_NAME)
db.create_db(self.cfg, self.pw_gen, self.distro, DB_NAME)

View File

@ -15,6 +15,7 @@
# under the License.
import os
import weakref
from urlparse import urlunparse
@ -276,7 +277,7 @@ class NovaInstaller(NovaMixin, comp.PythonInstallComponent):
self.pw_gen.get_password(pw_key, pw_prompt)
def _setup_network_initer(self):
LOG.info("Configuring nova network initializer template %s.", NET_INIT_CONF)
LOG.info("Configuring nova network initializer template %r", NET_INIT_CONF)
(_, contents) = utils.load_template(self.component_name, NET_INIT_CONF)
params = self._get_param_map(NET_INIT_CONF)
contents = utils.param_replace(contents, params, True)
@ -313,7 +314,7 @@ class NovaInstaller(NovaMixin, comp.PythonInstallComponent):
self.tracewriter.file_touched(tgt_fn)
def _setup_db(self):
LOG.info("Fixing up database named %s.", DB_NAME)
LOG.info("Fixing up database named %r", DB_NAME)
db.drop_db(self.cfg, self.pw_gen, self.distro, DB_NAME)
db.create_db(self.cfg, self.pw_gen, self.distro, DB_NAME)
@ -322,7 +323,7 @@ class NovaInstaller(NovaMixin, comp.PythonInstallComponent):
conf_gen = NovaConfConfigurator(self)
nova_conf_contents = conf_gen.configure()
conf_fn = self._get_target_config_name(API_CONF)
LOG.info("Writing nova configuration to %s" % (conf_fn))
LOG.info("Writing nova configuration to %r" % (conf_fn))
LOG.debug(nova_conf_contents)
self.tracewriter.dirs_made(*sh.mkdirslist(sh.dirname(conf_fn)))
self.tracewriter.cfg_file_written(sh.write_file(conf_fn, nova_conf_contents))
@ -424,10 +425,11 @@ class NovaRuntime(NovaMixin, comp.PythonRuntime):
# This will configure nova volumes which in a developer box
# is a volume group (lvm) that are backed by a loopback file
class NovaVolumeConfigurator(object):
def __init__(self, ni):
self.cfg = ni.cfg
self.app_dir = ni.app_dir
self.distro = ni.distro
def __init__(self, installer):
self.installer = weakref.proxy(installer)
self.cfg = installer.cfg
self.app_dir = installer.app_dir
self.distro = installer.distro
def setup_volumes(self):
self._setup_vol_groups()
@ -443,12 +445,12 @@ class NovaVolumeConfigurator(object):
mp['VOLUME_BACKING_FILE_SIZE'] = backing_file_size
try:
utils.execute_template(*VG_CHECK_CMD, params=mp)
LOG.warn("Volume group already exists: %s" % (vol_group))
LOG.warn("Volume group already exists: %r" % (vol_group))
except exceptions.ProcessExecutionError as err:
# Check that the error from VG_CHECK is an expected error
if err.exit_code != 5:
raise
LOG.info("Need to create volume group: %s" % (vol_group))
LOG.info("Need to create volume group: %r" % (vol_group))
sh.touch_file(backing_file, die_if_there=False, file_size=backing_file_size)
vg_dev_result = utils.execute_template(*VG_DEV_CMD, params=mp)
if vg_dev_result and vg_dev_result[0]:
@ -470,15 +472,14 @@ class NovaVolumeConfigurator(object):
LOG.info("Attempting to setup logical volumes for nova volume management.")
lvs_result = utils.execute_template(*VG_LVS_CMD, params=mp)
if lvs_result and lvs_result[0]:
LOG.debug("LVS result: %s" % (lvs_result))
vol_name_prefix = self.cfg.getdefaulted('nova', 'volume_name_prefix', DEF_VOL_PREFIX)
LOG.debug("Using volume name prefix: %s" % (vol_name_prefix))
LOG.debug("Using volume name prefix: %r" % (vol_name_prefix))
(sysout, _) = lvs_result[0]
for stdout_line in sysout.split('\n'):
stdout_line = stdout_line.strip()
if stdout_line:
# Ignore blank lines
LOG.debug("Processing LVS output line: %s" % (stdout_line))
LOG.debug("Processing LVS output line: %r" % (stdout_line))
if stdout_line.startswith(vol_name_prefix):
# TODO still need to implement the following:
# tid=`egrep "^tid.+$lv" /proc/net/iet/volume | cut -f1 -d' ' | tr ':' '='`
@ -495,21 +496,23 @@ class NovaVolumeConfigurator(object):
# This class has the smarts to build the configuration file based on
# various runtime values. A useful reference for figuring out this
# is at http://docs.openstack.org/diablo/openstack-compute/admin/content/ch_configuring-openstack-compute.html
# See also: https://github.com/openstack/nova/blob/master/etc/nova/nova.conf.sample
class NovaConfConfigurator(object):
def __init__(self, ni):
self.cfg = ni.cfg
self.pw_gen = ni.pw_gen
self.instances = ni.instances
self.component_dir = ni.component_dir
self.app_dir = ni.app_dir
self.tracewriter = ni.tracewriter
self.paste_conf_fn = ni.paste_conf_fn
self.distro = ni.distro
self.cfg_dir = ni.cfg_dir
self.xvnc_enabled = ni.xvnc_enabled
self.volumes_enabled = ni.volumes_enabled
self.options = ni.options
self.novnc_enabled = 'no-vnc' in self.options
def __init__(self, installer):
self.installer = weakref.proxy(installer)
self.cfg = installer.cfg
self.pw_gen = installer.pw_gen
self.instances = installer.instances
self.component_dir = installer.component_dir
self.app_dir = installer.app_dir
self.tracewriter = installer.tracewriter
self.paste_conf_fn = installer.paste_conf_fn
self.distro = installer.distro
self.cfg_dir = installer.cfg_dir
self.options = installer.options
self.xvnc_enabled = installer.xvnc_enabled
self.volumes_enabled = installer.volumes_enabled
self.novnc_enabled = 'no-vnc' in installer.options
def _getbool(self, name):
return self.cfg.getboolean('nova', name)
@ -737,11 +740,11 @@ class NovaConfConfigurator(object):
# Do a little check to make sure actually have that interface/s
if not utils.is_interface(public_interface):
msg = "Public interface %s is not a known interface" % (public_interface)
msg = "Public interface %r is not a known interface" % (public_interface)
raise exceptions.ConfigException(msg)
if not utils.is_interface(vlan_interface):
msg = "VLAN interface %s is not a known interface" % (vlan_interface)
msg = "VLAN interface %r is not a known interface" % (vlan_interface)
raise exceptions.ConfigException(msg)
nova_conf.add('public_interface', public_interface)
@ -827,7 +830,7 @@ class NovaConf(object):
else:
real_value = str(value)
self.lines.append({'key': real_key, 'value': real_value})
LOG.debug("Added nova conf key %s with value [%s]" % (real_key, real_value))
LOG.debug("Added nova conf key %r with value %r" % (real_key, real_value))
def _form_entry(self, key, value, params=None):
real_value = utils.param_replace(str(value), params)

View File

@ -153,7 +153,7 @@ class QuantumInstaller(QuantumMixin, comp.PkgInstallComponent):
if not self.q_vswitch_service or \
'no-ovs-db-init' in self.options:
return
LOG.info("Fixing up database named %s.", DB_NAME)
LOG.info("Fixing up database named %r", DB_NAME)
db.drop_db(self.cfg, self.pw_gen, self.distro, DB_NAME)
db.create_db(self.cfg, self.pw_gen, self.distro, DB_NAME)

View File

@ -20,7 +20,6 @@ import re
from devstack import date
from devstack import env
from devstack import log as logging
from devstack import settings
from devstack import shell as sh
from devstack import utils
@ -56,6 +55,15 @@ EXP_PAT = re.compile("^\s*export\s+(.*?)=(.*?)$", re.IGNORECASE)
# How we unquote a string (simple edition)
QUOTED_PAT = re.compile(r"^\s*[\"](.*)[\"]\s*$")
# Allow external includes via this template
EXTERN_TPL = """
# Allow local overrides of env variables using {fn}
if [ -f "{fn}" ]; then
source "{fn}"
fi
"""
EXTERN_INCLUDES = ['localrc', 'eucarc']
class RcWriter(object):
def __init__(self, cfg, pw_gen, root_dir):
@ -244,16 +252,10 @@ class RcWriter(object):
def _generate_extern_inc(self):
lines = list()
lines.append('# External includes stuff')
extern_tpl = """
# Allow local overrides of env variables
if [ -f "{localrc_fn}" ]; then
source "{localrc_fn}"
fi
"""
extern_inc = extern_tpl.format(localrc_fn=sh.abspth(settings.LOCALRC_FN))
lines.append(extern_inc.strip())
for inc_fn in EXTERN_INCLUDES:
extern_inc = EXTERN_TPL.format(fn=inc_fn)
lines.append(extern_inc.strip())
lines.append('')
lines.append("")
return lines

View File

@ -128,7 +128,7 @@ class ActionRunner(object):
if self._instance_needs_prereq(instance)
]
if components_needing_prereq:
LOG.info("Processing prerequisite action [%s] requested by (%s) components.",
LOG.info("Processing prerequisite action %s requested by (%s) components.",
self.PREREQ.NAME, ", ".join(components_needing_prereq))
prereq = self.PREREQ(self.distro,
self.cfg,
@ -142,12 +142,11 @@ class ActionRunner(object):
instances = self._construct_instances(persona, root_dir)
self._handle_prereq(persona, instances, root_dir)
component_order = self._order_components(persona.wanted_components)
LOG.info("Processing components [%s] (in that order) for action [%s]",
LOG.info("Processing components [%s] (in that order) for action %r",
"->".join(component_order), self.NAME)
self._verify_components(component_order, instances)
self._warm_components(component_order, instances)
self._run(persona, root_dir, component_order, instances)
return
class InstallRunner(ActionRunner):
@ -159,14 +158,14 @@ class InstallRunner(ActionRunner):
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):
LOG.info("Generating a file at [%s] that will contain your environment settings.",
LOG.info("Generating a file at %r that will contain your environment settings.",
settings.OSRC_FN)
writer.write(settings.OSRC_FN)
else:
LOG.info("Updating a file at [%s] that contains your environment settings.",
LOG.info("Updating a file at %r that contains your environment settings.",
settings.OSRC_FN)
am_upd = writer.update(settings.OSRC_FN)
LOG.info("Updated [%s] settings in rc file [%s]",
LOG.info("Updated %s settings in rc file %r",
am_upd, settings.OSRC_FN)
def _run(self, persona, root_dir, component_order, instances):

View File

@ -44,7 +44,6 @@ COMPONENT_CONFIG_DIR = "config"
# RC files generated / used
RC_FN_TEMPL = "os-%s.rc"
LOCALRC_FN = RC_FN_TEMPL % ('local')
OSRC_FN = RC_FN_TEMPL % ('core')
# Where the configs and templates should be at.

View File

@ -17,7 +17,7 @@ fi
# Find the other rc files
RC_DIR=$(cd $(dirname "$BASH_SOURCE") && pwd)
CORE_RC="os-core.rc"
EC2_RC="os-ec2.rc"
EC2_RC="eucarc"
if [ ! -f $RC_DIR/$CORE_RC ];
then

10
stack
View File

@ -86,11 +86,11 @@ def load_rc_files():
fns = [settings.OSRC_FN]
for fn in fns:
try:
LOG.debug("Attempting to load rc file at [%s] which has your environment settings." % (fn))
LOG.info("Attempting to load file %r which has your environment settings." % (fn))
am_loaded = env_rc.RcReader().load(fn)
LOG.debug("Loaded [%s] settings from rc file [%s]" % (am_loaded, fn))
LOG.info("Loaded %s settings from file %r" % (am_loaded, fn))
except IOError:
LOG.warn('Error reading rc file located at [%s]. Skipping loading it.' % (fn))
LOG.warn('Error reading file located at %r. Skipping loading it.' % (fn))
return len(fns)
@ -165,9 +165,9 @@ def run(args):
runner.run(persona_inst, root_dir)
end_time = time.time()
LOG.info("It took (%s) to complete action [%s]" %
LOG.info("It took (%s) to complete action %r" %
(utils.format_secs_taken((end_time - start_time)), action))
LOG.info("After action [%s] your settings which were created or read are:" % (action))
LOG.info("After action %r your settings which were created or read are:" % (action))
dump_config(config.configs_fetched)
return True