2239 Commits

Author SHA1 Message Date
Stephen Finucane
03776d82e5 compute: Fix 'server * -f yaml' output
Make use of 'FormattableColumn'-derived formatters, which provide better
output than what we were using before, particularly for the YAML output
format. For example, compare before for the 'server show' command:

  $ openstack --os-compute-api-version 2.79 server show test-server -f yaml
  ...
  addresses: private=fdff:77e3:9bb4:0:f816:3eff:fe6d:a944, 10.0.0.44
  flavor: disk='1', ephemeral='0', extra_specs.hw_rng:allowed='True', original_name='m1.tiny',
    ram='512', swap='0', vcpus='1'
  ...

To after:

  $ openstack --os-compute-api-version 2.79 server show test-server -f yaml
  ...
  addresses:
    private:
    - fdff:77e3:9bb4:0:f816:3eff:fe6d:a944
    - 10.0.0.44
  flavor:
    disk: 1
    ephemeral: 0
    extra_specs:
      hw_rng:allowed: 'True'
    original_name: m1.tiny
    ram: 512
    swap: 0
    vcpus: 1
  ...

Similarly, compare before for 'server list':

  $ openstack --os-compute-api-version 2.79 server list -f yaml
  - ...
    Networks: private=fdff:77e3:9bb4:0:f816:3eff:fe6d:a944, 10.0.0.44
    Power State: Running
    Properties: ''
    ...

To after:

  $ openstack --os-compute-api-version 2.79 server list -f yaml
  - ...
    Networks:
      private:
      - fdff:77e3:9bb4:0:f816:3eff:fe6d:a944
      - 10.0.0.44
    Power State: 1
    Properties: {}
    ...

We also fix the human-readable output for the 'tags' field.

Before:

  $ openstack --os-compute-api-version 2.79 server list
  ...
  | tags   | ['bar', 'foo']  |

After:

  $ openstack --os-compute-api-version 2.79 server list
  ...
  | tags   | bar, foo  |

Change-Id: I7a8349106e211c57c4577b75326b39b88bd9ac1e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-01-06 12:02:24 +00:00
Zuul
f6cad0c9d5 Merge "compute: Add missing options for 'server rebuild'" 2021-01-06 11:30:53 +00:00
Zuul
b663e8a080 Merge "Add 'flavor list --min-disk', '--min-ram' options" 2021-01-06 11:16:49 +00:00
Zuul
23afc0af92 Merge "image: Unset properties rather than setting to None" 2021-01-06 11:16:25 +00:00
youngho choi
6f616a29b3 Add support '--progress' option for 'image create'
openstack-client doesn’t support the upload progress bar.

This patch shows progressbar when create image
if you added '--progress' option like a python-glanceclient.

like this.
[=============================>] 100%
+------------------+---------------------------+
| Field            | Value                     |
+------------------+---------------------------+
| container_format | bare                      |
| created_at       | 2020-09-06T20:44:40Z      |
...

How to use
Add the'--progress' option on the 'openstack image create' command.

Code was written by referring to 'python-glanceclient' project
on stable/ussuri branch

Change-Id: Ic3035b49da10b6555066eee607a14a5b73797c00
task: 40003
story: 2007777
2021-01-04 17:25:34 +00:00
Stephen Finucane
29a7c9afce image: Unset properties rather than setting to None
Currently, we attempt to unset an image property by setting it to None.
This doesn't work for known properties and is rightly rejected by the
Glance API with the following error:

  BadRequestException: 400: Client Error for url:
  http://172.20.4.87/image/v2/images/368c5751-2b0b-4a38-a255-fd146fe52d31,
  Bad Request

The solution is to actually unset the field by deleting it.

Change-Id: Ie156bedbe0f9244f82c81401679706f484caf9aa
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Story: #2008463
Task: #41493
2020-12-22 17:11:32 +00:00
Zuul
d10706a8db Merge "Add project field in image list subcommand" 2020-12-22 13:49:26 +00:00
Zuul
0fd090eff3 Merge "Add name and enabled param in ListDomain parser" 2020-12-22 13:30:59 +00:00
Zuul
b3e69a2adb Merge "Add option to filter instances by AZ" 2020-12-22 13:30:55 +00:00
okozachenko
3c80b1b3b2 Add project field in image list subcommand
The motivation is to filter the image by owner

Change-Id: I1f08da175a06e62a844f76b0ec18cb3332efef86
2020-12-15 00:45:30 +02:00
Stephen Finucane
f9fd3642f8 compute: Add missing options for 'server rebuild'
This accepts a large number of options that we weren't exposing. Add the
following options: '--name', '--preserve-ephemeral', '--user-data',
'--no-user-data', '--trusted-image-cert' and '--no-trusted-image-certs'.
In addition, rename the '--key-unset' parameter to '--no-key-name', to
mimic e.g. '--no-property' on other commands.

Change-Id: I61c46e18bef1f086b62a015ebdc56be91071b826
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-12-09 18:38:26 +00:00
Stephen Finucane
da03bd80e3 Add 'flavor list --min-disk', '--min-ram' options
Allow us to filter on minimum disk and RAM, and close another gap with
novaclient.

Change-Id: Ib3f0bdf419675e1c35c3406fbac8a4c18ac56a33
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-12-09 15:28:12 +00:00
Stephen Finucane
f5b185c357 Make use of comparable 'FormattableColumn' subclasses
This requires fixes found in cliff 3.5.0 [1] and osc-lib 2.3.0 [2]. With
these fixes in place, we can remove the icky, still broken
'assertItemEqual' and 'assertListItemEqual' helpers.

[1] https://review.opendev.org/761421
[2] https://review.opendev.org/761394

Change-Id: Id6c26b37c3c7d5ec6761361abca57f9219b76838
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-12-09 15:17:25 +00:00
Artem Goncharov
f36a34b675 Switch compute aggregate functions to SDK
Continue journey towards having OSC consuming SDK for nova part.

Depends-On: https://review.opendev.org/#/c/762131/
Change-Id: Id16e6c47aa93f02f15f49e1f59f73fecaa3e3b80
2020-12-02 11:24:51 +00:00
Artem Goncharov
0f4f42b652 Switch compute flavors from novaclient/direct to SDK
Let's switch flavors from novaclient or direct API requests onto using
SDK. Microversion agreement comes out of the box.

SDK normalizes property names, while OSC uses server side names. In
order not to break OSC users continue using server-side names.

Depends-On: https://review.opendev.org/#/c/762989/
Change-Id: I62b2ed8488ee4ac9c42051311bcfb455506ddd90
2020-12-02 11:24:42 +00:00
Zuul
ea358057f8 Merge "stop image downloads to memory" 2020-12-02 04:45:15 +00:00
Zuul
30828112cf Merge "Remove None valued network quota entries" 2020-12-01 13:51:20 +00:00
Zuul
c7a43773c9 Merge "Add id and enabled param in ListIdentityProvider parser" 2020-12-01 13:50:56 +00:00
Dmitriy Rabotyagov
0f02029d91 Add option to filter instances by AZ
Since nova API microversion 2.83 it is possible for users to filter
instances by AZ. However even before that this functionality was available
for admin role.

Change-Id: Ife4c8e81aad2ff1dde50d9f23913d9dd9397b00c
2020-12-01 13:44:23 +02:00
Simon Merrick
5bdcd590ec stop image downloads to memory
+ Fixes issue with large images hogging memory
 + stream image downloads
 + output to stdout if file not specified

Change-Id: Ia01ff9b21a2dac5d0ccf2bd58a8640e88c5cbb36
Story: 2007672
Task: 39776
2020-11-25 21:25:22 +13:00
Rodolfo Alonso Hernandez
8387b114e3 Add "fields" parameter to ListPort query
This new query parameter will allow to send a query to the Neutron
server filtering only by those parameters needed by the list
command: ID, name, MAC address, fixed IPs and status.

When using input parameter "long", security groups IDs, device owner
and tags will be added to the fields filter.

With 4500 ports, those are the execution times for the command
"openstack port list" (average values in a development environment):

                 Neutron API (seconds)  CLI (seconds)
Without filter:  3.05                   10.15
With filter:     2.76                   8.19

Depends-On: https://review.opendev.org/#/c/754113/

Change-Id: I1cccf0bc3533f8085e8dd61bf2fbe78c49b74b31
Closes-Bug: #1897100
2020-11-18 17:42:14 +00:00
Zuul
73d56bc8d4 Merge "Add a few selectable fields to the "openstack server list" output" 2020-11-18 13:28:55 +00:00
Zuul
bba5725085 Merge "Switch 'openstack keypair' ops to use SDK" 2020-11-17 14:53:12 +00:00
Zuul
24edeb24a6 Merge "tests: Remove 'agent' functional tests" 2020-11-16 21:37:18 +00:00
Stephen Finucane
ebaf0eae2c tests: Remove 'agent' functional tests
The 'os-agents' API was recently removed from nova [1]. Remove the
functional tests, since they will always fail going forward but will
continue to run on older stable branches.

Also Squeeze https://review.opendev.org/#/c/762559/ inside, since those
2 are simultaneously blocking gate

[1] https://review.opendev.org/#/c/749309/

Change-Id: I0bf7d4c0ba2a9d4637db0d209d8d52163d772f12
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-11-16 15:54:27 +01:00
Zuul
ce31c417de Merge "Resolve issues with 'server migration list'" 2020-11-12 11:20:21 +00:00
Zuul
e2bd1530cf Merge "functional: Remove test for 'quota set --force'" 2020-11-09 18:50:43 +00:00
Zuul
4d3bad9f19 Merge "Add 'openstack server evacuate' command" 2020-11-09 16:56:19 +00:00
Stephen Finucane
1a5dd4af5b Resolve issues with 'server migration list'
The 'os-migrations' API accepts 'instance_uuid' and 'migration_type'
query string parameters, not 'server' and 'type'. For the former, as the
name would suggest, the value should be a server UUID, not a name.

In addition, this is a list command and therefore should subclass the
'Lister' base class.

Change-Id: I736f5575156fc04d7ada7783a1865ab3b438396f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-11-09 15:05:54 +00:00
Artem Goncharov
512ba114a1 Switch 'openstack keypair' ops to use SDK
Let's continue our journey and start using SDK for the keypair
operations

Depends-On: https://review.opendev.org/#/c/761883/
Change-Id: Id411e70b8e1a79c0e88a0e22be7ff37e5c30fcda
2020-11-09 13:14:53 +01:00
Stephen Finucane
ffd7e93961 functional: Remove test for 'quota set --force'
Change I1d1ac1ac46f49f64794ffc8631e166935537966c introduced the 'quota
set --force' parameter to force set nova quotas. As part of that fix, we
introduced a functional test, 'QuotaTests.test_quota_set_force' that
works by attempting to set the 'limit' of the quota for instances to the
current usage ('is_use') minus one.

This test is flawed. It doesn't create any instances so when it fires by
itself, it will always set the 'limit' to 0. When it fires at the same
time as other tests (remember, we run tests in parallel), notably tests
that rely on booting instances, it can cause other tests to fail with
the following error:

  Quota exceeded for instances: Requested 1, but already used 0 of 0
  instances (HTTP 403)

We could attempt to work around this by creating a new project and using
that project to fiddle with quotas. That's a lot of work though, and the
returns are questionable: the 'quota set' command is an admin-only
command by default and the '--force' parameter should almost never be
used. Simply remove this test.

Change-Id: Ic07ff6f4a7c1c27852c892eb906bb144aae91788
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Story: #2008327
Task: #41225
2020-11-06 17:40:13 +00:00
jay
311f4130d2 Add a few selectable fields to the "openstack server list" output
Added ``-c project_id | user_id | created_at`` to ``openstack server list``
    command to get these columns as an output.

Change-Id: I18991adf899c7b72c98bb89871bf0715d35943f0
Story: 2007925
2020-11-05 14:01:12 +01:00
Zuul
cb6659d7cd Merge "Compute: Add user id support for keypair" 2020-11-04 00:28:41 +00:00
Zuul
71cdb113fe Merge "Add 'openstack server migration list --type' option" 2020-11-03 12:58:49 +00:00
Zuul
a40d22f1ed Merge "Fix formatting of the flavor properties" 2020-11-03 10:07:13 +00:00
Zuul
4cdc953888 Merge "Add support for 'keypairs list --project' parameter" 2020-11-02 17:23:23 +00:00
Sean Mooney
01eb4e8393 Add 'openstack server evacuate' command
This change adds a new 'openstack server evacuate' command to provide
parity with the 'nova evacuate' command. The term "evacuate" is
notoriously poor, in that it implies the instance is moved rather than
recreated, but it is retained since people are familiar with it now.

Change-Id: I1e32ca51036c501862d8e89b3144a9695d98a06f
2020-11-02 17:08:17 +00:00
Zuul
2ffd06b3d5 Merge "Switch console url show operations to SDK" 2020-11-02 17:00:51 +00:00
Artem Goncharov
ad3369ed1f Fix formatting of the flavor properties
Do not stringify flavor properties to allow proper output formatting to
json/yaml/etc

Change-Id: I9f4c42acb85b726af87123134dd19de98fe95074
2020-11-02 15:09:09 +01:00
He Jie Xu
17f641e1c3 Compute: Add user id support for keypair
This patch adds functionality of specific the user id when create,
delete, show and list keypairs.

Change-Id: Ib826f1f4f5a73d1875ba0f02e124b3222c4d05ed
Co-Authored-By: tianhui <tianhui@awcloud.com>
2020-11-02 12:55:04 +00:00
Zuul
7fdbc6b8af Merge "Add support for 'keypairs list --user' parameter" 2020-11-02 12:06:41 +00:00
Artem Goncharov
e05d39abb5 Switch console url show operations to SDK
Switch from using novaclient to SDK for openstack console url show operation.

Depends-On: https://review.opendev.org/756286
Change-Id: Ibe247825148788c549c2c1e991aae92338cdf557
2020-10-24 10:19:52 +02:00
Zuul
deae091f78 Merge "Validate 'server group create --policy' option" 2020-10-21 20:05:12 +00:00
Zuul
0228790024 Merge "Cleanup of 'server migration list' command" 2020-10-21 19:57:47 +00:00
Zuul
eb75c44656 Merge "Switch openstack console log show operation to use OpenStackSDK" 2020-10-21 16:19:21 +00:00
Zuul
77a45fe685 Merge "Compute: Add tag support for server add fixed ip" 2020-10-15 17:42:50 +00:00
Zuul
d59057ad3d Merge "Compute: Add tags support for server" 2020-10-14 17:38:33 +00:00
Zuul
96658a3116 Merge "Restore behavior of image create with same name." 2020-10-14 09:59:54 +00:00
Stephen Finucane
5645fad762 Add support for 'keypairs list --project' parameter
It would be lovely to do this server side but doing so requires a new
microversion, a blueprint and a spec. This is less performant but should
do the trick for the odd time users want to do this.

Change-Id: I26e7d38966304dd67be5da8ed0bb24f87191b82f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-10-14 10:27:05 +01:00
Stephen Finucane
98a0016cfa Add support for 'keypairs list --user' parameter
This has been supported by nova and novaclient since the veritable dark
ages. Add it to OSC.

Change-Id: Ifc95e7dd6c00807c80e87e10046ab154d0989014
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-10-14 10:25:50 +01:00