Skip to content

Commit 004ac7f

Browse files
authored
netbox_device_interface - Add mark_connected (#506)
1 parent e8f14a5 commit 004ac7f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

plugins/modules/netbox_device_interface.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@
124124
- Any tags that the interface may need to be associated with
125125
required: false
126126
type: list
127+
mark_connected:
128+
description:
129+
- Mark an interface as connected without a cable attached (netbox >= 2.11 required)
130+
required: false
131+
type: bool
127132
required: true
128133
type: dict
129134
update_vc_child:
@@ -235,6 +240,15 @@
235240
name: GigabitEthernet2/0/1
236241
enabled: false
237242
update_vc_child: True
243+
- name: Mark interface as connected without a cable (netbox >= 2.11 required)
244+
netbox.netbox.netbox_device_interface:
245+
netbox_url: http://netbox.local
246+
netbox_token: thisIsMyToken
247+
data:
248+
device: test100
249+
name: GigabitEthernet1
250+
mark_connected: true
251+
state: present
238252
"""
239253

240254
RETURN = r"""
@@ -288,6 +302,7 @@ def main():
288302
untagged_vlan=dict(required=False, type="raw"),
289303
tagged_vlans=dict(required=False, type="raw"),
290304
tags=dict(required=False, type="list"),
305+
mark_connected=dict(required=False, type="bool"),
291306
),
292307
),
293308
)

tests/integration/targets/latest/tasks/netbox_device_interface.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,25 @@
289289
that:
290290
- test_eleven is failed
291291
- test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification"
292+
293+
- name: "12 - Create interface and mark it as connected"
294+
netbox.netbox.netbox_device_interface:
295+
netbox_url: "http://localhost:32768"
296+
netbox_token: "0123456789abcdef0123456789abcdef01234567"
297+
data:
298+
device: test100
299+
name: GigabitEthernet5
300+
type: 1000Base-T (1GE)
301+
mark_connected: true
302+
register: test_twelve
303+
304+
- name: "12- ASSERT"
305+
assert:
306+
that:
307+
- test_twelve is changed
308+
- test_twelve['msg'] == "interface GigabitEthernet5 created"
309+
- test_twelve['diff']['before']['state'] == 'absent'
310+
- test_twelve['diff']['after']['state'] == 'present'
311+
- test_twelve['interface']['name'] == "GigabitEthernet5"
312+
- test_twelve['interface']['device'] == 1
313+
- test_twelve['interface']['mark_connected'] == true

0 commit comments

Comments
 (0)