Trove-Client-Look-And-Feel
Contents
Description
The purpose of the enhancement is to make the output from the Trove Client (python-troveclient) more closely resemble that of the other OpenStack clients. It is understood that there is a project to unify all the clients into one - https://wiki.openstack.org/wiki/OpenStackClient (OSC) - however until the Trove Client becomes part of it, it makes sense to emulate OSC's look and feel as much as possible. The documentation on OSC doesn't specify the formatting rules for lists, however by looking at the output of several commands some obvious choices become apparent.
ubuntu@ubuntu:/opt/stack$ openstack hypervisor list +----+---------------------+ | ID | Hypervisor Hostname | +----+---------------------+ | 1 | ubuntu | +----+---------------------+ ubuntu@ubuntu:/opt/stack$ openstack image list +--------------------------------------+---------------------------------+ | ID | Name | +--------------------------------------+---------------------------------+ | 7c1ac34d-d168-46d5-a95f-897930c64ba6 | ubuntu_mysql | | d0cd5294-4734-487f-8f8b-4c294b50c17e | cirros-0.3.1-x86_64-uec | | f96b51e4-4016-45aa-9230-17b8db7f0c50 | cirros-0.3.1-x86_64-uec-ramdisk | | e76a031c-1f88-46a7-a335-6bbb9132e8cd | cirros-0.3.1-x86_64-uec-kernel | +--------------------------------------+---------------------------------+ ubuntu@ubuntu:/opt/stack$ openstack flavor list +----+----------------+-------+------+-----------+------+-------+-------------+-----------+-------------+ | ID | Name | RAM | Disk | Ephemeral | Swap | VCPUs | RXTX Factor | Is Public | Extra Specs | +----+----------------+-------+------+-----------+------+-------+-------------+-----------+-------------+ | 1 | m1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True | | | 10 | eph.rd-smaller | 768 | 2 | 2 | | 1 | 1.0 | True | | | 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | | | 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | | | 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | | | 42 | m1.nano | 64 | 0 | 0 | | 1 | 1.0 | True | | | 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | | | 6 | tinier | 506 | 10 | 0 | | 1 | 1.0 | True | | | 7 | m1.rd-tiny | 512 | 2 | 0 | | 1 | 1.0 | True | | | 8 | m1.rd-smaller | 768 | 2 | 0 | | 1 | 1.0 | True | | | 84 | m1.micro | 128 | 0 | 0 | | 1 | 1.0 | True | | | 9 | eph.rd-tiny | 512 | 2 | 1 | | 1 | 1.0 | True | | +----+----------------+-------+------+-----------+------+-------+-------------+-----------+-------------+
Heading labels should be capitalized variable names, with the '_' changed to a space. ID's are capitalized as well. All columns are left-aligned except numeric ones, which are right-aligned. Some names (acronyms) are capitalized as well. Due to 'special allowances,' it should also be possible to over-ride the build-in label generator by passing in a dictionary of labels to use. For example, passing in labels={'ram': 'RAM'} would make the heading 'RAM' instead of 'Ram.'
Thus the output from 'trove flavor-list' would change from:
+----+----------------+-------+ | id | name | ram | +----+----------------+-------+ | 1 | m1.tiny | 512 | | 2 | m1.small | 2048 | | 3 | m1.medium | 4096 | | 4 | m1.large | 8192 | | 5 | m1.xlarge | 16384 | | 6 | tinier | 506 | | 7 | m1.rd-tiny | 512 | | 8 | m1.rd-smaller | 768 | | 9 | eph.rd-tiny | 512 | | 10 | eph.rd-smaller | 768 | | 42 | m1.nano | 64 | | 84 | m1.micro | 128 | +----+----------------+-------+
to:
+----+----------------+-------+ | ID | Name | RAM | +----+----------------+-------+ | 1 | m1.tiny | 512 | | 2 | m1.small | 2048 | | 3 | m1.medium | 4096 | | 4 | m1.large | 8192 | | 5 | m1.xlarge | 16384 | | 6 | tinier | 506 | | 7 | m1.rd-tiny | 512 | | 8 | m1.rd-smaller | 768 | | 9 | eph.rd-tiny | 512 | | 10 | eph.rd-smaller | 768 | | 42 | m1.nano | 64 | | 84 | m1.micro | 128 | +----+----------------+-------+
which corresponds very closely to the 'openstack flavor list' command listed previously. Note that the ID field is right aligned as it is at present a numeric, however this would automatically change once implemented as a UUID (see bug 1226259)
Justification/Benefits
This change should improve the user experience when using Trove with other OpenStack clients. Also there will be less of an impact to users when we eventually move to OSC, although there is a risk that the list format currently used by OSC may change.
Impacts
This change has minimal to no impact on existing code. The underlying code (in PrettyTable) would not need to be touched - the change could be made by simply modifying the arguments sent to it. All calls to this wrapper (troveclient.utils.print_list) should function with the new formatting without any additional refactoring required.
Configuration
No configuration file changes are needed
Database
No database changes are required
Public API
No public APIs require changes
CLI interface
The CLI interface will not change, just the output from the commands
ReST Part
No changes here
Internal API
No changes here
RPC API description
Not Applicable
Guest Agent
Not affected