849 Commits

Author SHA1 Message Date
Zuul
bc6cff777f Merge "compute: Make 'hypervisor show' a bit faster" 2024-08-12 16:45:25 +00:00
Stephen Finucane
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
Stephen Finucane
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
Stephen Finucane
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
Stephen Finucane
209f8e9e17 network: Replace use of in-tree API client
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>
2024-07-09 18:19:36 +01:00
Stephen Finucane
30a64579b6 compute: Migrate 'server create' to SDK
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>
2024-07-09 18:17:22 +01:00
Stephen Finucane
d22f26446a compute: Prevent use of conflicting v*-fixed-ip for 'server create --nic'
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>
2024-07-09 14:35:05 +01:00
Stephen Finucane
e6dc0f39c0 compute: Migrate 'server evacuate' to SDK
Change-Id: I8ea2da0921c5fd306271f03fa733c0f9787afb82
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/918745
2024-07-08 16:07:07 +01:00
Stephen Finucane
b9b5e7615a compute: Migrate remaining server actions to SDK
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>
2024-07-08 16:06:59 +01:00
Stephen Finucane
8d904a9efb compute: Migrate 'server rebuild' to SDK
Change-Id: Ic7cdb05327a4a74364f08451e531d02c631b7633
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Depends-on: https://review.opendev.org/c/openstack/openstacksdk/+/918730
2024-07-08 11:07:09 +00:00
Stephen Finucane
2057462120 compute: Avoid third API call during 'server show'
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>
2024-07-08 11:06:11 +00:00
Stephen Finucane
628ac48901 compute: Always use SDK client to display server
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>
2024-07-08 12:00:49 +01:00
Stephen Finucane
bcaf2ab559 compute: Migrate 'server set', 'server unset' commands
Change-Id: I2c249e9ca3952100dcf7f97fcafa879b733d34c6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-07-08 10:30:44 +01:00
Stephen Finucane
c8621e5b8b compute: Migrate 'server migrate' to SDK
Change-Id: I56d31c2fd4f8bf19eedd8f9eecd8a41cdafc5b55
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-07-08 10:30:44 +01:00
Stephen Finucane
abef798f30 compute: Migrate 'server add/remove security group' to SDK
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>
2024-07-08 10:30:44 +01:00
Stephen Finucane
402327f2e4 tests: Migrate to 'set_xxx_api_version' helpers
Clean things up somewhat.

Change-Id: I868f496fc8285a28e8fd551377f2ae6228051d19
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-07-08 09:59:21 +01:00
Stephen Finucane
7252a7a781 compute: Migrate 'host set' to SDK
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>
2024-07-02 17:52:02 +01:00
Stephen Finucane
0f07c97e84 compute: Migrate 'agent *' to SDK
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>
2024-07-02 17:52:02 +01:00
Stephen Finucane
aa5eb881e5 compute: Migrate tests for ShowServer to SDK objects
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>
2024-07-02 17:51:49 +01:00
Stephen Finucane
40ce56201c compute: Remove unnecessary try-except
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
2024-07-01 11:11:02 +00:00
Zuul
1ea291167b Merge "Improve output of 'server migrate --wait'" 2024-05-07 14:52:05 +00: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
0646f9b4e4 tox: Remove bandit skips, run via pre-commit
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>
2024-04-26 13:17:15 +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
Bence Romsics
bbe686109d
Improve output of 'server migrate --wait'
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
2024-04-16 10:58:42 +02:00
Zuul
4d30527659 Merge "Add support for showing requested az in output" 2024-04-15 13:00:47 +00:00
Youngjun
9e4dbd1d82 refectory: remove unreachable code
Change-Id: If12a550451f5aafe3e2fb5aaa0257319ea908fe3
Signed-off-by: Youngjun <yj.yoo@okestro.com>
2024-03-12 16:41:17 +09: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
f0f811ce4b Merge "[codespell] fix typos in doc,tests and help messages" 2024-01-30 09:34:00 +00:00
Rajesh Tailor
a1f7bd28e6 Add support for showing requested az in output
This change adds support for showing the availability zone
requested during instance create in server show and server
list --long output.

Depends-On: https://review.opendev.org/c/openstack/nova/+/904568
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/904490
Change-Id: I1772e06b4f043ef3118f036f3908ec70515144bd
2024-01-24 19:08:29 +05:30
Zuul
50544ae78b Merge "compute: Fix formatting of 'server show'" 2024-01-18 14:12:32 +00:00
Bence Romsics
cc2a0bab24 Correct error message for "create server --wait"
Error message should say "Error creating server" and not "unshelving".

Change-Id: I49dc6160f47a13d38128b3da1ba16437bd089c86
Closes-Bug: #2048896
2024-01-10 14:19:35 +01:00
Zuul
2642b070db Merge "compute: Add 'server create --server-group' option" 2023-12-05 18:43:15 +00:00
Rajesh Tailor
71839eb5fa [codespell] fix typos in doc,tests and help messages
Change-Id: I4823782daa1af3872bc22603147e3073152cc777
2023-11-21 11:31:07 +05:30
Stephen Finucane
c08d6e0391 parseactions: Use ArgumentError, not ArgumentTypeError
If you use the former, you get a pretty error message when there's a
failure. If you use the latter, you get an ugly traceback when used with
the '--debug' flag.

Without this change:

  $ openstack flavor create ... --property '' foo
  ...
  Traceback (most recent call last):
    File "/tmp/venv/lib/python3.11/site-packages/cliff/app.py", line 402, in run_subcommand
      parsed_args = cmd_parser.parse_args(sub_argv)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 1862, in parse_args
      args, argv = self.parse_known_args(args, namespace)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 1895, in parse_known_args
      namespace, args = self._parse_known_args(args, namespace)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 2107, in _parse_known_args
      start_index = consume_optional(start_index)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/argparse.py", line 2047, in consume_optional
      take_action(action, args, option_string)
    File "/usr/lib64/python3.11/argparse.py", line 1971, in take_action
      action(self, namespace, argument_values, option_string)
    File "/tmp/venv/lib/python3.11/site-packages/osc_lib/cli/parseractions.py", line 45, in __call__
      raise argparse.ArgumentTypeError(msg % str(values))
  argparse.ArgumentTypeError: Expected 'key=value' type, but got:
  clean_up CreateFlavor: Expected 'key=value' type, but got:

With this change:

  $ openstack flavor create ... --property '' foo
  ...
  usage: openstack flavor create [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN]
                                 [--noindent] [--prefix PREFIX] [--max-width <integer>]
                                 [--fit-width] [--print-empty] [--id <id>]
                                 [--ram <size-mb>] [--disk <size-gb>]
                                 [--ephemeral <size-gb>] [--swap <size-mb>]
                                 [--vcpus <vcpus>] [--rxtx-factor <factor>]
                                 [--public | --private] [--property <key=value>]
                                 [--project <project>] [--description <description>]
                                 [--project-domain <project-domain>]
                                 <flavor-name>
  openstack flavor create: error: argument --property: Expected 'key=value' type, but got:
  clean_up CreateFlavor:

Change-Id: I9e78b35ad9d016d7a33655141ec579397c5344c0
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-11-15 11:33:19 +00:00
Stephen Finucane
432698fea2 Use CommandError, not SystemExit, to exit
Change-Id: Id2bcc18420b17cf3afed5584ef5104c3ef413830
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-11-15 11:28:49 +00:00
Stephen Finucane
885f5912eb compute: Address bug in shelve offload logic
We were reusing a variable from a previous loop, which meant this would
never work with multiple servers. Correct the mistake.

Change-Id: I52246e183fb2cf0d855d92058dd305b48783589d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-11-15 11:26:02 +00:00
Zuul
0b78dfe30b Merge "Add pagination helpers" 2023-11-07 08:47:24 +00:00
Stephen Finucane
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
Stephen Finucane
7708106cf0 compute: Add 'server create --server-group' option
Add an alias for requesting a server group. This is more syntactic
sugar, though it comes with the added bonus of letting users request a
server group by name instead of just ID.

Change-Id: I3d9a7ce04a02fdf374b7a8082618eccdea8c3217
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-11-02 17:48:03 +00:00
cw0306-lee
6b9f40576d Removed start, end time format. Before fix, openstack usage list command resulted 'str' object has no attribute 'isoformat' error.
story: 2010943
task: 48951
Change-Id: I9ee3384cc6df9ca768ac664f01472244dd8e3267
2023-10-30 14:17:39 +09:00
Zuul
f576cb62b6 Merge "tests: Use consistent shortcut to fake compute client" 2023-10-27 16:38:53 +00:00
Zuul
0fb1cae1a8 Merge "Fix "server create"command with --boot-from-volume" 2023-10-11 15:59:24 +00:00
Stephen Finucane
187a454ec0 tests: Use consistent shortcut to fake compute client
This removes the need for a number of base test case subclasses. We use
'compute_client' rather than 'client' to avoid conflicts with clients
for other services.

Change-Id: I430214cd79eca481bd8d8c53bf97eaede6766eb4
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-29 10:14:32 +01:00
Zuul
619925e45f Merge "Remove use of oslo.utils" 2023-09-19 13:14:12 +00:00
Stephen Finucane
08551106e6 Remove use of oslo.utils
While a relatively small library, this is one import that we really
don't need. Remove it.

Change-Id: I726f3c3548cbd896588ef0613222e36c529f5bcc
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-11 11:02:55 +01:00
rladntjr4
89e5d67a16 Fix "server create"command with --boot-from-volume
This patch modifes the "server create --boot-from-volume" command
without image option print "'NoneType' object has no attribute 'id'"

story: 2010892
task: 48669
Change-Id: I566f81c285d4ebc1e23ea0762d67492fb6b3bcbe
2023-08-25 23:09:28 +09:00
Chengen Du
2ae621f098 Add a warning for resizing servers booted from volumes
Story: 2010858
Task: 48521
Change-Id: Ib72da4d2c2b4bfbbdbc1e8302b65d240e4e1d459
2023-08-01 17:36:00 +08:00
Zuul
90fe18e51b Merge "Dropping the use of 'addFixedIp' server action" 2023-05-18 11:52:56 +00:00
Zuul
d0a17d48a9 Merge "compute: Fix bug with start/stop server" 2023-05-17 23:20:17 +00:00