diff options
| author | youngho choi <0505zxc@gmail.com> | 2020-09-07 06:35:04 +0900 |
|---|---|---|
| committer | Stephen Finucane <stephenfin@redhat.com> | 2021-01-04 17:25:34 +0000 |
| commit | 6f616a29b300238c004b676edd98a5337be38193 (patch) | |
| tree | d0b560c75f2da28827b0acd75a3da9c98065b411 /openstackclient/image | |
| parent | f083fc685bde09dfcb3d561cf87044ecda8bf3ad (diff) | |
| download | python-openstackclient-6f616a29b300238c004b676edd98a5337be38193.tar.gz | |
Add support '--progress' option for 'image create'
openstack-client doesn’t support the upload progress bar.
This patch shows progressbar when create image
if you added '--progress' option like a python-glanceclient.
like this.
[=============================>] 100%
+------------------+---------------------------+
| Field | Value |
+------------------+---------------------------+
| container_format | bare |
| created_at | 2020-09-06T20:44:40Z |
...
How to use
Add the'--progress' option on the 'openstack image create' command.
Code was written by referring to 'python-glanceclient' project
on stable/ussuri branch
Change-Id: Ic3035b49da10b6555066eee607a14a5b73797c00
task: 40003
story: 2007777
Diffstat (limited to 'openstackclient/image')
| -rw-r--r-- | openstackclient/image/v2/image.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py index fa7f4be5..71779293 100644 --- a/openstackclient/image/v2/image.py +++ b/openstackclient/image/v2/image.py @@ -30,6 +30,7 @@ from osc_lib.command import command from osc_lib import exceptions from osc_lib import utils +from openstackclient.common import progressbar from openstackclient.common import sdk_utils from openstackclient.i18n import _ from openstackclient.identity import common @@ -256,6 +257,12 @@ class CreateImage(command.ShowOne): "(only meaningful with --volume)"), ) parser.add_argument( + "--progress", + action="store_true", + default=False, + help=_("Show upload progress bar."), + ) + parser.add_argument( '--sign-key-path', metavar="<sign-key-path>", default=[], @@ -412,6 +419,11 @@ class CreateImage(command.ShowOne): if fp is None and parsed_args.file: LOG.warning(_("Failed to get an image file.")) return {}, {} + if fp is not None and parsed_args.progress: + filesize = os.path.getsize(fname) + if filesize is not None: + kwargs['validate_checksum'] = False + kwargs['data'] = progressbar.VerboseFileWrapper(fp, filesize) elif fname: kwargs['filename'] = fname elif fp: |
