Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose PD sizes, and support older MegaCli binaries. #40

Merged
merged 2 commits into from
Feb 10, 2015

Conversation

negz
Copy link
Contributor

@negz negz commented Jan 31, 2015

I recently had the need to expose the sizes of the physical disks behind the Dell PERCs in our production machines as facts. We're stuck with a fairly old build of MegaCli due to some other tooling dependencies, so I also hacked around a few of the facts to fall back on the older syntax.

Apologies in advance for my horrible Ruby skills. :)

@jhoblitt
Copy link
Owner

jhoblitt commented Feb 2, 2015

I have no objection to supporting older versions of megacli but I dislike attempting to run multiple versions of each command. How about using the megacli_version fact to select the correct set of options for each fact?

@jhoblitt
Copy link
Owner

jhoblitt commented Feb 2, 2015

Another option would be define multiple resolutions for each fact. Eg., https://docs.puppetlabs.com/facter/2.3/custom_facts.html#fact-precedence

@negz
Copy link
Contributor Author

negz commented Feb 2, 2015

Makes sense - I'll look into the multiple resolution option tomorrow. Thanks!

@jhoblitt
Copy link
Owner

jhoblitt commented Feb 2, 2015

Hopefully it's possible to determine the megacli version and have one set of the resolutions bail out before execing. That would minimize the number of times the megacli binary is actually run, which is desirable in my opinion as it can be fairly slow.

@negz
Copy link
Contributor Author

negz commented Feb 2, 2015

https://docs.puppetlabs.com/facter/2.3/custom_facts.html#confining-facts

So I would guess we can likely do that using Puppet's confine optional. Particularly if it's possible to check greater/less than via confine. What I need to figure out in that case is at what version of megacli did the command syntax change? :)

@negz
Copy link
Contributor Author

negz commented Feb 2, 2015

http://www.lsi.com/downloads/Public/RAID%20Controllers/RAID%20Controllers%20Common%20Files/Linux%20MegaCLI%208.07.10.txt

My best guess it was 8.02.16 based on the following line from the above:

LSIP200100159 (CO) (auto4comp UNIV_VIVA_Cli) CLI version command 

@jhoblitt
Copy link
Owner

jhoblitt commented Feb 3, 2015

It's not well documented but it is possible to pass a block to confine. https://github.com/puppetlabs/facter/blob/master/lib/facter/util/confine.rb#L17-L19

@negz
Copy link
Contributor Author

negz commented Feb 3, 2015

Hah, which was apparently committed by my colleague @dalen. ;)

@jhoblitt
Copy link
Owner

jhoblitt commented Feb 3, 2015

It's hard to use puppet without touching @dalen code. :)

@jhoblitt
Copy link
Owner

jhoblitt commented Feb 3, 2015

Out of curiosity, why are you restricted to an old version of megacli? LSI informed me that they are planning to eventually drop it completely for storcli.

@negz
Copy link
Contributor Author

negz commented Feb 3, 2015

To be quite honest, mostly due to laziness in this instance.

We have a whole bunch of tooling built around megacli 8.00.11. I need to expose PD sizes via Facter to unblock a thing that in turn unblocks the actual thing that I'm supposed to be working on. Adding legacy support to puppet-smartd is the path of least resistance compared to auditing, updating, and testing the rest of our tooling to work with current build.

Nic Cope added 2 commits February 3, 2015 16:25
At around version 8.02.16 some arguments to MegaCli changed. This change
attempts to determine whether MegaCli is modern (8.02.16 or newer) or
legacy (everything else). Facts affected by the changed arguments are
gated using a confine statement.

This change also handles cases where the MegaCli binary is lowercase (megacli).
@negz
Copy link
Contributor Author

negz commented Feb 3, 2015

PTAL

I like this method better, though it does still feel like there's a fair bit of duplication given that a lot of these facts simply run a command, then extract something from the output using a regex. It might be worth factoring all that out into a utility function that takes a command to run and a regex to return on, but I'd like to get this PR merged first if it looks good to you.

@jhoblitt
Copy link
Owner

What I had envisioned was constraining the resolution directly based on the megacli_version but megacli_legacy seems reasonable at this point. I suspect, new resolutions will eventually need to be made with storcli rather than having to deal with a megacli API change.

jhoblitt pushed a commit that referenced this pull request Feb 10, 2015
Expose PD sizes, and support older MegaCli binaries.
@jhoblitt jhoblitt merged commit 5a8d71c into jhoblitt:master Feb 10, 2015
@jhoblitt
Copy link
Owner

@negz This was a huge PR. Thank you for all the effort to get this merged!

@jhoblitt
Copy link
Owner

@negz This PR is included in the v2.4.0 release that was just pushed to the forge. Thanks again!

@negz
Copy link
Contributor Author

negz commented Feb 10, 2015

Awesome, thanks a bunch!

P.S. By way of a feature request, it might be nice to move the megacli facts out into a new package. I for one won't actually be using the smartd stuff - I just want to expose some details about our RAID controllers.

@jhoblitt
Copy link
Owner

I've been planning to eventually to move the megaraid specific facts into this module https://github.com/jhoblitt/puppet-megaraid but it needs a bit of TLC first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants