Skip to content
Snippets Groups Projects
Commit 9df4b4c9 authored by Neda Moeini's avatar Neda Moeini
Browse files

Improved naming and removed some unnecessary part.

parent 669e8581
No related branches found
No related tags found
1 merge request!77Netbox integration including intial CLI for populating base data and ...
Pipeline #84163 passed
......@@ -17,11 +17,7 @@ def netbox_initial_setup() -> None:
typer.echo("Initial setup of NetBox ...")
typer.echo("Connecting to NetBox ...")
try:
nbclient = NetBoxClient()
except RequestError as e:
typer.echo(f"Error connecting to NetBox: {e}")
return
nbclient = NetBoxClient()
typer.echo("Creating GEANT site ...")
try:
......
......@@ -7,7 +7,7 @@ from pynetbox.models.dcim import Devices, DeviceTypes, Interfaces
from gso.products import Router
from gso.settings import load_oss_params
from gso.utils.device_info import FEASIBLE_LAG_RANGE, TierInfo
from gso.utils.device_info import FEASIBLE_IP_TRUNK_LAG_RANGE, TierInfo
from gso.utils.exceptions import NotFoundError, WorkflowStateError
......@@ -49,8 +49,8 @@ class NetBoxClient:
"""Implement all methods to communicate with the NetBox API."""
def __init__(self) -> None:
netbox_params = load_oss_params().NETBOX
self.netbox = pynetbox.api(netbox_params.api, netbox_params.token)
self.netbox_params = load_oss_params().NETBOX
self.netbox = pynetbox.api(self.netbox_params.api, self.netbox_params.token)
def get_all_devices(self) -> list[Devices]:
return list(self.netbox.dcim.devices.all())
......@@ -207,7 +207,7 @@ class NetBoxClient:
]
# Generate all feasible lags
all_feasible_lags = [f"LAG-{i}" for i in FEASIBLE_LAG_RANGE]
all_feasible_lags = [f"LAG-{i}" for i in FEASIBLE_IP_TRUNK_LAG_RANGE]
# Return available lags not assigned to the device
return [lag for lag in all_feasible_lags if lag not in lag_interface_names]
......@@ -30,5 +30,4 @@ class TierInfo:
return getattr(self, name)
# Ranges of LAGs that are feasible for a given device type.
FEASIBLE_LAG_RANGE = range(1, 11)
FEASIBLE_IP_TRUNK_LAG_RANGE = range(1, 10)
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