Showing posts with label storage. Show all posts
Showing posts with label storage. Show all posts

Wednesday, August 25, 2010

The Kind of Hacks That Make You Feel Like You've Got a Furball

Ok, so, I had to dig through the script-fu memory banks to try to help a storage guy build a parameterized script to control the creation of metaluns on a CLARiiON array.
Now, the guy I'm working with is very much a "Windows guy". His way of doing things has been the "click-click-click-click-click" way. For better or worse, when you need to do tasks in a large-scale environment, all that clicking becomes very tedious. Being a Windows guy, his first impulse was to try scripting on Windows (*facepalm*). Needless to say, that proved an odious task. So, he asked if I could help him.
A lot of my scripting-fu relies on "finger memory". Basically, if I have an end state in mind, my hands just sort of vomit forth the code needed to reach that end state. Walking someone through that process can be rather painful, especially when you're as big into regex as I am and they have no clue. That, and having to simultaneously tutor on vi during the process just raises the aggro-stakes.
At any rate, the operation he needed to do required creating a script that used six variables to do the work. The first run through the script, we simply hard-coded the variables so we could vet the overall logic flow. Obviously, hard-coding a dynamic task is sub-optimal. So, we then went through the process or converting the hard-coded variables to ones that were set via passing parameters to the script at the command line.
Guy I'm working with is decently clued, so he didn't want a completely "blind" script (one with absolutely no validity checking). He wanted for the script to, at the very least, ensure that the user passed the requisite number of arguments. Should the script user fail to do so, they'ed get a usage statement. So, what was the most effective way to determine whether the number of arguments passed matched the number of arguments that the script needed in order to do it's job?
After mulling it over, I came up with the following bit of ugliness:
#!/bin/ksh

NUMVARS=0
for i in "$@"
do
   echo "Args for $0 is $i"
   NUMVARS=$(($NUMVARS + 1))
done

echo $NUMVARS

if [ ${NUMVARS} -lt 6 ]
then
   echo "Insufficient arguments"
fi
It's not exactly "ideal", but it's a start. How suitable it will end up being in the context of the final script is yet to be seen.
If you've got ideas on a more elegant approach within a /bin/sh-type construct, I'd love to hear it. Probably going to have to shred that, any way, when we add in the other bounds-checking.

Thursday, August 12, 2010

Small Steps (HPSE)

Finally starting to see a bit of success with HPSE. Not horrendously surprising that prior success had been limited, as the other testing environment had been rather broken. Today: finally sorted out how to get our CLARiiONs "seen" by HPSE. 

Dug through the logs and noticed an rpm invocation failure, at some point. As all of the agents are written in java and didn't have the decompilers necessary to see the source code, tried some things to force debug output. Not really much luck. However, in talking to the vendor, discovered that when their matrix says "supports versions X and Y" they mean it only supports those versions. The rpm failures may have been spurious, but, they may also have been indicating that the HPSE softare is ridiculously hard-coded about which packages it's looking for (woulda made Rain Man proud).

Oh well, at least at this point, we're seeing storage.