Making db instance restart async.

This commit is contained in:
Sudarshan Acharya
2012-06-08 13:53:16 -05:00
parent c3380d3735
commit 2041ea6a03
4 changed files with 21 additions and 7 deletions

View File

@@ -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):
"""

View File

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

View File

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

View File

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