diff options
author | Tim Rupp <caphrim007@gmail.com> | 2017-03-08 00:43:36 -0800 |
---|---|---|
committer | John R Barker <john@johnrbarker.com> | 2017-03-08 08:43:36 +0000 |
commit | a8910e78ca218438ecfd21f62ca1b8535adf7649 (patch) | |
tree | 0309fad04c18143fd2531aa959bed8984bc548e3 | |
parent | fbf55886ba9f6bd42f59c2a1e286f08778c8ab45 (diff) | |
download | ansible-a8910e78ca218438ecfd21f62ca1b8535adf7649.tar.gz |
Using the wrong variable (#22386)
-rw-r--r-- | lib/ansible/module_utils/f5_utils.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/ansible/module_utils/f5_utils.py b/lib/ansible/module_utils/f5_utils.py index a6e1c59c10..ef328db5e7 100644 --- a/lib/ansible/module_utils/f5_utils.py +++ b/lib/ansible/module_utils/f5_utils.py @@ -287,20 +287,27 @@ class AnsibleF5Parameters(object): self._values = defaultdict(lambda: None) if params: for k,v in iteritems(params): - try: + 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 - setattr(self, self.api_params[k], v) - except (KeyError, TypeError): - # Otherwise set things to attributes as normal - try: - setattr(self, k, v) - except AttributeError: - # If all else fails, stash them in a dictionary. For - # instance, if the module developer forgot a map, - # or said developer didn't need to add a setter for - # the property - self._values[k] = v + 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) + 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 def __getattr__(self, item): # Ensures that properties that weren't defined, and therefore stashed |