Commit Graph

65 Commits

Author SHA1 Message Date
René Ribaud ee9b277c5f Microversion 2.91: Support specifying destination host to unshelve
This patch adds ``host`` to novaclient api.
This can help administrators to specify a ``host``
to unshelve a shelve offloaded server from 2.91 microversion.

Depends-On: https://review.opendev.org/c/openstack/nova/+/831507
Implements: blueprint unshelve-to-host
Change-Id: I7efc8f0b0ef159e16cefee761bff5d7e90d0c427
2022-07-28 14:49:46 +02:00
Stephen Finucane 8066f8c745 Microversion 2.90 - Configurable hostnames
Change-Id: Icd4362a07196e59bafcdfaff44323ce1386d4f55
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Depends-On: https://review.opendev.org/c/openstack/nova/+/778550/
2021-09-02 11:01:07 +01:00
Takashi Natsume 7ef2c28bf3 Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I4d45ae17f6f84f945f5dd049a929216ce6b6b58e
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
2020-04-26 10:12:09 +00:00
Victor Coutellier 9ee74d3ac6 Microversion 2.83 - Add more filters for the nova list command
Add these new filters, admin-only until microversion 2.82:

- availability-zone
- config-drive
- key-name
- power-state
- task-state
- vm-state
- progress

Existing user filter will be available to non admin since microversion
2.83.

Part of blueprint non-admin-filter-instance-by-az

Change-Id: Id2b5e600c0a41790830823031b20983808cb5ace
2020-04-07 18:34:13 +02:00
Stephen Finucane b9a7e03074 Random cleanups
Remove some cruft from Sphinx config files, drop the use of 'u' prefixed
strings, which are unnecessary in Python 3, and generally tidy stuff up.

Change-Id: Ib0f33576e160ec842d7fc82b4fcfee99829623d7
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-02-21 09:56:37 +00:00
Stephen Finucane c4c44bcb2d Remove six
Mostly a find-replace job. Let's do this now so we don't have to carry
it for the next decade.

Change-Id: I7bef9fb7c6895f746cee1aca6522786f38b9857c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-02-21 09:48:38 +00:00
Yongli He aae95dcc7a Microversion 2.78 - show server topology
Add support microversion 2.78 which adds server topology
information in the output of the following new command:

  nova server-topology

Depends-on: https://review.opendev.org/#/c/621476/
Change-Id: I6467d52d2528a37348458baf4842b571a97f3ed2
Implements: blueprint show-server-numa-topology
2019-09-06 17:24:17 -04:00
zhangbailin ecfa521b21 Microversion 2.77: Support Specifying AZ to unshelve
This patch adds a new parameter ``--availability-zone`` to ``nova
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/#/c/663851/
Implements: blueprint support-specifying-az-when-restore-shelved-server

Change-Id: I8bce8f430bc54f03bacc105e37fc8b3bbf2432c2
2019-08-28 17:43:22 -04:00
zhu.boxiang 41c25881e6 Add host and hypervisor_hostname to create servers
Adds the --host and --hypervisor-hostname options to
the nova boot command and related python API bindings.

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

Change-Id: If16d00b75f4d5f2b96aa6e3f32a973108049d928
Blueprint: add-host-and-hypervisor-hostname-flag-to-create-server
2019-07-08 19:26:01 +00:00
Surya Seetharaman f78a4706d3 Allow passing negative values for the locked search_opt in cs.servers.list
This patch adds support for novaclient to pass the "locked" search_opts
with a "False" value upto the server side. This is required for the OSC
change[1] to support the "unlocked" filter parameter.

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

Related to blueprint add-locked-reason

Change-Id: I0907f4ad2decb308c9db8b0cf9e7962bf1b517b5
2019-05-22 11:06:52 -04:00
Surya Seetharaman a1ac69c69a Microversion 2.73: Support adding the reason behind a server lock
This patch adds a new parameter ``--reason`` to ``nova lock``
command and ``--locked`` filtering/sorting parameter to
``nova list`` command. This can help users to provide a reason
when locking the server and to filter/sort instances based on their
locked or value from 2.73 microversion.

Implements blueprint add-locked-reason
Depends-On: https://review.opendev.org/#/c/648662/

Change-Id: I438e6db2dd5000ba388d0a0f1c8ab74b96b47a71
2019-05-13 14:37:43 +02:00
Zuul 1ae9a85840 Merge "Fix output of interface-attach command" 2019-02-26 01:48:44 +00:00
Matt Riedemann 874b03068f Make Server.networks use a predictable sort order
This changes the Server.networks property method to return
an OrderedDict where the keys (network labels) are sorted
which will allow for a predictable sort order on the resulting
networks attached to a Server resource.

This affects the output of "nova list" and "nova show" commands
so a simple release note is added to mention the change.

Change-Id: I2e9b3c6a256509c045966035da24d58628f1b33b
2019-02-20 11:58:35 -05:00
Takashi NATSUME 7e56102201 Fix output of interface-attach command
Add output of a result in the 'nova interface-attach'
command when it is successful.
Make the following methods return a 'NetworkInterface'
object instead of a 'Server' object.

* The 'interface_attach' method
  in the 'novaclient.v2.Server' class
* The 'interface_attach' method
  in the 'novaclient.v2.ServerManager' class

Remove unnecessary code in the 'nova interface-detach'
command because the response body is not returned.

Change-Id: Id5316d8ad4a4b67e8399b51e602aafc83bc128c6
Closes-Bug: #1816511
2019-02-19 13:22:49 +09:00
Stephen Finucane 162f4769b8 Microversion 2.68: Remove 'forced' live migrations, evacuations
Update the commands and Python API bindings to reflect the new
microversion. The various evacuate microversion functions are DRY'd up
along the way.

Change-Id: Ibfc905292258ffde05800387e5d6bbad4823085c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Depends-On: https://review.openstack.org/#/c/634600/
Implements: blueprint remove-force-flag-from-live-migrate-and-evacuate
2019-02-13 21:15:23 +00:00
Zuul 58b3ac457a Merge "Replace MB with MiB" 2018-10-27 05:55:20 +00:00
Alessandro Pilotti 3a8d09ec77 Fixes Python3 issue in decoding password
The 'nova get-password' command shows a passowrd as bytes
instead of string in Python 3 currently.
It should be shown as string.
So fix it.

Co-Authored-By: Takashi Natsume <natsume.takashi@lab.ntt.co.jp>
Change-Id: Ibcfb071fcc3c74535b800295ec95ca5ec8bc3c9b
Closes-Bug: #1794167
2018-10-26 11:06:44 +09:00
Takashi NATSUME 80b4286981 Replace MB with MiB
Change-Id: Ie5bd325d8e0f7e9af76c1ddae1d679b0e797c84b
2018-10-22 07:11:25 +00:00
Matt Riedemann 4fef02de71 Add support for microversion 2.67: BDMv2 volume_type
This adds the nova boot command and python API binding
support for creating a server with block device mappings
defined using a specific volume type.

Depends-On: https://review.openstack.org/606398/
Depends-On: https://review.openstack.org/#/c/610349/

Part of blueprint boot-instance-specific-storage-backend

Change-Id: I484ee065119b5783db212ea64efa60e87c40338c
2018-10-14 05:34:24 -04:00
Jackie Truong 7f10707e5d Microversion 2.63 - Add trusted_image_certificates
This change adds a `--trusted-image-certificate-id` option to the
`nova boot` and `nova rebuild` commands. This option takes in a
a single trusted certificate ID. The option may be used multiple times
to specify multiple trusted certificate IDs, which will be
used to validate certificates in the image signature verification
process. If ID values are not specified using this option, the value of
the newly added OS_TRUSTED_IMAGE_CERTIFICATE_IDS environment variable
will be used instead. This value will be converted into a list before
being passed on.

The ``nova rebuild`` command also gets a new
``--trusted-image-certificates-unset`` option to unset/reset the
trusted image certificates in a server during rebuild. This is
similar to unsetting key_name and user_data during rebuild.

Corresponding `trusted_image_certificates` kwarg has been added to the
server create and rebuild Python API bindings.

Co-Authored-By: Brianna Poulos <Brianna.Poulos@jhuapl.edu>
Co-Authored-By: Matt Riedemann <mriedem.os@gmail.com>
Change-Id: I235541a689732826950c7b2a510d5835211120c3
Implements: blueprint nova-validate-certificates
2018-06-15 10:40:24 -04:00
Matt Riedemann abaa86fd86 Revert "Fix listing of instances above API max_limit"
This reverts commit eff607ccef.

There was no apparent need for the change being reverted since
user can list all servers by specifying --limit=1 when running
the nova list command.

The change introduced a problem whereby the first pass to
list instances from the server would get up to
[api]/max_limit (default 1000) results and then call again
with a marker. If the last instance in the list (the marker)
is corrupted in the instance_mappings table in the API DB
by not having an associated cell mapping, listing instances
will always fail with a MarkerNotFound error even though
the CLI user is not passing a marker nor specifying
--limit=-1. The corrupted instance mapping record resulting
in the MarkerNotFound error is something else that should
be fixed on the server side (and likely result in a 500) but
the change in behavior of the CLI makes it always fail
if you hit this even if you're not passing a marker.

Change-Id: Ibb43f500a74733b85bd3242592d36985bfb45856
Closes-Bug: #1773945
2018-06-05 19:57:49 +00:00
Jacek Tomasiak eff607ccef Fix listing of instances above API max_limit
Output of `nova list` command contained only `max_limit` entries even
when there were more. The list needs to be obtained in multiple
requests and the paging loop was terminated prematurely.

Change-Id: I4194e6d5e34ecc0ac704851c08bb895e223aa850
Closes-Bug: 1743532
2018-02-07 18:00:20 +01:00
Matt Riedemann 038cfdd5b3 Add support for the 2.57 microversion
With the 2.57 microversion, we:

* Deprecate the --file option from the nova boot and
  nova rebuild CLIs and API bindings.
* Add --user-data and --user-data-unset to the nova rebuild
  CLI and API bindings.
* Deprecate the maxPersonality and maxPersonalitySize fields
  from the nova limits and nova absolute-limits CLIs and API
  bindings.
* Deprecate injected_files, injected_file_content_bytes, and
  injected_file_path_bytes from the nova quota-show,
  nova quota-update, nova quota-defaults, nova quota-class-show,
  and nova quota-class-update CLIs and API bindings.

Part of blueprint deprecate-file-injection

Change-Id: Id13e3eac3ef87d429454042ac7046e865774ff8e
2018-01-15 14:42:53 +08:00
Matt Riedemann 01fb16533b Remove deprecated fixedip/floatingip/virtual interface CLIs/APIs
The add-fixed-ip, remove-fixed-ip, floating-ip-associate,
floating-ip-disassociate, and virtual-interface-list CLIs
and related python API bindings were deprecated in the 9.0.0
release in Pike via change Ie76283962c375b735f30ccb3053db07cf2330de2.
This removes the CLIs and related python API bindings and will go
into the 10.0.0 release.

Change-Id: Icb667973c65d26395db660b1c7b919550db66d08
2018-01-11 21:03:00 -05:00
Takashi NATSUME e5e8cebc81 Microversion 2.56 - Enable cold migration with target host
Change-Id: I4deea811ffae3e7944d5ec10ca0bbf2bfa056a7c
Implements: blueprint cold-migration-with-target-queens
2017-12-04 10:48:47 +09:00
Takashi NATSUME bef6765104 Microversion 2.54 - Enable reset keypair while rebuild
Adds support for microversion 2.54 which adds resetting keypair and
unsetting keypair in rebuild operation.
Adds optional ``--key-name`` and ``--key-unset`` options
in the ``nova rebuild`` command.
The ``--key-name`` and ``--key-unset`` cannot be specified
at the same time.

Change-Id: Ie2a39bb29dd59c070adc94e79ea0f6473227a427
Implements: blueprint rebuild-keypair-reset
2017-11-17 05:44:57 +00:00
Monty Taylor e24421b793 Stop posting to os-volumes_boot
os-volumes_boot is an old clone of /servers and is not documented in the
API docs. POST to /servers.

Change-Id: If0161a89877f19f24e91d780cf227fdc48e7e860
2017-11-16 11:25:50 -05:00
Jeremy Liu da44174c54 Fix reservation_id not supported by Nova API
Nova API accepts "return_reservation_id" instead of "reservation_id" when
creating instances [1]. This patch fixed that.

[1] https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/schemas/multiple_create.py#L19

Change-Id: Ie58248aa1cd981b877c7e592db698faffcd01d9a
Closes-bug: #1693818
2017-08-06 14:06:02 +08:00
Andrey Kurilin ec15bf30e7 Allow tuple as for nics value
`novaclient.servers.boot` accepts 'nics' argument with information about
network interfaces to attach. Originally, it accepts a list or a string.

In case if a list value, the proper method iterates over it for
processing and constructs a right structure for Nova-API. A tuple type
is similar to a list type in the processing method and can look more
logical for some developers (a tuple is a sequence of immutable python
object, which can be ideal for predefined nics) and doensn't require
anything to change in code except one validation check.

Also, this patch adds more info in the error message for validation
step.

Change-Id: Ief9d22fefb0a64afc346c56e832c6c0b2b3d8fcb
2017-07-27 15:57:19 +00:00
Kevin_Zheng 30c9215da7 Microversion 2.52 - Support tag when boot
Change-Id: Ib65894f0e128c599db8d3440fe5a8427e62d5782
Depends-On: Ifcaaf285c8f98a1d0e8bbbc87b2f57fbce057346
Implements: blueprint support-tag-instance-when-boot
2017-07-19 14:19:56 -04:00
Takashi NATSUME e11a1266bb Microversion 2.49 - Virt device tagged attach
Change-Id: I65a2d33710f85e9b8c342d6ff4c1e4cc82990b8c
Implements: blueprint virt-device-tagged-attach-detach
2017-07-12 01:16:31 +09:00
Matt Riedemann 603f0eae9f 2.45: createImage/createBackup image_id is in response body
This adds support for microversion 2.45 which changes the response
on the createImage and createBackup server action APIs to return
the image_id for the created snapshot image in a json dict in the
response body rather than in a Location header (which is gone in
microversion >= 2.45).

Since the 'nova backup' command was not printing out the created
image ID before, that is also added in this microversion.

Part of blueprint remove-create-image-location-header-response

Change-Id: Id48aa7b14e2d25008287549b04db437ca9c3f548
2017-04-26 09:32:59 -04:00
Matt Riedemann e303cf11bf 2.44: Deprecate multinic/floatingIP actions and os-virtual-interfaces
The 2.44 microversion deprecates the addFixedIP, removeFixedIP,
addFloatingIP, removeFloatingIP server action APIs and
os-virtual-interfaces API.

This change deprecates the CLIs and python API bindings in novaclient.

Implements blueprint deprecate-multinic-proxy-api

Change-Id: Ie76283962c375b735f30ccb3053db07cf2330de2
2017-04-25 21:11:47 -04:00
Matt Riedemann 0f46143f3b Remove deprecated floating_ips APIs
These were deprecated in Newton:

aaebeb05a0

The floating IP fixtures and GET API methods in the
manager are still used for testing the addFloatingIP
and removeFloatingIP server operations, so the manager
is moved to the test_servers module.

Change-Id: I2138e43160772c7c896bc5e93195a8169ebfe6c3
2017-03-20 19:26:58 -04:00
huangtianhua 2512a28dc1 Make _console() public
Heat wants to use 'novaclient.v2.servers.
ServerManager._console' method to simplify the
implementation of retrieving server console.
It's better to change the method to public for
public use.
The patch changes:
1. add public method named get_console_url() for class
   'novaclient.v2.servers.Server'
2. rename _console() to get_console_url() for class
   'novaclient.v2.servers.ServerManager'

Change-Id: I3d1485468d1d0a79d4002981ebe05b6cdf2332e7
Closes-Bug: #1651677
2017-01-18 09:36:43 +08:00
Jamie Lennox e88afc046b Clean up requests-mock usage
In line with other clients testing we've found that having the
requests-mock fixture at self.requests can be misleading for new people
as it looks like you're calling requests itself.

Also make use of some of the new features of requests-mock like query
parsing, json handling, method names.

Change-Id: Id61b88c53478d49f91c3f880ed5b90d638051ba0
2016-10-05 06:53:05 +11:00
Matt Riedemann 030ce53d4e Add support for v2.37 and auto-allocated networking
This adds support for the v2.37 microversion. The networks
part of the server create request is required in this
microversion so if nothing is specified for --nic arguments
on the command line we default to 'auto' for backward
compatibility in the CLI.

Part of blueprint get-me-a-network

Change-Id: I6636ddcd3be7bf393d2d69cc6c1ba5c7d65ff674
2016-08-19 21:32:52 -04:00
Clenimar Filemon adbfdd0aa2 Refactor test_servers APIVersion setup
Set APIVersion in the base test class instead of
in every derived test class.

Change-Id: Ifbc6af6f1e42033c9ad8923cb063d345e520fb00
Co-Authored-By: Andrey Kurilin <akurilin@mirantis.com>
2016-08-02 13:58:15 +00:00
Artom Lifshitz 7fb0bd4f35 Virtual device tagging client support
In order to support virtual device role tagging that was introduced in
microversion 2.32, this patch adds:

* The 'tag' key to the --nic flag when booting an instance.
* The 'tag' key to the --block-device flag when booting an instance.

Change-Id: I1866c670994254bc2849b494e318f4ff8cc44eb7
Implements: blueprint virt-device-role-tagging
2016-07-12 07:39:58 -04:00
Sylvain Bauza c649678991 Add support for microversion 2.30
Now the os-migrateLive API supports a new body argument called 'force' which
helps the operators to bypass the scheduler call in case they provide a host.

Also modifies the host_evacuate_live helper method in the contrib tree to make
sure operators also have the force flag in case they need it for a global call.

Change-Id: Id7fcd88ad060390ac6d1a21510d84363ed643957
Implements: blueprint check-destination-on-migrations-newton
2016-06-22 09:40:40 +02:00
Sylvain Bauza 1aa042e0cb Add support for microversion 2.29
Now the os-evacuate API supports a new body argument called 'force' which
helps the operators to bypass the scheduler call in case they provide a host.

Also modifies the host_evacuate helper method in the contrib tree to make sure
operators also have the force flag in case they need it for a global call.

Change-Id: I5272e9809a7d8be482e87548c6a3b11186c5d1e1
Partially-Implements: blueprint check-destination-on-migrations-newton
2016-06-22 09:40:33 +02:00
Andrey Kurilin f9bdba2dd7 Extend microversion stuff to support resource classes
Current implementation of novaclient.api_versions.wraps allow to use
versioned methods for shell functions and resource managers. As resource
managers can have versioned methods, resource objects can have it too, but
it was not implemented yet. This patch fixes this omission.

Changes:
 - Add api_version property to base resource class. It is mapped to
   api_version property of manager class;
 - Move `novaclient.utils.generate_function_name` to
   `novaclient.api_versions._generate_function_name`, since this method is
   specific to microversion stuff and should not used outside api_versions
   module;
 - Rewrite _generate_function_name to handle class(owner) name. Previously,
   it was improssible to have two classes in one module with versioned
   methods with equal names.
 - Remove call of generate_function_name from novaclient.shell. Shell module
   should not take care about function identifiers. get_substitutions accepts
   object with __id__ property now.
 - Mark _add_substitution as private method, since it should not be used
   outside api_versions module
 - Split all versioned methods of Server resource from novaclient.v2.servers
   module.

Change-Id: Icfce16bfa6f919d7f8451d592f4a8e276b1f1709
2016-06-16 05:57:59 +00:00
Sergey Nikitin 19ff19e1b8 Added functional tests for server tags (microverison 2.26)
Also fixed wrong shell output in 'server-tag-list'
and removes 'server-tag-show' command.

Change-Id: Icfd73e50108c7b1226e51307c0afc3f8f54ff2d6
2016-06-15 21:13:38 +03:00
Sergey Nikitin ff9b97b2c6 Added Support of microverison 2.26
This microversion allows to create/delete/update
server tags and to search servers by tags.

Implements: blueprint tag-instances

Change-Id: I66b6d4a763c507335f27a425bc3d4c2aae377c00
2016-05-18 17:36:17 +03:00
Jenkins f9360ae6d4 Merge "Provide user with coherent interface to get request_ids" 2016-03-02 13:05:05 +00:00
Eli Qiao ae598280ac [microversion] Bump to 2.25
microversion v2.25 will change parameter of os-migrateLive, this patch
adds supports to that changes.

os-migrateLive will abandon disk_over_commit and the default value of
block_migration will be set to `auto`

Depends-on: Ibb0d50f0f7444028ef9d0c294aea41edf0024b31
Implements: blueprint making-live-migration-api-friendly
Change-Id: I01b22593724616bc0a7793c509ecabf095d6927d
2016-03-02 17:24:17 +08:00
Andrey Kurilin 1d1e43957d [microversions] Add support for 2.19
2.19 - Allow the user to set and get the server description. The user will
       be able to set the description when creating, rebuilding, or updating
       a server, and get the description as part of the server details.

Methods `rebuild` and `create` of novaclient.v2.servers.ServerManager were
not wrapped with `api_versions.wraps` decorator to reduce code and docsting
duplication. Version checks added inside these methods.

Change-Id: I75b804c6edd0cdf02c2cd002d0b5968fec8da545
2016-02-16 16:20:41 +02:00
Cao Shufeng f535e6945b Provide user with coherent interface to get request_ids
Currently, users must use different interface to get request_ids.
1. Commonly, ListWithMeta, DictWithMeta or TupleWithMeta, etc is
returned to user. And request_ids is returned as an attribute of
*WithMeta.

    For a server delete action:
        result = serverManager.delete(server)
        # result = TupelWithMeta
        request_ids = result.request_ids

2. Some places reutrn a tuple which contains request_ids in one of
its elements.

    For a server stop action:
        result = serverManager.stop(server)
        # result = (Response, TupleWithMeta)
        request_ids = result[1].request_ids

Such kind of difference makes user confused.
This change provides a backwards compatibility solution for users
who don't care about request_ids as TupleWithMeta is subclass of
tuple.

Change-Id: I164bb95abce6dc96cf455033f02822ccb0d87b8f
Closes-Bug: 1542179
2016-02-15 09:49:33 +00:00
Takashi NATSUME f9aa277c62 Add return-request-id-to-caller function(1/5)
Add return-request-id-to-caller function to
'Server' resource and 'ServerManager'.
The methods in the resource class and resource manager return
a wrapper class that has 'request_ids' property.
The caller can get request ids of the callee via the property.

* novaclient/v2/servers.py

Co-authored-by: Ankit Agrawal <ankit11.agrawal@nttdata.com>
Change-Id: I8c2d3abcebba7823f42e2f27356e73bc6d7ade42
Implements: blueprint return-request-id-to-caller
2016-01-27 11:44:19 +09:00
Andrey Kurilin 6cbb22583b [microversions] Add support for 2.17
Description of microversion:
  Add a new API for triggering crash dump in an instance. Different operation
  systems in instance may need different configurations to trigger crash dump.

Note:
 - it is hard to write a functional test for this microversion, since it
   requires instance in error state
 - all possible failed responses already covered by novaclient.exceptions

Nova's change: I6ed777ff637254b4b79417008f9055dd19fc7405

Change-Id: If03b1864bbe7074c720b946fc2700bd5d07debc3
2016-01-25 14:24:49 +02:00