finish stubbing out the standby agent

This commit is contained in:
Russell Haering
2013-10-13 10:20:45 -07:00
parent ee40766be2
commit 0cee477518

View File

@@ -16,7 +16,7 @@ limitations under the License.
from teeth_agent.client import TeethClient
from teeth_agent.logging import get_logger
from teeth_agent.protocol import require_parameters
from teeth_agent.protocol import require_parameters, CommandValidationError
from teeth_agent.task import PrepareImageTask
log = get_logger()
@@ -30,9 +30,21 @@ class StandbyAgent(TeethClient):
def __init__(self, addrs):
super(StandbyAgent, self).__init__(addrs)
self._add_handler('v1', 'prepare_image', self.prepare_image)
self._add_handler('v1', 'standby.cache_images', self.cache_images)
self._add_handler('v1', 'standby.prepare_image', self.prepare_image)
self._add_handler('v1', 'standby.run_image', self.run_image)
log.msg('Starting agent', addrs=addrs)
@require_parameters('task_id', 'image_ids')
def cache_images(self, command):
"""
Cache a set of images. Ordered in priority, we may only cache a
subset depending on storage availability.
"""
if not isinstance(command.params['image_ids'], list):
raise CommandValidationError('"image_ids" must be a list')
pass
@require_parameters('task_id', 'image_id')
def prepare_image(self, command):
"""Prepare an Image."""
@@ -42,6 +54,12 @@ class StandbyAgent(TeethClient):
t = PrepareImageTask(self, task_id, image_id)
t.run()
@require_parameters('task_id', 'image_id')
def run_image(self, command):
"""
Run the specified image.
"""
def update_task_status(self, task):
"""Send an updated task status to the agent endpoint."""
pass