896 Commits

Author SHA1 Message Date
88b59d8975 Merge "evacuate: respect original SHUTOFF state in --wait completion" 2025-05-21 10:29:33 +00:00
waf
3909e93301 evacuate: respect original SHUTOFF state in --wait completion
When running `openstack server evacuate --wait`, the command would hang
indefinitely if the instance was originally in SHUTOFF state, because
only “ACTIVE” was treated as a successful completion. We now capture
the server’s status before evacuation and dynamically include
“SHUTOFF” in the `success_status` list if the instance was already
shut off. This ensures that a shutoff instance is accepted as a valid
completion without requiring manual intervention.

Unit tests have been added and updated to cover both:
- pre-evacuation ACTIVE → success_status=['active']
- pre-evacuation SHUTOFF → success_status=['active','shutoff']

Closes-Bug: #2103426
Change-Id: I86ad1cd173a144b16fde1dbac87819fab2d7a50a
2025-05-21 16:52:24 +09:00
d5238d1dab Merge "Add a column to all_projects tag of server list cmd" 2025-05-19 14:17:25 +00:00
a74850d2c4 Add a column to all_projects tag of server list cmd
Add a Project ID column to the --all-projects tag of server list cmd
Differentiate from the basic command, add a column for Project ID
to facilitate easier identification.
Add test code for the Project ID column of --all-projects tag.

Change-Id: I12af2c91f934e7cd268d21cf76dda78646ed2ff4
2025-05-19 12:38:20 +01:00
32762bcda6 compute: Fix key used for NIC fixed IP field
Change-Id: If099ac0e2663228681e87e2f4821b746c8113ffc
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #2106221
2025-05-18 15:12:17 +01:00
efce69b47f Merge "Don't warn about unsupported version with SDK-based commands" 2025-05-15 16:19:20 +00:00
9de5e58bc8 Merge "Bump Python version used for linters to 3.10" 2025-05-09 16:13:11 +00:00
7c7c066096 Bump Python version used for linters to 3.10
Change-Id: I693516fc2a08218c50d83a3ab121b51254f97958
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-05-07 17:55:39 +01:00
5d730f374b Add support for spice-direct console types.
This patch adds support for Nova microversion 2.99 which exposes the new
spice-direct console type and the pre-existing /os-console-auth-token/ API.

+----------+----------------------------------------------------------+
| Field    | Value                                                    |
+----------+----------------------------------------------------------+
| protocol | spice                                                    |
| type     | spice-direct                                             |
| url      | http://127.0.0.1:13002/nova?token=f78009fb-41ad-...      |
+----------+----------------------------------------------------------+

+----------------------+--------------------------------------+
| Field                | Value                                |
+----------------------+--------------------------------------+
| host                 | 127.0.0.1                            |
| instance_uuid        | f2477018-aa93-...                    |
| internal_access_path | None                                 |
| port                 | 5900                                 |
| tls_port             | 5901                                 |
+----------------------+--------------------------------------+

Change-Id: I2d33646d6ac9b25076d69be76dcef8f5c465cd1b
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/940479
2025-05-07 19:34:17 +10:00
7d64003196 tests: Stop returning FakeResource in compute tests
This was still being used in places where we have our own API bindings
because SDK does not support the API. Those bindings should be returning
dicts, not FakeResource objects. Correct this, and in doing so fix the
bug this highlights in our cell-down output.

Change-Id: I6647d94fcf5ada8186edbf64c03abd3d8ae7ca56
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-04-14 16:43:22 +01:00
db4739fc5c Merge "Require confirmation to reset server state." 2025-04-11 13:23:47 +00:00
25cd1178b3 Require confirmation to reset server state.
This change updates the server set state command to require confirmation
before it is applied. The same pattern as project clean is used and a
new --auto-approve flag is added to allow skipping the prompt.

Operators often use reset state in cases that are incorrect
this change updates the warning to be more explicit
about when and when not to use it.

Change-Id: Iab14739cf6043ad45ad49edff0580e81d75af2fd
2025-04-11 11:53:14 +01:00
d123be0819 Fix 'openstack keypair list --project <project>'
The --project option of 'openstack keypair list' is supposed to filter
keypairs by a project but has not been working and instead returns
keypairs from all projects.

The reason appears to be because it uses a request for a user list
filtered by project but tenant_id/project_id is not a valid filter for
GET /users.

This fixes the issue by requesting role assignments for the specified
project and then requesting keypairs for users with a role in the
project.

This change depends on a recent openstacksdk bug fix change
Ic552dee83d56278d2b866de0cb365a0c394fe26a which fixed the user_id query
parameter for the compute /os-keypairs APIs. The bug fix was released in
openstacksdk 4.4.0.

Closes-Bug: #2096947

Change-Id: Ibb5757766e3040e58d64388b95678fab9b2b6f23
2025-04-10 17:59:29 -07:00
616d6f3a29 Merge "Add support for showing scheduler_hints in server details" 2025-04-10 18:37:26 +00: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
c66abfc76f Workaround for failing tests on openstacksdk change
The 'show-instance-action-finish-time' blueprint [1] adds support for
showing 'finish_time' for InstanceAction object.

This change adds 'finish_time' as hidden column, so it doesn't fail
tests.

We need to remove this from hidden_column list, once all the changes
related to blueprint are merged and show the field only if microversion
is >= 2.101

This is a workaround for failing tests on patch [2], as per suggestion
from Stephen.

[1] https://blueprints.launchpad.net/openstack/?searchtext=show-instance-action-finish-time
[2] https://review.opendev.org/c/openstack/openstacksdk/+/930562

Implements: blueprint show-instance-action-finish-time
Change-Id: Ib9294a603daed0fdb936be128dfba254b9108799
2025-04-09 12:23:38 +05:30
c68622402e Add support for showing scheduler_hints in server details
Adds support for a new compute microversion that returns the
associated scheduler_hints in ``GET /servers/{server_id}``,
``GET /servers/detail``, ``PUT /servers/{server_id}`` and
``POST /server/{server_id}/action`` (rebuild) responses.

Change-Id: Ia5a4e0047b5123f2fb063cfc9ab1f58b2844308f
2025-04-08 19:27:29 +00:00
dae2539490 compute: Migrate to 'compute' client alias
This is no longer assigned to novaclient, meaning we can use it for SDK.

Change-Id: I43d9ede39d36cc29301f94fa462b9b9d9441807c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-04-03 16:39:03 +01:00
dc8596fe74 Prepare for osc-lib changes
Change-Id: I665cd61272f881dce2d387da6035a2f35c866add
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-04-01 13:39:50 +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
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
f65e4835d3 Fix missing space in help messages
This change fixes missing space in help messages to make those
consistent and pretty rendering when calling help.

Change-Id: I947374821a4dbb5e68651c0e72fc5fd2f938e6a1
2025-03-05 19:58:27 +05:30
83de58fa33 Merge "compute: Workaround bug #2089821" 2024-12-10 14:03:49 +00:00
22b30b99ce compute: Workaround bug #2089821
By passing a dict instead of a single value, we force SDK to populate
the correct attribute on the object.

Change-Id: I9f4c5964dc0546215474c92db567966ffad68a1a
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Related-bug: #2089821
2024-12-09 13:56:58 +00:00
5ef5cc9c82 compute: Add server create --no-security-group option
To allow users to create servers with no security groups associated with
the ports.

Change-Id: I91b1d9dd5c3fbba838640841d98341cd8ccb1b16
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-11-29 10:33:18 +00:00
fb1f841d2d Replace deprecated datetime.utcnow()
The datetime.utcnow() is deprecated in Python 3.12.
Replace datetime.utcnow() with
datetime.now(datetime.timezone.utc).replace(tzinfo=None).

Change-Id: Ic20174a9c6cacac05471fa57b105c1f784a73057
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
2024-11-13 15:48:59 +00:00
58d1b06fdc evacuate SDK actually uses admin_pass param
Change I0cd86675a884e6c2cbd3a861b8e111f961f0f336 was incorrect,
the SDK param name is admin_pass.

Change-Id: Ibe22c3d7d7ba0f1a5178475143e35fee5cac2ca2
2024-09-18 08:46:44 +02:00
b92291f0aa Merge "compute: Allow adding, removing multiple SGs" 2024-09-17 13:26:47 +00:00
e46a7a2adc Merge "pre-commit: Migrate pyupgrade to ruff" 2024-09-13 17:35:54 +00:00
eaec72e2ba Merge "pre-commit: Migrate bandit to ruff" 2024-09-13 17:35:52 +00:00
f63784606d Merge "evacuate: Fix password parameter name for SDK" 2024-09-13 17:35:50 +00:00
8932282952 evacuate: Fix password parameter name for SDK
The parameter is called admin_password on the SDK side.

Change-Id: I0cd86675a884e6c2cbd3a861b8e111f961f0f336
2024-09-13 13:22:26 +02:00
067261e80d Merge "Removed the emit_duplicated_warning() funtion." 2024-09-12 19:19:48 +00:00
e319df4726 Merge "compute: Fix --host in server list for new openstacksdk" 2024-09-12 18:37:15 +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
fc6852cd94 pre-commit: Migrate bandit to ruff
The name of the errors change and we need to move things around a
little, but it's otherwise a straight swap.

Change-Id: I0a19765ebeaa14c0534faa1542165b76ed2bf4e2
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-09-12 18:08:23 +01:00
2bf123f315 Removed the emit_duplicated_warning() funtion.
Since this function is called once, I moved its implementaion to where
its called.

Story: 2010344

Change-Id: Iaf06def1a06ffbb605ee42569e6f87b409a72772
2024-09-12 14:42:57 +01:00
ffa683ab4e compute: Fix --host in server list for new openstacksdk
With `openstacksdk` 3.2.0 the `host` attribute of an Instance got added
to the `Server` class [0]. With that change, listing servers with the `host`
attribute leads to a query-filter for `compute_host` as expected, but
`openstacksdk` will also filter for the `host` attribute locally after
the results are returned. Since `compute_host` being
`OS-EXT-SRV-ATTR:host` is not the same as `host, this means no results
are returned.

Since we want to keep the old behaviour of filtering by `compute_host`
i.e. the service host name, we need to switch to filter for
`compute_host`. This is already supported in older versions of
`openstacksdk`.

[0] 0f311ff3e2

Change-Id: I0cd32c5b7d6d4d21194f3efdcfb9b205dea6a91e
Closes-bug: #2074200
2024-09-12 12:51:36 +00: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
9c5fd76d9e Merge "compute: Add 'uuid' column to aggregate list" 2024-08-27 17:21:35 +00:00
bc6cff777f Merge "compute: Make 'hypervisor show' a bit faster" 2024-08-12 16:45:25 +00:00
4a2fd82b07 compute: Make 'hypervisor show' a bit faster
In the event that a user provides a hypervisor name rather than an ID to
the 'hypervisor show' command, passing 'details=True' (the default) to
'find_hypervisor' will ensure we get the detailed response we need.
However, this comes at the cost of retrieving reams of additional
irrelevant data for all the other hypervisors. Rather than doing this,
use a summary view and then a second call to fetch only the hypervisor
we care about.

Change-Id: I92b53802e41a962c6f916c3a111dc2de7c12d0fc
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #2072965
2024-08-07 13:50:28 +01:00
04ebe0853d compute: Add 'uuid' column to aggregate list
Change-Id: I15d4a2d5980c1ba3e00f7d1bd09f11d0f42564e1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #2073542
2024-08-07 13:24:23 +01:00
b8459c57c8 compute: Only pass admin_password on rebuild if set
In SDK change I3bc3150877c6c00aa9ec4355104308d7755aa1d4, we modified the
'rebuild_server' proxy method to use a sentinel 'unset' value so that we
could distinguish between fields that were not being changed and those
that were being changed to 'null'. However, we are currently passing the
'admin_password' field to the 'rebuild_server' SDK proxy command
regardless of whether it is set or not. Resolve this conflict.

Change-Id: If7b7585aadd43cdc6d2a9358f14223e43dc21a73
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #2076232
2024-08-07 13:06: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