Coverage for src/meshadmin/cli/commands/nebula.py: 50%

24 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 11:46 +0200

1import asyncio 

2from pathlib import Path 

3 

4import structlog 

5import typer 

6 

7from meshadmin.cli.utils import get_context_config, start_nebula 

8from meshadmin.common.utils import download_nebula_binaries, get_nebula_path 

9 

10nebula_app = typer.Typer() 

11logger = structlog.get_logger(__name__) 

12 

13 

14@nebula_app.command() 

15def download(): 

16 try: 

17 context = get_context_config() 

18 nebula_path = get_nebula_path() 

19 if not nebula_path or not Path(nebula_path).exists(): 

20 logger.info("Nebula binaries not found, downloading...") 

21 download_nebula_binaries(context["endpoint"]) 

22 else: 

23 logger.info("Nebula binaries already downloaded") 

24 except Exception as e: 

25 logger.error("Failed to download nebula binaries", error=str(e)) 

26 raise typer.Exit(code=1) 

27 

28 

29@nebula_app.command() 

30def start(): 

31 context = get_context_config() 

32 asyncio.run(start_nebula(context["network_dir"], context["endpoint"]))