Commit graph

210 commits

Author SHA1 Message Date
Stephen Finucane
3cd544df53 Add custom command classes
These are effectively identical to the osc-lib variants except they
include the attributes that the OSC shell implementation will set on
this during shell init. This helps from a typing perspective.

Change-Id: I53d9058273748ecd4d4eecec5f7291d5f38ce5ab
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-12-11 18:55:13 +00:00
Takashi Kajinami
92a277ff4c ruff: Enable E5 check
... to enforce maximum line length, to keep consistent code format.

Note that E501 check is disabled in test code now, until we decide how
to update ~50 lines violating the limit due to too long names.

Change-Id: I122c8b9035d6381dafb34438517c26b01e5201f5
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
2025-12-11 02:43:20 +09:00
Zuul
d90e18b08c Merge "Support image save with chunk-size option" 2025-08-15 13:37:16 +00:00
Zuul
6ba9473cdb Merge "Adds CLI support for `glance md-namespace-properties-delete`" 2025-08-15 13:37:13 +00:00
Mridula Joshi
2177f07dfb Adds CLI support for `glance md-namespace-properties-delete`
This patch modifies the command to delete all metadef properties
inside a namespace. This operation can be called by `image metadef
property delete`

Change-Id: Iff9bda0dddfa157be0438a66d1d05da7b0b437c3
Signed-off-by: Mridula Joshi <mrjoshi@redhat.com>
2025-08-15 11:16:46 +00:00
Artem Goncharov
a73698490a image: Add hashing-related fields
Add support for the 'os_hash_algo' and 'os_hash_value' image attributes
added with Image API 2.7.

Change-Id: Id8fe6f3fecf77f537587e9088b207ef2077a9def
Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com>
2025-08-15 12:01:58 +01:00
Hang Yang
13fe801968 Support image save with chunk-size option
Add '--chunk-size' option to 'image save' command to control the size of
bytes to read at one time.

Change-Id: I0a02323384433010b8c6804a4337040acb13da8f
Signed-off-by: Hang Yang <hangyang@verizonmedia.com>
2025-08-15 11:59:30 +01:00
Zuul
7bb5857081 Merge "Remap custom named Image attributes when unsetting" 2025-08-15 04:48:23 +00:00
Mridula Joshi
9f55b253a3 Adds CLI support for `glance md-namespace-objects-delete`
This patch adds operation which delete all metadef object inside a
namespace.
This can be implemented by `image metadef object delete`

Change-Id: Ib196e295aad1921d8bc0c451522e0ad530389134
Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/901671
Signed-off-by: Cyril Roelandt <cyril@redhat.com>
2025-08-07 20:25:50 +02:00
Alexey Stupnikov
e37148484c Remap custom named Image attributes when unsetting
Some Image attributes defined in openstacksdk are named differently
from actual properties managed by Glance. Because openstackclient
checked property names to be unset against Image object properties,
it was impossible to unset such properties.

This patch introduces a IMAGE_ATTRIBUTES_CUSTOM_NAMES dictionary
mapping real property names with custom attribute names.

Closes-bug: #2115732
Change-Id: I7296fc293dff9208464c9a07f58ce3e9ffabd3e9
Signed-off-by: Alexey Stupnikov <aleksey.stupnikov@gmail.com>
2025-07-29 18:24:57 +02:00
Takashi Kajinami
ea85c7aa4d Replace deprecated datetime.utcfromtimestamp
It was deprecated in Python 3.12 in favor of datetime.fromtimestamp[1].

[1] https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp

Change-Id: Ia805157eaecac0c61d4c5f88daa430ec6d69a9d4
2025-06-18 18:15:52 +09:00
djp
9ad18c4967
Fix openstack image import --method web-download --uri 'invalid value'
although python-openstackclient run command(image import) with invalid uri,
but the request succeeds. Fixed it to throw an exception
when requesting with an invalid URI.

unit test added. the test cover --uri 'invalid value'

Task: 52251
Story: 2011468
Closes-Bug: 2111777
Change-Id: I62cd8cdf054b6a5e07d664a543b0923ce5f20f83
2025-05-30 22:47:29 +09:00
Stephen Finucane
181bb194c7 image: Migrate 'create image' volume calls to SDK
Change-Id: Ie57a5c17a6df5a333abd6b11e28b65833740e102
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-04-04 18:11:27 +01:00
Stephen Finucane
e28046cc19 typing: Correct type for missing attributes
Change-Id: I55652220ecd663fa024937646dfef92595e1cd0f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-03-31 17:52:16 +01:00
Stephen Finucane
9435ef825a typing: Remove use of optional imports
Do them inline instead.

Change-Id: Icab1a0452249efc79f214c4d7b369d02291e94b4
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-03-31 17:48:36 +01:00
Stephen Finucane
7380fbe300 typing: Add types for empty dicts, tuples
In some cases, simply remove them.

Change-Id: I24a311a24eb533325dda83005777bcb2e0afc320
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-03-31 17:48:36 +01:00
Stephen Finucane
bdd55d989d typing: Indicate tuples to be extended
Change-Id: Ie5907de8d60f2f39e98f6a88227cebb2e2ff565c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-03-31 17:48:36 +01:00
Zuul
ab2e68f407 Merge "Prepare for ruff bump" 2025-03-31 10:37:30 +00:00
Stephen Finucane
290bc580e6 Prepare for ruff bump
Change-Id: Ia9c402edebc8537d5019d18920b6679b05ea4378
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-03-19 12:04:39 +00:00
Pavlo Shchelokovskyy
1efca54465 Fix image import --disallow-failure flag
the flag should store False to 'allow_failure', not True.

Also, make the --allow-failure and --disallow-failure flags
mutually exclusive.

Change-Id: I03699e14d4d69d9f08caab647293732fc211dbad
2025-03-14 10:52:39 +00:00
Pavlo Shchelokovskyy
4f95e0aa18 Show final image state after image create
creating the image is a 2step process, first an 'empty' image is created
and then the data is uploaded.
Currently the output of the 'image create' command is that 'empty'
image, in `queued` status etc.
A more user friendly approach would be to make a second refresh call
to show the user image as it is after data was uploaded.

Change-Id: I2f78b113dcc3c941f8cf8dd9b63262971a780a39
2025-01-16 15:35:43 +00:00
Stephen Finucane
f98006ca9d pre-commit: Migrate pyupgrade to ruff
Change-Id: Ic50d2a5e0bc9dcdfe29f382607135cab510cd396
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-09-12 18:08:23 +01:00
Stephen Finucane
2ba90581d5 pre-commit: Migrate from flake8 to ruff
Well, mostly. We still keep our own flake8 hooks and the hacking hooks
enabled. Everything else can be handled by ruff.

Doing this enables a couple of hacking checks that were previously
unaddressed. It also highlights a few cases that flake8 missed. Both are
addressed.

Change-Id: If81c7055e9ef692425da2789bae18a96d04b104f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-08-29 15:55:13 +01:00
Stephen Finucane
c5b772db76 trivial: Prepare for pyupgrade pre-commit hook
This change is entirely automated save for the update of some mocks from
'io.open' to '__builtins__.open').

We are keeping this change separate from addition of the actual hook so
that we can ignore the commit later.

Change-Id: I0a9d8736632084473b57b57b693322447d7be519
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-04-23 12:24:23 +01:00
Stephen Finucane
ee23995004 pre-commit: Bump versions
We fold in the new black changes also.

Change-Id: I326a0529b6b9f2aa9fbc33862567131839460797
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-04-23 12:22:26 +01:00
Zuul
a79cb608b0 Merge "Add image metadef resource type association commands 'create', 'list', 'delete'" 2024-04-15 14:01:02 +00:00
Zuul
c13977fd68 Merge "image cache clear: fix value of default target" 2024-04-15 13:00:43 +00:00
Antonia Gaete
276dbb6f56 Add image metadef resource type association commands
'create', 'list', 'delete'

Change-Id: I2c860427b0b2693076cfe57841f0e512ad1f6388
2024-04-15 11:42:45 +00:00
Cyril Roelandt
0970dd4096 image cache clear: fix value of default target
When using the "openstack image cache clear" command, the "clear_cache"
method from the OpenStack SDK is used. It expects its only argument to
be one of "both", "cache" or "queue". However, when passing neither
"--cache" nor "--queue", it is currently passed None as a value. Fix
this by specifying "both" as the default value to be passed.

Change-Id: I17c6e3d435a84b4ba453845086ff3fe272b54f58
2024-03-14 04:03:08 +01:00
Mridula Joshi
2a90a6f07b Adds CLI support for `glance md-object-property-show`
This patch adds a command "image metadef object property show" which
describe a specific metadata definitions property inside an object.

Change-Id: I738e2e3c27c9819290d5a2a8781878b81f03b5f9
2024-02-15 14:16:34 +00:00
Zuul
2eea916b35 Merge "Adds CLI support for `glance md-object-update`" 2024-02-14 12:01:10 +00:00
Mridula Joshi
3cd5ad2c1b Adds CLI support for `glance md-object-update`
This patch adds a command "image metadef object update" which
update metadata definitions object inside a namespace.

Change-Id: I2dd8f54f9224abda5adc7a1b6a1c270c49d473a7
2024-02-13 18:28:00 +00:00
Stephen Finucane
c128ae1969 trivial: Don't ignore missing resources
An openstacksdk 'find_foo' proxy method will return None by default if a
resource is not found. You can change this behavior by setting
'ignore_missing=False'. We were doing this in most, but not all cases:
correct the issue.

In the event of calling 'image delete' with multiple images, it will no
longer fail on the first missing image and will instead attempt to
delete remaining images before failing.

Change-Id: I1e01d3c096dcaab731c28e496a182dd911229227
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-02-13 16:33:56 +00:00
Zuul
0e5802c945 Merge "trivial: Fix typo" 2024-02-02 12:38:41 +00:00
Zuul
c8ecba2a9e Merge "image: Fix the default description of image visibility" 2024-02-02 11:23:51 +00:00
Stephen Finucane
d0f81f5717 trivial: Fix typo
Change-Id: I936cc07af38bdd5d389cc5edafa93861f8fac3a6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-02-02 10:14:29 +00:00
Stephen Finucane
8a63b51039 image: Trivial fixes
Mostly stylistic, with the exception that we now allow deleting multiple
metadef properties in a given namespace.

Change-Id: Ib0c243f0d647ce74c0165ee666beed6eb5d5c5a7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-01-29 13:53:34 +00:00
Zuul
dc8d9d3541 Merge "Adding CLI command for `glance member-get`" 2024-01-26 17:37:15 +00:00
Mridula Joshi
1517f4af21 Explicitly specify namespace fields for output
Rather than excluding the few fields we don't want, explicitly indicate
the ones we do want.

Note that this is a problem in the tests for virtually all commands
that will be seen as the SDK continues to evolve and new fields are
added to existing resources.

Change-Id: Ia8d487e1e7804fa177fce46497c0202aed8acb08
2024-01-16 15:14:55 +00:00
Mridula Joshi
93b2e66d2d Adding CLI command for `glance member-get`
This patch adds a command ``image member get`` which displays
a particular member associated to the image.

Change-Id: I48d3151f8e204e1eb5cfff67ce1e333d1cfb9322
2023-12-20 05:03:40 +00:00
Zuul
19896ec720 Merge "Adds command `image metadef object delete`" 2023-11-22 11:05:26 +00:00
Mridula Joshi
5d1afcee68 Adds command `image metadef object delete`
Change-Id: Ib94b7ba625ca0679ae4ae841e217ea251baff371
2023-11-17 10:46:35 +00:00
Zuul
1ac5d63c53 Merge "Adds command `image metadef object list`" 2023-11-08 18:01:44 +00:00
Zuul
8aee1a2889 Merge "Adds command `image metadef object show`" 2023-11-08 18:01:42 +00:00
Zuul
71f232aafa Merge "Add "image metadef property set" command" 2023-11-08 10:46:35 +00:00
Mridula Joshi
4bb6efa8f8 Adds command `image metadef object list`
Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/858350
Change-Id: I0691f7519e8fb9f01836e6232e0bcebd2c428ac3
2023-11-08 10:44:31 +00:00
Masayoshi Mizuma
a3730afe2e image: Fix the default description of image visibility
The default image visibility was changed to 'shared' in API v2.5. Fix
the help information of image visibility, centralizing options in the
process.

Change-Id: Ib3017fc4f618c1e14e3b26b616ff9374d0e24eaa
Co-authored-by: Stephen Finucane <stephenfin@redhat.com>
2023-11-08 10:41:07 +00:00
Zuul
c09c1fbf51 Merge "Add "image metadef property delete" command" 2023-11-08 10:35:38 +00:00
Mridula Joshi
78ef009a3a Adds command `image metadef object show`
Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/858350
Change-Id: I97bcb0ccee9d25fb26475ec9e10660556e6072a6
2023-11-08 09:57:02 +00:00
Zuul
0439f17ed3 Merge "image: Add support for cache commands" 2023-11-07 09:31:24 +00:00