diff --git a/watcher/applier/action_plan/__init__.py b/watcher/applier/action_plan/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/watcher/applier/messaging/applier_command.py b/watcher/applier/action_plan/base.py similarity index 95% rename from watcher/applier/messaging/applier_command.py rename to watcher/applier/action_plan/base.py index 880a0251f..4dee074a7 100644 --- a/watcher/applier/messaging/applier_command.py +++ b/watcher/applier/action_plan/base.py @@ -22,7 +22,7 @@ import six @six.add_metaclass(abc.ABCMeta) -class ApplierCommand(object): +class BaseActionPlanHandler(object): @abc.abstractmethod def execute(self): raise NotImplementedError( diff --git a/watcher/applier/messaging/launcher.py b/watcher/applier/action_plan/default.py similarity index 93% rename from watcher/applier/messaging/launcher.py rename to watcher/applier/action_plan/default.py index 1da7e0e16..529022480 100644 --- a/watcher/applier/messaging/launcher.py +++ b/watcher/applier/action_plan/default.py @@ -18,8 +18,8 @@ # from oslo_log import log +from watcher.applier.action_plan.base import BaseActionPlanHandler from watcher.applier.default import DefaultApplier -from watcher.applier.messaging.applier_command import ApplierCommand from watcher.applier.messaging.events import Events from watcher.common.messaging.events.event import Event from watcher.objects.action_plan import ActionPlan @@ -28,9 +28,9 @@ from watcher.objects.action_plan import Status LOG = log.getLogger(__name__) -class LaunchActionPlanCommand(ApplierCommand): +class DefaultActionPlanHandler(BaseActionPlanHandler): def __init__(self, context, manager_applier, action_plan_uuid): - super(LaunchActionPlanCommand, self).__init__() + super(DefaultActionPlanHandler, self).__init__() self.ctx = context self.action_plan_uuid = action_plan_uuid self.manager_applier = manager_applier diff --git a/watcher/applier/messaging/trigger.py b/watcher/applier/messaging/trigger.py index dd07198ad..1c1c8d931 100644 --- a/watcher/applier/messaging/trigger.py +++ b/watcher/applier/messaging/trigger.py @@ -18,7 +18,7 @@ # from oslo_log import log -from watcher.applier.messaging.launcher import LaunchActionPlanCommand +from watcher.applier.action_plan.default import DefaultActionPlanHandler LOG = log.getLogger(__name__) @@ -29,9 +29,9 @@ class TriggerActionPlan(object): def do_launch_action_plan(self, context, action_plan_uuid): try: - cmd = LaunchActionPlanCommand(context, - self.manager_applier, - action_plan_uuid) + cmd = DefaultActionPlanHandler(context, + self.manager_applier, + action_plan_uuid) cmd.execute() except Exception as e: LOG.error("do_launch_action_plan " + unicode(e)) diff --git a/watcher/tests/applier/messaging/test_launch_action_plan_command.py b/watcher/tests/applier/action_plan/test_default_action_handler.py similarity index 78% rename from watcher/tests/applier/messaging/test_launch_action_plan_command.py rename to watcher/tests/applier/action_plan/test_default_action_handler.py index 815a1b51c..dbd099bb1 100644 --- a/watcher/tests/applier/messaging/test_launch_action_plan_command.py +++ b/watcher/tests/applier/action_plan/test_default_action_handler.py @@ -19,35 +19,33 @@ from mock import call from mock import MagicMock - +from watcher.applier.action_plan.default import DefaultActionPlanHandler from watcher.applier.messaging.events import Events -from watcher.applier.messaging.launcher import LaunchActionPlanCommand - from watcher.objects.action_plan import Status from watcher.objects import ActionPlan from watcher.tests.db.base import DbTestCase from watcher.tests.objects import utils as obj_utils -class TestLaunchActionPlanCommand(DbTestCase): +class TestDefaultActionPlanHandler(DbTestCase): def setUp(self): - super(TestLaunchActionPlanCommand, self).setUp() + super(TestDefaultActionPlanHandler, self).setUp() self.action_plan = obj_utils.create_test_action_plan( self.context) def test_launch_action_plan_wihout_errors(self): try: - command = LaunchActionPlanCommand(self.context, MagicMock(), - self.action_plan.uuid) + command = DefaultActionPlanHandler(self.context, MagicMock(), + self.action_plan.uuid) command.execute() except Exception as e: self.fail( "The ActionPlan should be trigged wihtour error" + unicode(e)) def test_launch_action_plan_state_failed(self): - command = LaunchActionPlanCommand(self.context, MagicMock(), - self.action_plan.uuid) + command = DefaultActionPlanHandler(self.context, MagicMock(), + self.action_plan.uuid) command.execute() action_plan = ActionPlan.get_by_uuid(self.context, self.action_plan.uuid) @@ -55,8 +53,8 @@ class TestLaunchActionPlanCommand(DbTestCase): def test_trigger_audit_send_notification(self): messaging = MagicMock() - command = LaunchActionPlanCommand(self.context, messaging, - self.action_plan.uuid) + command = DefaultActionPlanHandler(self.context, messaging, + self.action_plan.uuid) command.execute() call_on_going = call(Events.LAUNCH_ACTION_PLAN.name, {