calebgroom / clb

Command-line tool for Rackspace Cloud Load Balancers
BSD 3-Clause "New" or "Revised" License
30 stars 10 forks source link

Batch processing-friendly output rather than prettytable #2

Closed calebgroom closed 13 years ago

calebgroom commented 13 years ago

All tabular data is sent through prettytable (http://code.google.com/p/prettytable/) today. An alternative output format should be available for easy parsing.

ipauldev commented 13 years ago

Please note: formatting doesn't appear to work here, so replace "--TAB--" with an actual \t tab.

You requested an example sample output. The following is current output, and after that, I've included sample output for what it might look like after.

Current output for list: +-------------------------------------+------+------+----------+-----------+-------+----------------------+ | Name | ID | Port | Protocol | Algorithm | Nodes | IPs | +-------------------------------------+------+------+----------+-----------+-------+----------------------+ | mylb1 | 5001 | 80 | HTTP | RANDOM | 2 | IPV4/10.10.10.1 | | mylb2 | 5002 | 443 | HTTPS | RANDOM | 2 | IPV4/10.10.10.1 | | mylb3 | 5003 | 80 | HTTP | RANDOM | 2 | IPV4/10.10.10.2 | +-------------------------------------+------+------+----------+-----------+-------+----------------------+

Batch-mode output for list: name--TAB--id--TAB--port--TAB--protocol--TAB--algorithm--TAB--nodes--TAB--ips mylb1--TAB--5001--TAB--80--TAB--HTTP--TAB--RANDOM--TAB--2--TAB--IPV4/192.168.1.1 mylb2--TAB--5002--TAB--443--TAB--HTTPS--TAB--RANDOM--TAB--2--TAB--IPV4/192.168.1.1 mylb3--TAB--5003--TAB--80--TAB--HTTP--TAB--RANDOM--TAB--2--TAB--IPV4/192.168.1.2

Current output for show mylb3: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | Name | mylb1 | | ID | 5003 | | Status | BUILD | | Port | 80 | | Protocol | HTTP | | Algorithm | RANDOM | | VIP 1294 | 10.10.10.1 (PUBLIC) | | Node 1 | 192.168.1.1:80 / ENABLED / ONLINE| | Node 2 | 192.168.1.2:80 / ENABLED / ONLINE| | Node 3 | 192.168.1.2:80 / ENABLED / ONLINE| | Session Persistence | None | | Connection Logging | False | | Cluster | ztm-n06.lbaas.ord1.rackspace.net | | Created | 2011-04-11 10:57:31 | | Updated | 2011-04-11 10:57:31 | +---------------------+----------------------------------+

batch mode for show mylb3: name--TAB--id--TAB--status--TAB--port--TAB--protocol--TAB--algorith--TAB--vip--TAB--vip-type--TAB--session-persistence--TAB--connection-logging--TAB--cluster--TAB--created--TAB--updated mylb3--TAB--5003--TAB--BUILD--TAB--80--TAB--HTTP--TAB--RANDOM--TAB--10.10.10.1--TAB--PUBLIC--TAB--None--TAB--False--TAB--ztm-n06.lbaas.ord1.rackspace.net--TAB--2011-04-11 10:57:31--TAB--2011-04-11 10:57:31

node-ip--TAB--port--TAB--enabled--TAB--online 192.168.1.1--TAB--80--TAB--ENABLED--TAB--ONLINE 192.168.1.2--TAB--80--TAB--ENABLED--TAB--ONLINE 192.168.1.3--TAB--80--TAB--ENABLED--TAB--ONLINE

calebgroom commented 13 years ago

Commit coming adds --batch and --delimiter arguments.

Here's the normal output:

$ bin/clb list
+----------------+------+------+----------+-------------+-------+--------------------+
|      Name      |  ID  | Port | Protocol |  Algorithm  | Nodes |        IPs         |
+----------------+------+------+----------+-------------+-------+--------------------+
| lb-with-nodes2 | 1713 | 80   | HTTP     | ROUND_ROBIN | 3     | IPV4/10.183.252.96 |
| lb-node-csv    | 7362 | 80   | HTTP     | RANDOM      | 2     | IPV4/10.183.253.16 |
| publiclb       | 8738 | 21   | HTTP     | ROUND_ROBIN | 2     | IPV4/50.56.4.210   |
+----------------+------+------+----------+-------------+-------+--------------------+

Batch mode with comma-delimited output:

$ bin/clb --batch --delimiter=',' list
Name,ID,Port,Protocol,Algorithm,Nodes,IPs
lb-with-nodes2,1713,80,HTTP,ROUND_ROBIN,3,IPV4/10.183.252.96,
lb-node-csv,7362,80,HTTP,RANDOM,2,IPV4/10.183.253.16,
publiclb,8738,21,HTTP,ROUND_ROBIN,2,IPV4/50.56.4.210,

The way I'm doing the output doesn't support tab as a delimiter. I can fix that soon.