Commit Graph

259 Commits

Author SHA1 Message Date
Zuul 4d30527659 Merge "Add support for showing requested az in output" 2024-04-15 13:00:47 +00:00
Stephen Finucane bb6b1e38cb tests: Remove use of unnecessary fake argparse Namespace
Change-Id: I135c24d0f6450d5af4e1860218bf3a65c09e36cc
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-04-11 11:23:20 +01: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
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
Zuul 2642b070db Merge "compute: Add 'server create --server-group' option" 2023-12-05 18:43:15 +00:00
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
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
Zuul 491e5b9e9a Merge "tests: Add compute v2 FakeClientMixin" 2023-10-27 16:38:55 +00:00
Zuul f576cb62b6 Merge "tests: Use consistent shortcut to fake compute client" 2023-10-27 16:38:53 +00:00
Zuul 14a4f89030 Merge "tests: Add volume v1, v2, v3 FakeClientMixin" 2023-10-27 16:23:55 +00:00
Zuul dd5a21ff02 Merge "tests: Use consistent shortcut to fake volume client" 2023-10-27 16:23:53 +00:00
Zuul b884e83e37 Merge "tests: Use central SDK client fake" 2023-10-27 16:20:27 +00:00
Zuul 0fb1cae1a8 Merge "Fix "server create"command with --boot-from-volume" 2023-10-11 15:59:24 +00:00
Stephen Finucane 912a21a8fd tests: Add compute v2 FakeClientMixin
This ensures we are speccing the compute proxy API.

Change-Id: I7adbf2666d71f222fbd9c1479216f72cb9893348
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-29 10:14:32 +01: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
Stephen Finucane 98fb1678bc tests: Add volume v1, v2, v3 FakeClientMixin
This ensures we are speccing the image proxy API, as we did previously
for the network tests in Ic203964c7dede7dd80ae2d93b8fa1b7e6634a758.

Change-Id: I132ccd1170cc903f6edc505926b071170aeaa08c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-29 10:14:32 +01:00
Stephen Finucane 4cabf6f7a2 tests: Use consistent shortcut to fake volume client
This removes the need for a number of base test case subclasses. We use
'volume_client' rather than 'client' to avoid conflicts with clients for
other services.

Change-Id: I28d78f32142bb3a3fde0ba1780c504adc31cc77c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-29 10:14:30 +01:00
Stephen Finucane 02cc064258 tests: Use central SDK client fake
Avoid double mocking.

Change-Id: Ic8fadd41f3687eabd3a149681effae6883edb12e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-29 10:12:19 +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
Stephen Finucane 28b1267921 tests: Use consistent shortcut to fake image client
This removes the need for a number of base test case subclasses. We use
'image_client' rather than 'client' to avoid conflicts with clients for
other services.

Note that this highlights a minor bug with the 'volume create' command
when using the v1 block storage API and creating a volume from an image.
This is corrected, though it can be assumed that no one is actually
using this code path to say it hasn't been reported in the few years
since the bug was introduced in Ussuri.

Change-Id: I571be27f68bb7669dcb883f3b4799731b4a35479
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-08-28 13:52:23 +01:00
Stephen Finucane a39bde5c3a tests: Add network v2 FakeClientMixin
This ensures we are speccing the network proxy API. Future changes will
do the same for the image proxy API and eventually the compute proxy API
(once everything has been converted).

Change-Id: Ic203964c7dede7dd80ae2d93b8fa1b7e6634a758
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-08-28 13:52:23 +01:00
Stephen Finucane b25742499a tests: Use consistent shortcut to fake network client
This removes the need for a number of base test case subclasses. We use
'network_client' rather than 'network' for consistency with other
services.

Change-Id: I61f7c43341acf19ae16d06db34e18970297fbb93
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-08-28 13:52:23 +01:00
Zuul f3a51b0051 Merge "trivial: Remove duplicate definitions" 2023-05-18 12:33:01 +00:00
Zuul 90fe18e51b Merge "Dropping the use of 'addFixedIp' server action" 2023-05-18 11:52:56 +00:00
Stephen Finucane e984ca18a4 trivial: Remove duplicate definitions
These are already set in the 'TestServer' super class.

Change-Id: I90cfd9ff004c59cadc3e760eb120a460687701fe
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-18 10:14:12 +00:00
Zuul d0a17d48a9 Merge "compute: Fix bug with start/stop server" 2023-05-17 23:20:17 +00:00
Zuul a2728356af Merge "Allow server rebuild --wait for SHUTOFF servers" 2023-05-17 23:20:11 +00:00
Stephen Finucane e91844dd0e Dropping the use of 'addFixedIp' server action
Dropping the use of 'AddFixedIp' server action entirely in favour of
creating an interface with a fixed IP using the 'os-interface' API. The
reason for doing this is because this mechanism allows us to request an
explicit fixed IP.

Adds back support for using the --fixed-ip-address argument for users
who use older nova-api versions.

Change-Id: Ieac4b0fbcb38fe7207eaaa6a79e0c6770ee11d80
2023-05-17 17:47:05 +01:00
Stephen Finucane f43e2ed20d compute: Fix formatting of 'server show'
In change Ic253184ee5f911ec2052419d328260dc4664b273, we switched to
using the SDK for the 'server show' command. There were a couple of
issues with this change, which we address here:

- openstacksdk uses different names for fields than the nova API. We
  opted to output both the original names and the openstacksdk aliases
  in the output. With testing, however, it's become obvious that the
  resulting output is very long and rather unfriendly from a UX
  perspective. We opt to only show fields with their original names.

- A number of fields included in the output are only valid in requests
  and will never be present in responses. These are removed.

- A number of fields are not present in later API microversions or are
  only present under certain conditions. These are removed from output
  when not included in responses.

- The image and flavor fields both had errant logic that resulted in
  unnecessary or incorrect information being show. This logic is
  corrected.

With these changes, the output now resembles the output seen before the
migration to openstacksdk. In the future we may wish to build on this
further and switch from a blacklist model (removing the fields we do not
wish to show from output) to a whitelist model (specifically stating
which fields to show) but that's a change for another day.

Change-Id: I7e3eaa0149bff202c8fd4538356cbc75b4f7e708
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-05-17 17:24:44 +01:00
Stephen Finucane 0a63f8603e compute: Fix bug with start/stop server
A mistake was introduced during the conversion from novaclient to SDK in
change I5ebfa6b2468d5f20b99ea0eab1aea9377be09b8c. Fix the issue and add
functional tests to prevent it being reintroduced.

Change-Id: I6b314eab31bcf452e88b8b6a239ac2e296497cb9
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Story: 2010750
Task: 48004
2023-05-17 15:59:33 +01:00
Pavlo Shchelokovskyy 417a7ad203 Allow server rebuild --wait for SHUTOFF servers
currently the command is waiting only for ACTIVE server status,
but if the server was SHUTOFF before, it will be SHUTOFF after
rebuild as well, so the command is stuck in waiting forever.

Additionally, we now also pre-validate the server status on client side,
and raise an error if the server to be rebuilt is not in ACTIVE, ERROR
or SHUTOFF state.

Change-Id: If90a4bbba9a7ecd972f8b594c52fee4f75a0ae5e
Co-Authored-By: Oleksiy Molchanov <omolchanov@mirantis.com>
Story: 2010751
Task: 48005
2023-05-17 11:38:37 +00:00
Stephen Finucane 31ae635ffe tests: Use SDK objects where expected
We had not migrated a number of tests to use SDK objects instead of fake
novaclient-like objects when migrating the commands themselves. Address
this now.

Change-Id: Ib0da07fd9d793968b111986bd36a6d4311469d4e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-16 16:55:08 +00:00
Stephen Finucane 19be070204 tests: Remove unnecessary nesting of compute resources
Change-Id: I27326b8f2e0d84d3ef2c2fbdcb5c96a5ac1d79e4
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-16 16:21:44 +01:00
Stephen Finucane 28ffa2bf9f Blacken openstackclient.compute
Black used with the '-l 79 -S' flags.

A future change will ignore this commit in git-blame history by adding a
'git-blame-ignore-revs' file.

Change-Id: I9af45c062d179ab3dc2a5e969e1c467932753a2b
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-10 10:51:30 +01:00
Stephen Finucane 864f51f427 compute: Migrate 'reboot server' to SDK
Change-Id: Ibad4078f680d3b2615b9ca6f6c72c4fd28030b55
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-04-04 13:40:38 +01:00
Zuul ad992486fb Merge "Remove unused helpers for legacy novaclient" 2023-04-03 20:36:15 +00:00
Zuul 5d2687bfc4 Merge "Switch server shelve, unshelve to SDK" 2023-04-03 20:36:13 +00:00
Zuul eafe579534 Merge "compute: Switch server restore to SDK" 2023-04-03 20:36:11 +00:00
Zuul 0a9a1753b5 Merge "Remove unnecessary 'self.methods'" 2023-03-30 19:05:04 +00:00
Zuul 17d03f49aa Merge "Switch server start, server stop to SDK" 2023-03-30 19:05:02 +00:00
Zuul 4e9181aa1e Merge "Switch server lock, unlock to sdk" 2023-03-30 19:05:00 +00:00
Zuul fa90ad1392 Merge "Switch list server volume to sdk" 2023-02-21 13:28:35 +00:00
Stephen Finucane 1701768c2d Remove unused helpers for legacy novaclient
These are no longer used.

Change-Id: I9514e98a5549130c12f3b785e90debf3437e6933
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-12-19 17:25:25 +00:00
Stephen Finucane f56f0e333e Switch server shelve, unshelve to SDK
This one is a little more complicated because we support waiting.

Change-Id: I5bd65b44c23bfee1e0144dbd060563ecc3cfb942
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-12-19 17:25:23 +00:00
Stephen Finucane 004b2ab2fb compute: Switch server restore to SDK
Change-Id: I8df9711b736991c01136988aa06c8540d640f52f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/868108
2022-12-19 17:02:48 +00:00
Stephen Finucane 29fafabeed Remove unnecessary 'self.methods'
This was used by 'run_method_with_servers', not the SDK-equivalent.

Change-Id: Ia3333a95e406f430beb4f2cfb887e81ab7b72cfe
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-12-19 16:56:45 +00:00
Thrivikram Mudunuri 9241514137 Switch server start, server stop to SDK
Switch the server start and server stop commands from novaclient to SDK.

Change-Id: I5ebfa6b2468d5f20b99ea0eab1aea9377be09b8c
2022-12-19 16:56:20 +00:00