Merge "Rename command to action_plan"
This commit is contained in:
commit
0042356245
watcher
applier
tests/applier/action_plan
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)
|
||||
class ApplierCommand(object):
|
||||
class BaseActionPlanHandler(object):
|
||||
@abc.abstractmethod
|
||||
def execute(self):
|
||||
raise NotImplementedError(
|
@ -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
|
@ -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))
|
||||
|
@ -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, {
|
Loading…
x
Reference in New Issue
Block a user