Giter Site home page Giter Site logo

ttafsir / evengsdk Goto Github PK

View Code? Open in Web Editor NEW
61.0 4.0 14.0 1.88 MB

Open source Python library and command line utilities for EVE-NG API

Home Page: https://ttafsir.github.io/evengsdk/

License: MIT License

Python 98.03% Jinja 0.72% Makefile 1.25%
eve-ng api network-programming network-automation networking-labs networking labs netdevops eve-ng-api eve-ng-cli

evengsdk's Introduction

evengsdk

license Downloads PyPI version

Documentation: https://ttafsir.github.io/evengsdk

Open source library and command line utilities to work with the EVE-NG REST API .

Evegnsdk allows you to quickly build network topologies in EVE-NG for testing and development. The CLI tool also enables you quickly integrate EVE-NG into your CI/CD toolset for automated testing and validation.

Requirements

  • Python 3.8+
  • An EVE-NG instance

๐Ÿš€Installation

You can install evengsdk using pip

pip install eve-ng

Basic Usage

You can interact with the EVE-NG API through the client.api interface

>>> from evengsdk.client import EvengClient
>>> from pprint import pprint
>>>
>>> client = EvengClient("10.246.32.254", log_file="test.log")
>>> client.login(username="admin", password="eve")
>>>
>>> resp = client.api.list_node_templates()
>>> pprint(resp.get("data"))
{'a10': 'A10 vThunder.missing',
 'acs': 'Cisco ACS.missing',
 'aruba': 'Aruba WiFi Controller.missing',
 'arubacx': 'Aruba OS-CX Virtual Switch.missing',
 'asa': 'Cisco ASA.missing',
 'asav': 'Cisco ASAv',
 'bigip': 'F5 BIG-IP LTM VE',
 'cumulus': 'Cumulus VX',

 <OUTPUT OMMITTED FOR BREVITY>

 'linux': 'Linux',
 'mikrotik': 'MikroTik RouterOS.missing',
 'nsx': 'VMWare NSX.missing',
 'nxosv9k': 'Cisco NX-OSv 9K',
 'paloalto': 'Palo Alto.missing',
 'pfsense': 'pfSense Firewall.missing',
 'vcenter': 'VMWare vCenter.missing',
 'vios': 'Cisco vIOS Router',
 'viosl2': 'Cisco vIOS Switch',
 'vmx': 'Juniper vMX.missing',
 'vwlc': 'Cisco vWLC.missing',
 'vyos': 'VyOS',
 'xrv9k': 'Cisco XRv 9000.missing'}
>>>

Example: Build a Lab

from evengsdk.client import EvengClient


client = EvengClient("10.246.32.254", log_file="test.log", ssl_verify=False, protocol="https")
client.disable_insecure_warnings()  # disable warnings for self-signed certificates
client.login(username="admin", password="eve")
client.set_log_level("DEBUG")

# create a lab
lab = {"name": "test_lab", "description": "Test Lab", "path": "/"}
resp = client.api.create_lab(**lab)
if resp['status'] == "success":
  print("lab created successfully.")

# we need the lab path to create objects in the lab
lab_path = f"{lab['path']}{lab['name']}.unl"

# create management network
mgmt_cloud = {"name": "eve-mgmt", "network_type": "pnet1"}
client.api.add_lab_network(lab_path, **mgmt_cloud)

# create Nodes
nodes = [
    {"name": "leaf01", "template": "veos", "image": "veos-4.22.0F", "left": 50},
    {"name": "leaf02", "template": "veos", "image": "veos-4.22.0F", "left": 200},
]
for node in nodes:
    client.api.add_node(lab_path, **node)

# connect nodes to management network
mgmt_connections = [
    {"src": "leaf01", "src_label": "Mgmt1", "dst": "eve-mgmt"},
    {"src": "leaf02", "src_label": "Mgmt1", "dst": "eve-mgmt"}
]
for link in mgmt_connections:
    client.api.connect_node_to_cloud(lab_path, **link)

# create p2p links
p2p_links = [
    {"src": "leaf01", "src_label": "Eth1", "dst": "leaf02", "dst_label": "Eth1"},
    {"src": "leaf01", "src_label": "Eth1", "dst": "leaf02", "dst_label": "Eth2"},
]
for link in p2p_links:
    client.api.connect_node_to_node(lab_path, **link)

client.logout()

๐Ÿ“บ The eve-ng CLI Application

The CLI application makes it very simple to quick work with EVE-NG, especially in situation where you would like to automate lab builds and testing using CI/CD.

The CLI application provides an interface to manage EVE-NG objects including:

  • Folders - manage the directory-like structures that contains labs
  • Labs - manage labs and objects inside labs (nodes, networks, links, etc)
    • nodes
    • networks
  • Users - manage system users
  • System - View system status and resources (node templates, network types, user roles, etc..)
โžœ eveng --help
Usage: eveng [OPTIONS] COMMAND [ARGS]...

  CLI application to manage EVE-NG objects

Options:
  --host TEXT           [required]
  --username TEXT       [default: (current user); required]
  --password TEXT       [required]
  --port INTEGER        HTTP port to connect to. Default is 80
  --debug / --no-debug  Enables or disables debug mode.
  -v, --verbose         Enables verbosity.
  --help                Show this message and exit.

Commands:
  folder               folder sub commands
  lab                  lab sub commands
  list-network-types   list EVE-NG network types
  list-node-templates  list EVE-NG node templates
  list-user-roles      list EVE-NG user roles
  node                 node sub commands
  show-status          View EVE-NG server status
  show-template        get EVE-NG node template details
  user                 user sub commands
  version              display library version

CLI sample output

image-20220114112752004

โš™๏ธ Configuration

It is simple enough to pass the proper flags to eve-ng specify details for your EVE-NG host. However, you may also pass the connection details as environment variables. You can set the following evengsdk environment variables:

  • EVE_NG_HOST - EVE-NG host name or IP address
  • EVE_NG_USERNAME - EVE-NG username
  • EVE_NG_PASSWORD EVE-NG API/GUI password
  • EVE_NG_LAB_PATH - EVE-NG default lab path. Ex. /myLab.unl

You may set the variables and export them to your shell environment. You can also define your environment variables in a .env folder that will automatically be sourced. The example. below shows the contents of a .env file that will permit you to both source the file and automatically load the variables as needed.

export EVE_NG_HOST=192.168.2.100
export EVE_NG_USERNAME=admin
export EVE_NG_PASSWORD=eve
export EVE_NG_PORT=80
export EVE_NG_PROTOCOL=http
export EVE_NG_SSL_VERIFY=False
export EVE_NG_INSECURE=True
export EVE_NG_LAB_PATH='/mylab.unl'

๐Ÿ—๏ธ Topology Builder

The CLI application allows you to build lab topologies using a declarative model in order to quickly spin a lab and configure nodes using configuration files or jinja templates. Below is a sample topology that is the examples directory of this project.

---
  name: test
  description: Arista VEOS leaf-spine lab
  path: "/"
  nodes:
    - name: leaf01
      template: veos
      image: veos-4.22.0F
      node_type: qemu
      left: 50
      top: 135
      configuration:
        file: examples/configs/test_leaf01.cfg
    - name: leaf02
      template: veos
      image: veos-4.22.0F
      node_type: qemu
      left: 200
      top: 135
      configuration:
        template: base.j2
        vars:
          hostname: leaf02
          management_address: 10.10.10.1
    - name: leaf03
      template: veos
      image: veos-4.22.0F
      node_type: qemu
      left: 350
      top: 135
      configuration:
        template: base.j2
        vars: examples/data/leaf03.yml
    - name: leaf04
      template: veos
      image: veos-4.22.0F
      node_type: qemu
      left: 500
      top: 135
    - name: spine01
      template: veos
      image: veos-4.22.0F
      node_type: qemu
      left: 150
      top: 474
    - name: spine02
      template: veos
      image: veos-4.22.0F
      node_type: qemu
      left: 350
      top: 474
  networks:
    - name: vCloud
      network_type: pnet1
      visibility: 1
      top: 300
      left: 475
  links:
    network:
      - {"src": "leaf01", "src_label": "Mgmt1", "dst": "vCloud"}
      - {"src": "leaf02", "src_label": "Mgmt1", "dst": "vCloud"}
      - {"src": "leaf03", "src_label": "Mgmt1", "dst": "vCloud"}
      - {"src": "leaf04", "src_label": "Mgmt1", "dst": "vCloud"}
      - {"src": "spine01", "src_label": "Mgmt1", "dst": "vCloud"}
      - {"src": "spine02", "src_label": "Mgmt1", "dst": "vCloud"}
    node:
      - {"src": "leaf01", "src_label": "Eth3", "dst": "spine01", "dst_label": "Eth1"}
      - {"src": "leaf02", "src_label": "Eth3", "dst": "spine01", "dst_label": "Eth2"}
      - {"src": "leaf03", "src_label": "Eth3", "dst": "spine01", "dst_label": "Eth3"}
      - {"src": "leaf04", "src_label": "Eth3", "dst": "spine01", "dst_label": "Eth4"}
      - {"src": "leaf01", "src_label": "Eth2", "dst": "spine02", "dst_label": "Eth1"}
      - {"src": "leaf02", "src_label": "Eth2", "dst": "spine02", "dst_label": "Eth2"}
      - {"src": "leaf03", "src_label": "Eth2", "dst": "spine02", "dst_label": "Eth3"}
      - {"src": "leaf04", "src_label": "Eth2", "dst": "spine02", "dst_label": "Eth4"}

To create a topology from the example above simply run the following command

eve-ng lab create-from-topology -t examples/test_topology.yml --template-dir examples/templates

By default, the configuration tool searches for templates in templates directory, but you can use --template-dir as shown above to specify another location.

evengsdk's People

Contributors

dependabot[bot] avatar mplattner avatar ttafsir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

evengsdk's Issues

[ERROR] Exception seen with lock file when creating topology from YAML

Describe the bug

Using https://ttafsir.github.io/evengsdk/topology_builder/ when we create a topology from YAML file, occasionally we keep running into the following exception

Type: ErrorException
Code: 2
Message: unlink(/opt/unetlab/labs/himanshu/AVD_ASYM_AA_MH.unl.lock): No such file or directory
File: /opt/unetlab/html/includes/functions.php
Line: 793
Trace

#0 : Slim\Slim::handleErrors(2, 'unlink(/opt/une...', '/opt/unetlab/ht...', 793,
Array)
#1 /opt/unetlab/html/includes/functions.php(793): unlink('/opt/unetlab/la...')
#2 /opt/unetlab/html/api.php(922): unlockFile('/opt/unetlab/la...')
#3 : {closure}(Array)
#4
/opt/unetlab/html/includes/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)
#5 /opt/unetlab/html/includes/Slim/Slim.php(1357): Slim\Route->dispatch()
#6
/opt/unetlab/html/includes/Slim/Middleware/Flash.php(85): Slim\Slim->call()
#7 /opt/unetlab/html/includes/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
#8
/opt/unetlab/html/includes/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#9 /opt/unetlab/html/includes/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#10
/opt/unetlab/html/api.php(1339): Slim\Slim->run()
#11 {main}

The same run of the lab runs successfully other times. The issue is majorly intermittent.

This is mostly seen when creating p2p links between nodes. One more thing noticed is this is not seen for smaller scale labs (i.e less nodes.)

Thus wanted to check if this is a possible bug on the eve-ng api end?

Also, enabling debugging does not seems to work, can you please help me with the same?

(source .env && eve-ng --debug -v lab create-from-topology -t templates/eve-ng-topology.yaml)

Windows - Unable to delete a lab in a subdirectory

Summary

I am unable to remove a nested lab via this library.

Issue Type

Bug Report

Python Version

3.8.10

OS / Environment

Windows 10

Steps to Reproduce

On a Windows system, attempt to delete a lab in a subdirectory.

Expected Results

Lab is deleted successfully.

Actual Results

Exception has occurred: ValueError
WindowsPath('//Ansible/test_lab.unl/') has an empty name
  File "C:\Projects\autolab\app.py", line 22, in <module>
    client.api.delete_lab(lab)

Comments

This is due to the Path import being ambiguous, and as a result will use the system Pathlib, which in my case is WindowsPath.

Discovered Solution

By replacing the import with PurePosixPath and removing the .resolve(), I am able to utilize the SDK. Perhaps introduce a check for the OS the user is on and substitute these function calls?

from pathlib import Path

path = Path(path).resolve()

[BUG] Node configs persist after lab is deleted

Describe the bug
Node configs persist after the lab is deleted. When I delete and recreate a lab, the new lab comes up with the startup configs from the deleted lab.

To Reproduce
Steps to reproduce the behavior:

  • delete a lab without wiping the configs
  • create a new lab of the same name

Expected behavior
I expected the delete operation to clean up existing config

Additional context
Manually wiping the configs before deleting seems to resolve the issue.

addNode seems to be coded towards using a vEOS image only?

I tried to use the api to add a cisco 3725 template/image and getting a NoneType object is not subscriptable when building the node list .
Looking at addNode it is trying to find in the template options things like "ethernet" and "cpu" etc, which the cisco ios template does not allow you to set. Seems like need some logic to say if they are not in the template (besides set to None), just don't add them to the dictionary passed to the eve api?

resp=client.api.node_template_detail('c3725')
nodes = [
... {"name": "srelab01", "template": "c3725", "image": "c3725-adventerprisek9-mz.124-15.T14.image", "left": 50},
... {"name": "srelab02", "template": "c3725", "image": "c3725-adventerprisek9-mz.124-15.T14.image", "left": 200}
... ]
for node in nodes:
... client.api.add_node(lab_path, **node)
...
Traceback (most recent call last):
File "", line 2, in
File "/usr/local/lib/python3.8/dist-packages/eve_ng-0.2.5-py3.8.egg/evengsdk/api.py", line 1005, in add_node
ethernet = ethernet or template_defaults.get("ethernet")["value"]
TypeError: 'NoneType' object is not subscriptable

fix lab commands

  • fix return values from API
  • clean up duplicate and commented code

Crash with lab topology

Describe the bug
For some lab, I get a crash in the display plugin output

To Reproduce
execute lab topology

Expected behavior
Not crash

Screenshots

Additional context
python error message was : KeyError: 'beziercurviness1'

I fixed the issue replacing line 58 of display.py with
if isinstance(item, dict) and key in item:

Add close_lab method to api wrapper

How would you like to improve the project?
The EVE-NG API allows you to start multiple labs at once which is problematic in the community version because the telnet ports for console access overlap. The current way to close labs is to simply shut all nodes. However, there appears to be a better way to close the labs with an available (not well documented) endpoint.

Describe the solution you'd like
Implement a wrapper for the /labs/close endpoint to close the current lab.

Additional context
the EVE-NG API has a /labs/close endpoint that is not documented in the main documentation.

refactor table based output

  • migrate from tabulate to rich for improved output
  • change default display for list command to use table plugin

Display started labs in lab list command

How would you like to improve the project?
Display a visual indicator to show which lab is started when I list all labs. The API allows you to start any lab, even when the GUI restricts starting only one lab at a time. This seems to cause issues with stopping and starting nodes. The start and stop commands are still accepted but are ineffectual.

Describe the solution you'd like
At a minimum, it'd be helpful to see which labs have any running nodes at the CLI before attempting to start another. This could help inform you to stop one lab before starting the other.

Describe alternatives you've considered
NA

Additional context

[CHORE] refactor tests

  • remove duplication of fixtures
  • factor out classes to individual file for better maintenance
  • fix connection issues related to test fixtures

[BUG] version info requires CLI options

Describe the bug
using the eve-ng version command without required flags for the EvengCLient fails

To Reproduce
Steps to reproduce the behavior:
Without passing environment vars or setting values for required options like --host, --username, when I use eve-ng version, I get an error for missing options.

Expected behavior
The version info should be dependent of any flags or options

Screenshots
image

Additional context
It's worth looking at the click.version_option here

speed up topology builder with concurrency

How would you like to improve the project?
A clear and concise description of what the problem is.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

import_lab is not implemented in api wrapper

the lab import cli command is implemented to use api.import_lab, which does not exist.

@click.pass_context
def import_lab(ctx, folder, src):
    """
    Import lab into EVE-NG from ZIP archive
    """

    client = get_client(ctx)
    resp = client.api.import_lab(Path(src), folder)

Need to implement api.import_lab

Add support for internal, private and nat interfaces

How would you like to improve the project?
The PRO version supports additional network types (internal, private, and nat) interfaces that are not currently supported. This is partly due to a semi-static mapping of the interface types.

Describe the solution you'd like
Querying available network types from the EVE-NG server would provide a more dynamic way to manage network types across both community and pro versions.

[BUG] user CLI commands return no output

Describe the bug
All of the eve-ng user subcommands return empty data.

To Reproduce
Steps to reproduce the behavior:

โžœ eve-ng user list

โžœ eveng user edit

โžœ

Expected behavior
at least the admin user or an error should have been shown.

Additional context
The CLI commands are currently not fully implemented.

`eveng node list` raises AttributeError when lab has no nodes AttributeError when lab has no nodes

โ”‚   250 โ”‚   """                                                                                    โ”‚
โ”‚   251 โ”‚   client = get_client(ctx)                                                               โ”‚
โ”‚   252 โ”‚   resp = client.api.list_nodes(path)                                                     โ”‚
โ”‚ โฑ 253 โ”‚   node_indexes = resp.get("data", {}).keys()                                             โ”‚
โ”‚   254 โ”‚   nodes_list = [(idx, resp["data"][idx]) for idx in node_indexes]                        โ”‚
โ”‚   255 โ”‚                                                                                          โ”‚
โ”‚   256 โ”‚   node_table = []                                                                        โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ locals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ                                โ”‚
โ”‚ โ”‚ client = <evengsdk.client.EvengClient object at 0x1032b6fa0>  โ”‚                                โ”‚
โ”‚ โ”‚    ctx = <click.core.Context object at 0x104471130>           โ”‚                                โ”‚
โ”‚ โ”‚ output = 'json'                                               โ”‚                                โ”‚
โ”‚ โ”‚   path = '/lab_to_edit.unl'                                   โ”‚                                โ”‚
โ”‚ โ”‚   resp = {                                                    โ”‚                                โ”‚
โ”‚ โ”‚          โ”‚   'code': 200,                                     โ”‚                                โ”‚
โ”‚ โ”‚          โ”‚   'status': 'success',                             โ”‚                                โ”‚
โ”‚ โ”‚          โ”‚   'message': 'Successfully listed nodes (60026).', โ”‚                                โ”‚
โ”‚ โ”‚          โ”‚   'data': []                                       โ”‚                                โ”‚
โ”‚ โ”‚          }                                                    โ”‚                                โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ                                โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
AttributeError: 'list' object has no attribute 'keys'

[CHORE] Fix failing build job due to dev requirements

Fix failing CI jobs due to dev requirements issue.

The build job fails while running format checks with black:

| Check for added large files..............................................Passed
| Check for merge conflicts................................................Passed
| Check for broken symlinks............................(no files to check)Skipped
| Detect Private Key.......................................................Passed
| Fix End of Files.........................................................Passed
| Don't commit to branch..................................................Skipped
| Trim Trailing Whitespace.................................................Passed
| black....................................................................Failed
| - hook id: black
| - exit code: 1
|
| Traceback (most recent call last):
|   File "/root/.cache/pre-commit/repo0qs1w1pj/py_env-python3/bin/black", line 8, in <module>
|     sys.exit(patched_main())
|   File "/root/.cache/pre-commit/repo0qs1w1pj/py_env-python3/lib/python3.8/site-packages/black/__init__.py", line 6606, in patched_main
|     patch_click()
|   File "/root/.cache/pre-commit/repo0qs1w1pj/py_env-python3/lib/python3.8/site-packages/black/__init__.py", line 6595, in patch_click
|     from click import _unicodefun  # type: ignore
| ImportError: cannot import name '_unicodefun' from 'click' (/root/.cache/pre-commit/repo0qs1w1pj/py_env-python3/lib/python3.8/site-packages/click/__init__.py)
|
| flake8...................................................................Passed
[Lint/build-1               ]   โŒ  Failure - Run pre-commit checks
[Lint/build-1               ] exit with `FAILURE`: 1

[BUG] configuration enable not working for eve-ng CLI

Describe the bug

Python 3.9.1
eve-ng, version 0.2.7

When using eve-ng CLI app to create topology the configuration enable is not working.

To Reproduce

following is the topology definition file:

---
  name: AVD_LAB_TESTING
  description: EVPN AVD_LAB_TESTING
  path: "/himanshu/"
  author: "himanshu"
  nodes:
    - name: DC1_SPINE1
      template: veos
      image: veos-4.28.1F
      node_type: qemu
      left: 405
      top: 216
      cpu: 2
      ram: 3072
      configuration:
        file: configs/DC1_SPINE1.cfg
    - name: JumpBox
      template: veos
      image: veos-4.28.1F
      node_type: qemu
      left: 702
      top: 51
      cpu: 2
      ram: 2048
      ethernet: 11
  networks:
    - name: Net
      network_type: pnet0
      visibility: 1
      top: 36
      left: 243
  links:
    network:
      - {"src": "JumpBox", "src_label": "Mgmt1", "dst": "Net"}
    node:
      - {"src": "DC1_SPINE1", "src_label": "Mgmt1", "dst": "JumpBox", "dst_label": "Eth1", "media": "ethernet"}
(source .env && eve-ng lab create-from-topology -t templates/evpn-a-a-mh.yml)

[21:43:12] Lab created: /himanshu//AVD_LAB_TESTING.unl                                                                                                             commands.py:452
[21:43:13] node DC1_SPINE1 completed                                                                                                                               commands.py:202
           node JumpBox completed                                                                                                                                  commands.py:202
           network Net completed. ID: 1                                                                                                                            commands.py:226
[21:43:14] link JumpBox:Mgmt1 -> Net completed                                                                                                                     commands.py:146
[21:43:15] link DC1_SPINE1:Mgmt1 <-> JumpBox:Eth1 completed                                                                                                        commands.py:166

Expected behavior

We can see the config is uploaded,

(source .env && eve-ng node config --node-id 2 --path himanshu/AVD_LAB_TESTING.unl)

!RANCID-CONTENT-TYPE: arista
!
vlan internal order ascending range 1006 1199
!
transceiver qsfp default-mode 4x10G
!
service routing protocols model multi-agent
!
hostname DC1_SPINE1
<snipped>

but seems the enable_node_config is not getting invoked:

(source .env && eve-ng node read --node-id 2 --path himanshu/AVD_LAB_TESTING.unl)

{
  "console": "telnet",
  "config": "0",
  "delay": 0,
  "left": 405,
  "icon": "AristaSW.png",
  "image": "veos-4.28.1F",
  "name": "DC1_SPINE1",
  "status": 0,
  "template": "veos",
  "type": "qemu",
  "top": 216,
  "url": "telnet://<snipped>:33538",
  "cpulimit": 1,
  "cpu": 2,
  "ethernet": 9,
  "ram": 3072,
  "uuid": "fc459b6c-7f18-4c04-8049-97fc2133fa62",
  "qemu_options": "-machine type=pc,accel=kvm -serial mon:stdio -nographic -display none -no-user-config -rtc base=utc -boot order=d",
  "qemu_version": "4.1.0",
  "qemu_arch": "x86_64",
  "qemu_nic": ""
}

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

It seems there was a previous issue logged for this where the fix #98 was added to devel branch

but in the master we can see the function is different:

 190   โ”‚     # configure node
 191   โ”‚     if resp["status"] == "success" and config:
 192   โ”‚         node_id = resp["data"]["id"]
 193   โ”‚         resp = client.api.upload_node_config(path, node_id, config)
 194   โ”‚         if resp["status"] == "success":
 195   โ”‚             if config := topology.get_node_config(node["name"]):
 196   โ”‚                 node_id = resp["data"]["id"]
 197   โ”‚                 resp = client.api.upload_node_config(topology.path, node_id, config)
 198   โ”‚                 if resp["status"] == "success":
 199   โ”‚                     client.api.enable_node_config(topology.path, node_id)

Make library compatible with PRO version

How would you like to improve the project?
there are slight differences between the community and pro API that need to be accounted for:

  • starting and stopping nodes
  • wiping nodes
  • exporting labs
  • node configs

Unable to import from topology using IOL devices

Describe the bug
Cant import from topology using IOL devices

To Reproduce
Steps to reproduce the behavior:

Create topology YML using any iol devices:

---
  name: LAB
  description: Iol test lab
  path: "/"
  nodes:
    - name: leaf01
      template: iol
      image: iol-i86bi_LinuxL3-AdvEnterpriseK9-M2_157_3_May_2018.bin
      node_type: iol
      left: 500
      top: 135

    - name: leaf02
      template: iol
      image: i86bi_LinuxL3-AdvEnterpriseK9-M2_157_3_May_2018.bin
      node_type: iol
      left: 600
      top: 135


  networks:
    - name: MGMT
      network_type: pnet1
      visibility: 1
      top: 300
      left: 475
  links:
    network:
      - {"src": "leaf01", "src_label": "e0/0", "dst": "MGMT"}
    node:
      - {"src": "leaf01", "src_label": "e0/3", "dst": "leaf02", "dst_label": "e0/3"}
**eve-ng --verbose lab create-from-topology -t examples/iol.yml** 
Verbose logging is enabled. (LEVEL=40)
[16:27:52] Lab created: //LAB.unl                                                                             commands.py:430
[16:27:53] network vCloud completed. ID: 1                                                                    commands.py:221
ERROR: Error creating lab: node leaf01 not found or invalid

Expected behavior
Create the LAB

Screenshots
NA

Additional context
It works fine using any qemu devices, also its posible to add iol devices using CLI and works fine: Ex: eve-ng node create --name testnode--nde-type iol --template iol --image i86bi_LinuxL3-AdvEnterpriseK9-M2_157_3_May_2018.bin

Create Lab from Topology File

As a user, I'd like to create labs using a declarative topology file so that I can define and maintain labs using an IaC approach and so that I can easily share topology between projects and with others.

get_node_by_name not working

Traceback (most recent call last):
  File "/Users/thiamt/Projects/eve-ng-sdk-project/src/examples.local/create_lab.py", line 67, in <module>
    r3 = client.api.add_node(lab_path, **attrs)
  File "/Users/thiamt/Projects/eve-ng-sdk-project/src/evengsdk/api.py", line 882, in add_node
    if not self.node_exists(path, name):
  File "/Users/thiamt/Projects/eve-ng-sdk-project/src/evengsdk/api.py", line 596, in node_exists
    node = self.get_node_by_name(path, nodename)
  File "/Users/thiamt/Projects/eve-ng-sdk-project/src/evengsdk/api.py", line 268, in get_node_by_name
    return next((v for _, v in nodes.items() if v["name"] == name), None)
AttributeError: 'list' object has no attribute 'items'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.