Updating string printouts

This commit is contained in:
Joshua Harlow 2012-03-28 11:14:58 -07:00
parent 071543eb97
commit 51d65678d9
2 changed files with 26 additions and 17 deletions

View File

@ -21,6 +21,7 @@ from devstack import exceptions as excp
from devstack import log as logging from devstack import log as logging
from devstack import settings from devstack import settings
from devstack import shell as sh from devstack import shell as sh
from devstack import utils
LOG = logging.getLogger("devstack.progs.actions") LOG = logging.getLogger("devstack.progs.actions")
@ -48,7 +49,7 @@ class ActionRunner(object):
Return boolean where True means invoke the prereq. Return boolean where True means invoke the prereq.
""" """
return return False
@abc.abstractmethod @abc.abstractmethod
def _run(self, persona, root_dir, component_order, instances): def _run(self, persona, root_dir, component_order, instances):
@ -120,30 +121,31 @@ class ActionRunner(object):
raise raise
def _handle_prereq(self, persona, instances, root_dir): def _handle_prereq(self, persona, instances, root_dir):
if not self.PREREQ: preq_cls = self.PREREQ
if not preq_cls:
return return
components_needing_prereq = [ components_needing_prereq = []
c for (c, instance) in instances.items():
for (c, instance) in instances.items() if self._instance_needs_prereq(instance):
if self._instance_needs_prereq(instance) components_needing_prereq.append(c)
] preq_cls_name = preq_cls.NAME or "???"
if components_needing_prereq: if components_needing_prereq:
LOG.info("Processing prerequisite action %s requested by (%s) components.", LOG.info("Processing prerequisite action %r requested by (%s) components.",
self.PREREQ.NAME, ", ".join(components_needing_prereq)) preq_cls_name, ", ".join(components_needing_prereq))
prereq = self.PREREQ(self.distro, prereq_instance = preq_cls(self.distro,
self.cfg, self.cfg,
self.pw_gen, self.pw_gen,
keep_old=self.keep_old, keep_old=self.keep_old,
force=self.force, force=self.force
) )
prereq.run(persona, root_dir) prereq_instance.run(persona, root_dir)
def run(self, persona, root_dir): def run(self, persona, root_dir):
instances = self._construct_instances(persona, root_dir) instances = self._construct_instances(persona, root_dir)
self._handle_prereq(persona, instances, root_dir) self._handle_prereq(persona, instances, root_dir)
component_order = self._order_components(persona.wanted_components) component_order = self._order_components(persona.wanted_components)
LOG.info("Processing components [%s] (in that order) for action %r", LOG.info("Processing components for action %r", (self.NAME or "???"))
"->".join(component_order), self.NAME) utils.log_iterable(component_order, header="Activating in the following order:")
self._verify_components(component_order, instances) self._verify_components(component_order, instances)
self._warm_components(component_order, instances) self._warm_components(component_order, instances)
self._run(persona, root_dir, component_order, instances) self._run(persona, root_dir, component_order, instances)

View File

@ -152,6 +152,13 @@ def mark_unexecute_file(fn, kvs, comment_start='#'):
sh.chmod(fn, 0644) sh.chmod(fn, 0644)
def log_iterable(to_log, header=""):
if header:
LOG.info(header)
for c in to_log:
LOG.info("|-- %s", color_text(c, 'blue'))
@contextlib.contextmanager @contextlib.contextmanager
def progress_bar(name, max_am, reverse=False): def progress_bar(name, max_am, reverse=False):
widgets = list() widgets = list()