Skip to content
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

fixed interface connection new API resource #45

Merged
merged 1 commit into from
Jun 13, 2021
Merged
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
16 changes: 9 additions & 7 deletions netbox/dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,24 +634,26 @@ def get_interface_connections(self, **kwargs):
"""
return self.netbox_con.get('/dcim/interface-connections/', **kwargs)

def create_interface_connection(self, interface_a, interface_b, **kwargs):
def create_interface_connection(self, termination_a_id, termination_b_id, termination_a_type, termination_b_type, **kwargs):
"""Create a new interface-connection

:param interface_a: id of the source interface
:param interface_b: id of the destination interface
:param termination_a_id: id of the source interface
:param termination_a_type: type of source interface ("dcim.consoleport", "dcim.consoleserverport", "dcim.interface")
:param termination_b_id: id of the destination interface
:param termination_b_type: type of destination interface ("dcim.consoleport", "dcim.consoleserverport", "dcim.interface")
:param kwargs:
:return:
"""
required_fields = {"interface_a": interface_a, "interface_b": interface_b}
return self.netbox_con.post('/dcim/interface-connections/', required_fields, **kwargs)
required_fields = {"termination_a_id": termination_a_id, "termination_a_type": termination_a_type, "termination_b_id": termination_b_id, "termination_b_type": termination_b_type}
return self.netbox_con.post('/dcim/cables/', required_fields, **kwargs)

def delete_interface_connection(self, interface_connection_id):
"""Delete interface-connection by id

:param interface_connection_id: id of interface-connection to remove
:return: bool True if successful otherwise raise DeleteException
"""
return self.netbox_con.delete('/dcim/interface-connections/', interface_connection_id)
return self.netbox_con.delete('/dcim/cables/', interface_connection_id)

def update_interface_connection(self, interface_connection_id, **kwargs):
"""Update interface connection
Expand All @@ -660,7 +662,7 @@ def update_interface_connection(self, interface_connection_id, **kwargs):
:param kwargs: requests body dict
:return: bool True if successful otherwise raise UpdateException
"""
return self.netbox_con.patch('/dcim/interface-connections/', interface_connection_id, **kwargs)
return self.netbox_con.patch('/dcim/cables/', interface_connection_id, **kwargs)

def get_interface_templates(self, **kwargs):
"""Return interface templates"""
Expand Down