diff --git a/reddwarf/instance/models.py b/reddwarf/instance/models.py index 4833ae086a..e4e8afdb19 100644 --- a/reddwarf/instance/models.py +++ b/reddwarf/instance/models.py @@ -447,13 +447,8 @@ class Instance(SimpleInstance): # status is no longer in effect. self.db_info.task_status = InstanceTasks.REBOOTING self.db_info.save() - try: - self.get_guest().restart() - except rd_exceptions.GuestError: - LOG.error("Failure to restart MySQL.") - finally: - self.db_info.task_status = InstanceTasks.NONE - self.db_info.save() + LOG.debug("Instance %s set to RESTARTING." % self.id) + task_api.API(self.context).restart(self.id) def validate_can_perform_restart_or_reboot(self): """ diff --git a/reddwarf/taskmanager/api.py b/reddwarf/taskmanager/api.py index e73781817b..086c84d8fe 100644 --- a/reddwarf/taskmanager/api.py +++ b/reddwarf/taskmanager/api.py @@ -70,6 +70,10 @@ class API(object): old_flavor_size=old_flavor_size, new_flavor_size=new_flavor_size) + def restart(self, instance_id): + LOG.debug("Making async call to restart instance: %s" % instance_id) + self._cast("restart", instance_id=instance_id) + def delete_instance(self, instance_id): LOG.debug("Making async call to delete instance: %s" % instance_id) self._cast("delete_instance", instance_id=instance_id) diff --git a/reddwarf/taskmanager/manager.py b/reddwarf/taskmanager/manager.py index 95ed1b97ce..65b78082e3 100644 --- a/reddwarf/taskmanager/manager.py +++ b/reddwarf/taskmanager/manager.py @@ -64,6 +64,10 @@ class TaskManager(service.Manager): instance_tasks.resize_flavor(new_flavor_id, old_flavor_size, new_flavor_size) + def restart(self, context, instance_id): + instance_tasks = models.InstanceTasks.load(context, instance_id) + instance_tasks.restart() + def delete_instance(self, context, instance_id): instance_tasks = models.InstanceTasks.load(context, instance_id) instance_tasks.delete_instance() diff --git a/reddwarf/taskmanager/models.py b/reddwarf/taskmanager/models.py index 309903bf07..0aa2c21cc8 100644 --- a/reddwarf/taskmanager/models.py +++ b/reddwarf/taskmanager/models.py @@ -20,6 +20,7 @@ from novaclient import exceptions as nova_exceptions from reddwarf.common import config from reddwarf.common import remote from reddwarf.common import utils +from reddwarf.common.exception import GuestError from reddwarf.common.exception import PollTimeOut from reddwarf.common.exception import VolumeCreationFailure from reddwarf.common.exception import NotFound @@ -210,6 +211,16 @@ class InstanceTasks: LOG.error(e) self._log_service_status(instance_id, ServiceStatuses.UNKNOWN) + def restart(self): + LOG.debug("Restarting instance %s " % self.db_info.id) + try: + self.guest.restart() + except GuestError: + LOG.error("Failure to restart instance %s " % self.db_info.id) + finally: + self.db_info.task_status = inst_models.InstanceTasks.NONE + self.db_info.save() + def _create_volume(self, instance_id, volume_size): LOG.info("Entering create_volume") LOG.debug(_("Starting to create the volume for the instance"))