accept command name in decorator

This commit is contained in:
Jim Rollenhagen 2014-02-20 12:13:51 -08:00
parent 408bc793eb
commit 54cf6cfb60
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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')