255 Commits

Author SHA1 Message Date
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
11495e655a Don't warn about unsupported version with SDK-based commands
This doesn't make sense: SDK (and the server) will handle this for us.

Change-Id: I31b84e09eca0dc2bc5316d6727620346ae519512
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #2106760
2025-04-10 18:21:17 +01:00
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
c9e4e5404f Merge "Permit use of tuple API_VERSIONS" 2025-04-01 12:02:24 +00:00
b2eccdcb1a Permit use of tuple API_VERSIONS
The values of these dictionaries are not used when SDK is in use,
which should soon account for all use cases. Eventually we should
probably look for plugins to return a proper class or typeddict but
that's a job for another day.

This began as a fix for in openstackclient/object/client.py which
referenced a non-existent class and quickly snowballed.

Change-Id: I7b807ec3a97124b35828ffdecbb36f6fde11e7b5
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-04-01 10:36:02 +01:00
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
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
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
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
ab2e68f407 Merge "Prepare for ruff bump" 2025-03-31 10:37:30 +00:00
290bc580e6 Prepare for ruff bump
Change-Id: Ia9c402edebc8537d5019d18920b6679b05ea4378
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-03-19 12:04:39 +00:00
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
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
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
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
438e40db36 Remove python-novaclient
There are a few remnants left here but this is trivial to clean up now.

Change-Id: I517d906796338e64a31afa08b9ee6909b08e0115
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-07-18 13:28:51 +01:00
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
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
a79cb608b0 Merge "Add image metadef resource type association commands 'create', 'list', 'delete'" 2024-04-15 14:01:02 +00:00
c13977fd68 Merge "image cache clear: fix value of default target" 2024-04-15 13:00:43 +00:00
276dbb6f56 Add image metadef resource type association commands
'create', 'list', 'delete'

Change-Id: I2c860427b0b2693076cfe57841f0e512ad1f6388
2024-04-15 11:42:45 +00:00
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
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
2eea916b35 Merge "Adds CLI support for `glance md-object-update`" 2024-02-14 12:01:10 +00:00
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
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
0e5802c945 Merge "trivial: Fix typo" 2024-02-02 12:38:41 +00:00
c8ecba2a9e Merge "image: Fix the default description of image visibility" 2024-02-02 11:23:51 +00:00
d0f81f5717 trivial: Fix typo
Change-Id: I936cc07af38bdd5d389cc5edafa93861f8fac3a6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-02-02 10:14:29 +00:00
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
dc8d9d3541 Merge "Adding CLI command for `glance member-get`" 2024-01-26 17:37:15 +00:00
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
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
19896ec720 Merge "Adds command `image metadef object delete`" 2023-11-22 11:05:26 +00:00
5d1afcee68 Adds command `image metadef object delete`
Change-Id: Ib94b7ba625ca0679ae4ae841e217ea251baff371
2023-11-17 10:46:35 +00:00
1ac5d63c53 Merge "Adds command `image metadef object list`" 2023-11-08 18:01:44 +00:00
8aee1a2889 Merge "Adds command `image metadef object show`" 2023-11-08 18:01:42 +00:00
71f232aafa Merge "Add "image metadef property set" command" 2023-11-08 10:46:35 +00:00
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
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
c09c1fbf51 Merge "Add "image metadef property delete" command" 2023-11-08 10:35:38 +00:00
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
0439f17ed3 Merge "image: Add support for cache commands" 2023-11-07 09:31:24 +00:00
e54bdfbba3 Merge "Adds command `image metadef object create`" 2023-11-07 09:31:21 +00:00
c7e3529dea Add pagination helpers
Add some pagination helpers to configure pagination parameters for
various commands. Two pagination schemes are supported, based on what we
currently support across OSC commands: marker-based pagination and
offset-based pagination.

Change-Id: I551bb4c3ff0568c6df5244a1d0f0669497bee58f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-11-03 23:16:18 +00:00
f8c708900c Adds command `image metadef object create`
Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/858350
Change-Id: Ie74231c823d6128d149d5f01c90a66ed3afa3d1a
2023-11-01 07:15:59 +00:00
705ecef7a9 Add "image metadef property set" command
Change-Id: I8fbe8ef5b5119fb500df0ed1b6e645ea00eadf01
2023-10-18 14:02:34 +00:00
9094e540b5 Add "image metadef property delete" command
Change-Id: I2e13b26139424c421ae609804c546a6b42add5a4
2023-10-18 13:27:02 +00:00
d9c4c43a40 Add "image metadef property create" command
Change-Id: Icb4fab0aef13b28212771da3a3b7c4a0775bb38e
2023-10-18 13:26:15 +00:00