From 88f8551672def68900063228d91f92719e613f1e Mon Sep 17 00:00:00 2001 From: Sean O'Keeffe Date: Wed, 8 Aug 2018 09:54:31 +0100 Subject: [PATCH] change check_missing to None --- module_utils/ansible_nailgun_cement.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/module_utils/ansible_nailgun_cement.py b/module_utils/ansible_nailgun_cement.py index 9629f3e39d..e8baa7628b 100644 --- a/module_utils/ansible_nailgun_cement.py +++ b/module_utils/ansible_nailgun_cement.py @@ -235,12 +235,12 @@ def update_fields(new, old, fields): # Common functionality to manipulate entities -def naildown_entity_state(entity_class, entity_dict, entity, state, module, check_missing=[]): +def naildown_entity_state(entity_class, entity_dict, entity, state, module, check_missing=None): changed, _ = naildown_entity(entity_class, entity_dict, entity, state, module, check_missing) return changed -def naildown_entity(entity_class, entity_dict, entity, state, module, check_missing=[]): +def naildown_entity(entity_class, entity_dict, entity, state, module, check_missing=None): """ Ensure that a given entity has a certain state """ changed, changed_entity = False, entity if state == 'present_with_defaults': @@ -340,13 +340,14 @@ def update_entity(old_entity, entity_dict, module, check_missing): # depending on what 'type' of same object you are requesting. Content View # Filters are a prime example. We list these attributes in `check_missing` # so we can ensure the entity is as the user specified. - if key not in entity_dict and key in check_missing: + if check_missing is not None and key not in entity_dict and key in check_missing: volatile_entity.__setattr__(key, None) fields.append(key) - for key in check_missing: - if key in entity_dict and key not in volatile_entity.get_values(): - volatile_entity.__setattr__(key, entity_dict[key]) - fields.append(key) + if check_missing is not None: + for key in check_missing: + if key in entity_dict and key not in volatile_entity.get_values(): + volatile_entity.__setattr__(key, entity_dict[key]) + fields.append(key) if len(fields) > 0: if not module.check_mode: result = volatile_entity.update(fields)