From 4254841a845ad6b7212a827aaebdc52512baa65f Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 27 Feb 2012 17:18:00 -0800 Subject: [PATCH] More adjustments to runners. --- devstack/component.py | 4 ++-- devstack/{runners/runnerbase.py => runner.py} | 10 ++++++++-- devstack/runners/fork.py | 6 ++++-- devstack/runners/screen.py | 6 ++++-- devstack/runners/upstart.py | 13 +++++-------- 5 files changed, 23 insertions(+), 16 deletions(-) rename devstack/{runners/runnerbase.py => runner.py} (73%) diff --git a/devstack/component.py b/devstack/component.py index c27d88b8..ba834062 100644 --- a/devstack/component.py +++ b/devstack/component.py @@ -405,8 +405,8 @@ class ProgramRuntime(ComponentBase): # Configure it with the given settings LOG.info("Configuring runner for program [%s]" % (app_name)) runtime_info = (app_pth, app_dir, program_opts) - starter.configure(app_name, runtime_info, self.tracedir) - LOG.info("Configured runner for program [%s]" % (app_name)) + cfg_am = starter.configure(self.component_name, app_name, runtime_info) + LOG.info("Configured %s files for runner for program [%s]" % (cfg_am, app_name)) def start(self): # Select how we are going to start it diff --git a/devstack/runners/runnerbase.py b/devstack/runner.py similarity index 73% rename from devstack/runners/runnerbase.py rename to devstack/runner.py index f808569a..c0f9b20c 100644 --- a/devstack/runners/runnerbase.py +++ b/devstack/runner.py @@ -20,5 +20,11 @@ class RunnerBase(object): def __init__(self, cfg): self.cfg = cfg - def configure(self, component_name, app_name, runtime_info, tracedir): - return list() + def configure(self, component_name, app_name, runtime_info): + raise NotImplementedError() + + def start(self, component_name, name, runtime_info, tracedir): + raise NotImplementedError() + + def stop(self, component_name, name, trace_dir): + raise NotImplementedError() diff --git a/devstack/runners/fork.py b/devstack/runners/fork.py index 1b0aedfb..8b392efa 100644 --- a/devstack/runners/fork.py +++ b/devstack/runners/fork.py @@ -24,12 +24,11 @@ import time from devstack import exceptions as excp from devstack import log as logging +from devstack import runner as base from devstack import settings from devstack import shell as sh from devstack import trace as tr -from devstack.runners import runnerbase as base - LOG = logging.getLogger("devstack.runners.fork") #maximum for the number of available file descriptors (when not found) @@ -173,6 +172,9 @@ class ForkRunner(base.RunnerBase): runtrace.trace(k, v) return tracefn + def configure(self, component_name, app_name, runtime_info): + return 0 + def start(self, component_name, name, runtime_info, tracedir): (program, appdir, program_args) = runtime_info fn_name = FORK_TEMPL % (name) diff --git a/devstack/runners/screen.py b/devstack/runners/screen.py index d713eaf5..b3c305e0 100644 --- a/devstack/runners/screen.py +++ b/devstack/runners/screen.py @@ -22,13 +22,12 @@ import time from devstack import date from devstack import exceptions as excp from devstack import log as logging +from devstack import runner as base from devstack import settings from devstack import shell as sh from devstack import trace as tr from devstack import utils -from devstack.runners import runnerbase as base - LOG = logging.getLogger("devstack.runners.screen") #my type @@ -78,6 +77,9 @@ class ScreenRunner(base.RunnerBase): base.RunnerBase.__init__(self, cfg) self.socket_dir = sh.joinpths(tempfile.gettempdir(), SCREEN_SOCKET_DIR_NAME) + def configure(self, component_name, app_name, runtime_info): + return 0 + def stop(self, component_name, name, tracedir): fn_name = SCREEN_TEMPL % (name) trace_fn = tr.trace_fn(tracedir, fn_name) diff --git a/devstack/runners/upstart.py b/devstack/runners/upstart.py index d55db1e8..15fd73d9 100644 --- a/devstack/runners/upstart.py +++ b/devstack/runners/upstart.py @@ -21,13 +21,12 @@ import subprocess from devstack import date from devstack import log as logging +from devstack import runner as base from devstack import settings from devstack import shell as sh from devstack import trace as tr from devstack import utils -from devstack.runners import runnerbase as base - LOG = logging.getLogger("devstack.runners.upstart") #my type @@ -48,7 +47,6 @@ CONF_EXT = ".conf" #shared template UPSTART_CONF_TMPL = 'upstart.conf' -# Keep track of what we've emitted in the current python session class UpstartRunner(base.RunnerBase): @@ -71,11 +69,10 @@ class UpstartRunner(base.RunnerBase): self.events.add(component_event) sh.unlink(trace_fn) - def configure(self, component_name, app_name, runtime_info, tracedir): - LOG.debug("Configure called for app:%s" % (app_name)) - result = list() - result.append(self._do_upstart_configure(component_name, app_name, runtime_info)) - return result + def configure(self, component_name, app_name, runtime_info): + LOG.debug("Configure called for app: %s" % (app_name)) + self._do_upstart_configure(component_name, app_name, runtime_info) + return 1 def _get_upstart_conf_params(self, component_name, program_name, *program_args): params = dict()