Commit Graph

885 Commits

Author SHA1 Message Date
Zuul f07ad89f6c Merge "Bump hacking" 2024-02-15 02:25:50 +00:00
Pranali Deore 3c5dd2381f Remove incorrect validation for glance-download import method
Since REMOTE SERVICE INTERFACE has default value to 'public',
it doesn't make sense to have validation for the same.

Removing this validation and added few missing tests for
glance-download import method

Closes-Bug: #2051761
Change-Id: I89adf23aac5db4f2c46379546def2f71d7c8e163
2024-01-31 09:57:50 +00:00
Takashi Kajinami 7ddca13fcb Bump hacking
hackihg 3.0.x is too old.

Change-Id: I9d0d19bc6ecf4cb934cce77ce25e89882202dbd6
2024-01-27 23:18:53 +09:00
Zuul 881f4e6343 Merge "do_image_import: always pass remote_* to gc.images.image_import" 2023-07-04 18:50:19 +00:00
Zuul f53d6714fd Merge "md-property-create: add a mandatory "--type" option" 2023-06-28 16:41:03 +00:00
Nobuto Murata 7d78cc4b9d Bump the CHUNKSIZE to use CPU more efficiently
The chunk size used for downloading images was 64KiB for some time. That
is okay for relatively small images but the client side of CPU can be a
bottleneck especially for large images. Bump the default chunk size from
64KiB to 1MiB so we can use the client side CPU more efficiently.

[64KiB chunk size - current]
INFO cinder.image.image_utils Image download 1907.35 MB at 68.61 MB/s
-> ~ 549 Mbps

[1MiB chunk size - patched]
INFO cinder.image.image_utils Image download 1907.35 MB at 132.10 MB/s
-> 1,057 Mbps

Closes-Bug: #2020139
Change-Id: I8b6e19621fc989526b02319d88fcfde88a17eee0
2023-05-19 09:40:22 +09:00
Cyril Roelandt 1ea41f042c do_image_import: always pass remote_* to gc.images.image_import
In do_image_import, gc.images.image_import may be called from two
different places, depending on the command used ("glance image-import"
or "glance image-create-via-import"). Make sure we always pass the
remote_* arguments to gc.images.import.

Change-Id: I76c6ea00523d93bad900776866de6ba22bc516b4
Partial-Bug: #2012442
2023-05-03 15:38:40 +02:00
Cyril Roelandt e2190c4feb do_image_import: fix argument retrieval
The argparse module automatically replaces '-' characters with '_'
characters when converting an option string to an attribute:

«For optional argument actions, the value of dest is normally inferred
from the option strings. ArgumentParser generates the value of dest by
taking the first long option string and stripping away the initial --
string. If no long option strings were supplied, dest will be derived
from the first short option string by stripping the initial - character.
Any internal - characters will be converted to _ characters to make sure
the string is a valid attribute name.»[1]

This means that the value of the "--remote-region" option of the
"image-import" command will be available as "args.remote_region";
"remote-region" would not be a valid attribute anyway.

We make sure to retrieve the proper value for the following
options: --remote-region, --remote-image-id and
--remote-service-interface.

[1] https://docs.python.org/3/library/argparse.html#dest

Change-Id: I1d8c69acd5d61fdc426469cd87d1ace81871e60f
Partial-Bug: #2012442
2023-04-18 03:21:03 +02:00
Zuul 2d893b12dd Merge "Unhardcode the value of DEFAULT_PAGE_SIZE from the tests" 2023-02-09 15:33:18 +00:00
Zuul 590f793c9f Merge "Remove unicode-related Python2-only code" 2023-01-12 22:39:42 +00:00
Zuul 9b9c677715 Merge "Boolean options: use strict checking" 2023-01-12 22:39:41 +00:00
Cyril Roelandt 6c95122777 Fix functional tests and docs generation
First, fix test_help(). A commit[1], which first appeared in Python
3.10, changes the output of the help feature of argparse. Options used
to be in a section named "Optional arguments:", and they are now in a
section named "Options:".

Second, tox 4 changes the behaviour of tox, and
{toxinidir}/requirements.txt is no longer installed automagically in the
docs virtual environment. This causes autodoc to fail on some imports.
We explicitely add {toxinidir}/requirements.txt to the list of
dependencies to fix this issue.

These issues should be fixed in separate patches, but since they both
block the CI, they depend on each other.

[1] https://github.com/python/cpython/pull/23858

Change-Id: Ia7866390b31f469bdea95624325a13aaf45a496e
Closes-Bug: #2002566
2023-01-12 14:05:25 +01:00
Cyril Roelandt 88e3b0ad98 Boolean options: use strict checking
Boolean options (such as "--protected" for glance md-namespace-update)
should accept a limited amount of valid values, rather than assuming an
"invalid" value means "False".

The following values (no matter the case) will now be interpreted as
True: ‘t’,’true’, ‘on’, ‘y’, ‘yes’, or ‘1’.

The following values (no matter the case) will now be interpreted as
False: ‘f’, ‘false’, ‘off’, ‘n’, ‘no’, or ‘0’.

Change-Id: I0e7942045d883ac398bab4a7a85f2b4ac9b1ed8c
Closes-Bug: #1607317
2022-11-14 17:31:39 +01:00
Cyril Roelandt 4bb406d377 Unhardcode the value of DEFAULT_PAGE_SIZE from the tests
The value of DEFAULT_PAGE_SIZE (20) was hardcoded in multiple places in
the tests, which means all the tests would break should we ever want to
change that value.

Co-Authored-By:	韩春蕾 <1922361860@qq.com>

Change-Id: I6e8dbae32c3a24d3fbeebcea5bfe0dd9ae247035
2022-11-14 12:04:23 +01:00
Cyril Roelandt fc8f9ac2ed Remove unicode-related Python2-only code
This commit:
- removes the old "u" prefix from all strings
- removes the unicode_key_value_to_string function

Change-Id: I1da347e31e828fd2359f0935a4da47257116d4cb
2022-11-14 11:49:33 +01:00
Cyril Roelandt 74fa436657 schema_args: Do not generate option for read-only properties
The schema_args decorator generates command line options based on the
properties defined in a schema. This commit makes sure read-only
properties are skipped during this process, since trying to modify their
value would result in a Glance error.

Closes-Bug: #1561828
Change-Id: I7ccc628a23c9ebdaeedcb9e6d43559f497ce9555
2022-09-26 23:54:06 +02:00
Cyril Roelandt 393e84d30a md-property-create: add a mandatory "--type" option
The "type" property is required when using md-property-create, so there
should be a mandatory option for it, as is the case for "name" and
"title".

Change-Id: I3a118b6f2e375ad60bd4170c5ce0ae284a0c9060
Closes-Bug: #1934626
2022-09-07 18:55:50 +02:00
Zuul f2999ce752 Merge "Add support for glance-download import method" 2022-08-30 14:57:55 +00:00
Pranali Deore 92cd70a224 Add support for glance-download import method
Implements: blueprint glance-download-import-support
Change-Id: Ia2bfad82bccf9acb6103b21112e680c44e295d39
2022-08-30 11:20:40 +00:00
Erno Kuvaja 219568c2a4 Bump default pagesize
Bumping default pagesize to 200. With the previous
default value of 20 glanceclient was doing lots of
extra requests and schema validations.

Based on my tests no performance improvement was
seen over the pagesize of 200.

Change-Id: I6d740ca3a9b32bf5d064d3ea74273bb619b32ad4
Closes-Bug: #1987834
2022-08-26 12:46:20 +01:00
Benedikt Loeffler 8df9328a60 Check if stdin has isatty attribute
When the stdin is closed, it has no isatty atrribute which leads to a KeyError.

Closes-Bug: #1980890
Change-Id: If9a3bf68b8dfd953b346697241166578d18bb563
2022-07-07 02:55:10 +02:00
Zuul 68d18dc2f2 Merge "glance help <subcommand>: Clearly specify which options are mandatory" 2022-05-05 16:00:57 +00:00
whoami-rajat cf7504e795 Add doc and test for verbose parameter
We currently have support to show verbose output for image-list
with the command ``glance --verbose image-list`` but there is
no documentation about it.
This patch adds the documentation and a test to run it via CLI.

Closes-Bug: #1969565
Change-Id: Ic6db4f5ab2fecded373b044aa002f9a9bc262513
2022-04-21 14:34:42 +05:30
Erno Kuvaja 62f4f67d1d Add support for Cache API
This change provides support for the Cache API changes and
deprecation path for glance-cache-manage command.

Change-Id: I6fca9bbe6bc0bd9b14d8dba685405838131160af
2022-02-22 16:39:33 +00:00
Zuul 63bb03a145 Merge "Add an optional parameter --append" 2022-02-17 18:51:52 +00:00
Zuul 683b694fff Merge "Add an optional parameter --detail" 2022-02-16 19:32:15 +00:00
Mridula Joshi b8863535a8 Add an optional parameter --append
This patch will add an optional parameter --append to the glanceclient
command md-tag-create-multiple to provide the facility of appending
the tags.
If the parameter is present  it will append the tags to existing one,
else it will overwrite the existing tags.

Depends-On: https://review.opendev.org/c/openstack/glance/+/804966
Change-Id: I1841e7146da76b13f4cd8925e19f59d0eaf08f7a
2022-02-16 14:00:28 +00:00
Mridula Joshi 282ce9c209 Add an optional parameter --detail
This patch appends th --detail parameter to the ``stores-info``
command. With sufficient permissions, display additional
information about the stores.

Depends-On: https://review.opendev.org/c/openstack/glance/+/824438
Change-Id: I6ae08ab3eaab0c2b118aa7607246214b28025dfe
2022-02-02 14:31:44 +00:00
Dan Smith 3f001f5f11 Add support for usage API
This is really a very simple activity of fetching and showing the
results of the usage API in table form for the user.

Depends-On: https://review.opendev.org/c/openstack/glance/+/794860
Change-Id: I3d9360785a759e4a6e7905710400baea80776052
2022-01-31 13:27:54 -08:00
Cyril Roelandt 91ae9347db glance help <subcommand>: Clearly specify which options are mandatory
Earlier glance help <subcommand> was listing required arguments as
optional arguments in help text. Added new argument group to list
required argument properly.

$ glance help stores-delete

Example before this change:
usage: glance stores-delete --store <STORE_ID> <IMAGE_ID>

Delete image from specific store.

Positional arguments:
  <IMAGE_ID>          ID of image to update.

Optional arguments:
  --store <STORE_ID>  Store to delete image from.

After this change:
usage: glance stores-delete --store <STORE_ID> <IMAGE_ID>

Delete image from specific store.

Positional arguments:
  <IMAGE_ID>          ID of image to update.

Required arguments:
  --store <STORE_ID>  Store to delete image from.

Change-Id: I51ea4c43fa62164ed43e78d1ae0fb0cb2521fc83
Closes-Bug: #1933390
2021-12-14 15:14:10 +00:00
Rajat Dhasmana 5d714bed0b Correct releasenote path for member-get command
This patch moves the releasenote of member-get command to correct
path.

Closes-Bug: #1944798
Change-Id: Ifa76fc993b0ff47131401ba233e77001cd74107c
2021-09-22 10:15:16 -04:00
Mridula Joshi 1eb0bbbed7 Fix undesirable raw Python error
Using the glanceclient without a subcommand while
passing an optional argument triggers the raw Python
error `ERROR: 'Namespace' object has no attribute
'func'`. This bug can be reproduced by issuing the
command `glance --os-image-api-version 2`.
Added a default value to `func` as placeholder
so that a help message is shown instead of the Python error.

Closes-Bug: #1903727
Change-Id: Ie4288262e408192310cbbc240bd1779b265a64fd
2021-08-03 10:35:40 +00:00
Mridula Joshi cb084f5289 Add member-get command
It is observed that python-glanceclient was missing support for GET /v2/image/{image_id}/member/{member_id} API.
This patch adds new command `member-get` to support this missing operation.

Closes-Bug: #1938154

Change-Id: I3709f6a39535aa45bee70f468f015ac60a1375a8
2021-08-02 09:08:50 +00:00
Abhishek Kekane e0a35a1150 Get tasks associated with image
Add support to get tasks associated with specific image.
bp: messages-api

Change-Id: Ia505cf6f47ca6c628e195be3ca5231d22d53040d
2021-03-02 10:02:14 -08:00
James Page 5aca99d653 Update test certificates to use strong signing
Modern OpenSSL (and specifically on Ubuntu) will reject certificates
signed using the sha1 algorithm.  Refresh test CA and associated
certificates using sha256.

Change-Id: Ie22a4630eb0f5993a909efed27088321c1865ca8
2020-08-07 21:31:07 +00:00
Erno Kuvaja 77eab17cf9 Fixes "stores" property added to the image
"stores" property gets added to the image when
`glance image-create-via-import` is called with --stores

Change-Id: I514e6e3ac2f3a1f56fb7883ed403a04b1e7f13b0
Closes-Bug: #1889666
2020-07-30 18:39:31 +01:00
Zuul a29c6be97d Merge "Do not use the six library." 2020-07-17 19:32:29 +00:00
Zuul dca62b4de1 Merge "Do not use the six library in the tests." 2020-07-16 21:25:14 +00:00
Zuul 3cd06f763f Merge "Pass Global Request ID on with session client" 2020-07-16 15:54:26 +00:00
Erno Kuvaja bae1d89cc7 Pass Global Request ID on with session client
Closes-bug: #1886650
Change-Id: I3a08c1beb398ba9f2556b6779c925f679bdc2c49
2020-07-13 22:55:23 +01:00
Cyril Roelandt b513c8db4b Do not use the six library.
Change-Id: I3dbfcfa0f5f590a41ed549afd44537d8ed41433a
2020-06-23 21:51:07 +02:00
Cyril Roelandt 928935e5c0 Do not use the six library in the tests.
Change-Id: Ic8a2a736a733e0151ca82f19bfde428dc04cf255
2020-06-15 21:04:56 +02:00
Hervé Beraud e8455f5c18 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I732a57361319687ca0a64693f0e60bc0d8f5b3d2
2020-06-02 20:47:47 +02:00
Brian Rosmaita 56186d6d5a Fail gracefully when MD5 is unavailable
The glanceclient currently assumes that MD5 will always be available.
This is not the case, however, in a FIPS-compliant environment.  This
patch enables the glanceclient to fail gracefully in such a case.

Closes-bug: #1871675
Change-Id: Ibd89989e06cc5be7da71f5f21561d73b5abc4104
2020-05-04 08:56:58 -04:00
Sean McGinnis 6a045884cb
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I446ee142c7a17446372c910f7f2a36d55df18e04
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 11:58:08 -05:00
Abhishek Kekane dff5c881bd Pass --all-stores, --allow-failure as bool to API
Newly added command line options --all-stores, --allow-failure are boolean
but we are passing it as a string to glance API. This will cause problem if
those parameters are not converted to boolean at API side.

Passing these parameters as boolean instead of string to API.

Change-Id: I8d4eab9241fc9bb24bc40b47bf18d63c86a97d77
Closes-Bug: #1871674
2020-04-08 17:11:55 +00:00
Andreas Jaeger 82da2378ea Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Remove hacking and friends from lower-constraints, they are not needed
for installation.

Change-Id: I5ae47a7b11ff29a301e440c15daf30db7738485b
2020-04-02 15:48:09 +02:00
Zuul 6b5a163022 Merge "update doc url to new" 2020-03-26 16:32:58 +00:00
Erno Kuvaja d91bcae8a5 Delete image from specific store
Add support to delete image from specific store.

bp: delete-from-store
Change-Id: Ie57d7de5822264a5ea8a5f4587ab8cfb4afb79de
2020-03-20 07:21:59 +00:00
Abhishek Kekane 2e0396c0c9 Add support for copy-image import method
This change adds support for copy-image import method which will
copy existing images into multiple stores.

Change-Id: I748a8fb3dbaf9c2e4d887a2ecd4325e27a8429c4
bp: copy-image-multiple-stores
2020-02-27 06:49:11 +00:00