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
Branches
Tags
1 merge request!77Netbox integration including intial CLI for populating base data and ...
Pipeline #84163 passed
This commit is part of merge request !77. Comments created here will be created in the context of that merge request.
...@@ -17,11 +17,7 @@ def netbox_initial_setup() -> None: ...@@ -17,11 +17,7 @@ def netbox_initial_setup() -> None:
typer.echo("Initial setup of NetBox ...") typer.echo("Initial setup of NetBox ...")
typer.echo("Connecting to NetBox ...") typer.echo("Connecting to NetBox ...")
try: nbclient = NetBoxClient()
nbclient = NetBoxClient()
except RequestError as e:
typer.echo(f"Error connecting to NetBox: {e}")
return
typer.echo("Creating GEANT site ...") typer.echo("Creating GEANT site ...")
try: try:
......
...@@ -7,7 +7,7 @@ from pynetbox.models.dcim import Devices, DeviceTypes, Interfaces ...@@ -7,7 +7,7 @@ from pynetbox.models.dcim import Devices, DeviceTypes, Interfaces
from gso.products import Router from gso.products import Router
from gso.settings import load_oss_params 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 from gso.utils.exceptions import NotFoundError, WorkflowStateError
...@@ -49,8 +49,8 @@ class NetBoxClient: ...@@ -49,8 +49,8 @@ class NetBoxClient:
"""Implement all methods to communicate with the NetBox API.""" """Implement all methods to communicate with the NetBox API."""
def __init__(self) -> None: def __init__(self) -> None:
netbox_params = load_oss_params().NETBOX self.netbox_params = load_oss_params().NETBOX
self.netbox = pynetbox.api(netbox_params.api, netbox_params.token) self.netbox = pynetbox.api(self.netbox_params.api, self.netbox_params.token)
def get_all_devices(self) -> list[Devices]: def get_all_devices(self) -> list[Devices]:
return list(self.netbox.dcim.devices.all()) return list(self.netbox.dcim.devices.all())
...@@ -207,7 +207,7 @@ class NetBoxClient: ...@@ -207,7 +207,7 @@ class NetBoxClient:
] ]
# Generate all feasible lags # 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 available lags not assigned to the device
return [lag for lag in all_feasible_lags if lag not in lag_interface_names] return [lag for lag in all_feasible_lags if lag not in lag_interface_names]
...@@ -30,5 +30,4 @@ class TierInfo: ...@@ -30,5 +30,4 @@ class TierInfo:
return getattr(self, name) return getattr(self, name)
# Ranges of LAGs that are feasible for a given device type. FEASIBLE_IP_TRUNK_LAG_RANGE = range(1, 10)
FEASIBLE_LAG_RANGE = range(1, 11)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment