diff --git a/reddwarf/guestagent/api.py b/reddwarf/guestagent/api.py index 9e5efcd2b6..aabc96c82e 100644 --- a/reddwarf/guestagent/api.py +++ b/reddwarf/guestagent/api.py @@ -132,7 +132,7 @@ class API(object): def restart(self): """Restart the MySQL server.""" LOG.debug(_("Sending the call to restart MySQL on the Guest.")) - self.call("restart") + self._call("restart") def start_mysql_with_conf_changes(self, updated_memory_size): """Start the MySQL server.""" diff --git a/reddwarf/guestagent/dbaas.py b/reddwarf/guestagent/dbaas.py index ac2de51b27..cd2f09675d 100644 --- a/reddwarf/guestagent/dbaas.py +++ b/reddwarf/guestagent/dbaas.py @@ -147,7 +147,7 @@ class MySqlAppStatus(object): def begin_mysql_restart(self): """Called before restarting MySQL.""" - self.restart_mode = true + self.restart_mode = True def end_install_or_restart(self): """Called after MySQL is installed or restarted. @@ -232,7 +232,7 @@ class MySqlAppStatus(object): The database is update and the status is also returned. """ - if self.is_mysql_installed and self.is_mysql_running: + if self.is_mysql_installed and not self._is_mysql_restarting: LOG.info("Determining status of MySQL app...") status = self._get_actual_db_status() self.set_status(status) @@ -501,12 +501,8 @@ class DBaaSAgent(object): LOG.info('"prepare" call has finished.') def restart(self): - try: - self.begin_mysql_restart() - self._internal_stop_mysql() - self._start_mysql() - finally: - self.end_install_or_restart() + app = MySqlApp(self.status) + app.restart() def update_status(self): """Update the status of the MySQL service""" @@ -626,7 +622,7 @@ class MySqlApp(object): try: self.status.begin_mysql_restart() self._internal_stop_mysql() - self.start_mysql() + self._start_mysql() finally: self.status.end_install_or_restart() diff --git a/reddwarf/instance/models.py b/reddwarf/instance/models.py index 070498f9ed..7b66721871 100644 --- a/reddwarf/instance/models.py +++ b/reddwarf/instance/models.py @@ -23,7 +23,6 @@ import netaddr from reddwarf import db from reddwarf.common import config -from reddwarf.guestagent import api as guest_api from reddwarf.common import exception as rd_exceptions from reddwarf.common import utils from reddwarf.instance.tasks import InstanceTask @@ -260,7 +259,7 @@ class Instance(object): raise RuntimeError("Not implemented (yet).") def restart(self): - if instance_state in SERVER_INVALID_ACTION_STATUSES: + if self.server.status in SERVER_INVALID_ACTION_STATUSES: msg = _("Restart instance not allowed while instance %s is in %s " "status.") % (self.id, instance_state) LOG.debug(msg) @@ -278,21 +277,21 @@ class Instance(object): self.db_info.save() try: self.get_guest().restart() - except RemoteError: + except rd_exceptions.GuestError: LOG.error("Failure to restart MySQL.") finally: self.db_info.task_status = InstanceTasks.NONE - self._instance_update(context,instance_id, task_state=None) + self.db_info.save() - def validate_can_perform_action_on_instance(): + def validate_can_perform_action_on_instance(self): """ Raises exception if an instance action cannot currently be performed. """ if self.status != InstanceStatus.ACTIVE: msg = "Instance is not currently available for an action to be " \ "performed (status was %s)." % self.status - LOG.trace(msg) - raise UnprocessableEntity(msg) + LOG.error(msg) + raise rd_exceptions.UnprocessableEntity(msg) diff --git a/reddwarf/instance/service.py b/reddwarf/instance/service.py index 943aad67d0..c01affd48d 100644 --- a/reddwarf/instance/service.py +++ b/reddwarf/instance/service.py @@ -109,7 +109,7 @@ class InstanceController(BaseController): raise rd_exceptions.BadRequest(msg) if selected_action: - return selected_action(self, instance, body) + return selected_action(instance, body) else: raise rd_exceptions.BadRequest(_("Invalid request body.")) diff --git a/reddwarf/openstack/common/config.py b/reddwarf/openstack/common/config.py index 7ae703e1ea..92066937b1 100644 --- a/reddwarf/openstack/common/config.py +++ b/reddwarf/openstack/common/config.py @@ -310,6 +310,8 @@ def load_paste_app(app_name, options, args, config_dir=None): logger.debug("*" * 80) app = deploy.loadapp("config:%s" % conf_file, name=app_name) except (LookupError, ImportError), e: + import traceback + print traceback.format_exc() raise RuntimeError("Unable to load %(app_name)s from " "configuration file %(conf_file)s." "\nGot: %(e)r" % locals())