First, I spent quite a bit of time looking for an answer before posting here, but I have no experience with what is going on under the hood with EVE-NG. It seems that what I want to do must be possible with the REST API, but I could be barking up the wrong tree entirely.
I have a topology with 14 nodes (10 routers + 4 switches) running on an EVE-NG instance with 6 vCPUs. If I try to start everything at once, it takes *forever* to boot everything. If I boot up the devices in three groups (5 routers + 5 routers + 4 switches), waiting for the previous group to finish, then the lab starts up no problem and performs just fine. Throwing more vCPUs at the problem does "fix" it, but it seems wasteful to pay for more vCPUs just to make booting the lab more convenient (I am using Google Compute).
How can I script EVE-NG to boot up a group of nodes, wait for some specified amount of time, then boot up another group, etc.? It'd be really nice to just run a script and come back when my lab is ready to go instead of coming back to start up more nodes every 5 minutes or so.
I am imagining something like this (pseudocode):
boot.nodes(1,2,3,4,5)
sleep(300)
boot.nodes(6,7,8,9,10)
sleep(300)
boot.nodes(11,12,13,14)
Any help would be greatly appreciated!
Wish to script starting nodes in staggered fashion
Moderator: mike
-
- Posts: 4
- Joined: Thu Dec 13, 2018 7:45 am
-
- Posts: 5177
- Joined: Wed Mar 15, 2017 4:44 pm
- Location: London
- Contact:
Re: Wish to script starting nodes in staggered fashion
Boot delay.
We always had such option in the EVE.
This feature is useful in conjunction with the “Start all nodes” function if your lab requires certain nodes to start up before others or to avoid a mass-start of very heavy nodes.
right click on node/edit and set delay time in seconds. It means that node after start, will trigger waiting time before boot.
Example
your first 5 nodes in lab leave delay 0;
next 5 nodes set delay 300;
next 5 nodes set delay to 600.
First 5 nodes will start and boot immediately,
Next 5 nodes will start, but boot only after 5 mins. (300sec)
Next portion of 5 will start and boot after 10 mins. (600sec)
You can vary this delay time to achieve required result
BTW it is described in our cookbook as well.
https://www.eve-ng.net/images/EVE-COOK-BOOK-1.7.pdf
Section 9.1.1.1 table p17
Uldis
P.S.
Your lab:
boot.nodes(1,2,3,4,5)
delay 0
boot.nodes(6,7,8,9,10)
delay 300
boot.nodes(11,12,13,14)
delay 600
We always had such option in the EVE.
This feature is useful in conjunction with the “Start all nodes” function if your lab requires certain nodes to start up before others or to avoid a mass-start of very heavy nodes.
right click on node/edit and set delay time in seconds. It means that node after start, will trigger waiting time before boot.
Example
your first 5 nodes in lab leave delay 0;
next 5 nodes set delay 300;
next 5 nodes set delay to 600.
First 5 nodes will start and boot immediately,
Next 5 nodes will start, but boot only after 5 mins. (300sec)
Next portion of 5 will start and boot after 10 mins. (600sec)
You can vary this delay time to achieve required result

BTW it is described in our cookbook as well.
https://www.eve-ng.net/images/EVE-COOK-BOOK-1.7.pdf
Section 9.1.1.1 table p17
Uldis
P.S.
Your lab:
boot.nodes(1,2,3,4,5)
delay 0
boot.nodes(6,7,8,9,10)
delay 300
boot.nodes(11,12,13,14)
delay 600
You do not have the required permissions to view the files attached to this post.
-
- Posts: 4
- Joined: Thu Dec 13, 2018 7:45 am
Re: Wish to script starting nodes in staggered fashion
Thank you much Uldis! This is even easier than what I was thinking.
I did look through the cookbook, but apparently not carefully enough
I did look through the cookbook, but apparently not carefully enough

-
- Posts: 59
- Joined: Wed Feb 12, 2020 7:43 am
- Location: UK
- Contact:
Re: Wish to script starting nodes in staggered fashion
Last night I just finished some code to start up my lab before I get up in the morning , its written in Python and runs a separate Ubuntu Box ( raspberry pi ) , reason being this is low power, this then starts up my server by powering it on
I've included just code that logs into eve and starts the lab
here is a code sample
the reason i mention is this is a way to start lots of nodes if you wanted to add a delay just add
time.sleep(30)
I've included just code that logs into eve and starts the lab
here is a code sample
Code: Select all
import json
import sys
DATACENTER=["4","17","44","45","41","25","12","10","11","3","2"]
SITE1=["6","14","15","7","27","26","18","13","28","20","5","1","40","39","38"]
SITE2=["34","35","37","36","9","8","19","21","31","32","33"]
def start_jncie_lab():
syslog.syslog('lab: getemail.py : running start_jncie() ')
import urllib3
import requests
import pprint
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
try:
print('starting JNCIE LAB')
syslog.syslog('lab: getemail.py : EVENG JNCIE LAB Via API ')
myobj = '{"username":"admin2","password":"eve"}'
response = requests.post('https://172.27.233.244/api/auth/login',myobj,verify=False)
cookie=response.cookies
response = requests.get('http://172.27.233.244/api/status',cookies=cookie,verify=False)
parsed = json.loads(response.text)
print(json.dumps(parsed, indent=2, sort_keys=True))
for device in DATACENTER :
response=requests.get('https://172.27.233.244/api/labs/JNCIE-ENT/JNCIE-ENTStudyLab.unl/nodes/'+device+'/start',cookies=cookie,verify=False)
syslog.syslog('lab: getemail.py : starting JNCIE LAB virtual machines')
parsed = json.loads(response.text)
print(json.dumps(parsed, indent=2, sort_keys=True))
print(device)
for device in SITE1 :
response=requests.get('https://172.27.233.244/api/labs/JNCIE-ENT/JNCIE-ENTStudyLab.unl/nodes/'+device+'/start',cookies=cookie,verify=False)
syslog.syslog('lab: getemail.py : starting JNCIE LAB virtual machines')
parsed = json.loads(response.text)
print(json.dumps(parsed, indent=2, sort_keys=True))
print(device)
for device in SITE2 :
response=requests.get('https://172.27.233.244/api/labs/JNCIE-ENT/JNCIE-ENTStudyLab.unl/nodes/'+device+'/start',cookies=cookie,verify=False)
syslog.syslog('lab: getemail.py : starting JNCIE LAB virtual machines')
parsed = json.loads(response.text)
print(json.dumps(parsed, indent=2, sort_keys=True))
print(device)
except:
print("could not start JNCIE lab")
syslog.syslog('lab: getemail.py : EVENG JNCIE LAB COULD NOT START JNCIE LAB EXCEPTION ')
traceback.print_exc()
exit()
print('done')
time.sleep(30)
-
- Posts: 1
- Joined: Sat May 18, 2024 4:35 am
Re: Wish to script starting nodes in staggered fashion
You can use EVE-NG's REST API to perform this task. EVE-NG's REST API allows you to interact with the system and perform actions such as starting or shutting down nodes. Below is an example of how you could slice master write a Python script to start groups of nodes in stages as you described.
First, you need to make sure you have the following information:
EVE-NG URL (e.g. ...)
Username and password for authentication
Laboratory ID
IDs of the nodes you want to launch
Here is an example Python script:
python
import time
import requests
from requests.auth import HTTPBasicAuth
# Configuration
eve_ng_url = '...
username = 'your-username'
password = 'your-password'
lab_id = 'your-lab-id'
nodes_groups = [
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14]
]
wait_time = 300 # Wait time between groups (seconds)
# Function to start the button
def start_node(node_id):
url = f'{eve_ng_url}/lab/{lab_id}/node/{node_id}/start'
response = requests.get(url, auth=HTTPBasicAuth(username, password))
if response.status_code == 200:
print(f'Node {node_id} started successfully.')
else:
print(f'Failed to start node {node_id}: {response.status_code}')
# Function to initialize the button group
def start_nodes_group(nodes):
for node_id in nodes:
start_node(node_id)
# Main program
for group in nodes_groups:
start_nodes_group(group)
print(f'Waiting for {wait_time} seconds before starting the next group...')
time.sleep(wait_time)
print('All nodes have been started.')
Make sure you have the requests library installed if you haven't already:
pip install requests
First, you need to make sure you have the following information:
EVE-NG URL (e.g. ...)
Username and password for authentication
Laboratory ID
IDs of the nodes you want to launch
Here is an example Python script:
python
import time
import requests
from requests.auth import HTTPBasicAuth
# Configuration
eve_ng_url = '...
username = 'your-username'
password = 'your-password'
lab_id = 'your-lab-id'
nodes_groups = [
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14]
]
wait_time = 300 # Wait time between groups (seconds)
# Function to start the button
def start_node(node_id):
url = f'{eve_ng_url}/lab/{lab_id}/node/{node_id}/start'
response = requests.get(url, auth=HTTPBasicAuth(username, password))
if response.status_code == 200:
print(f'Node {node_id} started successfully.')
else:
print(f'Failed to start node {node_id}: {response.status_code}')
# Function to initialize the button group
def start_nodes_group(nodes):
for node_id in nodes:
start_node(node_id)
# Main program
for group in nodes_groups:
start_nodes_group(group)
print(f'Waiting for {wait_time} seconds before starting the next group...')
time.sleep(wait_time)
print('All nodes have been started.')
Make sure you have the requests library installed if you haven't already:
pip install requests
-
- Posts: 4
- Joined: Mon Dec 11, 2023 2:59 am
Re: Wish to script starting nodes in staggered fashion
Uldis, I am really grateful. I was surprised by how easy this is.kiteboy wrote: ↑Thu Mar 31, 2022 1:14 pmLast night I just finished some code to start up my lab before I get up in the morning , its written in Python and runs a separate Ubuntu Box ( raspberry pi ) , reason being this is low power, this then starts up my server by powering it on
I've included just code that logs into eve and starts the lab
here is a code sample slope gamethe reason i mention is this is a way to start lots of nodes if you wanted to add a delay just addCode: Select all
import json import sys DATACENTER=["4","17","44","45","41","25","12","10","11","3","2"] SITE1=["6","14","15","7","27","26","18","13","28","20","5","1","40","39","38"] SITE2=["34","35","37","36","9","8","19","21","31","32","33"] def start_jncie_lab(): syslog.syslog('lab: getemail.py : running start_jncie() ') import urllib3 import requests import pprint urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) try: print('starting JNCIE LAB') syslog.syslog('lab: getemail.py : EVENG JNCIE LAB Via API ') myobj = '{"username":"admin2","password":"eve"}' response = requests.post('https://172.27.233.244/api/auth/login',myobj,verify=False) cookie=response.cookies response = requests.get('http://172.27.233.244/api/status',cookies=cookie,verify=False) parsed = json.loads(response.text) print(json.dumps(parsed, indent=2, sort_keys=True)) for device in DATACENTER : response=requests.get('https://172.27.233.244/api/labs/JNCIE-ENT/JNCIE-ENTStudyLab.unl/nodes/'+device+'/start',cookies=cookie,verify=False) syslog.syslog('lab: getemail.py : starting JNCIE LAB virtual machines') parsed = json.loads(response.text) print(json.dumps(parsed, indent=2, sort_keys=True)) print(device) for device in SITE1 : response=requests.get('https://172.27.233.244/api/labs/JNCIE-ENT/JNCIE-ENTStudyLab.unl/nodes/'+device+'/start',cookies=cookie,verify=False) syslog.syslog('lab: getemail.py : starting JNCIE LAB virtual machines') parsed = json.loads(response.text) print(json.dumps(parsed, indent=2, sort_keys=True)) print(device) for device in SITE2 : response=requests.get('https://172.27.233.244/api/labs/JNCIE-ENT/JNCIE-ENTStudyLab.unl/nodes/'+device+'/start',cookies=cookie,verify=False) syslog.syslog('lab: getemail.py : starting JNCIE LAB virtual machines') parsed = json.loads(response.text) print(json.dumps(parsed, indent=2, sort_keys=True)) print(device) except: print("could not start JNCIE lab") syslog.syslog('lab: getemail.py : EVENG JNCIE LAB COULD NOT START JNCIE LAB EXCEPTION ') traceback.print_exc() exit() print('done')
time.sleep(30)