Rename (pre/post)condition to (pre/post)_condition

This patch updates the applier's abstract methods to be consistent
with other abstract methods of similar nature.

Also included are a few other miscellaneous changes.

Change-Id: Ia1527c00332011412aba2ab326ec986f1e773001
Closes-bug: 1606634
This commit is contained in:
Joe Cropper
2016-08-06 16:21:30 -05:00
parent 27b3c5254d
commit ea01031268
11 changed files with 65 additions and 65 deletions

View File

@@ -15,8 +15,6 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import abc
@@ -28,7 +26,7 @@ from watcher.common.loader import loadable
@six.add_metaclass(abc.ABCMeta)
class BaseAction(loadable.Loadable):
# NOTE(jed) by convention we decided
# NOTE(jed): by convention we decided
# that the attribute "resource_id" is the unique id of
# the resource to which the Action applies to allow us to use it in the
# watcher dashboard and will be nested in input_parameters
@@ -99,7 +97,7 @@ class BaseAction(loadable.Loadable):
raise NotImplementedError()
@abc.abstractmethod
def precondition(self):
def pre_condition(self):
"""Hook: called before the execution of an action
This method can be used to perform some initializations or to make
@@ -110,7 +108,7 @@ class BaseAction(loadable.Loadable):
raise NotImplementedError()
@abc.abstractmethod
def postcondition(self):
def post_condition(self):
"""Hook: called after the execution of an action
This function is called regardless of whether an action succeded or

View File

@@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import six
import voluptuous
@@ -95,8 +96,8 @@ class ChangeNovaServiceState(base.BaseAction):
else:
return nova.disable_service_nova_compute(self.host)
def precondition(self):
def pre_condition(self):
pass
def postcondition(self):
def post_condition(self):
pass

View File

@@ -66,8 +66,8 @@ class Migrate(base.BaseAction):
if (value is not None and
len(value) > 0 and not
utils.is_uuid_like(value)):
raise voluptuous.Invalid(_("The parameter"
" resource_id is invalid."))
raise voluptuous.Invalid(_("The parameter "
"resource_id is invalid."))
@property
def schema(self):
@@ -116,11 +116,11 @@ class Migrate(base.BaseAction):
dest_hostname=destination,
block_migration=True)
else:
LOG.debug("Nova client exception occured while live migrating "
"instance %s.Exception: %s" %
LOG.debug("Nova client exception occurred while live "
"migrating instance %s.Exception: %s" %
(self.instance_uuid, e))
except Exception:
LOG.critical(_LC("Unexpected error occured. Migration failed for"
LOG.critical(_LC("Unexpected error occurred. Migration failed for "
"instance %s. Leaving instance on previous "
"host."), self.instance_uuid)
@@ -134,7 +134,7 @@ class Migrate(base.BaseAction):
dest_hostname=destination)
except Exception as exc:
LOG.exception(exc)
LOG.critical(_LC("Unexpected error occured. Migration failed for"
LOG.critical(_LC("Unexpected error occurred. Migration failed for "
"instance %s. Leaving instance on previous "
"host."), self.instance_uuid)
@@ -152,8 +152,8 @@ class Migrate(base.BaseAction):
return self._cold_migrate_instance(nova, destination)
else:
raise exception.Invalid(
message=(_('Migration of type %(migration_type)s is not '
'supported.') %
message=(_("Migration of type '%(migration_type)s' is not "
"supported.") %
{'migration_type': self.migration_type}))
else:
raise exception.InstanceNotFound(name=self.instance_uuid)
@@ -164,11 +164,11 @@ class Migrate(base.BaseAction):
def revert(self):
return self.migrate(destination=self.source_node)
def precondition(self):
# todo(jed) check if the instance exist/ check if the instance is on
def pre_condition(self):
# TODO(jed): check if the instance exists / check if the instance is on
# the source_node
pass
def postcondition(self):
# todo(jed) we can image to check extra parameters (nework reponse,ect)
def post_condition(self):
# TODO(jed): check extra parameters (network response, etc.)
pass

View File

@@ -53,15 +53,15 @@ class Nop(base.BaseAction):
return self.input_parameters.get(self.MESSAGE)
def execute(self):
LOG.debug("executing action NOP message:%s ", self.message)
LOG.debug("Executing action NOP message: %s ", self.message)
return True
def revert(self):
LOG.debug("revert action NOP")
LOG.debug("Revert action NOP")
return True
def precondition(self):
def pre_condition(self):
pass
def postcondition(self):
def post_condition(self):
pass

View File

@@ -16,8 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import time
import time
from oslo_log import log
import voluptuous
@@ -53,16 +53,16 @@ class Sleep(base.BaseAction):
return int(self.input_parameters.get(self.DURATION))
def execute(self):
LOG.debug("Starting action Sleep duration:%s ", self.duration)
LOG.debug("Starting action sleep with duration: %s ", self.duration)
time.sleep(self.duration)
return True
def revert(self):
LOG.debug("revert action Sleep")
LOG.debug("Revert action sleep")
return True
def precondition(self):
def pre_condition(self):
pass
def postcondition(self):
def post_condition(self):
pass