Merge "Check whether action value is string before calling format()"
This commit is contained in:
commit
571df6eb16
|
@ -19,6 +19,7 @@ import jsonschema
|
|||
from oslo_db import exception as db_exc
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from sqlalchemy import orm
|
||||
|
||||
from ironic_inspector.common.i18n import _, _LE, _LI
|
||||
|
@ -202,7 +203,7 @@ class IntrospectionRule(object):
|
|||
ext = ext_mgr[act.action].obj
|
||||
for formatted_param in ext.FORMATTED_PARAMS:
|
||||
value = act.params.get(formatted_param)
|
||||
if not value:
|
||||
if not value or not isinstance(value, six.string_types):
|
||||
continue
|
||||
|
||||
# NOTE(aarefiev): verify provided value with introspection
|
||||
|
|
|
@ -419,6 +419,20 @@ class TestApplyActions(BaseTest):
|
|||
self.assertRaises(utils.Error, self.rule.apply_actions,
|
||||
self.node_info, data=self.data)
|
||||
|
||||
def test_apply_data_non_format_value(self, mock_ext_mgr):
|
||||
self.rule = rules.create(actions_json=[
|
||||
{'action': 'set-attribute',
|
||||
'path': '/driver_info/ipmi_address',
|
||||
'value': 1}],
|
||||
conditions_json=self.conditions_json
|
||||
)
|
||||
mock_ext_mgr.return_value.__getitem__.return_value = self.ext_mock
|
||||
|
||||
self.rule.apply_actions(self.node_info, data=self.data)
|
||||
|
||||
self.assertEqual(1, self.act_mock.apply.call_count)
|
||||
self.assertFalse(self.act_mock.rollback.called)
|
||||
|
||||
def test_rollback(self, mock_ext_mgr):
|
||||
mock_ext_mgr.return_value.__getitem__.return_value = self.ext_mock
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
This fixes setting non string 'value' field for rule's
|
||||
actions. As non string value is obviously not a formatted
|
||||
value, this adds a check to avoid AttributeError exception.
|
Loading…
Reference in New Issue