From 32146acf4e43e6f95f54d9179bf01f0df9814217 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Wed, 8 Mar 2017 13:10:02 -0800 Subject: [PATCH] Actual attributes were being created and messing with the modules (#22424) --- lib/ansible/module_utils/f5_utils.py | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/ansible/module_utils/f5_utils.py b/lib/ansible/module_utils/f5_utils.py index ef328db5e75..2c70b662700 100644 --- a/lib/ansible/module_utils/f5_utils.py +++ b/lib/ansible/module_utils/f5_utils.py @@ -288,26 +288,26 @@ class AnsibleF5Parameters(object): if params: for k,v in iteritems(params): if self.api_map is not None and k in self.api_map: - # Handle weird API parameters like `dns.proxy.__iter__` by - # using a map provided by the module developer - class_attr = getattr(type(self), self.api_map[k], None) - if isinstance(class_attr, property): - # There is a mapped value for the api_map key - if class_attr.fset is None: - # If the mapped value does not have an associated setter - self._values[self.api_map[k]] = v - else: - # The mapped value has a setter - setattr(self, self.api_map[k], v) + dict_to_use = self.api_map + map_key = self.api_map[k] + else: + dict_to_use = self._values + map_key = k + + # Handle weird API parameters like `dns.proxy.__iter__` by + # using a map provided by the module developer + class_attr = getattr(type(self), map_key, None) + if isinstance(class_attr, property): + # There is a mapped value for the api_map key + if class_attr.fset is None: + # If the mapped value does not have an associated setter + self._values[map_key] = v else: - # If the mapped value is not a @property - self._values[self.api_map[k]] = v - try: - # There is no map, or the provided param is not in the api_map - setattr(self, k, v) - except AttributeError: - # At a minimum put it in values. - self._values[k] = v + # The mapped value has a setter + setattr(self, map_key, v) + else: + # If the mapped value is not a @property + self._values[map_key] = v def __getattr__(self, item): # Ensures that properties that weren't defined, and therefore stashed