seveas / python-hpilo

Accessing the HP iLO XML interface from python
https://seveas.github.io/python-hpilo
Other
320 stars 101 forks source link

Allow "*_priv" vars in mod_dir_config to be single digit #225

Closed bb-Ricardo closed 1 year ago

bb-Ricardo commented 4 years ago

Currently the privileges in mod_dir_config need to be comma separated to be accepted. This will not work for single privileges like "1" or "6".

This commit fixes this.

bb-Ricardo commented 3 years ago

Any reason this why this hasn't been merged? The other two PR got merged except this one.

Thank you

seveas commented 3 years ago

Must have missed it, sorry!

seveas commented 3 years ago

Finally getting around to looking at this properly, and I think it's all wrong and the old code works just fine

If you pass "1", the split turns it into ["1"], and the join turns it back into "1", so it does what it needs to do. Can you tell me what you're actually passing as argument, and how what the old code does is wrong? Maybe then I'll understand better what you're trying to achieve.

bb-Ricardo commented 3 years ago

Hi, what I do: Get the data from ILO as json, manipulate one attribute and sending the whole json back.

This didn't work. With this change it fixed it.

seveas commented 3 years ago

What was the value you changed it to?

bb-Ricardo commented 3 years ago

Just "6" as single privilege. And it's not an list so it cant iterate over it. Und just "6" should be valid.

seveas commented 3 years ago

It should be, and is valid. The old code will turn that "6" into ["6"] in the split, and then that ["6"] back into a "6" in the join. Can you run the old code in debug mode (setting the debug attribute of the ilo isntance, or passing --debug to hpilo_cli) and share the output. I have a sneaky suspicion it's not your "6" that's the problem, but something else returned by the iLO. I'd also like to see which error you're getting.

bb-Ricardo commented 3 years ago

Will be able to do that next week. Can only test it at work.

seveas commented 3 years ago

I figured out what the actual issue is: the xml parser magic turns the privileges you get from the ilo into integers and not single-digit strings. So when you feed those back in, those are the ones that are not iterable (strings are iterable just fine). 728c085 fixes it.

bb-Ricardo commented 3 years ago

Yes, this sounds like the issue I had. Was so long ago that I had trouble remembering what the actual problem was.

Thanks for fixing it.