Skip to content

Commit

Permalink
Update pfsense_dns_resolver.py
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire authored Jan 31, 2024
1 parent d1537e1 commit af6d76e
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions plugins/modules/pfsense_dns_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,33 +485,33 @@ def _params_to_obj(self):
host["aliases"] = "\n\t\t\t"

# reformat for acls
acls = []
for entry in params.get('acls'):
acl = dict()
for subparam in DNS_RESOLVER_ACL_ARGUMENT_SPEC:
if entry.get(subparam) is not None:
acl[subparam] = {}
if DNS_RESOLVER_ACL_ARGUMENT_SPEC[subparam]['type'] == 'list':
# this will break the config
acl_networks = []
for subentry in entry.get(subparam):
acl_network = dict()
for subsubparam in DNS_RESOLVER_ACL_NETWORK_ARGUMENT_SPEC:
if isinstance(subentry[subsubparam], str):
acl_network[subsubparam] = subentry[subsubparam]
else:
acl_network[subsubparam] = str(subentry[subsubparam])
acl_networks.append(acl_network)
# dict_to_element will generate multiple <aliases> elements, but pfsense wants <aliases> with multiple <item>-Elements
acl['row'] = acl_networks
else:
if isinstance(entry[subparam], str):
acl[subparam] = entry[subparam]
else:
acl[subparam] = str(entry[subparam])
acls.append(acl)
if params.get('acls') is not None:
obj[param] = acls
acls = []
for entry in params.get('acls'):
acl = dict()
for subparam in DNS_RESOLVER_ACL_ARGUMENT_SPEC:
if entry.get(subparam) is not None:
acl[subparam] = {}
if DNS_RESOLVER_ACL_ARGUMENT_SPEC[subparam]['type'] == 'list':
# this will break the config
acl_networks = []
for subentry in entry.get(subparam):
acl_network = dict()
for subsubparam in DNS_RESOLVER_ACL_NETWORK_ARGUMENT_SPEC:
if isinstance(subentry[subsubparam], str):
acl_network[subsubparam] = subentry[subsubparam]
else:
acl_network[subsubparam] = str(subentry[subsubparam])
acl_networks.append(acl_network)
# dict_to_element will generate multiple <aliases> elements, but pfsense wants <aliases> with multiple <item>-Elements
acl['row'] = acl_networks
else:
if isinstance(entry[subparam], str):
acl[subparam] = entry[subparam]
else:
acl[subparam] = str(entry[subparam])
acls.append(acl)
obj['acls'] = acls

return obj

Expand Down

0 comments on commit af6d76e

Please sign in to comment.