718 Commits

Author SHA1 Message Date
melanie witt
72a2477ec0 Fix 'server event list|show' for deleted servers
As of compute microversion >= 2.21, support for list and show of server
events for deleted servers was added. This however wasn't working using
the openstackclient because the compute GET /servers/{server_id} will
not return a deleted server, so osc_lib.utils.find_resource() fails to
find the server and the command bails early.

This adds a check for a uuid-like <server> arg and uses it directly if
the <server> cannot be found via find_resource().

A note is also added to the command help to indicate that list and show
for deleted servers will only work if a server ID is passed (name will
not work).

Story: 2009841
Task: 44443

Change-Id: Icd33b3b9a3a1855d7893dd111bbb2aca059f45fd
2022-02-09 23:26:25 +00:00
Zuul
7c7a30b3cd Merge "Skip original_name from flavor info" 2022-01-17 09:28:37 +00:00
Ritvik Vinodkumar
b5a2714b83 Switch compute service list, delete and set to sdk.
Switch the compute service commands from novaclient to SDK.

Change-Id: I16498905101d6c2702a3ccbaf8cf5e3098d51992
2022-01-14 18:36:37 +00:00
Artem Goncharov
f461af0ac8 Skip original_name from flavor info
In the new SDK we are going to add additional parameter to the flavor
which make no use for OSC. Exclude it explicitly since it also cause
failing tests.

Change-Id: Ie35e60498cf18f05c878611df6f88607a04b1870
2022-01-14 17:37:59 +01:00
Zuul
b79c0b6cfb Merge "Include hosts in aggregate list --long" 2021-12-25 10:54:27 +00:00
Zuul
eb139f6fe8 Merge "compute: Return information about fixed IP" 2021-12-25 10:54:24 +00:00
Zuul
9b49363c0d Merge "Switch add fixed IP to SDK" 2021-12-25 10:54:22 +00:00
Hugh Saunders
3a929611c0 compute: Pass through args to ssh
Why limit a user to preset ssh arguments? Capture them all and send
them along to ssh to deal with. This allows users to use the full range of
ssh arguments, including specifying a command to run on the
instance. For example:

  openstack server ssh -4 upg -- -l cirros -i ~/id_rsa_upg "date; uptime"

SSH arguments that openstackclient currently mirrors are deprecated
except for -4 and -6, as they are useful for retrieving the correct
instance IP.

Change-Id: Ia50786d5eee52688e180550fe16aeb8af610154b
Co-authored-by: Stephen Finucane <stephen@that.guru>
2021-12-15 17:41:58 +00:00
Stephen Finucane
ba69870d86 compute: Fix weird option definition for 'server ssh'
argparse allows you to specify multiple options for a given argument
when declaring the argument. For some reason, we weren't doing this for
the 'server ssh' command. There's no apparent reason for doing things
this way and it's been that way since the beginning (2013) so let's not
do that.

We also add unit tests since they were missing and should exist.

Change-Id: I67a9e6516d7057266210cd4083e9ddeb1cfaa5de
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-12-15 17:41:05 +00:00
Stephen Finucane
0cde82dcd8 compute: Return information about fixed IP
The compute API provides this information to us. We might as well use
it.

Change-Id: I5608fa80745975ce49712718452cfe296c0f64d2
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-12-14 15:55:33 +00:00
Ritvik Vinodkumar
9971d7253e Switch add fixed IP to SDK
Switch the add fixed IP command from novaclient to SDK.

Change-Id: I4752ea7b4bfc17e04b8f46dbe9a68d938501a89e
2021-12-14 14:55:22 +00:00
Dr. Jens Harbott
32e18253fa Fix RemoveServerVolume
The nova API we're using to delete a server volume attachment needs to
be handed a volume, not a volume attachment.

Also make sure that we create an error if the volume isn't actually
attached to the server.

Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Co-authored-by: Stephen Finucane <sfinucan@redhat.com>
Change-Id: I12abd3787ea47acb4da282d00fdc1989405a0564
2021-12-08 17:59:27 +00:00
Zuul
9eb42403d3 Merge "compute: Show flavor in 'server list' with API >= 2.47" 2021-11-30 19:45:10 +00:00
Zuul
d9ad0b5d46 Merge "Switch openstack server remove port/network to using sdk" 2021-11-30 19:08:01 +00:00
Zuul
e02fd2ab18 Merge "Switch server suspend and server resume to SDK" 2021-11-30 19:07:58 +00:00
Zuul
cf02135b52 Merge "Switch server pause and server unpause to SDK" 2021-11-30 19:07:55 +00:00
Khomesh Thakre
8e362402de compute: Show flavor in 'server list' with API >= 2.47
Fix the issue where the flavor name was empty in server list output.
This requires somewhat invasive unit test changes to reflect the changed
API response from the server, but this has the upside of meaning we
don't need new tests since what we have validates things.
Also drop the flavor ID column as it is removed from the compute API.

Change-Id: Ica3320242a38901c1180b2b29109c9474366fde0
Signed-off-by: Khomesh Thakre <khomeshthakre24@gmail.com>
Story: 2008257
Task: 41113
2021-11-30 16:52:37 +00:00
Stephen Finucane
4c3de28e83 compute: Reorder building of columns for 'server list'
This has no impact on the end result, but it should make fixing issues
introduced by API microversion 2.69 a little easier.

Change-Id: I7d70eac8aa1a6197ed05a49f071e6899ec219c03
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-11-30 09:34:38 -05:00
Thrivikram Mudunuri
ff96fea012
Switch server suspend and server resume to SDK
Switch the server suspend and server resume commands from novaclient to
SDK. Use the SDK versions of test fakes to support fake Server
resources.

Change-Id: Idd0b4f13fab0f238e42844a7d759538bbda24f68
2021-11-29 11:50:04 -05:00
Thrivikram Mudunuri
b515fe61b2
Switch server pause and server unpause to SDK
Switch the server pause and server unpause commands from novaclient to
SDK. Use the SDK versions of test fakes to support fake Server
resources.

Change-Id: Id626f06f3d7edd44b306b7fc7b9b00d04af09621
2021-11-29 11:47:58 -05:00
Diwei Zhu
f82afc7f37 Switch openstack server remove port/network to using sdk
Change-Id: I1540c1f52e9a107dba20eeea9dc323c5510fe2b1
2021-11-29 14:31:07 +00:00
Zuul
397688320d Merge "Switch server image create to SDK" 2021-11-29 13:38:51 +00:00
Diwei Zhu
fae293dd52 Switch command server remove volume to sdk
Change-Id: If6f6cf93b55a67e767c54de8ce21f25252cf99ca
2021-11-26 16:11:21 +00:00
Diwei Zhu
3078a0a121 Switch command server add volume to sdk.
File tests.unit.volume.v2.fakes is modified to provide sdk volume fakes.
File tests.unit.compute.v2.fakes is modified to provide sdk volume
attachment fakes. For test, setup_sdk_volumes_mock() method is created
so that volumes are created in similar way as servers are created.

Change-Id: I290ba83b6ba27a1377ab73fd0ae06ecced25efd1
2021-11-22 16:01:29 +00:00
Thrivikram Mudunuri
9acbd3e105
Switch server image create to SDK
Switch the server image create command from novaclient to SDK. Use the
SDK versions of test fakes to support fake Server resources. Also,
fetch updated image *after* waiting. If a user requests that we wait
(--wait) for a server image to become active before returning, then we
should probably return the final image. If we don't then the image can
appear to be in a non-active state when it fact it's active. Correct
this by fetching the image after the wait call.

Change-Id: I83a403c035add9ab041ed6d59b5b29e42267f143
2021-11-16 11:36:02 -05:00
Zuul
8b394e5641 Merge "Switch openstack server add port/network to using sdk." 2021-11-15 16:31:15 +00:00
Diwei Zhu
2183a61147 Switch openstack server add port/network to using sdk.
The old novaclient.v2.server.Server.interface_attach() method is
replaced with proxy.create_server_interface().
In swargs, 'net_id' and 'port_id' are mutual-exclusive, if one of
them is given with value, the other one cannot be None, as the
API would responde with 400 (None is not string).
In unit test, temporary method 'setup_sdk_servers_mock' is added,
because other tests are still using the old 'setup_servers_mock'.
Functional tests are added. Releasenote is generated.

Change-Id: I9899f0509febc5143560a1859ae6344d0a6d1427
2021-11-14 15:23:36 +00:00
Stephen Finucane
163cb01e46 compute: Return details of attached volumes
The API behind the 'server add volume' command returns details of the
created volume attachment, however, we were dropping these results
rather than displaying them to the user. Correct this.

Change-Id: I3f7e121220d29422ccf4e6940de2f28bb8496c83
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-11-03 11:57:31 +00:00
Diwei Zhu
57aad01886 Switch server backup to sdk.
Switch this command from novaclient to SDK. As this is the first command
related to server that we are migrating, we need to extend our test
fakes to support fake Server resources. The extended fakes will replace
the old ones once all commands related to server are switched.

Change-Id: If476fb1614a64320ed071bbda35e941bf3290a2e
2021-10-27 09:11:27 +00:00
Stephen Finucane
53debe7fe1 compute: Fix filtering servers by tags
The nova API expects the 'tags' and 'not-tags' filters of the 'GET
/servers' (list servers) API to be a CSV string [1]:

  tags (Optional)
    A list of tags to filter the server list by. Servers that match all
    tags in this list will be returned. Boolean expression in this case
    is 't1 AND t2'. Tags in query must be separated by comma.

    New in version 2.26

  not-tags (Optional)
    A list of tags to filter the server list by. Servers that don’t
    match all tags in this list will be returned. Boolean expression in
    this case is 'NOT (t1 AND t2)'. Tags in query must be separated by
    comma.

    New in version 2.26

We were instead providing a Python list, which was simply being URL
encoded. Correct this.

[1] https://docs.openstack.org/api-ref/compute/?expanded=list-servers-detail#list-servers

Change-Id: Ie0251a0dccdf3385089e5bbaedf646a5e928cc48
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-Bug: #1946816
2021-10-13 10:30:26 +01:00
Zuul
d79ebc5278 Merge "Add --trusted-image-cert option for server create" 2021-10-06 22:14:37 +00:00
Zuul
49d2c21366 Merge "Fix typo error in listing server's column name" 2021-10-06 17:32:24 +00:00
Pavlo Shchelokovskyy
28a376bfb0 Add --trusted-image-cert option for server create
this already exists for server rebuild, but was missing for server
create.

This option is supported from Compute API version >= 2.63, and is only
available for servers booted directly from images (not from volumes,
not from snapshots, and not from images first converted to volumes).

Additionally, this patch removes mentions of
OS_TRUSTED_IMAGE_CERTIFICATE_IDS env var from similar option help string
in server rebuild command as it is not actually implemented yet.

Change-Id: I4e9faea05c499bd91034d1d284c44fdcc8e18db5
2021-09-30 19:42:26 +03:00
Zuul
3a0571c4df Merge "compute: Add support for microversion 2.90" 2021-09-02 20:15:11 +00:00
Lee Yarwood
51ee17a94d compute: Add support for microversion 2.89
This microversion drops the duplicate ``id`` field while adding
``attachment_id`` and ``bdm_uuid`` to the output of the
os-volume_attachments API reflected within osc by the ``openstack server
volume list $server``command.

Depends-On: https://review.opendev.org/c/openstack/nova/+/804275
Change-Id: I8a7002d8d65d7795e106b768df868198ab8b8143
2021-09-02 14:35:17 +01:00
Stephen Finucane
8e833a3ed2 compute: Add support for microversion 2.90
Allow configuring hostname when creating a new server or updating or
rebuilding an existing server.

Change-Id: Ibe603eab78bbbec43605f56de62a20493b6aa93d
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Depends-On: https://review.opendev.org/c/openstack/python-novaclient/+/806917
2021-09-01 13:18:25 +01:00
LEE JAE YONG
4aad7dd779 Fix typo error in listing server's column name
openstack server list -c "Created At" command doesn't work
because the wrong variable was used here.

When we receive resp data, Created At data is saved with
the name "created". But in "server.py", we append columns
as created_at. So it seems to print an empty table.

Story: 2009149
Task: 43112
Change-Id: I06de6903d5cc427a8b0fdcd168fec47192f4365b
2021-08-28 07:17:04 +00:00
melanie witt
12c93c6d5f Show "Forced Down" compute service status with --long
Currently, the unified client does not have the ability to show the
"Forced Down" field of a GET /os-services response in microversion 2.11
even though the legacy client can.

This adds a "Forced Down" column to the 'openstack compute service list
--long' command output when microversion 2.11 is used.

Story: 2009115
Task: 43011

Change-Id: I10bc2fedbf0e867a990227962b2b6e60f5681f69
2021-08-17 01:34:05 +00:00
melanie witt
ed87f7949e Correct REST API response fields for /os-migrations API
The compute APIs are unfortunately inconsistent with regard to the
response parameters for migrations.

* GET /servers/{server_id}/migrations returns server_uuid
* GET /os-migrations returns instance_uuid

Because the 'Server UUID' column is being specified for parsing the
response from GET /os-migrations, it is always showing as an empty
string to users.

There are a few other mismatches between the column names and the REST
API response fields [1]:

* 'Old Flavor' vs 'old_instance_type_id'
* 'New Flavor' vs 'new_instance_type_id'
* 'Type' vs 'migration_type'

This adds a new list containing the REST API response field names to
pass to utils.get_item_properties so that the responses are correctly
parsed and the client output contains the response data instead of
empty strings.

Story: 2009078
Task: 42890

[1] https://docs.openstack.org/api-ref/compute/?expanded=list-migrations-detail#list-migrations

Change-Id: I8aab60619e0225047f6a1c31e44917ca8fcc799e
2021-07-28 15:25:06 +00:00
Zuul
59256becc9 Merge "compute: Note that '--password' is deployment-specific" 2021-07-27 12:13:40 +00:00
Zuul
ab6e905353 Merge "compute: Fix typo" 2021-07-02 18:29:30 +00:00
Stephen Finucane
13de349411 compute: Better help text for 'openstack server set --state'
Manually changing the server state is a potentially dangerous operation
that should only be done under limited circumstances. It's also an
admin-only operation by default. Highlight both points.

Change-Id: Ifd8aec94937764202131ba8caf6b507caa76d7e9
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Story: 2008549
Task: 41672
2021-06-16 18:09:32 +01:00
Stephen Finucane
280b14abcd compute: Note that '--password' is deployment-specific
Password injection requires either hypervisor-support or an agent
running in the guest that will talk to the metadata service. It can be
disabled for a deployment using the '[api] enable_instance_password'
nova config option. Indicate this, albeit briefly.

Change-Id: Ief94ea07fc7ab6a487af972e8759ca6704d8f085
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-16 16:19:36 +01:00
David Caro
eca1fcd65f
Include hosts in aggregate list --long
This makes it easier to get the total list of aggregates and the hosts
belonging to each of them (specially for scripting purposes).

Change-Id: I94833c15075ae655bc11e7c0fc47c0abad5846fc
Signed-off-by: David Caro <me@dcaro.es>
2021-06-03 09:44:39 +02:00
Stephen Finucane
d087952717 compute: Fix typo
Change-Id: I3795142318b63b7c8f836d78a415a2161f61164d
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-06-02 12:17:35 +01:00
Stephen Finucane
b1a41904c3 compute: Update 'server resize --revert', '--confirm' help
Update the help strings for these two arguments to indicate their
deprecated nature. This was previously flagged via a deprecation warning
but users would only see that if they were to run the command.

Change-Id: I31a5e27ac8bd2625a6073b54a51bf3e8d6126c8c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-05-20 16:58:57 +01:00
Stephen Finucane
2ccf7727a6 compute: Remove 'file://' prefix from '--block-device'
There are a couple of other (networking-related) options which accept
paths, none of which insist on a URI-style path. Let's just drop this
bit of complexity before we release the feature.

Change-Id: Ia7f781d82f3f4695b49b55a39abbb6e582cd879c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-03-11 15:56:59 +00:00
Stephen Finucane
d3bd0146ae compute: Add support for loading BDMs from files
The syntax of the '--block-device' parameter is complex and easily
screwed up. Allow users to load a block device config from a file. For
example:

  $ openstack server create ... --block-device file:///tmp/bdm.json ...

This should alleviate the pain that is BDMv2 somewhat.

No functional tests are provided since we already have tests for the CSV
style of passing parameters and the unit tests show that the net result
is the same.

Change-Id: I3e3299bbdbbb343863b4c14fb4d9196ff3e1698d
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-03-05 13:11:09 +00:00
Stephen Finucane
7c1d6f769c compute: Add functional tests for --block-device
This mostly reuses the existing tests for '--block-device-mapping',
which can hopefully be removed at some point in the future.

This highlights two issues with the implementation of this option.
Firstly, the 'boot_index' parameter is not required so don't mandate it.
Secondly, and more significantly, we were defaulting the destination
type for the 'image' source type to 'local'. Nova only allows you to
attach a single image to local mapping [1], which means this default
would only make sense if you were expecting users to use the
'--block-device' option exclusively and omit the '--image' option. This
is the *less common* case so this is a bad default. Default instead to a
destination type of 'volume' like everything else, and require users
specifying '--block-device' alone to pass 'destination_type=local'
explicitly.

[1] https://github.com/openstack/nova/blob/c8a6f8d2e/nova/block_device.py#L193-L206

Change-Id: I1718be965f57c3bbdb8a14f3cfac967dd4c55b4d
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-03-05 12:44:52 +00:00
Stephen Finucane
70480fa862 compute: Remove deprecated 'server migrate --live' option
It's been long enough. Time to remove this.

Change-Id: I37ef09eca0db9286544a4b0bb33f845311baa9b2
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2021-01-22 13:00:46 +00:00