Commit Graph

49 Commits

Author SHA1 Message Date
Takashi NATSUME 81ec72ecf8 Remove deprecated methods and properties
Remove deprecated methods, properties and unused classes.

Change-Id: I16e0b6e55a9c9da04c4582f9be672018d37bf368
2019-07-04 04:06:42 +00: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
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
Matt Riedemann daa9bdc823 Remove support for non-keystone auth systems
The support for non-keystone auth systems and plugins
was deprecated with 1f11840dd8
back in the 3.1.0 release in mitaka.

Now that we're working on shoring up the support for
keystone auth sessions in the client and eventually moving
to remove support for the non-session HTTPClient, we should
also remove the support to load non-keystone auth plugins.

The whole concept of non-keystone auth systems/plugins is
a legacy artifact and is a barrier to interoperability which
is a goal of nova and OpenStack in general.

Change-Id: Ia649db257c416ca054977812ecb3f1a8044fa584
2016-10-20 12:04:58 -04:00
Matt Riedemann fa377e7fca Handle error response for webob>=1.6.0
WebOb change https://github.com/Pylons/webob/pull/230 changed
the way in which the error response body is formatted such that
it's no longer a nested dict. So we have to handle both the
old convention of an error message key to the response body error
dict and the new way with just the error body dict.

This was reported upstream:

https://github.com/Pylons/webob/issues/235

But given this was apparently implemented as a long-overdue change
in WebOb the behavior is not likely to change.

Change-Id: If653a247d842786d2824b4b3a5c0cde1383ed7ab
Closes-Bug: #1559072
2016-03-18 19:22:03 -04: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
Andrey Kurilin 0d0749d39f Make _poll_for_status more user-friendly
NOTE: _poll_for_status is a private method, which is used only in shell
      module, so we can modify it without backward compatibility.

_poll_for_status is used for various resources with different interfaces.

In case of snapshotting, it works with Image resources, which doesn't have
"fault" attribute in "error" state. To prevent AttributeError, we should take
this into account.

Also, an exception raised by _poll_for_status(InstanceInErrorState) should
not be hardcoded for one type of resource, so this exception is renamed to
ResourceInErrorState. An exception InstanceInDeletedState, which is also
can be raised by _poll_for_status, is not modified, since I don't know cases
when it can be used with resources other than Server.

Change-Id: Ie0ee96999376cbf608caa1cf8521dbef5c939b52
Closes-Bug: #1538073
2016-02-04 20:06:43 +02:00
hgangwx 2283b46a2f Wrong usage of "a/an"
Wrong usage of "a/an" in the messages:
"It will be deprecated after an suitable deprecation"
"Delete metadata from an server"
"Get a list of actions performed on an server"
"based on an requests response"
"Get a aggregate by name or ID"

Should be:
"It will be deprecated after a suitable deprecation"
"Delete metadata from a server"
"Get a list of actions performed on a server"
"based on a requests response"
"Get an aggregate by name or ID"

Totally 5 occurrences in python-novaclient base code.

Change-Id: Iabe764f8b547b39431deb34221266695e0e79fa9
2015-12-30 15:05:50 +08:00
Monty Taylor 1f11840dd8 Migrate to keystoneauth from keystoneclient
As a stepping stone to the os-client-config patch, first switch to
using keystoneauth, its Session and its argparse registration and
plugin loading to sort out any issues with that level of plumbing.
The next patch will layer on the ability to use os-client-config
for argument processing and client construction.

Change-Id: Id681e5eb56b47d06000620f7c92c9b0c5f8d4408
2015-12-12 20:39:57 -08:00
Matt Riedemann 63c7a576e1 Revert "Do not expose exceptions from requests library"
This reverts commit 2961e82bfa

This broke cinder unit tests that have a timeout test for novaclient
where they mock the requests library raising a Timeout exception. That
test expects to get a requests Timeout passed through but with the
change being reverted it was getting a RequestTimeout exception from
novaclient, which breaks the test and fails the gate runs.

We could change the cinder unit test to handle both the requests.Timeout
and the new novaclient RequestTimeout, but that's just papering over
the cinder failure, we wouldn't know what other clients are failing
in the same way because they have code working around the requests
exceptions getting passed through, so we should treat this like an API
change.

I'd be in favor of making the same change again iff the novaclient
exceptions extended the requests exception types so it would be transparent
to consumers, since novaclient.exceptions.RequestTimeout would be a
requests.Timeout via inheritance. But given the gate breakage and it being
summit week I'm inclined to revert first and think about a better long term
fix later when people are back to discuss.

Change-Id: I368728588e5997eef860a168539eb66c58f2e72a
Closes-Bug: #1510790
2015-10-28 07:27:40 -07:00
Jason Dunsmore 2961e82bfa Do not expose exceptions from requests library
Novaclient expects the requests library to always be able to get a
response back and doesn't handle other cases where it might raise
an exception even before the request is completed (e.g.
ConnectionError).

These exceptions should be captured and properly converted to some
native novaclient exception.

Change-Id: Iec7247b715c38c29910b30e76413cead4e951a37
Co-Authored-By: Kuo-tung Kao <jelly.k@inwinstack.com>
Closes-Bug: #1406586
2015-10-22 14:34:23 -05:00
wangxiyuan ba79073d7b Add 'deleted' status check in _poll_for_status
When use command '--poll' to show progress, if the object's staus change
into 'deleted' for some reason, it will lead a endless loop.Becasue there
is no check about 'deleted' status.

For example, when use 'image-create --poll' to create a vm's snapshoot,
if glance's quota is small than the snapshoot, the image will be deleted.

Change-Id: I028e3064b3371f87873d74494c39255775a2c818
Closes-bug:#1470047
2015-07-28 11:05:04 +08:00
Andrey Kurilin 936cf572df Implements 'microversions' api type - Part 2
New decorator "novaclient.api_versions.wraps" replaces original method with
substitution. This substitution searches for methods which desire specified
api version.

Also, this patch updates novaclient shell to discover versioned methods and
arguments.

Related to bp api-microversion-support
Co-Authored-By: Alex Xu <hejie.xu@intel.com>
Change-Id: I1939c19664e58e2def684380d64c465dc1cfc132
2015-07-25 15:57:17 +08:00
Andrey Kurilin ea0b3bd608 Implements 'microversions' api type - Part 1
Compute API version will be transmitted to API side via
X-OpenStack-Nova-API-Version header, if minor part of version is presented.

New module "novaclient.api_versions" was added as storage for all api versions
related functions, classes, variables and etc.

`novaclient.api_versions.APIVersion` class is similar to
`nova.api.openstack.api_version_request.APIVersionRequest`. The main
difference relates to compare methods(method `cmp` is missed from Py3) and
processing "latest" version.

Related to bp api-microversion-support

Change-Id: I0e6574ddaec11fdd053a49adb6b9de9056d0fbac
2015-07-16 16:06:28 +03:00
Michal Dulko 310b87ecbb Add retry_after only to exceptions supporting it
Having retry_after in HTTP response header for 403 status code caused
client to fail with TypeError exception about unexpected keyword
argument. This is related to bug in nova-api. To prevent this kind of
client problems in the future patch adds check to from_response
function to pass retry-after header only to classes that inherit
from RetryAfterException and regression unit tests.

Change-Id: I6bfc8b33eb591d30b3c647397b11100094718e13
Closes-Bug: 1365251
2014-09-18 13:07:17 +02:00
Jenkins 5095d276ef Merge "Sync apiclient from oslo-incubator" 2014-07-25 12:57:04 +00:00
Russell Bryant d678dd2955 Revert "Reuse exceptions from Oslo"
This reverts commit 3bde9c3f42.

This change is a part of a series that is not backwards compatible.
It broke applications using the client library.

Change-Id: Id01a0a0feb601539d3855f445ebaf6a3cc000610
Partial-Bug: #1340596
2014-07-14 09:43:44 -04:00
Russell Bryant e14f9741a6 Revert "Set default http-based exception as `HttpError`"
This reverts commit 4e1ee66108.

This change is a part of a series that is not backwards compatible,
and caused breakage in applications that use the client library.

Change-Id: If614826fb0832602110c1ac8be2c0e6324a5a248
Partial-Bug: #1340596
2014-07-11 13:30:25 -04:00
Jamie Lennox cc7364067f Allow us to use keystoneclient's session
The session object is a cross-client means of standardizing the
transport layer.

Novaclient's HTTPClient object has diverged significantly from other
clients. It is easier to simply replace it if a session is provided. If
a session is provided then users of the library need to be aware that
functions such as authenticate() will no longer have any effect/are in
error because this is no longer managed by nova.

Change-Id: I8f146b878908239d9b6c1c7d6cdc01c7e124f4e5
2014-07-01 16:53:47 +01:00
liyingjun 52c5ad2ead Sync apiclient from oslo-incubator
Need to sync the latest apiclient from oslo-incubator to make nova
cli cache work. Command used:
python update.py --base novaclient --dest-dir ../python-novaclient/ \
--modules apiclient

syncd patches:

apiclient:
  * 12341ef504 Merge "Restore UUID and human-ID bash completion"
  * 468afcb335 Merge "Don't slugify names that don't exist"

Change-Id: Iec2ad851b47628c5dde4272f438cce4150e11912
Close-bug: 1337033
2014-06-26 05:15:53 +08:00
Andrey Kurilin 4e1ee66108 Set default http-based exception as `HttpError`
Since exceptions from oslo is used, ClientException doesn't have any
attributes related to HTTP, so `HttpError` should be set as default
http-based exception.

Also, attribute `code` is used in several project, so it should be
returned and marked as deprecated.

Partial-Bug: #1322183
Change-Id: I3c71e2d25d6e36b5bac0f2b3add74d6747cf7c25
2014-05-22 16:48:24 +03:00
Andrey Kurilin 3bde9c3f42 Reuse exceptions from Oslo
- Remove unused exceptions from novaclient.exceptions
- Reuse exceptions from common code

OpenStack clients which already use exception from common code:
- ironicclient   - I784007f36dd6a63fc4c77e0d0f0f000e05eb792f
- keystoneclient - Iedf4e5d753d4278d81751ba0f55fdef3566b56de
- saharaclient
- tuskarclient   - Iacbf219168fae62d864c6594dd41e0737e848cfa

Similar patches in other clients related to reusing exceptions
from common code:
- cinderclient   - I07f04ba5357e0196fe43b510e1d2fff5afa02faa
- glanceclient   - I9838391cff7e450f08d27668564b02e63259186c

Related to blueprint common-client-library-2

Change-Id: Ia35d65d57a0047f88a609070f8b4c76215cbd3e9
2014-04-25 16:00:13 +03:00
Jenkins 2005e17bed Merge "Raise exception when poll returns error state" 2014-04-02 20:10:36 +00:00
Ryan Hallisey d01b3abdb0 Raise exception when poll returns error state
When running nova boot --poll, any error states that occur will be
seen but, an exit code of 0 will be returned indicating success.
This would be problematic for scripts looking to see if an
operation completed successfully.

To fix this, an exception is raised after the nova api indicates to the
poll code that the vm is in an error state. The exceptions signals the shell
main function to exit with code 1.

Change-Id: I48f6b1c82e2f8b221dda898dcb804b0196018505
Fixes-Bug: #1292669
2014-03-21 11:59:58 -04:00
Johannes Erdfelt e43825bd1c Print a useful message for unknown server errors
If a server error is returned that has an unknown code, novaclient will
end up printing something similar to:

ClientException: <attribute 'message' of 'exceptions.BaseException' objects>

Setting a message for ClientException will ensure that something more
useful than that is printed.

Change-Id: I43a2a33017f9a5c1b79d7fd8af4153e91d296f7b
Closes-bug: 1295293
2014-03-20 15:54:19 -07:00
zhang-jinnan ca721d6e9b Remove None for dict.get()
Because If no default value is specified it defaults to None already.

Change-Id: I3caad9f17840347e30465c7bd4c9c4fe53d991e3
2014-02-19 21:02:11 +08:00
Sushil Kumar 953734d727 Enables H403 pep8 rules
Updates tox.ini to reduce ignored rules.

Updates code for H403 violation.

Change-Id: Iee7b34a27c62ce8cb0f26166b3c16e3386e2fecd
2013-12-14 15:16:20 +00:00
Chris Yeoh 50685437ed Enable hacking check for Apache 2.0 license
Removes H102 (license header not found) check from flake8
ignore list.

Adds missing apache license headers.

Change-Id: I109f23c6d8b2e3efb1dac7f764bd77e0d9d335f0
2013-12-06 10:47:41 +10:30
Kui Shi f1c3b79c2b py33: 'dict_keys' object does not support indexing
In python 3, dict.keys() is a class of 'dict_keys', it does not
support indexing.

Cast the dict to list to get the "first" value of dict, which is
compatible with python 2&3.

Closes-Bug: #1229005

Change-Id: I561b7ada9e5ad936659a657b3161a9b93a15a788
2013-09-22 23:55:46 +08:00
Jiajun Liu 1b5ed91650 recognize 429 as an rate limiting status
currently novaclient recognize 413 as rate limiting status while
it shoule be 429 according to HTTP protocol.

fixes bug 1191874

Change-Id: Ib1ae54f7d13d0ca579dd264e8d0d7630770e92d6
2013-07-17 02:32:29 +00:00
Brian Waldon f2559c4c39 Add MethodNotAllowed and Conflict exception classes
It is expected to recieve a 405 or a 409 from Nova, but novaclient presents
them as a generic ClientException. This patch adds MethodNotAllowed
and Conflict classes to represent these HTTP responses.

Change-Id: If89cee04ebd74daaa28ea30b5c57cdc63edc1551
2013-05-26 08:14:32 -07:00
Brian Waldon eae3d724c0 Expose retry_after attribute of OverLimit exception
Fixes bug 1174469

Change-Id: Ic1e67f6f91d4fe2072ff68dfb36330cd86c1d5b4
2013-04-29 13:47:57 -07:00
Brian Waldon 201b74b6cc Clean up exceptions.from_response
Change-Id: I359a911c0813697f091517de493be403e8c1d8a3
2013-04-29 11:33:32 -07:00
Sean McCully 0614ae75f6 ClientExceptions should include url and method
Fixes Bug 1103557.
novaclient abstracts out http request from user/client
making it unknown to user what root cause behind nova client
exceptions being raised. By including url and method in exception
handling, this allows user to handle accordingly.

Change-Id: I1a509bb932b3fd029bd0870ab699a39e21da19bb
2013-01-23 11:33:42 -06:00
Dean Troyer aa1df04bad Use requests module for HTTP/HTTPS
* Implement correct certificate verification
* Add --os-cacert
* Rework tests for requests

Pinned requests module to < 1.0 as 1.0.2 is now current in pipi
as of 17Dec2012.

Blueprint: tls-verify

Change-Id: I9a25a94c8dfcaf483c4c8328439809d65cf10b38
2012-12-20 13:04:46 -06:00
Andrew Laski 8cff1a20bc Add ConnectionRefused exception.
When novaclient gets a Connection Refused it now presents that as a
ConnectionRefused exception with appropriate information rather than as
an HTTP exception.  Addresses bug 1047078.

vagrant@precise64:/opt/stack/python-novaclient$ nova image-list
ERROR: ConnectionRefused: '[Errno 111] Connection refused'

Change-Id: Iebf4d78a524004d5e79d2219b35f90fbd38ee690
2012-09-07 16:04:54 -04:00
Chmouel Boudjnah 86c713b17a Allow different auth providers via plugin system.
- Remove the NOVA_RAX_AUTH hack and provide (temporary) compatibility
  with the new system.
- Example plugin for RAX and HP provided here :
    RAX - https://github.com/emonty/rackspace-auth-openstack
    HP - https://github.com/emonty/hpcloud-auth-openstack
- Plugin are allowed to specify their own auth_url directly.
- Thanks to mtaylor for helping on this.

Change-Id: Ie96835be617c6a20d9c3fc3bd1536083aecfdc0b
2012-08-06 09:10:00 +02:00
Alex Meade 1602966185 Display the request id on error response.
This changes displays the request id when an error code is returned
from the API.

Change-Id: I70621fe7477a4612334af32e83f3ee8c5340371d
2012-04-11 15:00:49 -04:00
Rick Harris 0028eb4ac2 Request ID when name is ambiguous.
Fixes bug 931605

Change-Id: If0778915d964995dbb6647d56ed21075aec08baa
2012-04-09 21:13:57 +00:00
Ziad Sawalha 38bc7ea570 Handle Ambiguous Endpoints Correctly
- Added --service_name argument to allow selecting
  endpoints by service name
- Renamed endpoint_name argument to endpoint_type (this breaks
  compatibility)
- Return AmbiguousEndpoints error if more than one endpoint
  matches filter
- Also addresses bug 924052

Use case:
  $ nova --projectid xxx --version 1.1 --password xxx --username xxx --url https://identity.openstackcloud.com/ image-list
  Found more than one valid endpoint. Use a more restrictive filter
  AmbiguousEndpoints: [
    {'serviceName': 'New Cloud', 'region': 'Test', 'publicURL': 'https://test.openstackcloud.com/v1.1/tttt', 'tenantId': 'tttt'},
    {'serviceName': 'Old Cloud', 'publicURL': 'https://servers.openstackcloud.com/v1.0/tttt', 'tenantId': 'tttt'}]

  $ nova --projectid tttt --version 1.1 --password xxx --username xxx --url https://identity.openstackcloud.com/ --service_name 'New Cloud' image-list
  +--------------------------------------+-----------------------------+--------+--------+
  |                  ID                  |             Name            | Status | Server |
  +--------------------------------------+-----------------------------+--------+--------+
  | 346f4039-a81e-4444-9223-4a3d13592a07 | Debian Squeeze (6.0)        | ACTIVE |        |
  | ac8985ea-c09e-4544-82af-eb459a02a6b2 | Fedora 15                   | ACTIVE |        |
  | ddddc02e-92fa-4f44-b36f-55b39bf66a67 | CentOS 5.6                  | ACTIVE |        |
  +--------------------------------------+-----------------------------+--------+--------+

Change-Id: I9a10b9ad5e5b9cf6e762659013496a93a79774db
2012-01-31 18:37:36 -06:00
Brian Waldon e0174b51bd Abstract Client building into novaclient.client
This prevents clients of the pythonic api from having to know the
internal module structure.

Change-Id: Idd5c522ac3ff6c2d7915f96ed327323ec83d54fc
2011-12-29 15:40:49 -05:00
Sandy Walsh 8491c76027 new service catalog implementation. 2011-09-26 12:28:43 -07:00
Sandy Walsh 2c3a865f6b proxy token support - no tests 2011-09-09 06:33:38 -07:00
Brian Waldon f6273ba08d removing extra newline 2011-08-10 13:30:33 -04:00
Brian Waldon 1f7605cb7e catching authorization failure (x-server-management-url KeyError) 2011-08-10 13:25:17 -04:00
Brian Lamar 454daa2cba Tests working again...merged in some work we did earlier. 2011-08-03 17:41:33 -04:00
Brian Lamar f8496672cc Split everything down the middle into v1_0 and v1_1, including tests. 2011-08-03 16:36:03 -04:00
Sandy Walsh 8e615f4446 Added Jacob Kaplan-Moss copyright notices on older/untouched files. 2011-02-25 02:00:13 -08:00
Sandy Walsh bd18c7e429 renamed to novaclient and fixed flavor tests 2011-02-26 05:04:40 -04:00