Skip to content

Commit f44c200

Browse files
BugFix: Find proper LAG if not defined as dictionary (#171)
1 parent a09382a commit f44c200

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

ansible.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[inventory]
2-
enable_plugins = netbox.netbox.nb_inventory
2+
enable_plugins = netbox.netbox.nb_inventory, auto, host_list, yaml, ini, toml, script

plugins/module_utils/netbox_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,11 @@ def _find_ids(self, data):
565565
id_list.append(query_id.id)
566566
else:
567567
self._handle_errors(msg="%s not found" % (list_item))
568-
569568
else:
570-
query_params = {QUERY_TYPES.get(k, "q"): search}
569+
if k in ["lag"]:
570+
query_params = self._build_query_params(k, data)
571+
else:
572+
query_params = {QUERY_TYPES.get(k, "q"): search}
571573
query_id = self._nb_endpoint_get(nb_endpoint, query_params, k)
572574

573575
# Code to work around Ansible templating converting all values to strings

tests/integration/v2.6/tasks/netbox_device_interface.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@
183183
- test_seven['interface']['name'] == "GigabitEthernet1"
184184
- test_seven['interface']['device'] == 1
185185

186+
- name: "Add port-channel1 to R1 to test finding proper port-channel1"
187+
netbox_device_interface:
188+
netbox_url: "http://localhost:32768"
189+
netbox_token: "0123456789abcdef0123456789abcdef01234567"
190+
data:
191+
device: "R1-Device"
192+
name: "port-channel1"
193+
form_factor: "Link Aggregation Group (LAG)"
194+
186195
- name: "8 - Create interface and assign it to parent LAG - non dict"
187196
netbox_device_interface:
188197
netbox_url: "http://localhost:32768"

tests/integration/v2.7/tasks/netbox_device_interface.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@
184184
- test_seven['interface']['name'] == "GigabitEthernet1"
185185
- test_seven['interface']['device'] == 1
186186

187+
- name: "Add port-channel1 to R1 to test finding proper port-channel1"
188+
netbox_device_interface:
189+
netbox_url: "http://localhost:32768"
190+
netbox_token: "0123456789abcdef0123456789abcdef01234567"
191+
data:
192+
device: "R1-Device"
193+
name: "port-channel1"
194+
form_factor: "Link Aggregation Group (LAG)"
195+
187196
- name: "8 - Create interface and assign it to parent LAG - non dict"
188197
netbox_device_interface:
189198
netbox_url: "http://localhost:32768"

tests/integration/v2.8/tasks/netbox_device_interface.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@
184184
- test_seven['interface']['name'] == "GigabitEthernet1"
185185
- test_seven['interface']['device'] == 1
186186

187+
- name: "Add port-channel1 to R1 to test finding proper port-channel1"
188+
netbox_device_interface:
189+
netbox_url: "http://localhost:32768"
190+
netbox_token: "0123456789abcdef0123456789abcdef01234567"
191+
data:
192+
device: "R1-Device"
193+
name: "port-channel1"
194+
form_factor: "Link Aggregation Group (LAG)"
195+
187196
- name: "8 - Create interface and assign it to parent LAG - non dict"
188197
netbox_device_interface:
189198
netbox_url: "http://localhost:32768"

0 commit comments

Comments
 (0)