Wish to script starting nodes in staggered fashion

Before posting something, READ the changelog, WATCH the videos, howto and provide following:
Your install is: Bare metal, ESXi, what CPU model, RAM, HD, what EVE version you have, output of the uname -a and any other info that might help us faster.

Moderator: mike

Post Reply
nick.williams5
Posts: 4
Joined: Thu Dec 13, 2018 7:45 am

Wish to script starting nodes in staggered fashion

Post by nick.williams5 » Sun Jan 20, 2019 6:23 am

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!

Uldis (UD)
Posts: 5060
Joined: Wed Mar 15, 2017 4:44 pm
Location: London
Contact:

Re: Wish to script starting nodes in staggered fashion

Post by Uldis (UD) » Sun Jan 20, 2019 8:39 am

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
You do not have the required permissions to view the files attached to this post.

nick.williams5
Posts: 4
Joined: Thu Dec 13, 2018 7:45 am

Re: Wish to script starting nodes in staggered fashion

Post by nick.williams5 » Sun Jan 20, 2019 3:50 pm

Thank you much Uldis! This is even easier than what I was thinking.
I did look through the cookbook, but apparently not carefully enough :)

kiteboy
Posts: 42
Joined: Wed Feb 12, 2020 7:43 am
Location: UK
Contact:

Re: Wish to script starting nodes in staggered fashion

Post by kiteboy » Thu Mar 31, 2022 1:14 pm

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

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')

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)

danielusa0106
Posts: 1
Joined: Wed Aug 03, 2022 4:27 am

Re: Wish to script starting nodes in staggered fashion

Post by danielusa0106 » Wed Aug 03, 2022 4:36 am

EVE-NG (Emulated Virtual Environment – Next Generation) is one of the most powerful emulators available today. Inheriting the features of UnetLab, EVE-NG can also emulate a variety of widely used network devices, with many different operating system platforms: Cisco routers/switches (using Cisco IOLs). or IOS on Dynamip Server), Juniper's network equipment, many common firewalls. wordle io games

Post Reply