Skip to content

Commit b7a12ff

Browse files
author
Thomas v.d. Jagt
committed
added delete_interface method
1 parent 5fa261b commit b7a12ff

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

netbox/dcim.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,6 @@ def get_interfaces(self, **kwargs):
325325
"""Return interfaces"""
326326
return self.netbox_con.get('/dcim/interfaces', **kwargs)
327327

328-
def get_interfaces_by_device(self, device_name, **kwargs):
329-
"""Get all interfaces by device
330-
331-
:param device_name: Name of device to get interfaces off
332-
:return: list of interfaces
333-
"""
334-
return self.netbox_con.get('/dcim/interfaces', device=device_name, **kwargs)
335-
336328
def create_interface(self, name, form_factor, device_id, **kwargs):
337329
"""Create a new interface
338330
@@ -360,12 +352,17 @@ def update_interface(self, interface, device, **kwargs):
360352
raise exceptions.NotFoundException('interface: {}'.format(interface)) from None
361353
return self.netbox_con.patch('/dcim/interfaces/', interface_id, **kwargs)
362354

363-
def delete_interface_by_id(self, interface_id):
364-
"""Delete interface by id
355+
def delete_interface(self, interface_name, device):
356+
"""Delete platform
365357
366-
:param interface_id: id of interface to remove
358+
:param interface_name: Name of interface to delete
359+
:param device: Device to which the interface belongs
367360
:return: bool True if successful otherwise raise DeleteException
368361
"""
362+
try:
363+
interface_id = self.get_interfaces(name=interface_name, device=device)[0]['id']
364+
except IndexError:
365+
raise exceptions.NotFoundException('interface: {}'.format(interface_name)) from None
369366
return self.netbox_con.delete('/dcim/interfaces/', interface_id)
370367

371368
def get_interface_connections(self, **kwargs):

0 commit comments

Comments
 (0)