Skip to content

Commit 4ef27f1

Browse files
Fix lag to be resolved without being a dictionary (#81)
1 parent 15a91eb commit 4ef27f1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

plugins/module_utils/netbox_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ def _build_query_params(self, parent, module_data, child=None):
561561
query_dict.update({match: value})
562562

563563
if parent == "lag":
564+
if not child:
565+
query_dict["name"] = module_data["lag"]
564566
query_dict.update({"form_factor": 200})
565567
if isinstance(module_data["device"], int):
566568
query_dict.update({"device_id": module_data["device"]})

tests/integration/integration-tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,39 @@
373373
- test_seven['msg'] == "interface GigabitEthernet1 already exists"
374374
- test_seven['interface']['name'] == "GigabitEthernet1"
375375
- test_seven['interface']['device'] == 1
376+
377+
- name: "8 - Create interface and assign it to parent LAG - non dict"
378+
netbox_device_interface:
379+
netbox_url: "http://localhost:32768"
380+
netbox_token: "0123456789abcdef0123456789abcdef01234567"
381+
data:
382+
device: test100
383+
name: GigabitEthernet4
384+
enabled: false
385+
form_factor: 1000Base-t (1GE)
386+
lag: "port-channel1"
387+
mtu: 1600
388+
mgmt_only: false
389+
mode: Access
390+
state: present
391+
register: test_eight
392+
393+
- name: "8 - ASSERT"
394+
assert:
395+
that:
396+
- test_eight is changed
397+
- test_eight['msg'] == "interface GigabitEthernet4 created"
398+
- test_eight['diff']['before']['state'] == 'absent'
399+
- test_eight['diff']['after']['state'] == 'present'
400+
- test_eight['interface']['name'] == "GigabitEthernet4"
401+
- test_eight['interface']['device'] == 1
402+
- test_eight['interface']['enabled'] == false
403+
- test_eight['interface']['form_factor'] == 1000
404+
- test_eight['interface']['mgmt_only'] == false
405+
- test_eight['interface']['lag'] == 14
406+
- test_eight['interface']['mode'] == 100
407+
- test_eight['interface']['mtu'] == 1600
408+
376409
##
377410
##
378411
### NETBOX_IP_ADDRESS

0 commit comments

Comments
 (0)