|
|
|
@ -78,6 +78,12 @@ options:
|
|
|
|
|
- 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.
|
|
|
|
|
container:
|
|
|
|
|
description:
|
|
|
|
|
- If set to true it'll create the network container to be added or removed
|
|
|
|
|
from the system.
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: '2.8'
|
|
|
|
|
state:
|
|
|
|
|
description:
|
|
|
|
|
- Configures the intended state of the instance of the object on
|
|
|
|
@ -133,6 +139,39 @@ EXAMPLES = '''
|
|
|
|
|
username: admin
|
|
|
|
|
password: admin
|
|
|
|
|
connection: local
|
|
|
|
|
- name: configure a ipv4 network container
|
|
|
|
|
nios_network:
|
|
|
|
|
network: 192.168.10.0/24
|
|
|
|
|
container: true
|
|
|
|
|
comment: test network container
|
|
|
|
|
state: present
|
|
|
|
|
provider:
|
|
|
|
|
host: "{{ inventory_hostname_short }}"
|
|
|
|
|
username: admin
|
|
|
|
|
password: admin
|
|
|
|
|
connection: local
|
|
|
|
|
- name: configure a ipv6 network container
|
|
|
|
|
nios_network:
|
|
|
|
|
network: fe80::/64
|
|
|
|
|
container: true
|
|
|
|
|
comment: test network container
|
|
|
|
|
state: present
|
|
|
|
|
provider:
|
|
|
|
|
host: "{{ inventory_hostname_short }}"
|
|
|
|
|
username: admin
|
|
|
|
|
password: admin
|
|
|
|
|
connection: local
|
|
|
|
|
- name: remove a ipv4 network container
|
|
|
|
|
nios_network:
|
|
|
|
|
networkr: 192.168.10.0/24
|
|
|
|
|
container: true
|
|
|
|
|
comment: test network container
|
|
|
|
|
state: absent
|
|
|
|
|
provider:
|
|
|
|
|
host: "{{ inventory_hostname_short }}"
|
|
|
|
|
username: admin
|
|
|
|
|
password: admin
|
|
|
|
|
connection: local
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
RETURN = ''' # '''
|
|
|
|
@ -141,8 +180,8 @@ from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
from ansible.module_utils.six import iteritems
|
|
|
|
|
from ansible.module_utils.net_tools.nios.api import WapiModule
|
|
|
|
|
from ansible.module_utils.network.common.utils import validate_ip_address, validate_ip_v6_address
|
|
|
|
|
from ansible.module_utils.net_tools.nios.api import NIOS_IPV4_NETWORK
|
|
|
|
|
from ansible.module_utils.net_tools.nios.api import NIOS_IPV6_NETWORK
|
|
|
|
|
from ansible.module_utils.net_tools.nios.api import NIOS_IPV4_NETWORK, NIOS_IPV6_NETWORK
|
|
|
|
|
from ansible.module_utils.net_tools.nios.api import NIOS_IPV4_NETWORK_CONTAINER, NIOS_IPV6_NETWORK_CONTAINER
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def options(module):
|
|
|
|
@ -170,15 +209,27 @@ def options(module):
|
|
|
|
|
return options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_ip_addr_type(ip):
|
|
|
|
|
'''This function will check if the argument ip is type v4/v6 and return appropriate infoblox network type
|
|
|
|
|
def check_ip_addr_type(obj_filter, ib_spec):
|
|
|
|
|
'''This function will check if the argument ip is type v4/v6 and return appropriate infoblox
|
|
|
|
|
network/networkcontainer type
|
|
|
|
|
'''
|
|
|
|
|
check_ip = ip.split('/')
|
|
|
|
|
|
|
|
|
|
if validate_ip_address(check_ip[0]):
|
|
|
|
|
return NIOS_IPV4_NETWORK
|
|
|
|
|
elif validate_ip_v6_address(check_ip[0]):
|
|
|
|
|
return NIOS_IPV6_NETWORK
|
|
|
|
|
ip = obj_filter['network']
|
|
|
|
|
if 'container' in obj_filter and obj_filter['container']:
|
|
|
|
|
check_ip = ip.split('/')
|
|
|
|
|
del ib_spec['container'] # removing the container key from post arguments
|
|
|
|
|
del ib_spec['options'] # removing option argument as for network container it's not supported
|
|
|
|
|
if validate_ip_address(check_ip[0]):
|
|
|
|
|
return NIOS_IPV4_NETWORK_CONTAINER, ib_spec
|
|
|
|
|
elif validate_ip_v6_address(check_ip[0]):
|
|
|
|
|
return NIOS_IPV6_NETWORK_CONTAINER, ib_spec
|
|
|
|
|
else:
|
|
|
|
|
check_ip = ip.split('/')
|
|
|
|
|
del ib_spec['container'] # removing the container key from post arguments
|
|
|
|
|
if validate_ip_address(check_ip[0]):
|
|
|
|
|
return NIOS_IPV4_NETWORK, ib_spec
|
|
|
|
|
elif validate_ip_v6_address(check_ip[0]):
|
|
|
|
|
return NIOS_IPV6_NETWORK, ib_spec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_vendor_specific_dhcp_option(module, ib_spec):
|
|
|
|
@ -215,7 +266,8 @@ def main():
|
|
|
|
|
options=dict(type='list', elements='dict', options=option_spec, transform=options),
|
|
|
|
|
|
|
|
|
|
extattrs=dict(type='dict'),
|
|
|
|
|
comment=dict()
|
|
|
|
|
comment=dict(),
|
|
|
|
|
container=dict(type='bool', ib_req=True)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
argument_spec = dict(
|
|
|
|
@ -231,7 +283,7 @@ def main():
|
|
|
|
|
|
|
|
|
|
# to get the argument ipaddr
|
|
|
|
|
obj_filter = dict([(k, module.params[k]) for k, v in iteritems(ib_spec) if v.get('ib_req')])
|
|
|
|
|
network_type = check_ip_addr_type(obj_filter['network'])
|
|
|
|
|
network_type, ib_spec = check_ip_addr_type(obj_filter, ib_spec)
|
|
|
|
|
|
|
|
|
|
wapi = WapiModule(module)
|
|
|
|
|
# to check for vendor specific dhcp option
|
|
|
|
|