Skip to content

Commit

Permalink
Tidy up validate-modules ignores for modules: net_tools/nios (#1598)
Browse files Browse the repository at this point in the history
* Added ``normalize_ib_spec()``

* Added suboptions

- ``http_pool_connections``
- ``http_pool_maxsize``
- ``silent_ssl_warnings``

* fixed validation-modules for plugins/modules/net_tools/nios/nios_a_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_aaaa_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_cname_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_dns_view.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_fixed_address.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_host_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_member.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_mx_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_naptr_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_network.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_network_view.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_ptr_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_srv_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_txt_record.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_zone.py

* fixed validation-modules for plugins/modules/net_tools/nios/nios_nsgroup.py

* Added function to normalize the ``ib_spec`` for ansible usage.

* Tidy up validate-modules ignores for net_tools/nios modules

* Update plugins/modules/net_tools/nios/nios_nsgroup.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/net_tools/nios/nios_nsgroup.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/net_tools/nios/nios_nsgroup.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/net_tools/nios/nios_nsgroup.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/net_tools/nios/nios_nsgroup.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/net_tools/nios/nios_nsgroup.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* fixed missing defaults, per PR tests

* added changelog fragment

* Update changelogs/fragments/nios-fix-ib_spec.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
  • Loading branch information
russoz and felixfontein authored Jan 11, 2021
1 parent 6375719 commit 6c7f8f9
Show file tree
Hide file tree
Showing 22 changed files with 326 additions and 276 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/nios-fix-ib_spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- nios modules - clean up module argument spec processing (https://github.com/ansible-collections/community.general/pull/1598).
18 changes: 18 additions & 0 deletions plugins/doc_fragments/nios.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ class ModuleDocFragment(object):
variable.
type: int
default: 1000
http_pool_connections:
description:
- Number of pools to be used by the C(infoblox_client.Connector) object.
- This is passed as-is to the underlying C(requests.adapters.HTTPAdapter) class.
type: int
default: 10
http_pool_maxsize:
description:
- Maximum number of connections per pool to be used by the C(infoblox_client.Connector) object.
- This is passed as-is to the underlying C(requests.adapters.HTTPAdapter) class.
type: int
default: 10
silent_ssl_warnings:
description:
- Disable C(urllib3) SSL warnings in the C(infoblox_client.Connector) object.
- This is passed as-is to the underlying C(requests.adapters.HTTPAdapter) class.
type: bool
default: true
notes:
- "This module must be run locally, which can be achieved by specifying C(connection: local)."
- Please read the :ref:`nios_guide` for more detailed information on how to use Infoblox with Ansible.
Expand Down
9 changes: 9 additions & 0 deletions plugins/module_utils/net_tools/nios/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ def member_normalize(member_spec):
return member_spec


def normalize_ib_spec(ib_spec):
result = {}
for arg in ib_spec:
result[arg] = dict([(k, v)
for k, v in iteritems(ib_spec[arg])
if k not in ('ib_req', 'transform', 'update')])
return result


class WapiBase(object):
''' Base class for implementing Infoblox WAPI API '''
provider_spec = {'provider': dict(type='dict', options=NIOS_PROVIDER_SPEC)}
Expand Down
8 changes: 6 additions & 2 deletions plugins/modules/net_tools/nios/nios_a_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@
ttl:
description:
- Configures the TTL to be associated with this A record
type: int
extattrs:
description:
- Allows for the configuration of Extensible Attributes on the
instance of the object. This argument accepts a set of key / value
pairs for configuration.
type: dict
comment:
description:
- Configures a text string comment to be associated with the instance
of this object. The provided text string will be configured on the
object instance.
type: str
state:
description:
- Configures the intended state of the instance of the object on
Expand All @@ -65,6 +68,7 @@
choices:
- present
- absent
type: str
'''

EXAMPLES = '''
Expand Down Expand Up @@ -128,9 +132,9 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import WapiModule
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import NIOS_A_RECORD
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import normalize_ib_spec


def main():
Expand All @@ -154,7 +158,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'])
)

argument_spec.update(ib_spec)
argument_spec.update(normalize_ib_spec(ib_spec))
argument_spec.update(WapiModule.provider_spec)

module = AnsibleModule(argument_spec=argument_spec,
Expand Down
11 changes: 9 additions & 2 deletions plugins/modules/net_tools/nios/nios_aaaa_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,37 @@
- Specifies the fully qualified hostname to add or remove from
the system
required: true
type: str
view:
description:
- Sets the DNS view to associate this AAAA record with. The DNS
view must already be configured on the system
default: default
aliases:
- dns_view
type: str
ipv6addr:
description:
- Configures the IPv6 address for this AAAA record.
aliases:
- ipv6
type: str
ttl:
description:
- Configures the TTL to be associated with this AAAA record
type: int
extattrs:
description:
- Allows for the configuration of Extensible Attributes on the
instance of the object. This argument accepts a set of key / value
pairs for configuration.
type: dict
comment:
description:
- Configures a text string comment to be associated with the instance
of this object. The provided text string will be configured on the
object instance.
type: str
state:
description:
- Configures the intended state of the instance of the object on
Expand All @@ -60,6 +66,7 @@
choices:
- present
- absent
type: str
'''

EXAMPLES = '''
Expand Down Expand Up @@ -112,9 +119,9 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import WapiModule
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import NIOS_AAAA_RECORD
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import normalize_ib_spec


def main():
Expand All @@ -138,7 +145,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'])
)

argument_spec.update(ib_spec)
argument_spec.update(normalize_ib_spec(ib_spec))
argument_spec.update(WapiModule.provider_spec)

module = AnsibleModule(argument_spec=argument_spec,
Expand Down
11 changes: 9 additions & 2 deletions plugins/modules/net_tools/nios/nios_cname_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,37 @@
- Specifies the fully qualified hostname to add or remove from
the system
required: true
type: str
view:
description:
- Sets the DNS view to associate this CNAME record with. The DNS
view must already be configured on the system
default: default
aliases:
- dns_view
type: str
canonical:
description:
- Configures the canonical name for this CNAME record.
aliases:
- cname
type: str
ttl:
description:
- Configures the TTL to be associated with this CNAME record
type: int
extattrs:
description:
- Allows for the configuration of Extensible Attributes on the
instance of the object. This argument accepts a set of key / value
pairs for configuration.
type: dict
comment:
description:
- Configures a text string comment to be associated with the instance
of this object. The provided text string will be configured on the
object instance.
type: str
state:
description:
- Configures the intended state of the instance of the object on
Expand All @@ -60,6 +66,7 @@
choices:
- present
- absent
type: str
'''

EXAMPLES = '''
Expand Down Expand Up @@ -101,9 +108,9 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import WapiModule
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import NIOS_CNAME_RECORD
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import normalize_ib_spec


def main():
Expand All @@ -127,7 +134,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'])
)

argument_spec.update(ib_spec)
argument_spec.update(normalize_ib_spec(ib_spec))
argument_spec.update(WapiModule.provider_spec)

module = AnsibleModule(argument_spec=argument_spec,
Expand Down
8 changes: 7 additions & 1 deletion plugins/modules/net_tools/nios/nios_dns_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,28 @@
required: true
aliases:
- view
type: str
network_view:
description:
- Specifies the name of the network view to assign the configured
DNS view to. The network view must already be configured on the
target system.
default: default
type: str
extattrs:
description:
- Allows for the configuration of Extensible Attributes on the
instance of the object. This argument accepts a set of key / value
pairs for configuration.
required: false
type: dict
comment:
description:
- Configures a text string comment to be associated with the instance
of this object. The provided text string will be configured on the
object instance.
required: false
type: str
state:
description:
- Configures the intended state of the instance of the object on
Expand All @@ -58,6 +62,7 @@
choices:
- present
- absent
type: str
'''

EXAMPLES = '''
Expand Down Expand Up @@ -105,6 +110,7 @@
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import WapiModule
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import NIOS_DNS_VIEW
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import normalize_ib_spec


def main():
Expand All @@ -123,7 +129,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'])
)

argument_spec.update(ib_spec)
argument_spec.update(normalize_ib_spec(ib_spec))
argument_spec.update(WapiModule.provider_spec)

module = AnsibleModule(argument_spec=argument_spec,
Expand Down
15 changes: 14 additions & 1 deletion plugins/modules/net_tools/nios/nios_fixed_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,29 @@
- Specifies the hostname with which fixed DHCP ip-address is stored
for respective mac.
required: true
type: str
ipaddr:
description:
- IPV4/V6 address of the fixed address.
required: true
type: str
mac:
description:
- The MAC address of the interface.
required: true
type: str
network:
description:
- Specifies the network range in which ipaddr exists.
required: true
type: str
network_view:
description:
- Configures the name of the network view to associate with this
configured instance.
required: false
default: default
type: str
options:
description:
- Configures the set of DHCP options to be included as part of
Expand All @@ -56,13 +61,16 @@
name:
description:
- The name of the DHCP option to configure
type: str
num:
description:
- The number of the DHCP option to configure
type: int
value:
description:
- The value of the DHCP option specified by C(name)
required: true
type: str
use_option:
description:
- Only applies to a subset of options (see NIOS API documentation)
Expand All @@ -72,16 +80,19 @@
description:
- The name of the space this DHCP option is associated to
default: DHCP
type: str
extattrs:
description:
- Allows for the configuration of Extensible Attributes on the
instance of the object. This argument accepts a set of key / value
pairs for configuration.
type: dict
comment:
description:
- Configures a text string comment to be associated with the instance
of this object. The provided text string will be configured on the
object instance.
type: str
state:
description:
- Configures the intended state of the instance of the object on
Expand All @@ -92,6 +103,7 @@
choices:
- present
- absent
type: str
'''

EXAMPLES = '''
Expand Down Expand Up @@ -163,6 +175,7 @@
from ansible.module_utils.six import iteritems
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import WapiModule
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import NIOS_IPV4_FIXED_ADDRESS, NIOS_IPV6_FIXED_ADDRESS
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import normalize_ib_spec


def validate_ip_address(address):
Expand Down Expand Up @@ -261,7 +274,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'])
)

argument_spec.update(ib_spec)
argument_spec.update(normalize_ib_spec(ib_spec))
argument_spec.update(WapiModule.provider_spec)

module = AnsibleModule(argument_spec=argument_spec,
Expand Down
Loading

0 comments on commit 6c7f8f9

Please sign in to comment.