Skip to content

Bugfix: netbox_device_interface: Add type and add deprecation to form_factor option #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions plugins/module_utils/netbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,15 @@ def _update_netbox_object(self, data):
data_before[key] = serialized_nb_obj[key]
data_after[key] = updated_obj[key]
except KeyError:
self._handle_errors(
msg="%s does not exist on existing object. Check to make sure valid field."
% (key)
)
if key == "form_factor":
msg = "form_factor is not valid for NetBox 2.7 onword. Please use the type key instead."
else:
msg = (
"%s does not exist on existing object. Check to make sure valid field."
% (key)
)

self._handle_errors(msg=msg)

if not self.check_mode:
self.nb_object.update(data)
Expand Down
21 changes: 17 additions & 4 deletions plugins/modules/netbox_device_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE)
This has to be specified exactly as what is found within UI
type: str
deprecated:
removed_in: "0.3.0"
why: "NetBox now uses Type instead of Form Factor from 2.7 on."
type:
description:
- |
Form factor of the interface:
ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE)
This has to be specified exactly as what is found within UI
type: str
enabled:
description:
- Sets whether interface shows enabled or disabled
Expand Down Expand Up @@ -156,7 +166,7 @@
data:
device: test100
name: port-channel1
form_factor: Link Aggregation Group (LAG)
type: Link Aggregation Group (LAG)
mtu: 1600
mgmt_only: false
mode: Access
Expand All @@ -169,7 +179,7 @@
device: test100
name: GigabitEthernet1
enabled: false
form_factor: 1000Base-t (1GE)
type: 1000Base-t (1GE)
lag:
name: port-channel1
mtu: 1600
Expand All @@ -184,7 +194,7 @@
device: test100
name: GigabitEthernet25
enabled: false
form_factor: 1000Base-t (1GE)
type: 1000Base-t (1GE)
untagged_vlan:
name: Wireless
site: Test Site
Expand Down Expand Up @@ -243,7 +253,10 @@ def main():
options=dict(
device=dict(required=False, type="raw"),
name=dict(required=True, type="str"),
form_factor=dict(required=False, type="raw"),
form_factor=dict(
required=False, type="raw", removed_in_version="2.10"
),
type=dict(required=False, type="str"),
enabled=dict(required=False, type="bool"),
lag=dict(required=False, type="raw"),
mtu=dict(required=False, type="int"),
Expand Down