1 import asyncio

2 from pathlib import Path

3

4 import structlog

5 import typer

6

7 from meshadmin.cli.utils import get_context_config, start_nebula

8 from meshadmin.common.utils import download_nebula_binaries, get_nebula_path

9

10 nebula_app = typer.Typer()

11 logger = structlog.get_logger(__name__)

12

13

14@nebula_app.command()

15 def 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()

30 def start():

31 context = get_context_config()

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