Rename command to action_plan
Some Python class and packages need to be renamed for a better compliance with the shared terminology which provides a better understanding of Watcher objects and components by every contributor. This patchset is there to change command to action_plan Partially implements: blueprint glossary-related-refactoring Change-Id: I19a70adeca347ce747a2221b5fc31658139c95a2
This commit is contained in:
0
watcher/applier/action_plan/__init__.py
Normal file
0
watcher/applier/action_plan/__init__.py
Normal file
@@ -22,7 +22,7 @@ import six
|
|||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class ApplierCommand(object):
|
class BaseActionPlanHandler(object):
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def execute(self):
|
def execute(self):
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
@@ -18,8 +18,8 @@
|
|||||||
#
|
#
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
|
from watcher.applier.action_plan.base import BaseActionPlanHandler
|
||||||
from watcher.applier.default import DefaultApplier
|
from watcher.applier.default import DefaultApplier
|
||||||
from watcher.applier.messaging.applier_command import ApplierCommand
|
|
||||||
from watcher.applier.messaging.events import Events
|
from watcher.applier.messaging.events import Events
|
||||||
from watcher.common.messaging.events.event import Event
|
from watcher.common.messaging.events.event import Event
|
||||||
from watcher.objects.action_plan import ActionPlan
|
from watcher.objects.action_plan import ActionPlan
|
||||||
@@ -28,9 +28,9 @@ from watcher.objects.action_plan import Status
|
|||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LaunchActionPlanCommand(ApplierCommand):
|
class DefaultActionPlanHandler(BaseActionPlanHandler):
|
||||||
def __init__(self, context, manager_applier, action_plan_uuid):
|
def __init__(self, context, manager_applier, action_plan_uuid):
|
||||||
super(LaunchActionPlanCommand, self).__init__()
|
super(DefaultActionPlanHandler, self).__init__()
|
||||||
self.ctx = context
|
self.ctx = context
|
||||||
self.action_plan_uuid = action_plan_uuid
|
self.action_plan_uuid = action_plan_uuid
|
||||||
self.manager_applier = manager_applier
|
self.manager_applier = manager_applier
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#
|
#
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from watcher.applier.messaging.launcher import LaunchActionPlanCommand
|
from watcher.applier.action_plan.default import DefaultActionPlanHandler
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@@ -29,9 +29,9 @@ class TriggerActionPlan(object):
|
|||||||
|
|
||||||
def do_launch_action_plan(self, context, action_plan_uuid):
|
def do_launch_action_plan(self, context, action_plan_uuid):
|
||||||
try:
|
try:
|
||||||
cmd = LaunchActionPlanCommand(context,
|
cmd = DefaultActionPlanHandler(context,
|
||||||
self.manager_applier,
|
self.manager_applier,
|
||||||
action_plan_uuid)
|
action_plan_uuid)
|
||||||
cmd.execute()
|
cmd.execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error("do_launch_action_plan " + unicode(e))
|
LOG.error("do_launch_action_plan " + unicode(e))
|
||||||
|
|||||||
@@ -19,35 +19,33 @@
|
|||||||
from mock import call
|
from mock import call
|
||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
|
|
||||||
|
from watcher.applier.action_plan.default import DefaultActionPlanHandler
|
||||||
from watcher.applier.messaging.events import Events
|
from watcher.applier.messaging.events import Events
|
||||||
from watcher.applier.messaging.launcher import LaunchActionPlanCommand
|
|
||||||
|
|
||||||
from watcher.objects.action_plan import Status
|
from watcher.objects.action_plan import Status
|
||||||
from watcher.objects import ActionPlan
|
from watcher.objects import ActionPlan
|
||||||
from watcher.tests.db.base import DbTestCase
|
from watcher.tests.db.base import DbTestCase
|
||||||
from watcher.tests.objects import utils as obj_utils
|
from watcher.tests.objects import utils as obj_utils
|
||||||
|
|
||||||
|
|
||||||
class TestLaunchActionPlanCommand(DbTestCase):
|
class TestDefaultActionPlanHandler(DbTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestLaunchActionPlanCommand, self).setUp()
|
super(TestDefaultActionPlanHandler, self).setUp()
|
||||||
self.action_plan = obj_utils.create_test_action_plan(
|
self.action_plan = obj_utils.create_test_action_plan(
|
||||||
self.context)
|
self.context)
|
||||||
|
|
||||||
def test_launch_action_plan_wihout_errors(self):
|
def test_launch_action_plan_wihout_errors(self):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
command = LaunchActionPlanCommand(self.context, MagicMock(),
|
command = DefaultActionPlanHandler(self.context, MagicMock(),
|
||||||
self.action_plan.uuid)
|
self.action_plan.uuid)
|
||||||
command.execute()
|
command.execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.fail(
|
self.fail(
|
||||||
"The ActionPlan should be trigged wihtour error" + unicode(e))
|
"The ActionPlan should be trigged wihtour error" + unicode(e))
|
||||||
|
|
||||||
def test_launch_action_plan_state_failed(self):
|
def test_launch_action_plan_state_failed(self):
|
||||||
command = LaunchActionPlanCommand(self.context, MagicMock(),
|
command = DefaultActionPlanHandler(self.context, MagicMock(),
|
||||||
self.action_plan.uuid)
|
self.action_plan.uuid)
|
||||||
command.execute()
|
command.execute()
|
||||||
action_plan = ActionPlan.get_by_uuid(self.context,
|
action_plan = ActionPlan.get_by_uuid(self.context,
|
||||||
self.action_plan.uuid)
|
self.action_plan.uuid)
|
||||||
@@ -55,8 +53,8 @@ class TestLaunchActionPlanCommand(DbTestCase):
|
|||||||
|
|
||||||
def test_trigger_audit_send_notification(self):
|
def test_trigger_audit_send_notification(self):
|
||||||
messaging = MagicMock()
|
messaging = MagicMock()
|
||||||
command = LaunchActionPlanCommand(self.context, messaging,
|
command = DefaultActionPlanHandler(self.context, messaging,
|
||||||
self.action_plan.uuid)
|
self.action_plan.uuid)
|
||||||
command.execute()
|
command.execute()
|
||||||
|
|
||||||
call_on_going = call(Events.LAUNCH_ACTION_PLAN.name, {
|
call_on_going = call(Events.LAUNCH_ACTION_PLAN.name, {
|
||||||
Reference in New Issue
Block a user