Cancel Action Plan

This patch adds feature to cancel action plan in watcher.
A General flow from watcher-api to watcher-applier is implemented.

action plan cancel can cancel any [ongoing, pending, recommended]
action plan, it will update the action states also to "cancelled".
For ongoing actions in action plan, actions needs to be aborted.
Seperate patches will be added to support abort operation
in each action.

Notification part is addressed by a seperate blueprint.
https://blueprints.launchpad.net/watcher/+spec/notifications-actionplan-cancel

Change-Id: I895a5eaca5239d5657702c8d1875b9ece21682dc
Partially-Implements: blueprint cancel-action-plan
This commit is contained in:
aditi
2017-05-26 11:40:36 +00:00
parent 58d86de064
commit d7a44739a6
16 changed files with 362 additions and 28 deletions

View File

@@ -32,6 +32,9 @@ class BaseAction(loadable.Loadable):
# watcher dashboard and will be nested in input_parameters
RESOURCE_ID = 'resource_id'
# Add action class name to the list, if implementing abort.
ABORT_TRUE = ['Sleep', 'Nop']
def __init__(self, config, osc=None):
"""Constructor
@@ -134,3 +137,6 @@ class BaseAction(loadable.Loadable):
def get_description(self):
"""Description of the action"""
raise NotImplementedError()
def check_abort(self):
return bool(self.__class__.__name__ in self.ABORT_TRUE)

View File

@@ -164,6 +164,10 @@ class Migrate(base.BaseAction):
def revert(self):
return self.migrate(destination=self.source_node)
def abort(self):
# TODO(adisky): implement abort for migration
LOG.warning("Abort for migration not implemented")
def pre_condition(self):
# TODO(jed): check if the instance exists / check if the instance is on
# the source_node

View File

@@ -23,7 +23,6 @@ import voluptuous
from watcher.applier.actions import base
LOG = log.getLogger(__name__)
@@ -69,3 +68,6 @@ class Nop(base.BaseAction):
def get_description(self):
"""Description of the action"""
return "Logging a NOP message"
def abort(self):
LOG.debug("Abort action NOP")

View File

@@ -70,3 +70,6 @@ class Sleep(base.BaseAction):
def get_description(self):
"""Description of the action"""
return "Wait for a given interval in seconds."
def abort(self):
LOG.debug("Abort action sleep")