HP ILO execute commands, get output, update ci
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 02:06 AM
Hi all,
My goal is to :
1, Create Discovery Schedule which will connect to HP ILO server,
2, run commands like show/map1/accounts1
3, get output from command, parse and update information on server
Discovery OOB will now fail at beginning when UNIX classify and interactive probe shell, because it could not classify.
I tried to create probes/sensors which are working fine, but how to incorporate his to "whole logic" of Discovery?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 04:05 AM
Hi @Marek Szabo,
According to me, you can discover it via SNMP. So, you need to look to see if port 161 is open on the Input of the Shazzam probe. If it is, then you likely don't have the SNMP community string setup in Credentials....or the device is not configured for SNMP.
Using the HTTP classifier we'd be able to do a GET against the iLo address where It contained a bunch of information about the card, its name, the server it was plugged into ect.. Enough for me to trigger the HTTP classification with a simple contains <some value in the return> match, that triggered the pattern.
Created an iLo table off the Hardware class and in the pattern, We can do another GET to pull in the same return and shoved that into a temp value where through the steps we can parse out the different values that were in the same. Then it got a little tricky.
We need to build a reference to the server so you could see the card record on the iLo class, not too hard we do it a million times a day in Probes and sensors but in this case, I couldn't 'shove' the name of the server into the reference field, don't work that way in patterns. So I built a pre post processing script (pre sensor) that when the name was returned in the pattern it did the glide query to find its sysID and filled the table with that value. Script below...
/* * 1. Pre sensor: You can change payload before it will be proccesed by Identification Engine. * Use IEJsonUtility in order to add relevant information to the payload * Input parameters in Pre sensor mode: payload, patternId * 2. Post sensor: You can update/add missing info to the DB based on result (Json) from * Identification Engine * Output parameters in Post sensor mode: payload * */ var rtrn = {}; //parsing the json string to a json object var payloadObj = JSON.parse(payload); //put your business logic here. var itemsDiscovered = payloadObj.items; var mainCi = null; //Find the main CI from the installed_on value in the payload of the pattern for(var index in itemsDiscovered){ if(Ci.extendsFromTable(itemsDiscovered[index].className,'cmdb_ci_hardware')){ mainCi = itemsDiscovered[index]; break; } } // lookup and match the sysID from main CI record. Set that sysID to the variable 'host' if (mainCi && mainCi.values.installed_on) { //gs.log('===== mainCi.values.installed_on before conversion: ' + mainCi.values.installed_on); var host = ''; var gr = new GlideRecord('cmdb_ci_server'); gr.addQuery('name', mainCi.values.installed_on); gr.query(); if (gr.next()){ host = gr.sys_id; } //now re-defined the value of installed_on to the sysID (String) that matched above, the system will do the rest mainCi.values.installed_on = host.toString(); //gs.log('===== mainCi.values.installed_on converted: ' + mainCi.values.installed_on); } //you can return a message and a status, on top of the input variables that you MUST return. //returning the payload as a Json String is mandatory in case of a pre sensor script, and optional in case of post sensor script. //if you want to terminate the payload processing due to your business logic - you can set isSucess to false. rtrn = {'status':{ 'message':'Enter your message here', 'isSuccess':true }, 'patternId':patternId, 'payload':JSON.stringify(payloadObj) };
Basically, I created a classifier that triggered a return from the HTTP payload.
I created an ilo Class off hardware and added a reference table to cmdb_ci_computer and attributes I wanted to populate, I then created the pattern that just did another get from the same classification and parsed out the variables and attributes.
I then added the above-mentioned pre/post-processing script so I could build the reference through the Identification Engine
Please mark Helpful / Accept Solution so that it helps others with similar questions.
Thanks & Regards
Prahlad Kumar
Tera Expert
LinkedIn - https://www.linkedin.com/in/prahlad-kumar-92a877117/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 05:18 AM
Hi Prahlad,
Thanks,but in my case they are not lot information from /redfish/v1 .I have tied it with "classic" GET through REST and i am not getting information which i need.