62 Commits

Author SHA1 Message Date
Justin Grudzien
c75b11d13a CLOUDSTACK-1875: add JSON output to cloudmonkey
Added
1. display = [default|json|tabularize] has been added in the config to replace tabularize = [true|false]
2. tabularize is deprecated but we will still set it as "false" once the user removes it out of their config to avoid throwing an error. This will be removed in the next major version.
3. display = "default" is added to the [ui] section of the config if it is not present.
4. You can now output JSON formatted text by setting the config display = json
5. You can now filter text in JSON output mode. (i.e. list users account=grudzien filter=account,id,email). Filtered output returns a properly formatted JSON document.

Removed
1. Removed the printing of attr keys in read_config().

Deprecated
1. tabularize = [true|false] is now messaged as deprecated.

Signed-off-by: Justin Grudzien <grudzien@gmail.com>
2013-04-05 22:48:15 +05:30
Rohit Yadav
0d62549d61 cli: Run onecmd if any arg is passed
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-03-20 13:14:09 +05:30
Rohit Yadav
4ad5d1a4f5 cli: Fix nonetype issue with cachemaker and exit after printing version
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-03-20 12:42:29 +05:30
Rohit Yadav
0b7a4e04aa cli: Check args from optparser and not sys.argv
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-03-19 18:04:52 +05:30
Rohit Yadav
19a290500e cli: Import project info from config in setup.py, fix debug msgs
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>

lsdfjk

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-03-19 16:05:11 +05:30
Rohit Yadav
4421f2bb60 CLOUDSTACK-1708: Let cloudmonkey accept cfg passed in cmd line
The patch adds feature in cloudmonkey to have multiple profiles by passing
custom cfg file to set custom profile in both interactive shell and cmd line tool
use cases.

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-03-19 16:05:11 +05:30
Rohit Yadav
cc9b7d4c20 cloudmonkey: print sync stats, asks users to use sync
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-03-06 17:21:32 +05:30
Rohit Yadav
1fd0563137 CLOUDSTACK-1037: Implement fuzzy parameter completion
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-02-07 16:01:05 +05:30
Rohit Yadav
d99f836d5d cli: Fix attribute error and fix helpdoc
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-02-06 16:54:46 +05:30
Rohit Yadav
a2e89c4200 cli: Use metaprogramming to generate code during runtime when new apis sync
- Fixes metaprogramming to inject methods during shell class object's runtime
- This enable new apis that are synced to come up with new verbs, docs etc.
- Fixes printing issue
- Fixes null bitfield parsing issue

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-02-04 17:57:08 +05:30
Rohit Yadav
b5a2e99809 CLOUDSTACK-1037: Fix cloudmonkey's caching, autocompletion and printing
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-02-02 08:39:45 -08:00
Rohit Yadav
631b6fd46a CLOUDSTACK-1037: Make cloudmonkey awesome-er
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-02-01 14:34:49 -08:00
Rohit Yadav
cb8705c756 cli: Pygments based output in cloudmonkey and new cfg processing
- Pygments based colored output for tabular and normal list outputs
- Fix cfg processing as per new cfg paths and ds
- Get rid of clint and old way of parsing and color printing

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-28 17:59:37 -08:00
Rohit Yadav
59d01bfe20 cli: Show filter only when a subject is specified in autocompletion
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
(cherry picked from commit 7ea83b82e63bc40c5fa38f7aae2032690aa7883c)

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-28 16:31:12 -08:00
Rohit Yadav
6c527ffbba cli: Fix cachegen aand cloudmonkey to generate api verbs, revert last commit
Fixes cachegen and reverts "mvn: fix cloudmonkey build"

This reverts commit 6d3de41d4262abeedab234a08e8fb5714b69a9bf.
2013-01-27 04:18:31 -08:00
Rohit Yadav
ddb794d960 cli: generate verbs on the fly, fix autocompletion whitespace bug
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-26 17:14:09 -08:00
Rohit Yadav
6f90a86b13 cli: fix cloudmonkey's pipe-ability
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-24 14:47:45 -08:00
Rohit Yadav
71257d6bb4 cli: give filter option only when output 'tabularized' is enabled
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-24 11:28:49 -08:00
Rohit Yadav
3c335bd883 cli: Fix asyncblock to search for correct key instead of hardcoded index
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-23 14:57:41 -08:00
Rohit Yadav
c13f0199f4 cli: Cosmetic fix for prompt of cloudmonkey
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-06 17:30:00 -08:00
Rohit Yadav
f1c15f0c2e cli: Remove unused method, fix welcome msg, prompt
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-05 02:11:45 -08:00
Rohit Yadav
c7563cb7bd cli: Show progress during polling for async jobs
If asyncblock is set to true, prints dots as polling requests are made.
When result is obtained, dots are wiped and result is printed.

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-04 15:17:06 -08:00
Rohit Yadav
9a66beb658 CLOUDSTACK-717: Fix response json handling in cloudmonkey
- Fixes response handling
- Sorts alphabetically, count and id are on top if available
- Fix colors

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-01-04 15:17:06 -08:00
Rohit Yadav
503a5f2ccd cli: Get rid of deprecated sets, go functional, use filter()
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-12-21 11:21:22 -08:00
Rohit Yadav
13944a0e5e cli: Cosmetic fixes for cloudmonkey and setup.py dependency version fix
- Fixes shell class name to CloudMonkey
- Fixes prettyprint version req. to 0.6

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-12-20 16:34:36 -08:00
Rohit Yadav
8f51c630bd CLOUDSTACK-545: Tabularize cloudmonkey's response using filter=<fields,> argument
- Adds new cloudmonkey config field, tabularize
- If tabularize is set to true, all the list of dict in response are printed as
  table
- The columns of the tables can be filtered using the filter= argument, for ex:
  list domains listall=true filter=id,name,path
- filter arg will take comma separated values, if they have space put them under
  quotes
- Empty filter argument will cause it to print the whole table
- Multiple fields with the same name will cause it to print the column again
- In case there is a typo in the field, that column is skipped. It takes an
  intersection of response dict keys and filter keys provided
- Uses opensource prettytable library to pretty print tabular data

TODOs:
- Handle recursive table printing for nested list of dicts
- Colorize table columns if community wants such a feature

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-12-20 16:33:08 -08:00
Rohit Yadav
0f2a0950b6 cli: extract apicmd response using the apiname+response key
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-12-16 22:10:54 -08:00
Rohit Yadav
1551b982c4 cli: Handle command breaks, ctrl+c, don't break the shell
- Fix handles shell loop
- Handles any control breaks without breaking the shell
- Handles ctrl+c to start afresh on the shell

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-12-12 15:21:03 -08:00
Rohit Yadav
3e8655b580 cli: Handle badline http error
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-21 18:27:11 +05:30
Rohit Yadav
3b2e715888 cli: string fixes, use the major,minor version numbers same as CloudStack
<cloudstack major>.<cloudstack minor>.<cloudmonkey increment number>

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-20 14:56:34 +05:30
Rohit Yadav
5a2e15f67c CLOUDSTACK-522: Log requests in cloudmonkey's log
Patch fixes cloudmonkey to log requests in the log_file.
Summary:
  - Fixes logger
  - Fixes color print issue
  - Fixes welcome message
  - Makes code pep8 compliant

BUG-ID : CLOUDSTACK-522
Reviewed-by: Rohit Yadav <bhaisaab@apache.org>
Reported-by: Rohit Yadav

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-20 12:20:23 +05:30
Chip Childers
f7d2041056 Added exit as a cloudmonkey command, in addition to the existing quit command.
Signed-off-by: Chip Childers <chip.childers@gmail.com>
2012-11-19 14:39:58 -05:00
Chip Childers
311ef69a77 CLOUDSTACK-514: Added protocol and path support to cloudmonkey.
This is the second half of making cloudmonkey and marvin more
flexible in environments that may have https enabled and / or
a different path for the cloudstack API.

Signed-off-by: Chip Childers <chip.childers@gmail.com>
2012-11-19 14:24:10 -05:00
Rohit Yadav
dc3c263d0f cli: move common code to common module
- Move config, grammar to common
- Cleanup cloudmonkey.py, import from common
- Import precached verbs, if fails init to {}

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-19 05:28:23 +05:30
Rohit Yadav
bbb2a56acb cli: refactoring, new grammar rules and command fixes
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-17 17:38:18 +05:30
Rohit Yadav
7ce53e89aa cli: make parse in posix mode
Posix mode allows the parse to:
- split by whitespace but value="between quotes are retained or enclose"
- quotes are stripped out

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-17 04:07:35 +05:30
Rohit Yadav
aa3ae45e6b CLOUDSTACK-499: Fix cloudmonkey's request and response methods
The old way of parsing involved complex object loading and traversing, in
new implementation json is used directly and authenticated requests via port
8080 making use of api and secret keys are recommended.

All args on shell are created in {"key": "value"} pairs which are used to create
url with &key=value. This way maps can be passed as args, example:

create networkoffering name=unique-name guestiptype=Isolated traffictype=GUEST
supportedservices=Dhcp,Dns serviceproviderlist[0].service=Dhcp
serviceproviderlist[0].provider=VirtualRouter serviceproviderlist[1].service=Dns
serviceproviderlist[1].provider=VirtualRouter

Added new conf variables:
- timeout: the no. of seconds after which an async job query timeouts
  default value of 3600 seconds
- asycnblock: if user wants their async commands to be tracked
  default value is 'true', if set to false, user can query using jobid which is
  returned by the async command and queried using:
     query asyncjobresult jobid=<jobid>

BUG-ID : CLOUDSTACK-499
Reviewed-by: Rohit Yadav <bhaisaab@apache.org>
Reported-by: Dave Cahill

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-16 22:18:32 +05:30
Rohit Yadav
08d16cf4d1 cli: Handle HTTP and URL errors
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-15 18:43:51 +05:30
Rohit Yadav
7ae8c4ad7e cli: Split using only space
Patch fixes lexical parser for default argument on shell.

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-15 18:43:51 +05:30
Rohit Yadav
c667eee570 cli: make commands pipe-able as on bash, on the shell
Makes commands pipe-able like bash.
Example while inside shell:
  > list virtualmachines | grep id
  > list accounts | more

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-08 12:35:20 +05:30
Rohit Yadav
8e64f34012 cli: autocomplete to assignment, adds syntactic sugar
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-07 18:34:23 +05:30
Rohit Yadav
a5ad9c3c50 cli: fix keyerror in help doc handler
- Check and then print help docs
- Add verb configure

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-07 16:05:01 +05:30
Rohit Yadav
36e7a7884e cli: fix autocompletion binding bug, make all params lowercase
- fix weird autocompletion bug which won't let you enter the letter b [0]
- make set params, api and secret key vars lowercase
- use partition to get strings for do_set
- while installing, check and only then add readline (requires gcc and can fail)
- show monkey prompt by default, let users change if needed

[0] http://superuser.com/questions/297527/cant-type-the-b-letter-in-python-shell-in-os-x

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 19:41:07 +05:30
Rohit Yadav
ac8ae30658 cli: fix argument parsing for set command, fixes unicode monkey char
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 17:59:53 +05:30
Rohit Yadav
77e957c91b cli: fix python sdist, add readline as installation requirement
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 17:06:11 +05:30
Rohit Yadav
a94f6f19bb cli: make parsing robust using shlex
Parsing bug fixed using the simple lexical analysis library

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 15:19:08 +05:30
Rohit Yadav
5c24c34d7f cli: use partition instead of split to parse through args
Use partition instead of splitting on whitespace. This is little robust, but
may still fail for parameters whose values have whitespaces such as names etc.

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 14:54:35 +05:30
Rohit Yadav
9e6b366023 cli: add autocompletion and dynamic help doc
- autocompletions for help docs
- more verbose doc strings with __doc__ import from the module and list of
  required args and all args

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 14:28:40 +05:30
Rohit Yadav
a1089c4304 cli: move code, refactor and add docstring
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 14:28:40 +05:30
Rohit Yadav
d0f9610355 cli: add feature to cache docstrings for an api
cached verb dictionary stores the following as a list:
- name of the API
- params (list of args)
- docstring

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-11-06 14:28:39 +05:30