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>
We also ensure we call neutron rather than the deprecated nova proxy API
in the event that neutron is available.
Change-Id: I8315ea164fd3fa6c1d759f16677bfd6c24c4ef63
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
None of these are actually supported by openstacksdk (intentionally so)
so we add our own manual implementations.
Change-Id: Ifd24f04ae4d1e56e0ce5ba0afe63828403bb7a6f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
The final step. Future changes will clean up the remnants of the
novaclient usage. This is a rather large patch, owing to the number of
things that novaclient was handling for us which SDK does not, but the
combination of unit and functional tests mean we should be handling
all of these differences.
Change-Id: I623e8c772235438a3d1590e1bbd832748d6e62ea
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Currently this check is handled by novaclient. In the future, we won't
have that so we need to do it ourselves. Do so now, fixing a typo along
the way and adding tests to prevent regressions.
Change-Id: Iaa9c087d846390b6a4f95ed3fa121dd8dc640903
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Migrate the following commands:
- 'server delete'
- 'server rescue'
- 'server unrescue'
- 'server resize'
- 'server resize confirm'
- 'server resize revert'
- 'server migrate confirm'
- 'server migrate revert'
- 'server remove fixed ip' ('server add fixed ip' was already migrated)
- 'server ssh'
That leaves a few commands to migrate, all of which are called out with
TODOs.
Change-Id: Idb769a93609da522c458e719bc69a63ff2ab107b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
We can use a detailed list instead when looking up by name. We also
improve tests somewhat.
Change-Id: I18b38e7fbcac813190b304c4d67d8ea03d8c1a80
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This affects the 'server create', 'server show', 'server rebuild' and
'server set' commands. We also fix a few mistakes around the fields
shown.
Change-Id: I9946e12146efff39f9ba1591c90a4a9bccd46919
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
We need to work around SDK's (intentional) lack of support for Nova's
deprecated '/os-security-groups' API but it's nothing too crazy.
Change-Id: I03ca1a73f98aa77b288148607baff336dae69fb1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This was the sole outstanding command to be migrated to SDK. We also
clean up the old in-tree wrappers we have in the process and add missing
error checks for the 'host list' and 'host show' commands.
Change-Id: I5635469b63ab3370fb5118e4f8a1758002381aa5
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
These are not supported by SDK natively (intentionally so) so we use raw
HTTP requests to manage this migration.
Change-Id: I72fa0d6f87899537a24090995b1ba884bc5f9d4d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This is a little more realistic. We fix a minor bug along the way and
start ignoring some newly added create-only fields.
Change-Id: I93eae610e16e2a3a859f684b889546ace3afa683
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
We don't need to transform one HTTP Forbidden-related error to another:
just use the original one. This also fixes an issue where we would end
up with an undefined variable (server_id) if a non-HTTP 403 exception
was raised, since that would be blindly ignored.
Change-Id: Icdd1764b6f2df4a635e3264ed8f93a115cc52ef2
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-Bug: #2062010
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>
Most of these skips were unnecessary. The few that did generate warnings
could be skipped.
We also set 'skip_install' since there's no reason to build the package
for linting purposes.
Change-Id: I9644e5c19720b9c41c60e0a5882b7cd7f6a71f7b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
We have seen users interpret the current output ('Complete') of
'server migrate --wait' as if it meant success as well and be surprised
when later they learned that the migration was complete and failed.
This change adds a pointer to the that output, how to actually check the
success/failure of a migration, hoping to eliminate this user confusion.
Change-Id: I09030705a39405366d6202a5ac743cc4d1ddd63c
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>