Skip to content
Snippets Groups Projects
Commit 94aa97d5 authored by Ubuntu's avatar Ubuntu Committed by Neda Moeini
Browse files

NAT-243: Added enabled and mark_connected paraters to interface

parent 17819655
No related branches found
No related tags found
1 merge request!77Netbox integration including intial CLI for populating base data and ...
......@@ -80,7 +80,14 @@ def get_device_by_name(nbclient, device_name):
# get all interfaces for a device
def get_interfaces_by_device(nbclient, device_name):
device = get_device_by_name(nbclient, device_name)
return list(nbclient.dcim.interfaces.filter(device_id=device.id))
if device is None:
raise ValueError(f"Device: {device_name} not found")
return list(nbclient.dcim.interfaces.filter(device_id=device.id,
enabled=False,
mark_connected=False,
))
# Create a interface
......@@ -97,8 +104,14 @@ def create_interface(nbclient,
Returns the new interface object as dict.
"""
device = get_device_by_name(nbclient, device_name)
if device is None:
raise ValueError(f"Device: {device_name} not found")
new_iface = nbclient.dcim.interfaces.create(name=iface_name,
type=type,
enabled=False,
mark_connected=False,
device=device.id)
return dict(new_iface)
......@@ -159,7 +172,7 @@ def create_device(nbclient,
# Get site id
device_site = nbclient.dcim.sites.get(name=site)
# Create new device
new_device = nbclient.dcim.devices.create(name=fqdn,
device_type=device_type.id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment