Hey Justin, thanks for posting this on community ML.
On Sat, Mar 30, 2013 at 9:20 AM, Justin Grudzien <[email protected]> wrote:
> My company is building a private cloud and we are moving to cloudstack. As
> we begun investigating the cloudmonkey CLI we found that the output was
> slightly hard to read. I have begun working on some optimizations that I
> think will benefit the community and I reached out to Rohit, who
> recommended that I join this list and present my ideas. Here is what I am
> proposing:
>
> 1. Add json output to cloudmonkey
> I have accomplished this by adding a config parameter called display, which
> can be set to json, tabularize, or default. I have removed the tabularize
> parameter.
>
+1
>
> Justins-MacBook-Pro:cloudmonkey grudzien$ cloudmonkey list users
> account=grudzien
> {
> "count": 1,
> "user": [
> {
> "account": "grudzien",
> "accountid": "b799783d-e5bb-460a-be0e-3966bd69edda",
> "accounttype": 1,
> "apikey": "*nokey*",
> "created": "2013-03-27T16:09:17-0500",
> "domain": "ROOT",
> "domainid": "7e61c32f-9873-4944-947a-dcc00d3bebdc",
> "email": "[email protected]",
> "firstname": "Justin",
> "id": "265930bc-62ef-41f8-849c-e58593ca4b1f",
> "lastname": "Grudzien",
> "secretkey": "*nokey*",
> "state": "enabled",
> "username": "grudzien"
> }
> ]
> }
>
> 2. Add filtering as a standard parameter for all output types.
> The only thing that has filtering now is the tabular output and grep breaks
> the json.
>
> Justins-MacBook-Pro:cloudmonkey grudzien$ cloudmonkey list users
> account=grudzien filter=account,email,username,state
> {
> "count": 1,
> "user": [
> {
> "account": "grudzien",
> "email": "[email protected]",
> "state": "enabled",
> "username": "grudzien"
> }
> ]
> }
>
Awesome.
>
> 3. Add color to the json output
> I was thinking of colorizing the keys in the key/value pairs to increase
> readability.
>
This is easily doable, all we have to do is define a regex rule in
printer.py for the regex type "txt": as key and ": xxx, as value.
> 4. Move the color option from the config file to the command line.
> There are two reasons for this. First, I want to be able to wrap a script
> around cloudmonkey and not have to worry about colorization that will
> impede me processing the output and second I think it would be more useful
> to use the highlighting on demand rather than having to back out of the
> shell to edit a config file.
>
I did not understand this one. What exactly are you proposing? You can
always set color to false or true. Are you talking about color themes?
> 5. Standardize messaging for the output types.
> Right now certain kinds of messaging is presented differently for an output
> type. For example, if I issue an api command that doesn't exist it displays
> a generic error message, regardless of the output type selected. Ideally,
> all output would be in the specified format.
>
Oh man, that would be just great! Pl. share your patch.
>
> I have the first two working and am planning on implementing the others as
> I flesh them out. I will submit a patch when I feel it is ready. Any early
> feedback on whether these changes will be useful to others is appreciated.
>
You can submit patches as you finish them, don't wait till all of 5 things
are done. I can help review them and merge them.
Thanks for your proposal and sharing them.
Cheers.
> Justin
>