Fix ironic inspector rule creation idempotency
Ironic inspector rules are registered both with the seed and (if using) overcloud ironic inspector services. These tasks often show up as changed even when no configuration changes have been made that would affect the rules. This is caused by inspector returning default values for fields that may be omitted in the requested rule. This change fixes the issue by including those defaults in the comparison. Change-Id: Ia24e328d4531201d76a65b6385e4463bb1f3c5c6 Story: 2007399 Task: 38997
This commit is contained in:
parent
5cfca2aa82
commit
2a00b4cc67
@ -14,6 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.openstack import *
|
||||
|
||||
@ -102,7 +104,16 @@ def _ensure_rule_present(module, client):
|
||||
# Check whether the rule differs from the request.
|
||||
keys = ('conditions', 'actions', 'description')
|
||||
for key in keys:
|
||||
if rule[key] != module.params[key]:
|
||||
expected = module.params[key]
|
||||
if key == 'conditions':
|
||||
# Rules returned from the API include default values in the
|
||||
# conditions that may not be in the requested rule. Apply
|
||||
# defaults to allow the comparison to succeed.
|
||||
expected = copy.deepcopy(expected)
|
||||
for condition in expected:
|
||||
condition.setdefault('invert', False)
|
||||
condition.setdefault('multiple', 'any')
|
||||
if rule[key] != expected:
|
||||
break
|
||||
else:
|
||||
# Nothing to do - rule exists and is as requested.
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue with idempotency of Ironic Inspector rule creation. See
|
||||
`story 2007399 <https://storyboard.openstack.org/#!/story/2007399>`__ for
|
||||
details.
|
Loading…
x
Reference in New Issue
Block a user