Support bash-completion for non-UUID IDs

Bug #1332270 reported by Rick Harris
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Undecided
Unassigned

Bug Description

Python-Novaclient currently support bash-completion against UUIDs and human-friendly IDs.

Some resources, like Flavors, may have non-UUID ID's though, like `performance-123` or `gpu-1gb`.

It'd be nice if we could tab-complete against these as well.

Two modifications need to be made to achieve this:

1. We need to modify Oslo's apiclient/base:Resource such that it will write non-UUIDs to the cache (remove the existing guard). While we're at it, we should change the cache name from `uuid` to `id` since it's no longer just UUIDs.

2. We need to refactor the Python-client bash-completion code to not care what cache-type it's writing to. Currently it hard-codes in `uuid` and `human_id` [1] but there's no technical reason it has to. For flexibility, the code should be made `cache_type` agnostic, so if we come along and want to write to a `extra-fancy-id` cache, we could.

[1] It does this by requiring the completion-cache context-managers to specify the `cache_type`:

with completion_cache('uuid', Flavor, 'a'):
    with completion_cache('human_id, Flavor, 'a'):
        write_to_completion_cache('human_id', 'some-human-id')

We should change it to be:

with completion_cache(Flavor, 'a'):
    write_to_completion_cache('human_id', 'some-human-id')

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/101373
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=4c8cefb98a425382204df2f38f24e6b5b71520dd
Submitter: Jenkins
Branch: master

commit 4c8cefb98a425382204df2f38f24e6b5b71520dd
Author: Rick Harris <email address hidden>
Date: Thu Jun 19 18:34:17 2014 -0500

    Overhaul bash-completion to support non-UUID based IDs

    There are a few things currently wrong with bash-completion as it stands now:

        1) IDs are currently required to be UUIDs. This is an arbitrary limitation
           and doesn't make sense for certain kinds of objects, like `Flavors`
           where a valid ID could be `performance-16gb`.

        2) The code is spread out between Oslo's `Resource` and Novaclient's
           `Manager` class. This makes it difficult to improve the code because it
           requires changes to two separate projects. We should centralize the
           code in Novaclient until the API is stable, then import the code into
           Oslo in its entirety, not partially like it is now.

        3) The completion code is handled by the `Manager` of which there is one
           per Resource-type. In the interest of centralizing this functionality,
           we should create a `CompletionCache` class and hang it off of `Client`
           of which there is one-per-session.

        4) The completion-code currently runs by default even in headless mode
           (e.g. novaclient without the shell). It'd be much more efficient to
           only write to the completion cache if we're accessing the `Client` from
           the novaclient shell. We can make this an option to support third-party
           CLI clients that want to use the completion-cache as well.

    NOTE:
        * The corresponding Oslo patch is here:

            https://review.openstack.org/#/c/101376/

        * This patch was tested in multithreaded mode to prevent any regression
          from:

            https://bugs.launchpad.net/python-novaclient/+bug/1213958.

    Change-Id: Idada83de103358974b739f81d4f392574f9e1237
    Closes-Bug: 1332270

Changed in python-novaclient:
status: New → Fix Committed
Michael Still (mikal)
Changed in python-novaclient:
milestone: none → 2.18.0
Michael Still (mikal)
Changed in python-novaclient:
status: Fix Committed → Fix Released
Revision history for this message
Matt Riedemann (mriedem) wrote :

Note that this was reverted here: https://review.openstack.org/#/c/157591/

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.