ReST API creating nodes and interfaces
Posted: Tue Jul 04, 2017 1:41 pm
Hello all,
I am interested in utilizing the ReST API to generate topologies via a python script. I am at this point able to create the folders, lab, and nodes but I am unable to understand how to connect two nodes. What is the best way to find help for this topic?
Here is what I have learned so far, I have created a user called api with the password eve for these examples. This allows me to be logged into the Web interface with the admin account and see my progress.
# Login and store a cookie, next requests will use the cookie stored for authentication.
curl -c cookie -b cookie -X POST -H "Content-type: application/json" -d '{"username":"api","password":"eve"}' http://172.16.5.131/api/auth/login
# List Folders
curl -b cookie -X GET http://172.16.5.131/api/folders/
# Create a lab
curl -X POST -H "Content-type: application/json" -b cookie http://172.16.5.131/api/labs -d '
{
"path":"/HomeLab",
"name":"Security",
"version":"1",
"author":"Mike",
"description":"Security Lab",
"lock":"0"
}
'
#Create a node
curl -X POST -H "Content-type: application/json" -b cookie http://172.16.5.131/api/labs/HomeLab/Security.unl/nodes -d '
{
"type":"iol",
"template":"iol",
"image":"L3-ADVENTERPRISEK9-M-15.4-2T.bin",
"name":"R1",
"icon":"Router.png",
"nvram":"1024",
"ram":"256",
"ethernet":"1",
"serial":"0",
"delay":"0",
"config":"0",
"left":"300",
"top":"200"
}
'
# Create a second node
curl -X POST -H "Content-type: application/json" -b cookie http://172.16.5.131/api/labs/HomeLab/Security.unl/nodes -d '
{
"type":"iol",
"template":"iol",
"image":"L3-ADVENTERPRISEK9-M-15.4-2T.bin",
"name":"R2",
"icon":"Router.png",
"nvram":"1024",
"ram":"256",
"ethernet":"1",
"serial":"0",
"delay":"0",
"config":"0",
"left":"350",
"top":"200"
}
'
Thanks to http://www.802101.com/unetlab-rest-api/ for getting me this far.
Any help with connecting two nodes via the API would be greatly appreciated.
Thanks all,
Mike
I am interested in utilizing the ReST API to generate topologies via a python script. I am at this point able to create the folders, lab, and nodes but I am unable to understand how to connect two nodes. What is the best way to find help for this topic?
Here is what I have learned so far, I have created a user called api with the password eve for these examples. This allows me to be logged into the Web interface with the admin account and see my progress.
# Login and store a cookie, next requests will use the cookie stored for authentication.
curl -c cookie -b cookie -X POST -H "Content-type: application/json" -d '{"username":"api","password":"eve"}' http://172.16.5.131/api/auth/login
# List Folders
curl -b cookie -X GET http://172.16.5.131/api/folders/
# Create a lab
curl -X POST -H "Content-type: application/json" -b cookie http://172.16.5.131/api/labs -d '
{
"path":"/HomeLab",
"name":"Security",
"version":"1",
"author":"Mike",
"description":"Security Lab",
"lock":"0"
}
'
#Create a node
curl -X POST -H "Content-type: application/json" -b cookie http://172.16.5.131/api/labs/HomeLab/Security.unl/nodes -d '
{
"type":"iol",
"template":"iol",
"image":"L3-ADVENTERPRISEK9-M-15.4-2T.bin",
"name":"R1",
"icon":"Router.png",
"nvram":"1024",
"ram":"256",
"ethernet":"1",
"serial":"0",
"delay":"0",
"config":"0",
"left":"300",
"top":"200"
}
'
# Create a second node
curl -X POST -H "Content-type: application/json" -b cookie http://172.16.5.131/api/labs/HomeLab/Security.unl/nodes -d '
{
"type":"iol",
"template":"iol",
"image":"L3-ADVENTERPRISEK9-M-15.4-2T.bin",
"name":"R2",
"icon":"Router.png",
"nvram":"1024",
"ram":"256",
"ethernet":"1",
"serial":"0",
"delay":"0",
"config":"0",
"left":"350",
"top":"200"
}
'
Thanks to http://www.802101.com/unetlab-rest-api/ for getting me this far.
Any help with connecting two nodes via the API would be greatly appreciated.
Thanks all,
Mike