alx9r / PsOmsa

PowerShell bindings for Dell Open Management Server Administration CLI
Other
1 stars 1 forks source link

Unnecessarily complicated? #10

Open JustinGrote opened 5 years ago

JustinGrote commented 5 years ago

Hey great job on the omreport parsing, but why did you do all the substringing yourself? This works just as well:

.\omreport.exe storage pdisk controller=0 -fmt ssv | select -skip 4 | convertfrom-csv -Delimiter ';'

Just wondering what I'm missing.

alx9r commented 5 years ago

@JustinGrote Thanks. It's been some time since I looked at this. If I recall correctly you are right that this is unnecessarily complicated, at least for today's omreport.exe. I believe the most reasonable way to achieve this is to simply convert the xml representation of the omreport.exe output to the .Net XML object. I expect that would look something like [xml]$xmlStringProducedbyOmreport which would be less to go wrong than what's happening in this module.

I can't remember exactly what I was facing that I ended up down this path, but I'd definitely pursue the XML parsing route rather than parsing of un- or semi-structured strings.

JustinGrote commented 5 years ago

I'm working on it now, sadly it's not easy enough to use the xml as the objects are in tons of different formats (some use attributes, some use

text) , and they use the non-resolved status integers that I can't find a

reliable reference for anywhere.

I'm going the ssv format, with a regex to pull out the relevant sections as the pull is inconsistent too.

On Wed, Jul 17, 2019, 1:36 PM alx9r notifications@github.com wrote:

@JustinGrote https://github.com/JustinGrote Thanks. It's been some time since I looked at this. If I recall correctly you are right that this is unnecessarily complicated, at least for today's omreport.exe. I believe the most reasonable way to achieve this is to simply convert the xml representation of the omreport.exe output to the .Net XML object. I expect that would look something like [xml]$xmlStringProducedbyOmreport which would be less to go wrong than what's happening in this module.

I can't remember exactly what I was facing that I ended up down this path, but I'd definitely pursue the XML parsing route rather than parsing of un- or semi-structured strings.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alx9r/PsOmsa/issues/10?email_source=notifications&email_token=ADUNKUQLJWKAHUMV5HAIHDDP757D7A5CNFSM4IERX622YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2GQLEI#issuecomment-512558481, or mute the thread https://github.com/notifications/unsubscribe-auth/ADUNKUQGPXLF3L2DOZGZCM3P757D7ANCNFSM4IERX62Q .

JustinGrote commented 5 years ago

OK, here's my SSV parser, it has to work around a couple dumb things like:

I only tested against storage queries (since most other OMReport info I can get from CIM, and against a system with multiple of all items. Feel free to swipe it.

Storage Commands Tested:

storage vdisk
storage battery
storage enclosure
storage controller
storage connector controller=0
storage connector controller=1
storage connector controller=2
storage connector controller=3
storage pdisk controller=0
storage pdisk controller=1
storage pdisk controller=2
storage pdisk controller=3

https://gist.github.com/JustinGrote/a1c71a0c0f4d30d69dccbedc29329521

EDIT: I revised it to match on SSV blocks rather than try to split on the super inconsistent headers. So far is much more reliable for the output.