Skip to content

Commit 6cf38c5

Browse files
author
Shiva Shankar Vaddepally
committed
supporting bgp and adding examples to modules
Signed-off-by: Shiva Shankar Vaddepally <[email protected]>
1 parent 0f85440 commit 6cf38c5

17 files changed

Lines changed: 312 additions & 100 deletions

examples/bgprouter.yaml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,26 @@
77
delegate_to: localhost
88
netscaler.adc.bgprouter:
99
state: present
10-
localAS: 100
11-
routerId: 2.2.2.2
10+
11+
localAS: 122
12+
routerId: "2.2.2.2"
1213
afParams:
13-
- addressFamily: ipv4
14+
- addressFamily: "ipv4"
1415
redistribute:
15-
- protocol: static
16-
routeMap: test
17-
- addressFamily: ipv6
16+
- protocol: "static"
17+
routeMap: "test"
18+
- addressFamily: "ipv6"
1819
neighbor:
19-
- address: 44.1.1.33
20+
- address: "44.1.1.33"
2021
remoteAS: 300
21-
ASOriginationInterval: 15
22-
advertisementInterval: 30
23-
updateSource: vlan101
24-
holdTimer: 90
25-
keepaliveTimer: 30
26-
state: Connect
22+
ASOriginationInterval: 11
23+
advertisementInterval: 34
24+
updateSource: "vlan101"
2725
singlehopBfd: false
2826
multihopBfd: false
2927
afParams:
30-
- addressFamily: ipv4
31-
activate: true
28+
- addressFamily: "ipv4"
3229
routeMap:
33-
- name: test
34-
direction: out
35-
- addressFamily: ipv6
36-
activate: false
30+
- name: "test"
31+
direction: "out"
32+
- addressFamily: "ipv6"

examples/ospf6interface.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
delegate_to: localhost
77
netscaler.adc.ospf6interface:
88
state: present
9-
name: vlan0
9+
10+
name: "vlan10"
1011
areaId: 0
1112
tagId: "22"
1213
instanceId: 0

examples/ospf6router.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
- name: Configure ospf6router
77
delegate_to: localhost
88
netscaler.adc.ospf6router:
9-
state: present
9+
state: unset
1010
tagId: 11
11-
routerId: 1.1.1.1
1211
afParams:
1312
- addressFamily: ipv6
13+
redistribute:
14+
- protocol: static
15+
metric: 111

examples/ospfinterface.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
priority: 1
1515
mtu: 1500
1616
networkType: broadcast
17-
authType: null
17+
authType: "null"
1818
retransmitInterval: 5
1919
transmitDelay: 1
2020
bfd: false

examples/ospfrouter.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
---
2-
- name: Sample routeMap playbook
2+
- name: Sample ospfrouter playbook
33
hosts: localhost
44
gather_facts: false
55
tasks:
6-
- name: Configure routeMap
6+
- name: Configure ospfrouter
77
delegate_to: localhost
88
netscaler.adc.ospfrouter:
99
state: present
10-
nsip: 10.106.210.21
11-
nitro_user: nsroot
12-
nitro_pass: notnsroot
13-
validate_certs: false
14-
nitro_protocol: http
15-
tagId: "11"
10+
11+
processId: 1
1612
routerId: "1.1.1.1"
17-
afParams:
18-
- addressFamily: "ipv6"
13+
passiveInterface:
14+
- vlan22
15+
redistribute:
16+
- protocol: connected
17+
networks:
18+
- ipaddress: "33.1.2.5"
19+
netmask: 25
20+
area: 1

examples/routemap.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
delegate_to: localhost
88
netscaler.adc.routemap:
99
state: present
10+
1011
name: test
1112
rules:
1213
- action: permit
1314
sequence: 10
14-
setMetric: 300
15+
setMetric: 105
1516
matchAsPath: "300"

plugins/module_utils/module_executor.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -305,34 +305,30 @@ def _add_nitro_attributes_aliases(self, payload):
305305

306306
@trace
307307
def _filter_resource_module_params(self):
308+
def filter_values(value):
309+
if isinstance(value, dict):
310+
cleaned_dict = {}
311+
for k, v in value.items():
312+
cleaned_v = filter_values(v)
313+
if cleaned_v is not None:
314+
cleaned_dict[k] = cleaned_v
315+
return cleaned_dict if cleaned_dict else None
316+
elif isinstance(value, list):
317+
cleaned_list = []
318+
for item in value:
319+
cleaned_item = filter_values(item)
320+
if cleaned_item is not None:
321+
cleaned_list.append(cleaned_item)
322+
return cleaned_list if cleaned_list else None
323+
else:
324+
return value if value is not None else None
325+
308326
log("DEBUG: self.module.params: %s" % self.module.params)
309327
for k, v in self.module.params.items():
310-
if (not k.endswith("_binding")) and (
311-
k
312-
in NITRO_RESOURCE_MAP[self.resource_name]["readwrite_arguments"].keys()
313-
):
314-
# self.module.params is a dict of key:value pairs. If an attribute is not
315-
# defined in the playbook, it's value will be None. So, filter out those attributes.
316-
# Also, filter out attributes ending with `_binding` as they are handled separately
317-
if v is not None:
318-
if isinstance(v, list):
319-
filtered_list = []
320-
for listitem in v:
321-
if isinstance(listitem, dict):
322-
filtered_dict = {
323-
key: value
324-
for key, value in listitem.items()
325-
if value is not None
326-
}
327-
if filtered_dict:
328-
filtered_list.append(filtered_dict)
329-
else:
330-
if listitem is not None:
331-
filtered_list.append(listitem)
332-
if filtered_list:
333-
self.resource_module_params[k] = filtered_list
334-
else:
335-
self.resource_module_params[k] = v
328+
if not k.endswith("_binding") and k in NITRO_RESOURCE_MAP[self.resource_name]["readwrite_arguments"]:
329+
cleaned_value = filter_values(v)
330+
if cleaned_value is not None:
331+
self.resource_module_params[k] = cleaned_value
336332

337333
if self.resource_name in NITRO_ATTRIBUTES_ALIASES:
338334
self.resource_module_params = self._add_nitro_attributes_aliases(

plugins/module_utils/nitro_resource_map.py

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16647,7 +16647,8 @@
1664716647
"choices": ["ipv4", "ipv6"],
1664816648
},
1664916649
"routeMap": {
16650-
"type": "dict",
16650+
"type": "list",
16651+
"elements": "dict",
1665116652
"options": {
1665216653
"direction": {
1665316654
"no_log": False,
@@ -16666,6 +16667,7 @@
1666616667
"multihopBfd": {"no_log": False, "type": "bool"},
1666716668
"remoteAS": {"no_log": False, "type": "int"},
1666816669
"singlehopBfd": {"no_log": False, "type": "bool"},
16670+
"state": {"no_log": False, "type": "str"},
1666916671
"updateSource": {"no_log": False, "type": "str"},
1667016672
},
1667116673
},
@@ -46870,7 +46872,19 @@
4687046872
"transmitDelay",
4687146873
],
4687246874
},
46873-
"add_payload_keys": [],
46875+
"add_payload_keys": [
46876+
"areaId",
46877+
"cost",
46878+
"deadInterval",
46879+
"helloInterval",
46880+
"instanceId",
46881+
"name",
46882+
"networkType",
46883+
"priority",
46884+
"retransmitInterval",
46885+
"tagId",
46886+
"transmitDelay",
46887+
],
4687446888
"bindings": [],
4687546889
"bindprimary_key": "",
4687646890
"delete_arg_keys": [],
@@ -46921,7 +46935,7 @@
4692146935
"no_log": False,
4692246936
"type": "int",
4692346937
},
46924-
"tagId": {"no_log": False, "type": "int"},
46938+
"tagId": {"no_log": False, "type": "str"},
4692546939
"transmitDelay": {
4692646940
"no_log": False,
4692746941
"type": "int",
@@ -46997,7 +47011,6 @@
4699747011
"update_payload_keys": [
4699847012
"afParams",
4699947013
"passiveInterface",
47000-
"routerId",
4700147014
"tagId",
4700247015
],
4700347016
},
@@ -47025,11 +47038,18 @@
4702547038
],
4702647039
},
4702747040
"add_payload_keys": [
47028-
"networks",
47029-
"passiveInterface",
47030-
"processId",
47031-
"redistribute",
47032-
"routerId",
47041+
"authKey",
47042+
"authType",
47043+
"bfd",
47044+
"cost",
47045+
"deadInterval",
47046+
"helloInterval",
47047+
"mtu",
47048+
"name",
47049+
"networkType",
47050+
"priority",
47051+
"retransmitInterval",
47052+
"transmitDelay"
4703347053
],
4703447054
"bindings": [],
4703547055
"bindprimary_key": "",
@@ -47054,7 +47074,11 @@
4705447074
"helloInterval": {"no_log": False, "type": "int"},
4705547075
"mtu": {"no_log": False, "type": "int"},
4705647076
"name": {"no_log": False, "type": "str"},
47057-
"networkType": {"no_log": False, "type": "str"},
47077+
"networkType": {
47078+
"no_log": False,
47079+
"type": "str",
47080+
"choices": ["broadcast", "non-broadcast", "point-to-multipoint", "point-to-point"],
47081+
},
4705847082
"priority": {"no_log": False, "type": "int"},
4705947083
"retransmitInterval": {"no_log": False, "type": "int"},
4706047084
"transmitDelay": {"no_log": False, "type": "int"},
@@ -47111,7 +47135,8 @@
4711147135
"primary_key_composite": [],
4711247136
"readwrite_arguments": {
4711347137
"networks": {
47114-
"type": "dict",
47138+
"type": "list",
47139+
"elements": "dict",
4711547140
"options": {
4711647141
"area": {"no_log": False, "type": "int"},
4711747142
"ipaddress": {"no_log": False, "type": "str"},
@@ -47121,7 +47146,8 @@
4712147146
"passiveInterface": {"no_log": False, "type": "list", "elements": "str"},
4712247147
"processId": {"no_log": False, "type": "int"},
4712347148
"redistribute": {
47124-
"type": "dict",
47149+
"type": "list",
47150+
"elements": "dict",
4712547151
"options": {
4712647152
"metric": {"no_log": False, "type": "int"},
4712747153
"metricType": {"no_log": False, "type": "int"},
@@ -50490,7 +50516,7 @@
5049050516
},
5049150517
},
5049250518
"singleton": False,
50493-
"update_payload_keys": ["rules"],
50519+
"update_payload_keys": ["name", "rules"],
5049450520
},
5049550521
"routerdynamicrouting": {
5049650522
"_supported_operations": [

plugins/modules/accesslist.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@
7373
"""
7474

7575
EXAMPLES = r"""
76+
---
77+
- name: Configure accessslist
78+
hosts: localhost
79+
tasks:
80+
- name: Create accesslist
81+
delegate_to: localhost
82+
netscaler.adc.accesslist:
83+
state: present
84+
id: 1
85+
remark: "Allow all traffic"
86+
rules:
87+
- action: permit
88+
address: 2.1.1.21
89+
wildcard: "0.0.0.255"
7690
"""
7791
RETURN = r"""
7892
---

plugins/modules/bfdinterface.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@
7474
"""
7575

7676
EXAMPLES = r"""
77+
---
78+
- name: Configure bfdinterface
79+
hosts: localhost
80+
tasks:
81+
- name: Create bfdinterface
82+
delegate_to: localhost
83+
netscaler.adc.bfdinterface:
84+
state: present
85+
name: vlan0
86+
passive: true
87+
interval: 752
88+
minrx: 501
89+
multiplier: 3
7790
"""
7891
RETURN = r"""
7992
---

0 commit comments

Comments
 (0)