Add the possibility to store several parameters for an Action
In watcher, an audit generates a set of actions which aims at achieving a given goal (lower energy consumption, ...). It is possible to configure different strategies in order to achieve each goal. Each strategy is written as a Python class which produces a set of actions. Today, the set of possible actions is fixed for a given version of Watcher and enables optimization algorithms to include actions such as instance migration, changing hypervisor state, changing power state (ACPI level, ...). This patchset add the possibility to store several parameters for an Action. The parameters store info that the custom Action needs. The parameters provided as tuples with the following fields: (parameter_name, parameter_type). It remove also the deprecated attributes (src,dst,description) APIImpact Partially implements: blueprint watcher-add-actions-via-conf Change-Id: Ic6727341822f8ac62f212d337814b2dca76044e3
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user