Skip to content

Commit 5c72cea

Browse files
author
David Vølker
committed
add module_type aswell as tests
1 parent 42721ed commit 5c72cea

File tree

14 files changed

+327
-21
lines changed

14 files changed

+327
-21
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
minor_changes:
3+
- Add `module_type` as supported to `netbox_rear_port_template`
4+
- Add `module_type` as supported to `netbox_front_port_template`

plugins/inventory/nb_inventory.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@
408408
from ansible.module_utils.six.moves.urllib.parse import urlencode
409409
from ansible.module_utils.six.moves.urllib.parse import urlparse
410410

411-
412411
try:
413412
from packaging import specifiers, version
414413
except ImportError as imp_exc:

plugins/module_utils/netbox_circuits.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
SLUG_REQUIRED,
1212
)
1313

14-
1514
NB_PROVIDERS = "providers"
1615
NB_PROVIDER_NETWORKS = "provider_networks"
1716
NB_CIRCUIT_TYPES = "circuit_types"

plugins/module_utils/netbox_dcim.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
SLUG_REQUIRED,
1313
)
1414

15-
1615
NB_CABLES = "cables"
1716
NB_CONSOLE_PORTS = "console_ports"
1817
NB_CONSOLE_PORT_TEMPLATES = "console_port_templates"

plugins/module_utils/netbox_ipam.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
SLUG_REQUIRED,
1616
)
1717

18-
1918
NB_AGGREGATES = "aggregates"
2019
NB_ASNS = "asns"
2120
NB_FHRP_GROUPS = "fhrp_groups"

plugins/module_utils/netbox_tenancy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
SLUG_REQUIRED,
1212
)
1313

14-
1514
NB_TENANTS = "tenants"
1615
NB_TENANT_GROUPS = "tenant_groups"
1716
NB_CONTACTS = "contacts"

plugins/module_utils/netbox_virtualization.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
SLUG_REQUIRED,
1212
)
1313

14-
1514
NB_VIRTUAL_MACHINES = "virtual_machines"
1615
NB_CLUSTERS = "clusters"
1716
NB_CLUSTER_GROUP = "cluster_groups"

plugins/module_utils/netbox_vpn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
SLUG_REQUIRED,
1515
)
1616

17-
1817
NB_L2VPNS = "l2vpns"
1918
NB_L2VPN_TERMINATIONS = "l2vpn_terminations"
2019
NB_TUNNELS = "tunnels"

plugins/module_utils/netbox_wireless.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
SLUG_REQUIRED,
1212
)
1313

14-
1514
NB_WIRELESS_LANS = "wireless_lans"
1615
NB_WIRELESS_LAN_GROUPS = "wireless_lan_groups"
1716
NB_WIRELESS_LINKS = "wireless_links"

plugins/modules/netbox_front_port_template.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
3434
device_type:
3535
description:
3636
- The device type the front port template is attached to
37-
required: true
37+
- Either I(device_type) or I(module_type) are required
38+
type: raw
39+
module_type:
40+
description:
41+
- The module type the front port template is attached to
42+
- Either I(device_type) or I(module_type) are required
3843
type: raw
3944
name:
4045
description:
@@ -103,6 +108,17 @@
103108
rear_port_template: Test Rear Port Template
104109
state: present
105110
111+
- name: Create front port template for a module type within NetBox
112+
netbox.netbox.netbox_front_port_template:
113+
netbox_url: http://netbox.local
114+
netbox_token: thisIsMyToken
115+
data:
116+
name: Test Front Port Template
117+
module_type: Test Module Type
118+
type: bnc
119+
rear_port_template: Test Rear Port Template
120+
state: present
121+
106122
- name: Update front port template with other fields
107123
netbox.netbox.netbox_front_port_template:
108124
netbox_url: http://netbox.local
@@ -160,7 +176,8 @@ def main():
160176
type="dict",
161177
required=True,
162178
options=dict(
163-
device_type=dict(required=True, type="raw"),
179+
device_type=dict(required=False, type="raw"),
180+
module_type=dict(required=False, type="raw"),
164181
name=dict(required=True, type="str"),
165182
type=dict(
166183
required=False,
@@ -192,12 +209,19 @@ def main():
192209
)
193210

194211
required_if = [
195-
("state", "present", ["device_type", "name", "type", "rear_port_template"]),
196-
("state", "absent", ["device_type", "name", "type", "rear_port_template"]),
212+
("state", "present", ["name", "type", "rear_port_template"]),
213+
("state", "absent", ["name", "type", "rear_port_template"]),
214+
]
215+
216+
required_one_of = [
217+
("device_type", "module_type"),
197218
]
198219

199220
module = NetboxAnsibleModule(
200-
argument_spec=argument_spec, supports_check_mode=True, required_if=required_if
221+
argument_spec=argument_spec,
222+
supports_check_mode=True,
223+
required_if=required_if,
224+
required_one_of=required_one_of,
201225
)
202226

203227
netbox_front_port_template = NetboxDcimModule(module, NB_FRONT_PORT_TEMPLATES)

0 commit comments

Comments
 (0)