Package: eve-ng
evengsdkDocumentation:https://ttafsir.github.io/evengsdkOpen source library and command line utilities to work with theEVE-NGREST 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.RequirementsPython 3.8+An EVE-NG instance:rocket:InstallationYou can installevengsdkusing pippipinstalleve-ngBasic UsageYou can interact with the EVE-NG API through theclient.apiinterface>>>fromevengsdk.clientimportEvengClient>>>frompprintimportpprint>>>>>>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',<OUTPUTOMMITTEDFORBREVITY>'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 Labfromevengsdk.clientimportEvengClientclient=EvengClient("10.246.32.254",log_file="test.log",ssl_verify=False,protocol="https")client.disable_insecure_warnings()# disable warnings for self-signed certificatesclient.login(username="admin",password="eve")client.set_log_level("DEBUG")# create a lablab={"name":"test_lab","description":"Test Lab","path":"/"}resp=client.api.create_lab(**lab)ifresp['status']=="success":print("lab created successfully.")# we need the lab path to create objects in the lablab_path=f"{lab['path']}{lab['name']}.unl"# create management networkmgmt_cloud={"name":"eve-mgmt","network_type":"pnet1"}client.api.add_lab_network(lab_path,**mgmt_cloud)# create Nodesnodes=[{"name":"leaf01","template":"veos","image":"veos-4.22.0F","left":50},{"name":"leaf02","template":"veos","image":"veos-4.22.0F","left":200},]fornodeinnodes:client.api.add_node(lab_path,**node)# connect nodes to management networkmgmt_connections=[{"src":"leaf01","src_label":"Mgmt1","dst":"eve-mgmt"},{"src":"leaf02","src_label":"Mgmt1","dst":"eve-mgmt"}]forlinkinmgmt_connections:client.api.connect_node_to_cloud(lab_path,**link)# create p2p linksp2p_links=[{"src":"leaf01","src_label":"Eth1","dst":"leaf02","dst_label":"Eth1"},{"src":"leaf01","src_label":"Eth1","dst":"leaf02","dst_label":"Eth2"},]forlinkinp2p_links:client.api.connect_node_to_node(lab_path,**link)client.logout():tv: Theeve-ngCLI ApplicationThe 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 labsLabs- manage labs and objects inside labs (nodes, networks, links, etc)nodesnetworksUsers- manage system usersSystem- View system status and resources (node templates, network types, user roles, etc..)➜eveng--help
Usage:eveng[OPTIONS]COMMAND[ARGS]...CLIapplicationtomanageEVE-NGobjects

Options:--hostTEXT[required]--usernameTEXT[default:(currentuser);required]--passwordTEXT[required]--portINTEGERHTTPporttoconnectto.Defaultis80--debug/--no-debugEnablesordisablesdebugmode.-v,--verboseEnablesverbosity.--helpShowthismessageandexit.

Commands:folderfoldersubcommandslablabsubcommandslist-network-typeslistEVE-NGnetworktypeslist-node-templateslistEVE-NGnodetemplateslist-user-roleslistEVE-NGuserrolesnodenodesubcommandsshow-statusViewEVE-NGserverstatusshow-templategetEVE-NGnodetemplatedetailsuserusersubcommandsversiondisplaylibraryversionCLI sample output:gear: ConfigurationIt is simple enough to pass the proper flags toeve-ngspecify details for your EVE-NG host. However, you may also pass the connection details as environment variables. You can set the followingevengsdkenvironment variables:EVE_NG_HOST- EVE-NG host name or IP addressEVE_NG_USERNAME- EVE-NG usernameEVE_NG_PASSWORDEVE-NG API/GUI passwordEVE_NG_LAB_PATH- EVE-NG default lab path. Ex./myLab.unlYou may set the variables and export them to your shell environment. You can also define your environment variables in a.envfolder that will automatically be sourced. The example. below shows the contents of a.envfile 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 BuilderThe 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 theexamplesdirectory of this project.---name:testdescription:Arista VEOS leaf-spine labpath:"/"nodes:-name:leaf01template:veosimage:veos-4.22.0Fnode_type:qemuleft:50top:135configuration:file:examples/configs/test_leaf01.cfg-name:leaf02template:veosimage:veos-4.22.0Fnode_type:qemuleft:200top:135configuration:template:base.j2vars:hostname:leaf02management_address:10.10.10.1-name:leaf03template:veosimage:veos-4.22.0Fnode_type:qemuleft:350top:135configuration:template:base.j2vars:examples/data/leaf03.yml-name:leaf04template:veosimage:veos-4.22.0Fnode_type:qemuleft:500top:135-name:spine01template:veosimage:veos-4.22.0Fnode_type:qemuleft:150top:474-name:spine02template:veosimage:veos-4.22.0Fnode_type:qemuleft:350top:474networks:-name:vCloudnetwork_type:pnet1visibility:1top:300left:475links: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 commandeve-nglabcreate-from-topology-texamples/test_topology.yml--template-direxamples/templatesBy default, the configuration tool searches for templates intemplatesdirectory, but you can use--template-diras shown above to specify another location.