summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/compute
Commit message (Collapse)AuthorAgeFilesLines
* compute: Return details of attached volumes5.7.0Stephen Finucane2021-11-031-8/+83
| | | | | | | | | 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>
* Switch server backup to sdk.Diwei Zhu2021-10-272-61/+112
| | | | | | | | | 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
* compute: Fix filtering servers by tagsStephen Finucane2021-10-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add --trusted-image-cert option for server createPavlo Shchelokovskyy2021-09-301-0/+150
| | | | | | | | | | | | | | | 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
* Merge "compute: Add support for microversion 2.90"Zuul2021-09-021-16/+155
|\
| * compute: Add support for microversion 2.90Stephen Finucane2021-09-011-16/+155
| | | | | | | | | | | | | | | | | | 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
* | compute: Add support for microversion 2.89Lee Yarwood2021-09-022-0/+52
|/ | | | | | | | | | 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
* Merge "Replace assertItemsEqual with assertCountEqual"Zuul2021-08-235-24/+24
|\
| * Replace assertItemsEqual with assertCountEqualDirk Mueller2021-05-035-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | assertItemsEqual was removed from Python's unittest.TestCase in Python 3.3 [1][2]. We have been able to use them since then, because testtools required unittest2, which still included it. With testtools removing Python 2.7 support [3][4], we will lose support for assertItemsEqual, so we should switch to use assertCountEqual. [1] - https://bugs.python.org/issue17866 [2] - https://hg.python.org/cpython/rev/d9921cb6e3cd [3] - testing-cabal/testtools#286 [4] - testing-cabal/testtools#277 Change-Id: I0bbffbec8889b8b3067cfe17d258f5cb16624f38
* | Show "Forced Down" compute service status with --longmelanie witt2021-08-172-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Correct REST API response fields for /os-migrations APImelanie witt2021-07-282-5/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix TestListMigrationV223 test class MIGRATION_COLUMNSmelanie witt2021-07-271-6/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | Currently only the test_server_migration_list adds the 'Id' and 'Type' columns to the expected output, so if the test_server_migration_list_no_options test is run by itself, it fails as the actual response contains 'Id' and 'Type' but the reference does not. This example run fails: tox -epy38 test_server_migration_list_no_options The reason the tests pass in the gate is because test_server_migration_list (which adds the 'Id' and 'Type' columns to self.MIGRATION_COLUMNS) appears to always run before test_server_migration_list_no_options, so the latter test gets the benefit of the former test's column additions. This changes the test class to just include the 'Id' and 'Type' columns all the time as they are always returned in microversion 2.23 anyway. Story: 2009079 Task: 42891 Change-Id: I2c97e9f64790b5e978e4d04230d45b8e343b53d4
* compute: Remove 'file://' prefix from '--block-device'Stephen Finucane2021-03-111-1/+1
| | | | | | | | | 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>
* compute: Add support for loading BDMs from filesStephen Finucane2021-03-051-0/+83
| | | | | | | | | | | | | | | | | 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>
* compute: Add functional tests for --block-deviceStephen Finucane2021-03-051-22/+6
| | | | | | | | | | | | | | | | | | | | | | 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>
* compute: Remove deprecated 'server migrate --live' optionStephen Finucane2021-01-221-163/+40
| | | | | | | It's been long enough. Time to remove this. Change-Id: I37ef09eca0db9286544a4b0bb33f845311baa9b2 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Stop silently ignore --(no-)disk-overcommitStephen Finucane2021-01-221-0/+34
| | | | | | | | | These options are not supported from Nova API microversion 2.25 and above. This can be a source of confusion. Start warning, with an eye on erroring out in the future. Change-Id: I53f27eb3e3c1a84d0d77a1672c008d0e8bb8536f Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Auto-configure shared/block live migrationStephen Finucane2021-01-221-20/+25
| | | | | | | | | | | | | API microversion 2.25 introduced the 'block_migration=auto' value for the os-migrateLive server action. This is a sensible default that we should use, allowing users to avoid stating one of the '--block-migration' or '--shared-migration' parameters explicitly. While we're here, we take the opportunity to fix up some formatting in the function, which is really rather messy. Change-Id: Ieedc77d6dc3d4a3cd93b29672faa97dd4e8c1185 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add 'server create --block-device' optionStephen Finucane2021-01-221-0/+256
| | | | | | | | | | One of the last big gaps with novaclient. As noted in the release note, the current '--block-device-mapping' format is based on the old BDM v1 format, even though it actually results in BDM v2-style requests to the server. It's time to replace that. Change-Id: If4eba38ccfb208ee186b90a0eec95e5fe6cf8415 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add missing 'server create' optionsStephen Finucane2021-01-211-0/+233
| | | | | | | | | Add some volume-related options, namely '--snapshot', '--swap', and '--ephemeral'. All are shortcuts to avoid having to use '--block-device-mapping'. Change-Id: I450e429ade46a7103740150c90e3ba9f2894e1a5 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Improve 'server create --block-device-mapping' option parsingStephen Finucane2021-01-211-29/+76
| | | | | | | Once again, custom actions to the rescue. Change-Id: I6b4f80882dbbeb6a2a7e877f63becae7211b7f9a Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Rename 'server migrate (confirm|revert)'Stephen Finucane2021-01-211-0/+152
| | | | | | | | | We're confirming or reverting a server migration, not a server migrate. We've a number of 'server migration *' commands now so it makes sense to move them under here. Change-Id: Ib95bb36511dad1aafe75f0c88d10ded382e4fa5c Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add 'server migration show' commandStephen Finucane2021-01-212-0/+171
| | | | | | | | This replaces the 'server-migration-show' command provided by novaclient. Change-Id: I413310b481cc13b70853eb579417f6e6fad10d98 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Rename FakeServerMigration to FakeMigrationStephen Finucane2021-01-212-12/+12
| | | | | | | | Server migrations are (confusingly) a different thing returned by a different API. Change-Id: Ib6b7c8f9cc3d1521a993616f832d41651dc46f73 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add support for 'server boot --nic ...,tag=<tag>'Stephen Finucane2021-01-211-0/+107
| | | | | | | | This has been around for a long time but was not exposed via OSC. Close this gap. Change-Id: I71aabf10f791f68ee7405ffb5e8317cc96cb3b38 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Improve 'server create --nic' option parsingStephen Finucane2021-01-211-52/+52
| | | | | | | Simplify the parsing of this option by making use of a custom action. Change-Id: I670ff5109522d533ef4e62a79116e49a35c4e8fa Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add missing options for 'server event list'Stephen Finucane2021-01-211-1/+234
| | | | | | | | Add pagination parameters, '--limit' and '--offset', and filtering parameters, '--changes-since' and '--changes-before'. Change-Id: Ieca8267c3b204ae2db580502cc8fe72c95eddf09 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add missing options for 'server group list'Stephen Finucane2021-01-211-4/+43
| | | | | | | | | Add pagination parameters, '--limit' and '--offset'. It's unfortunate that we can't use '--marker' like elsewhere but that requires server-side support to be truly effective. Change-Id: I186adc8cdf28e9c540ad22bca6684d9dd892976a Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add 'server * --all-projects' optionStephen Finucane2021-01-211-0/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add an '--all-projects' option to a number of commands: - server delete - server start - server stop This is in addition to 'server list', which already supports this option. This option allows users to request the corresponding action on one or more servers using the server names when that server exists in another project. This is admin-only by default. As part of this work, we also introduce a 'boolenv' helper function that allows us to parse the environment variable as a boolean using 'bool_from_string' helper provided by oslo.utils. This could probably be clever and it has the unfortunate side effect of modifying the help text in environments where this is configured, but it's good enough for now. It also appears to add a new dependency, in the form of oslo.utils, but that dependency was already required by osc-lib and probably more. Change-Id: I4811f8f66dcb14ed99cc1cfb80b00e2d77afe45f Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Merge "compute: Improve 'server migration list' options"Zuul2021-01-151-19/+32
|\
| * compute: Improve 'server migration list' optionsStephen Finucane2021-01-121-19/+32
| | | | | | | | | | | | | | | | | | | | Improve both the '--user' and '--project' options to allow names as well as UUIDs. There's no release note included since this entire command was added in change I15b4a5aca8d0dee59dd293e7b1c7272cdfbeea20, which hasn't been included in a release yet. Change-Id: I7654f3ffc54d38d5cfb03d8d1b2f4dc4fb06fb3d Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | Merge "compute: Add '--force' option to 'server delete'"Zuul2021-01-151-0/+21
|\ \ | |/
| * compute: Add '--force' option to 'server delete'Stephen Finucane2021-01-121-0/+21
| | | | | | | | | | | | | | This is an admin-only operation by default but can be useful. Change-Id: I25a4da697e27c0fba4d28b504377667eb18f15fe Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | Merge "compute: Add missing options for 'hypervisor list'"Zuul2021-01-151-0/+96
|\ \ | |/
| * compute: Add missing options for 'hypervisor list'Stephen Finucane2021-01-121-0/+96
| | | | | | | | | | | | | | Yet more pagination parameters. Change-Id: I9f0145c89ddc49c1d907e6e6e294319cf80fc6ff Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | Merge "compute: Add 'server volume update' command"Zuul2021-01-151-0/+120
|\ \ | |/
| * compute: Add 'server volume update' commandStephen Finucane2021-01-121-0/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're not going to expose the ability to swap volumes since that's a things humans should not generally use. From the API docs [1]: When updating volumeId, this API is typically meant to only be used as part of a larger orchestrated volume migration operation initiated in the block storage service via the os-retype or os-migrate_volume volume actions. Direct usage of this API to update volumeId is not recommended and may result in needing to hard reboot the server to update details within the guest such as block storage serial IDs. Furthermore, updating volumeId via this API is only implemented by certain compute drivers. We *do* want users to have the ability to change the delete on termination behavior though, so that's what we expose. [1] https://docs.openstack.org/api-ref/compute/?expanded=update-a-volume-attachment-detail#update-a-volume-attachment Change-Id: I50938e1237b4d298521b26a5f9cb90c018dfebaf Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | Merge "Add 'server unshelve --wait' option"Zuul2021-01-111-29/+51
|\ \
| * | Add 'server unshelve --wait' optionStephen Finucane2021-01-081-29/+51
| | | | | | | | | | | | | | | | | | | | | | | | This was recently added to the 'server shelve' command. Add it now for the 'unshelve' command. Change-Id: I633dd85b60cf70b4f8610f414d82669dd6a53111 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | | Merge "Add 'server shelve --offload', 'server shelve --wait' options"Zuul2021-01-111-6/+116
|\ \ \ | |/ / | | / | |/ |/|
| * Add 'server shelve --offload', 'server shelve --wait' optionsStephen Finucane2021-01-081-6/+116
| | | | | | | | | | | | | | | | | | | | | | | | The '--offload' option allows us to explicitly request that the server be offloaded once shelved or if already shelved. The '--wait' option allows us to wait for the shelve and/or offload operations to complete before returning. It is implied when attempting to offload a server than is not yet shelved. Change-Id: Id226831e3c09bc95c34b222151b27391a844b073 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | compute: Add 'server volume list' commandStephen Finucane2021-01-082-0/+227
| | | | | | | | | | | | | | This replaces the old 'nova volume-attachments' command. Change-Id: Icb98766f98bd1f2469bdb6df62b4624711f98422 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | tests: Remove unused fake methodStephen Finucane2021-01-081-19/+0
|/ | | | | | | | | The FakeServerMigration.get_server_migrations method was added in change I15b4a5aca8d0dee59dd293e7b1c7272cdfbeea20 but has never been used. Remove it. Change-Id: I6089c5200737b9319a8e96f2a2fc18b7cdd6b2c6 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add missing options for 'server image create'Stephen Finucane2021-01-081-0/+6
| | | | | | | | Add a '--property' option to record arbitrary key/value metadata to 'meta_data.json' on the metadata server. Change-Id: I267f3290fce3692cbd1ff6a9af146c2736ee31fe Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add missing options for 'keypair list'Stephen Finucane2021-01-081-0/+68
| | | | | | | | | Add pagination parameters, '--limit' and '--marker'. This isn't compatible with our client-side '--project' parameter so we error out for that. Change-Id: I403cf0fb7aabad4a3dfda5adae62d47ecf7faf5c Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* compute: Add missing options for 'server set'Stephen Finucane2021-01-081-0/+32
| | | | | | | | | | | | | | Add a new '--no-password' option to unset the password on an existing server. In addition, add a new '--password' option that replaces the interactive '--root-password' option. This makes sense given no other commands uses interactive password options. Checks that rely on specific API microversions now run before we execute any action, to avoid situations where an update is only partially applied. Change-Id: Ibf8717efdd418a2d95215b4d9ab2acf0d57c4a70 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* Merge "compute: Add missing options for 'server list'"Zuul2021-01-081-2/+138
|\
| * compute: Add missing options for 'server list'Stephen Finucane2021-01-071-2/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | This accepts a large number of options that we weren't exposing. Add the following options: '--availability-zone', '--key-name', '--config-drive' and '--no-config-drive', '--progress', '--vm-state', '--task-state' and '--power-state'. In addition, refine the 'openstack server list --status' parameter to restrict users to the actual choices supported by the server. Change-Id: Ieeb1f22df7092e66a411b6a36eafb3e16efc2fc2 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | trivial: Use plural for appended parametersStephen Finucane2021-01-063-26/+26
| | | | | | | | | | | | | | | | | | Multiple compute commands take a '--property' parameter or variant thereof. These should be stored in a 'properties' (plural) dest for sanity's sake. Correct this. Change-Id: If393836925fa736404527d9abd212b8ac9931027 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | compute: Add 'server show --topology' optionYongli He2021-01-061-0/+49
| | | | | | | | | | | | | | | | Add support for compute microversion 2.78 by adding a '--topology' option to 'openstack server show' command that retrieves server NUMA information. Change-Id: Ie22979df2ea9082ca64a4d43b571bd4025684825