bash completion mangles image and server names that contain periods

Bug #1193049 reported by David Cramer
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Low
Ikuo Kumagai

Bug Description

I have image and server names like:

docs-internal.rackspace.com-20130501

When I use the bash completion script (https://github.com/openstack/python-novaclient/blob/master/tools/nova.bash_completion), it competes these names like so, omitting the periods:

docs-internalrackspacecom-20130501

I notice that the names are already mangled in some files in ~/.novaclient/**/server-human-id-cache:

dcramer@anatine ~
$ cat ~/.novaclient/d41d8cd98f00b204e9800998ecf8427e/server-human-id-cache
docs-internal-dev
docs-staging-content
docs-internalrackspacecom
docs-backup
docs-stagingrackspacecom

Revision history for this message
David Cramer (david-thingbag) wrote :

It seems that the file names are munged by the fact that slugify(value), defined in utils.py, is called on the human name.

    @property
    def human_id(self):
        """Subclasses may override this provide a pretty ID which can be used
        for bash completion.
        """
        if self.NAME_ATTR in self.__dict__ and self.HUMAN_ID:
            return utils.slugify(getattr(self, self.NAME_ATTR))
        return None

It's not clear to me why it would be desirable slugify the human id if the intent is to use it for bash completion.

melanie witt (melwitt)
Changed in python-novaclient:
importance: Undecided → Low
status: New → Confirmed
Loic Dachary (dachary)
Changed in python-novaclient:
assignee: nobody → Loic Dachary (dachary)
Ikuo Kumagai (i-kumagai)
Changed in python-novaclient:
assignee: Loic Dachary (dachary) → Ikuo Kumagai (i-kumagai)
Revision history for this message
Ikuo Kumagai (i-kumagai) wrote :

I solved one of the problems .

The human_id is not suitable for completion. Because words of completion need fully match.
To resolve this issue is very simple. This need only to change the item to cache .

But this change will cause another problem.
If the name is separated by whitespace, the completion words also are separated.
For example, if the name is "aaa bbb ccc", the completion word is "aaa" or "bbb" or "ccc".
In order to fix this, it requires a change of cache logic and tools/nova.bash_completion .

Should I solve all of the problems , or whether it is only the first problem ?

Revision history for this message
Loic Dachary (dachary) wrote :

The original review had no discussion https://review.openstack.org/#/c/4945/ and from the comment in https://review.openstack.org/#/c/4945/3/novaclient/utils.py,unified it looks like the slugify function was copy pasted from http://code.activestate.com/recipes/577257-slugify-make-a-string-usable-in-a-url-or-filename/ which has a different focus : it is meant to create a valid path name from a string.

The human readable id for bash completion must not be transformed in any way because it will just make it an invalid id.

The call to the slugify function should just be removed when adding a value to the bash completion cache and that will resolve the problem.

The problem related to spaces in names should be addressed as a separate bug, I think. Although it is related, it is a different kind of problem.

Revision history for this message
Loic Dachary (dachary) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/136379

Changed in python-novaclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/136379
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=9a6a7664c2709023390e49447545799d5c7ca805
Submitter: Jenkins
Branch: master

commit 9a6a7664c2709023390e49447545799d5c7ca805
Author: Ikuo Kumagai <email address hidden>
Date: Fri Nov 21 13:47:30 2014 +0000

    Change the unsuitable item caching for completion

    This fix changes the item that cached for completion from
    "human_id" to "name".
    A string for completion shoud not be changed in any way,
    because changed keyword can not use as command line parameter.
    But the "human_id" means "human readable id" that is
    changed from "name" by method "to_slug". "to_slug" is meant to
    create a valid path name from a string.

    The tools/nova.bash_completion take the completion string from
    the file ".novaclient/*/*-cache". The file is created when client
    call "list" command. For example , "nova list","nova image-list",
    and the others.
    Currently, items that are written to the cache file is the "id"
    and "human_id".

    Closes-Bug: #1193049

    Change-Id: I241ec8b7c8729274ee43db6e360141fd381b265e

Changed in python-novaclient:
status: In Progress → Fix Committed
Michael Still (mikal)
Changed in python-novaclient:
milestone: none → 2.21.0
Michael Still (mikal)
Changed in python-novaclient:
status: Fix Committed → Fix Released
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.