summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/compute
Commit message (Collapse)AuthorAgeFilesLines
* Merge "compute: Show flavor in 'server list' with API >= 2.47" into ↵Zuul2022-07-061-115/+201
|\ | | | | | | stable/victoria
| * compute: Show flavor in 'server list' with API >= 2.47Khomesh Thakre2021-12-081-115/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Conflicts: openstackclient/tests/unit/compute/v2/test_server.py NOTE(melwitt): The conflicts and differences from the cherry picked change are because the following changes are not in Victoria: * I4811f8f66dcb14ed99cc1cfb80b00e2d77afe45f (compute: Add 'server * --all-projects' option) * I7a8349106e211c57c4577b75326b39b88bd9ac1e (compute: Fix 'server * -f yaml' output) * I84848c0bf8ab3c36dd821141191e2725e4e3b58b (Remove usage of six) * Ieeb1f22df7092e66a411b6a36eafb3e16efc2fc2 (compute: Add missing options for 'server list') * If065602792958ff0145ae9f2e05f5b7a3177905c (Compute: Add tags support for server) * I25a4da697e27c0fba4d28b504377667eb18f15fe (compute: Add '--force' option to 'server delete') * I463993170c03a1d98c47ab6a3c19131b7fca1099 (Remove oslo.utils) * I18991adf899c7b72c98bb89871bf0715d35943f0 (Add a few selectable fields to the "openstack server list" output) * I62b2ed8488ee4ac9c42051311bcfb455506ddd90 (Switch compute flavors from novaclient/direct to SDK) Change-Id: Ica3320242a38901c1180b2b29109c9474366fde0 Signed-off-by: Khomesh Thakre <khomeshthakre24@gmail.com> Story: 2008257 Task: 41113 (cherry picked from commit 8e362402dee07744668bcf7f6774af4fbe9a07e3) (cherry picked from commit 0873e7580eceab07c3be0824d2ea4163491f8d6e) (cherry picked from commit 4b7e777c0ce19aa67a9a33cbeb3b4ee2b052383f)
* | compute: Add missing options for 'server group list'Stephen Finucane2022-07-041-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> (cherry picked from commit 5ec4d4c7188f4766d270be32e12b64b709d2b835)
* Validate 'server group create --policy' optionStephen Finucane2021-01-111-0/+43
| | | | | | | | | | | | We were documenting that some of these policies were only supported with specific microversions, however, we weren't actually enforcing that, leading to a poor user experience. Correct this. Change-Id: Ic3c555226a220efd9b0f27edffccf6c4c95c2747 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Story: #2007727 Task: #39882 (cherry picked from commit ab0b1fe885ee0a210a58008b631521025be7f3eb)
* Merge "Fix --image-property option in 'create server'"Zuul2020-10-011-0/+59
|\
| * Fix --image-property option in 'create server'Myeongchul Chae2020-09-101-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a problem that the '-image-property' option, which can be used to create an instance, did not work as intended. I found that there were two problems with this option. First, I cannot select an image as its metadata. The second is that when there are multiple images available, the desired image may not be selected depending on the situation. This patch solves these two problems. I wrote the test case with these two problems considered together. Change-Id: Ib2745d7e067056ff4ca8bfaf6cff492d0dacb73a story: #2007860
* | Merge "Add API check for server_groups.create"Zuul2020-09-301-0/+22
|\ \
| * | Add API check for server_groups.createLewis Denny2020-08-261-0/+23
| |/ | | | | | | | | | | | | | | | | | | | | | | | | The policies field has been replaced with the policy field since Nova API version 2.64[1] This commit adds a check to make sure the correct field is used. [1]https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id59 Change-Id: I06d3211937d822c26070b7f8ad757c365dcbb1bb Story: #2007822 Task: #40101
* | Merge "Add API check for server_groups.list"Zuul2020-09-302-2/+131
|\ \
| * | Add API check for server_groups.listLewis Denny2020-08-212-2/+131
| |/ | | | | | | | | | | | | | | | | | | | | | | | | The policies parameter has been replaced with the policy parameter since Nova API version 2.64[1] This commit adds a check to make sure the correct parameter is used. [1]https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id59 Change-Id: Ia37beb7790884d6d15bec45074f446e64af1a2aa Story: #2008041 Task: #40703
* | Merge "Show words indicating booted from volume for server image"Zuul2020-09-301-4/+4
|\ \
| * | Show words indicating booted from volume for server imagemelanie witt2020-08-271-4/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | For a server booted from a volume, nova API does not store an image_id and instead returns an empty string. Currently, openstackclient similarly shows an empty string for Image Name and Image ID for servers booted from volumes. To aid CLI users in understanding the meaning of no image_id, we can display the string "N/A (booted from volume)" in the image field if the server was booted from a volume. Change-Id: I9c62cf6fe23b2e934dcbf5ebbf706b2705d2e424
* | Merge "Output correct json for security groups in 'openstack server show'"Zuul2020-09-251-0/+3
|\ \
| * | Output correct json for security groups in 'openstack server show'jay2020-09-141-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Fixes incorrect json output for 'openstack server show -f json'. The security group json output groups all the json as one for e.g. "security_groups": "name='group1'\nname='group2'" The correct output should be "security_groups" : [{"name" : "group1"}, {"name" : "group2"}] properties and volumes_attached fields also has similar issue. Story: 2007755 Change-Id: I1b1cac716329e0530400aff782c08000b21d8e1d
* | Allow openstack flavor set to update flavor description using nameGabriel Ramirez2020-06-101-0/+36
|/ | | | | | | | | | | Modified take_action() method for SetFlavor to use flavor id instead of flavor name when setting description Closes-Bug: #1844708 Story: #2007781 Task: #40019 Change-Id: If6798c89fef4c9feb4ebb460722b891f5655037d
* Correct image lookup during server rebuildAdam Harwell2020-05-041-0/+36
| | | | | | | | | | | | The switch to using glance from the SDK accidentally used get_image directly during a server rebuild, when it should have used find_image to match existing functionality. Bug introduced in: I36f292fb70c98f6e558f58be55d533d979c47ca7 Change-Id: I2005bd40a1bd6719670c7f7854316b4f9801b140 Story: 2007620 Task: 39643
* Switch image to use SDKArtem Goncharov2020-03-233-85/+81
| | | | | | | | | | | | | This is a work to switch OSC from using glanceclient to OpenStackSDK. With this change only v2 is using OpenStackSDK. V1 is still using glanceclient and will be switched in a separate change. Remove the direct depend on keystoneauth- let that flow through openstacksdk. Depends-on: https://review.opendev.org/#/c/698972 Change-Id: I36f292fb70c98f6e558f58be55d533d979c47ca7
* Stop silently ignoring invalid 'server create --hint' optionsStephen Finucane2020-02-031-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The '--hint' option for 'server create' expects a key-value pair like so: openstack server create --hint group=245e1dfe-2d0e-4139-80a9-fce124948896 ... However, the command doesn't complain if this isn't the case, meaning typos like the below aren't indicated to the user: openstack server create --hint 245e1dfe-2d0e-4139-80a9-fce124948896 Due to how we'd implemented this here, this ultimately results in us POSTing the following as part of the body to 'os-servers': { ... "OS-SCH-HNT:scheduler_hints": { "245e1dfe-2d0e-4139-80a9-fce124948896": null } ... } Which is unfortunately allowed and ignored by nova due to the use of 'additionalProperties' in the schema [1] Do what we do for loads of other options and explicitly fail on invalid values. This involves adding a new argparse action since none of those defined in osc-lib work for us. This is included here to ease backporting of the fix but will be moved to osc-lib in a future patch. [1] https://github.com/openstack/nova/blob/19.0.0/nova/api/openstack/compute/schemas/servers.py#L142-L146 Change-Id: I9e96d2978912c8dfeadae4a782c481a17cd7e348 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Story: #2006628 Task: #36840 Related-Bug: #1845322
* Raise flake8-import-order version to latestSean McGinnis2020-01-1013-19/+20
| | | | | | | | | | | We had this library capped at a release that is a few years old. Now that we have dropped py2 testing, we can pick up the latest version. This uncovered a few things to clean up. Mostly the fact that mock is now a part of the StdLib unittest since Python 3.3. Change-Id: I27484dd4c25378413ff16e97a35a1a46062357bc Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* Provide stderr in exception when check_parser failsMatt Riedemann2019-11-201-1/+2
| | | | | | | | | | | | | | | | | | | | For negative tests that are asserting an argparse failure it would be useful to assert the specific reason for the failure in the test rather than just getting an exception, especially to avoid false positives in the tests when what is being tested and failing isn't the actual expected reason for the failure. This wraps the check_parser code that parses the args and mocks sys.stderr so we can trap that output and put it in the exception message that gets raised to the test. As a result, we can tighten up a test that was passing before for the wrong reason [1]. [1] https://review.opendev.org/#/c/673725/12/openstackclient/tests/unit/compute/v2/test_server.py@605 Change-Id: I0f1dc1215bdfb3eba98ccaf66a0041d220b93812
* Microversion 2.79: Add delete_on_termination to volume-attach APIzhangbailin2019-11-191-0/+172
| | | | | | | | | | | | | Added ``--disable-delete-on-termination`` and ``--enable-delete-on-termination`` options to the ``openstack server add volume`` command that enables users to mark whether to delete the attached volume when the server is destroyed. Depends-On: https://review.opendev.org/#/c/681267/ Part of blueprint support-delete-on-termination-in-server-attach-volume Change-Id: I6b5cd54b82a1135335a71b9768a1a2c2012f755b
* Microversion 2.77: Support Specifying AZ to unshelvezhangbailin2019-09-031-0/+54
| | | | | | | | | | | | | This patch adds a new parameter ``--availability-zone`` to ``openstack server unshelve`` command. This can help users to specify an ``availability_zone`` to unshelve a shelve offloaded server from 2.77 microversion. Depends-On: https://review.opendev.org/679295 Implements: blueprint support-specifying-az-when-restore-shelved-server Change-Id: Ia431e27c2a17fe16466707cc362532860ecf22df
* Merge "Bump hacking version"Zuul2019-08-281-1/+1
|\
| * Bump hacking versionStephen Finucane2019-08-271-1/+1
| | | | | | | | | | | | | | | | Pick up newer versions of this library. Thankfully no serious changes are needed. Change-Id: I69e523844529fc1c8aa0c1ce764182dbe29cfeb6 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | Format aggregate command fields and de-race functional testsDean Troyer2019-08-261-18/+23
| | | | | | | | | | | | | | | | | | Rename metadata to property in all aggregate commands Beef up functional tests to reduce street racing Change-Id: I4598da73b85a954f3e6a3981db21891b45d9548c Signed-off-by: Dean Troyer <dtroyer@gmail.com>
* | Merge "Add 'openstack server resize (confirm|revert)' commands"Zuul2019-08-201-2/+80
|\ \
| * | Add 'openstack server resize (confirm|revert)' commandsStephen Finucane2019-08-091-2/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are currently exposed as flags on the 'openstack server resize' command but they are in fact operation and should be exposed as commands in their own right. The old flag-based variants are deprecated for removal in 4.0. Change-Id: I733796d3bda6c3755a3d3548bbe695abb474a6a0 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
* | | Merge "Add openstack server create --boot-from-volume option"Zuul2019-08-201-0/+27
|\ \ \ | | |/ | |/|
| * | Add openstack server create --boot-from-volume optionMatt Riedemann2019-08-091-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a --boot-from-volume option to the server create command which is used with the --image or --image-property option and will create a volume-backed server from the specified image with the specified size. Similar to the --volume option, the created root volume will not be deleted when the server is deleted. The --boot-from-volume option is not allowed with the --volume option since they both create a block device mapping with boot_index=0. Change-Id: I88c590361cb232c1df7b5bb010dcea307080d34c Story: 2006302 Task: 36017
* | | Fix compute service set handling for 2.53+Matt Riedemann2019-08-091-4/+100
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With compute API microversion 2.53 there is a single PUT /os-services/{service_id} API which takes the service id as a UUID. Since the openstack compute service set command only takes --host and --service (binary) to identify the service, this change checks if 2.53 or greater is being used and if so, looks up the service by host and binary and calls the appropriate methods in novaclient. If the command cannot uniquely identify a compute service with the given host and binary, an error is raised. A future change could add an --id option to be used with 2.53+ to pass the service id (as UUID) directly to avoid the host/binary filtering. Change-Id: I868e0868e8eb17e7e34eef3d2d58dceedd29c2b0 Story: 2005349 Task: 30302
* | Merge "Add host and hypervisor_hostname to create servers"Zuul2019-07-231-0/+231
|\ \
| * | Add host and hypervisor_hostname to create serverszhu.boxiang2019-07-191-0/+231
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the --host and --hypervisor-hostname options to ``openstack server create`` CLI. Depends-On: https://review.opendev.org/670558 Change-Id: If188c3d96fa506dbe62ef256418f2f9bca1520c2 Blueprint: add-host-and-hypervisor-hostname-flag-to-create-server
* | | Fix BFV server list handling with --name-lookup-one-by-onemelanie witt2019-06-281-8/+26
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the --name-lookup-one-by-one option passed to the 'server list' command, the image and flavor names will be looked up for each server being listed instead of fetching all image/flavor names. The current code assumes all servers have an image attribute, but servers booted from volumes have no image, so the following error is raised when listing BFV servers with --name-lookup-one-by-one: AttributeError: ('unicode'|'str') object has no attribute 'get' The error occurs when the code attempts server.image.get('id'). This fixes the --name-lookup-one-by-one code not to assume an image for a server. The unit tests for 'server list' have also been robustified to feature one BFV server to enhance our test coverage. Story: #2006063 Task: #34777 Change-Id: I312c971346c7ded93f6fcaa515098554b8580295
* | Use cliff formattable columns in image commandsAkihiro Motoki2019-06-222-8/+10
| | | | | | | | | | | | | | | | | | | | Related functional tests are converted into JSON format. Otherwise, it is not easy to check results. Partial-Bug: #1687955 Partially implement blueprint osc-formattable-columns Change-Id: Ib82e15738544975fede0c54cc5eaf239f4c67277
* | Merge "Microversion 2.73: Support adding the reason behind a server lock"Zuul2019-06-211-1/+148
|\ \
| * | Microversion 2.73: Support adding the reason behind a server lockSurya Seetharaman2019-06-211-1/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a new parameter ``--reason`` to ``openstack server lock`` command and ``--locked``, ``unlocked`` filtering parameters to ``openstack server list`` command. This can help users to provide a reason when locking the server and to filter instances based on their locked value from 2.73 microversion. Implements blueprint add-locked-reason Depends-On: https://review.opendev.org/#/c/661785/ Change-Id: Ib2714f98b24d47e570da8a6c231e765acd2ff595
* | | Allow "server migrate" (not live) to take "--host" optionMartin Chlumsky2019-06-211-5/+33
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | Currently, doing a cold migration while specifying a target host is not possible however nova api supports it since version 2.56. This patch allows passing "--host" when doing a cold migration. It runs normally if --os-compute-api-version is 2.56 or greater and returns an error otherwise. Change-Id: I960109008096ce8bb4e4c8ca6ffb22c33aacd995 Story: 2003325 Task: 24359
* | Merge "Deprecate openstack server migrate --host option"Zuul2019-06-061-1/+157
|\ \
| * | Deprecate openstack server migrate --host optionMatt Riedemann2019-05-241-1/+157
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Per the discussion at the Train Forum [1] this deprecates the problematic --live option on the server migrate command which, depending on the compute API version used, forcefully bypasses the scheduler and also does not allow you to live migrate a server and let the scheduler pick a host. The --live option is replaced here with two new options: * --live-migration: this simply tells the command you want to perform a live rather than cold migration; if specified with --live the --live-migration option takes priority. * --host: when specified, this will request a target host for the live migration and will be validated by the scheduler; if not specified, the scheduler will pick a host. This option is mutually exclusive with --live. We can build on the --host option by supporting cold migrations with a specified host when using compute API version 2.56 or greater but that will come in a separate change. If the --live option is ever used we log a warning. Note there are several related changes for this issue: - https://review.openstack.org/#/c/628334/ - https://review.openstack.org/#/c/626949/ - https://review.openstack.org/#/c/627801/ - https://review.openstack.org/#/c/589012/ - https://review.openstack.org/#/c/460059/ This change allows us to deprecate the --live option and provide a replacement which is backward compatible without having to use something potentially error-prone like nargs='?'. Closes-Bug: #1411190 [1] https://etherpad.openstack.org/p/DEN-osc-compute-api-gaps Change-Id: I95d3d588e4abeb6848bdccf6915f7b5da40b5d4f
* | Merge "Add changes-before attribute to server list"Zuul2019-06-061-0/+66
|\ \
| * | Add changes-before attribute to server listzhangbailin2019-05-311-0/+66
| |/ | | | | | | | | | | | | Closes-Bug: #1827844 Part of bp support-to-query-nova-resources-filter-by-changes-before Change-Id: I4f28168188973730247bcbcb70ba0e70eb81e3be
* | Merge "Compute: Add description support for server"Zuul2019-06-051-0/+223
|\ \ | |/ |/|
| * Compute: Add description support for serverChen2019-05-171-0/+223
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds functionality to configure server's description with: 1 server create 2 server set 3 server unset 4 server rebuild Change-Id: Ic06d97b29e51828b29d7ac5172645c288e4ada9e Story: 2002005 Task: 19640
* | Merge "API microversion 2.69: Handles Down Cells"Zuul2019-03-071-0/+44
|\ \
| * | API microversion 2.69: Handles Down CellsSurya Seetharaman2019-03-061-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch explicitly points out the change needed while forming the detailed lists for servers. In those cases where the server response for ``openstack server list`` has the flavor and image keys missing for the instances in the down cell, the servers will be skipped from being processed. Depends-On: https://review.openstack.org/591657/ Related to blueprint handling-down-cell Change-Id: Ibcfe9febdc45db1cb86c6e88f65976feceb01c02
* | | Merge "Add support for get details of Quota"Zuul2019-03-071-0/+32
|\ \ \
| * | | Add support for get details of QuotaSławek Kapłoński2019-02-241-0/+32
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | With passing "--detail" argument to "openstack quota list", details about current usage should be returned. It is currently supported by Nova and Neutron so details of resources from those projects can be returned. Change-Id: I48fda15b34283bb7c66ea18ed28262f48b9229fe Related-Bug: #1716043
* | | Paginate over usage list to return all usagesPavlo Shchelokovskyy2019-02-282-0/+27
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | since nova api 2.40 the os-simple-tenant-usage API supports pagination and will by default return a number of entities configured internally in Nova. This means that when there are many enough projects, the single call to usage.list() will not return usages for all projects. This patch effectively copy-pastes the logic to paginate over usage list results from novaclient/v2/shell.py code. Change-Id: I1b639fe386b7b7db3223f6965495094b9d51533a Story: #2005099 Task: #29713
* | Merge "Add --name-lookup-one-by-one option to server list"Zuul2018-11-081-1/+29
|\ \
| * | Add --name-lookup-one-by-one option to server listPavlo Shchelokovskyy2018-11-021-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | usually in a big cloud there are many images and flavors, while each given project might use only some of those. This patch introduces '--name-lookup-one-by-one' argument to server list command (mutually exclusive with '--no-name-lookup') When provided (or either '--image' or '--flavor' is specified) to the `server list` command, name resolving for corresponding entity is now using targeted GET commands instead of full entities list. In some situations this can significantly speedup the execution of the `server list` command by reducing the number of API requests performed. Change-Id: I59cbf3f75c55e5d3747654edcc9be86ad954cf40 Story: #2002039 Task: #19682