Skip to content
Snippets Groups Projects
Select Git revision
  • 03fca8471456c946185500fc5865e75106e2254a
  • develop default protected
  • master protected
  • feature/POL1-813-error-report-sensu-check
  • 0.23
  • 0.22
  • 0.21
  • 0.20
  • 0.19
  • 0.18
  • 0.17
  • 0.16
  • 0.15
  • 0.14
  • 0.13
  • 0.12
  • 0.11
  • 0.10
  • 0.9
  • 0.8
  • 0.7
  • 0.6
  • 0.5
  • 0.4
24 results

test_nokia.py

Blame
  • netbox.py 1.13 KiB
    """A CLI for interacting with Netbox."""
    
    import typer
    from pynetbox import RequestError
    
    from gso.services.netbox_client import NetboxClient
    from gso.utils.device_info import DEFAULT_SITE, ROUTER_ROLE
    
    app: typer.Typer = typer.Typer()
    
    
    @app.command()
    def netbox_initial_setup() -> None:
        """Set up NetBox for the first time.
    
        It includes:
        - Creating a default site (GEANT)
        - Creating device roles (Router)
        """
        typer.echo("Initial setup of NetBox ...")
        typer.echo("Connecting to NetBox ...")
    
        nbclient = NetboxClient()
    
        typer.echo("Creating GEANT site ...")
        try:
            nbclient.create_device_site(DEFAULT_SITE["name"], DEFAULT_SITE["slug"])
            typer.echo("Site created successfully.")
        except RequestError as e:
            typer.echo(f"Error creating site: {e}")
    
        typer.echo("Creating Router device role ...")
        try:
            nbclient.create_device_role(ROUTER_ROLE["name"], ROUTER_ROLE["slug"])
            typer.echo("Device role created successfully.")
        except RequestError as e:
            typer.echo(f"Error creating device role: {e}")
    
        typer.echo("NetBox initial setup completed successfully.")