diff --git a/watcher/api/controllers/v1/action.py b/watcher/api/controllers/v1/action.py index f8bb79e67..7555fb7c9 100644 --- a/watcher/api/controllers/v1/action.py +++ b/watcher/api/controllers/v1/action.py @@ -87,9 +87,6 @@ class Action(base.APIBase): mandatory=True) """The action plan this action belongs to """ - description = wtypes.text - """Description of this action""" - state = wtypes.text """This audit state""" @@ -99,17 +96,11 @@ class Action(base.APIBase): applies_to = wtypes.text """Applies to""" - src = wtypes.text - """Hypervisor source""" - - dst = wtypes.text - """Hypervisor source""" - action_type = wtypes.text """Action type""" - parameter = wtypes.text - """Additionnal parameter""" + input_parameters = wtypes.DictType(wtypes.text, wtypes.text) + """One or more key/value pairs """ next_uuid = wsme.wsproperty(types.uuid, _get_next_uuid, _set_next_uuid, diff --git a/watcher/db/sqlalchemy/models.py b/watcher/db/sqlalchemy/models.py index b65aabd31..858e4adff 100644 --- a/watcher/db/sqlalchemy/models.py +++ b/watcher/db/sqlalchemy/models.py @@ -155,17 +155,15 @@ class Action(Base): table_args() ) id = Column(Integer, primary_key=True) - uuid = Column(String(36)) + uuid = Column(String(36), nullable=False) action_plan_id = Column(Integer, ForeignKey('action_plans.id'), - nullable=True) + nullable=False) # only for the first version - action_type = Column(String(255)) - applies_to = Column(String(255)) - src = Column(String(255)) - dst = Column(String(255)) - parameter = Column(String(255)) - description = Column(String(255)) + action_type = Column(String(255), nullable=False) + applies_to = Column(String(255), nullable=True) + input_parameters = Column(JSONEncodedDict, nullable=True) state = Column(String(20), nullable=True) + # todo(jed) remove parameter alarm alarm = Column(String(36)) next = Column(String(36), nullable=True) diff --git a/watcher/objects/action.py b/watcher/objects/action.py index 63bd32de7..dbb74ec15 100644 --- a/watcher/objects/action.py +++ b/watcher/objects/action.py @@ -43,11 +43,9 @@ class Action(base.WatcherObject): 'action_plan_id': obj_utils.int_or_none, 'action_type': obj_utils.str_or_none, 'applies_to': obj_utils.str_or_none, - 'src': obj_utils.str_or_none, - 'dst': obj_utils.str_or_none, - 'parameter': obj_utils.str_or_none, - 'description': obj_utils.str_or_none, + 'input_parameters': obj_utils.dict_or_none, 'state': obj_utils.str_or_none, + # todo(jed) remove parameter alarm 'alarm': obj_utils.str_or_none, 'next': obj_utils.int_or_none, } diff --git a/watcher/tests/api/v1/test_actions.py b/watcher/tests/api/v1/test_actions.py index 4dcd093c8..055be3d83 100644 --- a/watcher/tests/api/v1/test_actions.py +++ b/watcher/tests/api/v1/test_actions.py @@ -84,11 +84,8 @@ class TestListAction(api_base.FunctionalTest): action = obj_utils.create_test_action(self.context, next=None) response = self.get_json('/actions/%s' % action['uuid']) self.assertEqual(action.uuid, response['uuid']) - self.assertEqual(action.description, response['description']) - self.assertEqual(action.src, response['src']) - self.assertEqual(action.dst, response['dst']) self.assertEqual(action.action_type, response['action_type']) - self.assertEqual(action.parameter, response['parameter']) + self.assertEqual(action.input_parameters, response['input_parameters']) self._assert_action_fields(response) def test_get_one_soft_deleted(self): diff --git a/watcher/tests/db/utils.py b/watcher/tests/db/utils.py index 6052a1435..e7ae15719 100644 --- a/watcher/tests/db/utils.py +++ b/watcher/tests/db/utils.py @@ -86,14 +86,11 @@ def get_test_action(**kwargs): 'action_type': kwargs.get('action_type', 'COLD_MIGRATION'), 'applies_to': kwargs.get('applies_to', '10a47dd1-4874-4298-91cf-eff046dbdb8d'), - 'src': kwargs.get('src', 'rdev-indeedsrv002'), - 'dst': kwargs.get('dst', 'rdev-indeedsrv001'), - 'parameter': kwargs.get('parameter', ''), - 'description': kwargs.get('description', 'Desc. Of The Action'), + 'input_parameters': kwargs.get('input_parameters', {'key1': 'val1', + 'key2': 'val2'}), 'state': kwargs.get('state', 'PENDING'), 'alarm': kwargs.get('alarm', None), 'next': kwargs.get('next', 2), - 'created_at': kwargs.get('created_at'), 'updated_at': kwargs.get('updated_at'), 'deleted_at': kwargs.get('deleted_at'),