From 54cf6cfb6036da4a25baeb3265580e36404082cf Mon Sep 17 00:00:00 2001 From: Jim Rollenhagen Date: Thu, 20 Feb 2014 12:13:51 -0800 Subject: [PATCH] accept command name in decorator --- teeth_agent/decorators.py | 4 ++-- teeth_agent/standby.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/teeth_agent/decorators.py b/teeth_agent/decorators.py index 0a91edba1..2fa79f923 100644 --- a/teeth_agent/decorators.py +++ b/teeth_agent/decorators.py @@ -18,7 +18,7 @@ import functools from teeth_agent import base -def async_command(validator=None): +def async_command(command_name, validator=None): """Will run the command in an AsyncCommandResult in its own thread. command_name is set based on the func name and command_params will be whatever args/kwargs you pass into the decorated command. @@ -35,7 +35,7 @@ def async_command(validator=None): # know about the mode bound_func = functools.partial(func, self) - return base.AsyncCommandResult(func.__name__, + return base.AsyncCommandResult(command_name, command_params, bound_func).start() return wrapper diff --git a/teeth_agent/standby.py b/teeth_agent/standby.py index d6c230f39..a938206c7 100644 --- a/teeth_agent/standby.py +++ b/teeth_agent/standby.py @@ -159,14 +159,14 @@ class StandbyMode(base.BaseAgentMode): self.command_map['prepare_image'] = self.prepare_image self.command_map['run_image'] = self.run_image - @decorators.async_command(_validate_image_info) + @decorators.async_command('cache_image', _validate_image_info) def cache_image(self, image_info=None): device = hardware.get_manager().get_os_install_device() _download_image(image_info) _write_image(image_info, device) - @decorators.async_command(_validate_image_info) + @decorators.async_command('prepare_image', _validate_image_info) def prepare_image(self, image_info=None, metadata=None, files=None): location = _configdrive_location() device = hardware.get_manager().get_os_install_device() @@ -178,7 +178,7 @@ class StandbyMode(base.BaseAgentMode): configdrive.write_configdrive(location, metadata, files) _copy_configdrive_to_disk(location, device) - @decorators.async_command() + @decorators.async_command('run_image') def run_image(self): script = _path_to_script('shell/reboot.sh') log.info('Rebooting system')