Monday, December 9, 2013

Extracting Inventory From HP C7000

Problem

I was recently tasked with obtaining an inventory report off our HP C7000 chassis. Warranty renewal time was here and the VAR needed our equipment's serial numbers to generate a quote from HP. Perform a quick Google for this problem and you'll see there is no "easy button". HP does not have an out of the box inventory reporting tool for the C7000.  My solution uses the "show all" command, several regular expressions and the lovely Notepad++ to generate a list of equipment and serial numbers.

Obtain HP Inventory Information

First grab the inventory using the "show all" command.  HP's documentation provides several ways to do this. I chose to grab the "show all" report from the Onboard Administrator WebUI. The report can be 10 - 20,000 lines long so be patient and let the page load completely.  Copy and paste the report into Notepad++.

Mark Equipment Types With Serial Numbers

You can copy and paste reports from multiple chassis into Notepad++. Once you have all your inventory reports run the following Search/Replace. Set your "Search Mode" to "Regular expression".  Find each of the following and replace.

Find what:
^.*(Onboard Administrator [1-2].*)\r\n.*\r\n.*\r\n.*(Serial.*\r\n)
^.*(Interconnect [0-9]).*\r\n.*\r\n.*\r\n.*(Serial.*\r\n)
^.*(Power Supply.*[0-9].*)\r\n.*\r\n.*(Serial.*\r\n)
^.*(Enclosure Type.*)\r\n.*\r\n.*(Serial.*\r\n)
^.*(Blade #[0-9].*)\r\n.*(Serial.*\r\n)
^.*(Fibre Channel.*)\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*(Serial.*\r\n)

Replace with:
INVENTORY,\1,\2

This will find the equipment and add "INVENTORY" to all the lines we want extract.  I used the "Mark" feature to extract the inventory report from the remaining text.  In the Search/Replace window select the "Mark" tab, check "Bookmark line" and set "Search Mode" to "Regular expression". Set "Find what:" to "^INVENTORY".

Extract Marked Text

All of the lines we want are now "Bookmarked". To remove the extraneous text select "Search" -> "Bookmarks" -> "Remove Unmarked Lines". The resulting text should look like this:
INVENTORY Enclosure Type: BladeSystem c7000 Enclosure G2 Serial Number: yourSerialNumber
INVENTORY Onboard Administrator 1 Serial Number: yourSerialNumber
INVENTORY Interconnect 1 Serial Number: yourSerialNumber
INVENTORY Power Supply  1 Serial Number: yourSerialNumber
INVENTORY Blade #1 Information: Serial Number: yourSerialNumber

Lastly, clean up the report so we can send it via email. Run a Search/Replace for "^INVENTORY " and replace with nothing. This is a suitable report that can be sent to a VAR or for inventory purposes.
Enclosure Type: BladeSystem c7000 Enclosure G2 Serial Number: yourSerialNumber
Onboard Administrator 1 Serial Number: yourSerialNumber
Interconnect 1 Serial Number: yourSerialNumber
Power Supply  1 Serial Number: yourSerialNumber
Blade #1 Information: Serial Number: yourSerialNumber

Summary

You can inventory your C7000 in a nicely formatted report suitable for import into a spreadsheet or email even though HP does not have an out of the box solution. The regular expressions could be altered to include model numbers or add commas to make spreadsheet import easier. I even see a potential way to automate this via a shell script on Linux.