Page 1 of 1

API issue: missing port in telnet console url

Posted: Mon Jan 03, 2022 3:53 pm
by kiwibear62
In the docs, if you call

curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes

You get info about all the nodes in the lab. Like this...

"data": {
"1": {
"console": "telnet",
"cpu": 1,
"delay": 0,
"ethernet": 4,
"icon": "Router.png",
"id": 1,
"image": "vios-adventerprisek9-m-15.4-1.3.0.181",
"left": 358,
"name": "R1",
"ram": 512,
"status": 0,
"template": "vios",
"top": 330,
"type": "qemu",
"url": "telnet://127.0.0.1:32769",
"uuid": "ab60e9de-2599-4b67-919a-b769fb6e270d"
},

Note the url for the console. You can telnet to port 32769. I am trying to do the same on my lab EVE-NG, I get the following...

"2": {
"config": "0",
"config_list": [],
"console": "telnet",
"cpu": 4,
"cpu_usage": "0",
"delay": 0,
"ethernet": 8,
"firstmac": "50:01:00:02:00:00",
"icon": "128Ticon-new.png",
"id": 2,
"image": "128T-517",
"left": 333,
"name": "Seattle",
"ram": 8192,
"ram_usage": "0",
"sat": 0,
"status": 0,
"template": "128T",
"top": 249,
"type": "qemu",
"url": "telnet://10.192.16.254:0",
"uuid": "faec3668-d0f3-4859-95fe-699ece75c62b"
},

Note how the port is '0'. This looks to me like a bug in the API code. I am running 4.0.1-65 Pro.

Any suggestions? Thanks!

Re: API issue: missing port in telnet console url

Posted: Tue Jan 04, 2022 8:18 pm
by kiwibear62
If the node is shut down, then it returns 0. If it is running, then the correct value is returned.

Re: API issue: missing port in telnet console url

Posted: Sat Jan 29, 2022 8:06 pm
by kiwibear62
Hi,
I am back working on this script. I have one lab, where the telnet port is returned, but in a different lab, on the same eve-ng server, the return is zero. I noticed that the ones that work, the status is '2', while the ones that don't have 'status':0.

I can't find details of what exactly status means in this call...

labs = s.get("https://10.192.16.254/api/labs/Test.unl/nodes/status", cookies=cookies, data=data, verify=False)

{
"code": 200,
"status": "success",
"message": "Successfully listed nodes (60026).",
"data": {
"1": {
"id": 1,
"labId": null,
"qemu": 1,
"status": 0,
"url": "telnet://10.192.16.254:0",
"cpu": 4,
"cpu_usage": "0",
"ram": 8192,
"ram_usage": "0"
},

Any suggestions?