Skip to content

Commit cd0b654

Browse files
authored
Updated netbox_circuit_termination.py to support NetBox 4.2.x (#1402)
* updated netbox_circuit_termination.py to support termination_id and termination_type requirements from NetBox 4.2.0 release * fixed typo in documentation * added backward compatibility with NetBox versions before 4.2.0 * black formatting and changelog fragement * fixed doc-choices-do-not-match-spec CI failure * fixed line length failure from CI checks --------- Co-authored-by: Nick Thompson <[email protected]>
1 parent df09c94 commit cd0b654

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- netbox_circuit_termination - Add parameters termination_id and termination_type for NetBox 4.2+

plugins/modules/netbox_circuit_termination.py

+60-4
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,36 @@
4949
required: false
5050
type: bool
5151
version_added: 3.5.0
52+
termination_id:
53+
description:
54+
- The ProviderNetwork, Location, Site, Region, or SiteGroup ID of the circuit termination will be assigned to.
55+
- This parameter is used with NetBox versions >= 4.2.0.
56+
required: false
57+
type: int
58+
version_added: 4.2.0
59+
termination_type:
60+
description:
61+
- The type the circuit termination will be assigned to.
62+
- This parameter is used with NetBox versions >= 4.2.0.
63+
choices:
64+
- dcim.site
65+
- dcim.location
66+
- dcim.region
67+
- dcim.sitegroup
68+
- circuits.providernetwork
69+
required: false
70+
type: str
71+
version_added: 4.2.0
5272
site:
5373
description:
54-
- The site the circuit termination will be assigned to
74+
- The site the circuit termination will be assigned to.
75+
- This parameter is used with NetBox versions before 4.2.0.
5576
required: false
5677
type: raw
5778
provider_network:
5879
description:
59-
- The provider_network the circuit termination will be assigned to
80+
- The provider_network the circuit termination will be assigned to.
81+
- This parameter is used with NetBox versions before 4.2.0.
6082
required: false
6183
type: raw
6284
port_speed:
@@ -93,7 +115,19 @@
93115
gather_facts: false
94116
95117
tasks:
96-
- name: Create circuit termination within NetBox with only required information
118+
- name: Create circuit termination within NetBox version 4.2.0 or later with only required information
119+
netbox.netbox.netbox_circuit_termination:
120+
netbox_url: http://netbox.local
121+
netbox_token: thisIsMyToken
122+
data:
123+
circuit: Test Circuit
124+
term_side: A
125+
termination_id: 1
126+
termination_type: dcim.site
127+
port_speed: 10000
128+
state: present
129+
130+
- name: Create circuit termination within NetBox versions earlier than 4.2.0 with only required information
97131
netbox.netbox.netbox_circuit_termination:
98132
netbox_url: http://netbox.local
99133
netbox_token: thisIsMyToken
@@ -163,6 +197,18 @@ def main():
163197
circuit=dict(required=True, type="raw"),
164198
term_side=dict(required=True, choices=["A", "Z"]),
165199
mark_connected=dict(required=False, type="bool"),
200+
termination_id=dict(required=False, type="int"),
201+
termination_type=dict(
202+
required=False,
203+
type="str",
204+
choices=[
205+
"dcim.site",
206+
"dcim.location",
207+
"dcim.region",
208+
"dcim.sitegroup",
209+
"circuits.providernetwork",
210+
],
211+
),
166212
site=dict(required=False, type="raw"),
167213
provider_network=dict(required=False, type="raw"),
168214
port_speed=dict(required=False, type="int"),
@@ -180,8 +226,18 @@ def main():
180226
("state", "absent", ["circuit", "term_side"]),
181227
]
182228

229+
mutually_exclusive = [
230+
("termination_id", "site"),
231+
("termination_type", "site"),
232+
("termination_id", "provider_network"),
233+
("termination_type", "provider_network"),
234+
]
235+
183236
module = NetboxAnsibleModule(
184-
argument_spec=argument_spec, supports_check_mode=True, required_if=required_if
237+
argument_spec=argument_spec,
238+
supports_check_mode=True,
239+
required_if=required_if,
240+
mutually_exclusive=mutually_exclusive,
185241
)
186242

187243
netbox_circuit_termination = NetboxCircuitsModule(module, NB_CIRCUIT_TERMINATIONS)

0 commit comments

Comments
 (0)