ttafsir / evengsdk

Open source Python library and command line utilities for EVE-NG API
https://ttafsir.github.io/evengsdk/
MIT License
63 stars 14 forks source link

[BUG] Create lab topology: crash if no "node" on links #170

Open brasil-iot opened 1 year ago

brasil-iot commented 1 year ago

Describe the bug If no 'node' on links, create-from-topology execute, lab created, but error displayed

To Reproduce eveng lab create-from-topology -t test.yml

test.yml

---
  name: test
  description: LabTest
  path: "/"
  nodes:
    - name: MK74-A
      template: mikrotik
      image: mikrotik-7.4
      left: 50
      top: 135
  networks:
    - name: vCloud
      network_type: pnet0
      visibility: 1
      top: 300
      left: 475
  links:
    network:
      - {"src": "MK74-A", "src_label": "eth1", "dst": "vCloud"}

Correction proposed in evengsdk/cli/lab/commands.py, line 476

        if topology.p2p_links is not None:
           # create p2p links
           p2p_tasks = [
               f"link [bold green]{link['src']}:{link['src_label']}[/bold green]"
               f" <-> [bold green]{link['dst']}:{link['dst_label']}[/bold green]"
               for link in topology.p2p_links
           ]

           with console.status("[bold green]Creating links..."):
               create_p2p_links(topology, tasks=p2p_tasks)`