Skip to content

Commit 9507081

Browse files
Add deprecation to form_factor, updated error message to advise to use type key and added type option to netbox_device_interface (#197)
1 parent 716ca38 commit 9507081

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

plugins/module_utils/netbox_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,15 @@ def _update_netbox_object(self, data):
678678
data_before[key] = serialized_nb_obj[key]
679679
data_after[key] = updated_obj[key]
680680
except KeyError:
681-
self._handle_errors(
682-
msg="%s does not exist on existing object. Check to make sure valid field."
683-
% (key)
684-
)
681+
if key == "form_factor":
682+
msg = "form_factor is not valid for NetBox 2.7 onword. Please use the type key instead."
683+
else:
684+
msg = (
685+
"%s does not exist on existing object. Check to make sure valid field."
686+
% (key)
687+
)
688+
689+
self._handle_errors(msg=msg)
685690

686691
if not self.check_mode:
687692
self.nb_object.update(data)

plugins/modules/netbox_device_interface.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@
6060
ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE)
6161
This has to be specified exactly as what is found within UI
6262
type: str
63+
deprecated:
64+
removed_in: "0.3.0"
65+
why: "NetBox now uses Type instead of Form Factor from 2.7 on."
66+
type:
67+
description:
68+
- |
69+
Form factor of the interface:
70+
ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE)
71+
This has to be specified exactly as what is found within UI
72+
type: str
6373
enabled:
6474
description:
6575
- Sets whether interface shows enabled or disabled
@@ -156,7 +166,7 @@
156166
data:
157167
device: test100
158168
name: port-channel1
159-
form_factor: Link Aggregation Group (LAG)
169+
type: Link Aggregation Group (LAG)
160170
mtu: 1600
161171
mgmt_only: false
162172
mode: Access
@@ -169,7 +179,7 @@
169179
device: test100
170180
name: GigabitEthernet1
171181
enabled: false
172-
form_factor: 1000Base-t (1GE)
182+
type: 1000Base-t (1GE)
173183
lag:
174184
name: port-channel1
175185
mtu: 1600
@@ -184,7 +194,7 @@
184194
device: test100
185195
name: GigabitEthernet25
186196
enabled: false
187-
form_factor: 1000Base-t (1GE)
197+
type: 1000Base-t (1GE)
188198
untagged_vlan:
189199
name: Wireless
190200
site: Test Site
@@ -243,7 +253,10 @@ def main():
243253
options=dict(
244254
device=dict(required=False, type="raw"),
245255
name=dict(required=True, type="str"),
246-
form_factor=dict(required=False, type="raw"),
256+
form_factor=dict(
257+
required=False, type="raw", removed_in_version="2.10"
258+
),
259+
type=dict(required=False, type="str"),
247260
enabled=dict(required=False, type="bool"),
248261
lag=dict(required=False, type="raw"),
249262
mtu=dict(required=False, type="int"),

0 commit comments

Comments
 (0)