question

dxia avatar image
dxia asked amichaels commented

Is there an REST API to perform auto discovery of Layer 1 Switch in iLO

I tried to use iLO restful API to create resources. It's OK to create an Layer 1 switch, however I cannot find the API to perform auto discover, which is available from the WebGUI. I tried to send the following POST request using iTest REST session, however the server's response indicates invalid login and just redirect me to the login page. Did I miss anything here? The REST request I sent to the server is like: POST /ilo/inventory/resource.discoverybutton/${deviceId}?t:ac=${deviceId} Where the deviceId is acquired when I create the device The post body is t%3Azoneid=discoveryStartedZone Authentication method is "Secure" with username and password, but w/o any configured certification, and ticked the box to accept any SSL certification. This setup works with other REST API which I used to create the folder and the device.
apiiTest Lab Optimizer (iLO)rest
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
rmustakov avatar image
rmustakov answered amichaels commented

As of Velocity 5.0, there is no public API to request resource discovery. This API will be added in future versions.

It is possible to automate discovery in a fashion similar to your approach - by making request to the endpoint used by Web UI. However, it is a fragile approach, as it basically means relying on implementation details which may (and will) change in the future.

Below are details on how to accomplish that. I will use `curl` in examples, but they can easily be mapped into iTest actions. Replace `velocity.example.com` as needed.

1. Log in and obtain `JSESSIONID` and `user_token`.

curl 'https://velocity.example.com/velocity/login.loginform' -H 'X-Requested-With: XMLHttpRequest' --data 'username=my_username&password=my_password&t%3Aformdata=RKIANTvJ3Ugm2L20c%2B7jeEPcZB0%3D%3AH4sIAAAAAAAAAJWQMUvDUBCAr0WlGJDa4uTiUNd0sYsudhGHoELQwe0luaRPkvee7y5NXFz9F%2F4CcXbv4OZ%2F8Ae4OjmYNBSHiOB08HHH93FPH7BeDGHb04lUh0KFM23nIs2RLBxrm7jCiHCGLguDxPZu4obaYiqDamZGK1RM7qmMIlSjC6tDJPLzIJNEUqvrh71hufuy0YWOB06oFVudnokMGQbejZiLcSpUMvbZSpUclYbBaQqu6oKiD1tNVk5oVXVWNU3%2BbAoEoTsNKihCPpGYRiMfOTf7lwvnfef1qxVyC%2FfQqcW9leNX6%2FS%2F1tYrFs%2FRQfz5%2BNYFKM2PwwiiQtuI6pC1KmMF2iv1Rq8YQL%2FBLDPUcUzIy1tg2KzR%2BRJ9A%2BMzFhzWAQAA&t%3Azoneid=loginZone&timeOffset=0'

Change `my_username` and `my_password` to actual username/password. Store `JSESSIONID` and `user_token` cookies, returned within `Set-Cookie` headers into variables. I will refer to them as ${sessionId} and ${token} in the next step.

2. Request resource discovery. Parameters here are: ${resourceId}, ${sessionId}, ${token}

curl 'https://velocity.example.com/velocity/inventory/resource.discoverybutton/${resourceId}?t:ac=${resourceId}' -H 'Cookie: JSESSIONID=${sessionId}; user_token=${token}' -H 'X-Requested-With: XMLHttpRequest' --data 't%3Azoneid=discoveryStartedZone'
1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

amichaels avatar image amichaels ♦ commented ·

The above steps could be executed via iTest using the REST session. Very cool. Thanks for the suggestion, and yes, this should only be a stop-gap solution as it is not via the documented API.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.