PowerShell: Automate SUN ILOM configuration

I’m currently winding down on a datacenter build that has consumed me for the better part of six months.  Last night our team went through and stood up vSphere on 200+ hosts. I know that’s nothing for you cloud providers, but that’s a lot of servers for the average IT shop.   Being a lights out datacenter we have 3 management paths to every server IP-KVM, ILOM, and serial ports.  Going through and setting all that up would have been a pain in the but, so I did a little searching and found how to configure the SUN ILOM via the serial port.  With that document and little experimentation I quickly had my script, now all that was left was to learn how to script via a COM port.  I turned to BING and found this article which pointed me to a new-to-me .Net Class…  about 4hrs later I had a complete solution, and yet another example of the Admin Development Model.

First I created a CSV that contained all the hosts to be loaded thereby making it easy for anyone to modify the parameters.

Once I had my input I wrote a simple PowerShell one liner to ingest the data, and extract the location of the server.  I could have done this in the csv, but that was being generated by our CMDB, so I chose to do this in script instead.

Then I turned my attention to the actual configuration itself. I found that I could just push the commands through via brute force, but didn’t like this solution because it lacked any feedback.  It turned out that It was actually harder to get the output then it was to push the commands. Mainly because the Service Processor on a SUN is ridiculously slow I had to insert insane sleeps into my script to actually capture the output.

I considered writing a control loop to handle the whole process, but then remembered my golden rule of scripting… don’t automate more then you have to.  In other words I had what I needed, and needed to move on.  I wanted to re-factor the whole thing and create something more elegent, but when performing administrative scripting don’t get caught up in all that.  We’re not developers we need solutions, and we need them quickly.  This script will be used once and then thrown away it simply wasn’t worth my time to optimize it… no matter how bad I wanted too.

Anyways now that I had all the components it was time to trow it all together.  At this point I turned my attention to the user interface.  I would have prefer a simple function, but the team has members that aren’t scripters, and there was talk of bringing in some extra hands to help.  Therefor I chose to put it in a simple GUI to remove any hesitation.   Currently my favorite tool for task like this one is PrimalForms it’s just fantastic at whipping up simple winforms in no time at all.

So after a little debugging I finished my little utility.  All in all, not only did we successfully configure all the ILOM’s in one night, but I fun doing it.

Leave a Reply