diff options
author | Eric Harney <eharney@redhat.com> | 2018-10-15 11:29:01 -0400 |
---|---|---|
committer | Brian Rosmaita <rosmaita.fossdev@gmail.com> | 2019-03-21 17:21:27 -0400 |
commit | 5a884fb68f8610b379ce5b6c7a857b3f78201359 (patch) | |
tree | 5ee10df1c1d1e182056cd70241f2ffcf435be42d | |
parent | 77fec74c5b68130a409be87d29841b84f0da7564 (diff) | |
download | python-cinderclient-5a884fb68f8610b379ce5b6c7a857b3f78201359.tar.gz |
Re-enable shell UUID completion cache
This enables writing ids to a local completion
cache when using the cinderclient shell, which
allows tools/cinder.bash_completion to complete
commands such as
cinder delete a<tab>
Volume ids are recorded on "cinder list" and
"cinder create" operations, similar for backup ids.
This functionality was unintentionally removed in
changes some time ago. Labeled as Partial-Bug
because I haven't added name caching yet, which also
used to exist.
Partial-Bug: #1712835
Change-Id: Id56aa43b061758a00a2a8c9c92a5a33ab9f7ab84
(cherry picked from commit c4b37c2830fdd90b57383a93e09a8bd40ca41221)
(cherry picked from commit 7319a40767641aa83d75cc99a807fd231f52f1ac)
-rw-r--r-- | cinderclient/v3/shell.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index d0f1b95..1738b0b 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -177,6 +177,13 @@ def do_backup_list(cs, args): if show_count: print("Backup in total: %s" % total_count) + with cs.backups.completion_cache( + 'uuid', + cinderclient.v3.volume_backups.VolumeBackup, + mode="w"): + for backup in backups: + cs.backups.write_to_completion_cache('uuid', backup.id) + @utils.arg('--detail', action='store_true', @@ -393,6 +400,12 @@ def do_list(cs, args): servers = [s.get('server_id') for s in vol.attachments] setattr(vol, 'attached_to', ','.join(map(str, servers))) + with cs.volumes.completion_cache('uuid', + cinderclient.v3.volumes.Volume, + mode="w"): + for vol in volumes: + cs.volumes.write_to_completion_cache('uuid', vol.id) + if field_titles: # Remove duplicate fields key_list = ['ID'] @@ -642,6 +655,11 @@ def do_create(cs, args): utils.print_dict(info) + with cs.volumes.completion_cache('uuid', + cinderclient.v3.volumes.Volume, + mode="a"): + cs.volumes.write_to_completion_cache('uuid', volume.id) + @utils.arg('volume', metavar='<volume>', @@ -2404,6 +2422,12 @@ def do_backup_create(cs, args): utils.print_dict(info) + with cs.backups.completion_cache( + 'uuid', + cinderclient.v3.volume_backups.VolumeBackup, + mode="a"): + cs.backups.write_to_completion_cache('uuid', backup.id) + @utils.arg('volume', metavar='<volume>', help='Name or ID of volume to transfer.') |