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
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
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
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>
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
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
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
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
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
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>
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>
This change fixes missing space in help messages to make those
consistent and pretty rendering when calling help.
Change-Id: I947374821a4dbb5e68651c0e72fc5fd2f938e6a1
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
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>
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>
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>
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
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>
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
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
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>