mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-30 11:24:50 +00:00
Fixed a bug in AnsibleFreeIPAParams
When accessing an instance of AnsibleFreeIPAParams with .get the obj was by-passing the call to _afm_convert which was the primaty reason why it was created. Also the class now extends Mapping instead of dict.
This commit is contained in:
@@ -52,6 +52,11 @@ import socket
|
|||||||
import base64
|
import base64
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
try:
|
||||||
|
from collections.abc import Mapping # noqa
|
||||||
|
except ImportError:
|
||||||
|
from collections import Mapping # noqa
|
||||||
|
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
unicode = str
|
unicode = str
|
||||||
@@ -351,19 +356,28 @@ def is_ipv6_addr(ipaddr):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class AnsibleFreeIPAParams(dict):
|
class AnsibleFreeIPAParams(Mapping):
|
||||||
def __init__(self, ansible_module):
|
def __init__(self, ansible_module):
|
||||||
self.update(ansible_module.params)
|
self.mapping = ansible_module.params
|
||||||
self.ansible_module = ansible_module
|
self.ansible_module = ansible_module
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
param = self.mapping[key]
|
||||||
|
if param is not None:
|
||||||
|
return _afm_convert(param)
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return iter(self.mapping)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.mapping)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def names(self):
|
def names(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
param = self.get(name)
|
return self.get(name)
|
||||||
if param is not None:
|
|
||||||
return _afm_convert(param)
|
|
||||||
|
|
||||||
|
|
||||||
class FreeIPABaseModule(AnsibleModule):
|
class FreeIPABaseModule(AnsibleModule):
|
||||||
|
|||||||
Reference in New Issue
Block a user