53 Commits

Author SHA1 Message Date
Hangdong Zhang
ca0219f972 Update and optimize documentation links
1. Update URLs according to document migration
2. Update the dead and outdated links
3. Optimize (e.g. http -> https)

Change-Id: I63c0f87a6a0b1e0c36dfbd52cef65ede376ae222
2017-07-18 16:53:39 +08:00
Tao Li
ee94c48806 Remove log translations
Log messages are no longer being translated. This removes all use of the
_LE, _LI, and _LW translation markers to simplify logging and to avoid
confusion with new contributions. See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: I0a2263090899a86ff922f00feb92d440f9226c4b
Closes-Bug: #1674374
2017-03-30 17:22:07 +08:00
Vladyslav Drok
fbcaf92521 Print pecan exceptions properly
Exceptions raised by pecan (for example the ones happening in _lookup
methods of ironic controllers) are not properly handled, as the
fields that contain the error details are different from wsme raised
exceptions. This change fixes it.

Closes-Bug: #1619471
Change-Id: I023870ed97d3e97df8ae67e7cec97d6fbf355e79
2017-02-10 19:40:20 +00:00
Marc Aubry
e512550ab7 Fix python3 compatibility when HTTP Error are returned
When trying to contact Ironic with a bad token, Forbidden exception
should be raised, in python3 a TypeError is raised due to json
lib being unable do decode a bytes object.

In order to be really python3 compatible, the json lib was replaced
with oslo.serialization module jsontuils since it's the recommended
migration to python3 guide. This is to ensure that data coming from
the requests lib can be read even if it's not string any more but
bytes.
https://wiki.openstack.org/wiki/Python3

Change-Id: I27540f58e31817d4de604334bc4c62899d82f4cc
Closes-Bug: #1629068
2016-11-08 11:30:30 -05:00
Sam Betts
11a3f12c3a Catch RetriableConnectionFailures from KAuth and retry
Some keystone auth failures are retriable, this patch ensures that when
ironiclient retries are turned on, we also retry on those failures.

Change-Id: I7181b2aa4c8d0cc3b5523cb913562bee2e1955a2
Closes-Bug: #1537076
2016-06-02 12:40:19 +01:00
Jenkins
c6e9bfd6b1 Merge "Set endpoint_override while doing session.request" 2016-04-12 17:40:47 +00:00
Dao Cong Tien
f463451c7a Fix typos in docstrings and comments
Change-Id: I56487bbe5c74fbd3e1d62918dbcf87dddf79a6e3
2016-04-06 09:56:49 +07:00
Vladyslav Drok
c9dc5faf20 Set endpoint_override while doing session.request
The recent refactor broke multi-region deployments by not using
endpoint_override when doing _http_request in SessionClient.
This change fixes it.

Closes-bug: #1557105
Change-Id: I99cbcd34eeec1388a00d1a0d910dd5759191f954
2016-03-21 18:01:28 +02:00
Vladyslav Drok
7226ad44aa Use keystoneauth instead of keystoneclient
This change also enables client to be authenticated via 'token'
keystone auth method, allowing to pass os_auth_token instead of
os_username and os_password.

Closes-bug: #1541411
Closes-bug: #1548907
Change-Id: I9739c95069ebf8d60f8362be154844e74334beb2
2016-03-03 18:07:32 +02:00
Anton Arefiev
b6b1981be4 Use requests lib in HTTPClient
This change proposes switch to requests lib instead using
HTTPConnection and VerifiedHTTPSConnection, requests lib is
recommended for higher-level http client interface.

Also HTTPConnection can't work with API server behind proxy.

Change-Id: I0393aaf38e59bdfdefb0e00aaa514a3246bf639b
Closes-Bug: 1500929
2016-03-03 11:13:30 +02:00
Jenkins
c233c4cdf0 Merge "Replace HTTP 'magic numbers' with constants" 2016-03-02 18:40:26 +00:00
Lokesh S
9c3641317e Log SHA1 hash of X-Auth-Token value
Remove logging of sensitive information like the token value from
X-Auth-Token. Instead, log the sha1 hash of the token value,
prefixed by '{SHA1}'.

Closes-bug: #1429701
Change-Id: If0536ce2d4f71d61c272427cefec7a4dbbdcdefa
2016-02-26 17:13:10 +00:00
John L. Villalovos
868082af61 Replace HTTP 'magic numbers' with constants
Replace HTTP 'magic numbers' (also known as unnamed numerical constants)
with constants provided by the http_client/httplib library.

For example, use 'http_client.OK' instead of '200'

Change-Id: I7fc70ec0c5fee128054c026a78671d07c48d5eaf
2016-02-04 16:35:31 -08:00
Lucas Alvares Gomes
eeb327b590 Do not log secrets
When logging the curl command or the http response we should obfuscate
the secrets.

Change-Id: Iaf8aef795782b5c4608f3a2be6887d0429176250
Partial-Bug: 1530972
2016-01-06 14:20:55 +00:00
Dmitry Tantsur
8224859c02 Scale back on how many warnings we issue
* Remove "Request returned failure status" warning, it does not carry
  any helpful information for an operator (or anyone).
* Demote retry warnings to debug level. Retrying is essentially a normal
  thing in the real world, and currently we're spamming logs with warnings.
  http://logs.openstack.org/93/255793/3/gate/gate-tempest-dsvm-ironic-agent_ssh/25175ed/logs/screen-n-cpu.txt.gz?level=TRACE

Change-Id: I6c40581b9dc5ab1fe3af4b882ede17a13edacc66
Closes-Bug: #1525002
2015-12-11 12:38:39 +01:00
Anton Arefiev
eaa2456b89 Add missing translation markers
There are couple places where translation markers missed:
 * /common/http.py
 * /osc/plugin.py
This change adds them.

Change-Id: I8fc7edb618023b524157a462ff0b1c3f025e17f3
Closes-Bug: 1517421
2015-11-19 17:15:52 +02:00
HaoZhi, Cui
b08c3cb301 replace LOG.warn with LOG.warning
LOG.warn is deprecated, change to LOG.warning

Change-Id: I9e4b87cc15dc0b6cbefa991bc025898adef151e8
Closes-Bug: #1508442
2015-11-19 02:29:02 +00:00
Ruby Loo
07fc85c5e1 Replace six.iteritems() with .items()
As mentioned in the developer's guide[0] and in a discussion[1],
we shouldn't use six.iteritems() unless there's a good reason (eg
large data set).

Since there's no need to use six.iteritems() in the places where
it is being used, this patch replaces them with items().

[0] http://docs.openstack.org/infra/manual/developers.html#peer-review
[1] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: If91afd37a7bf42dcbcf9dcd70fbbe82787de850e
2015-09-28 18:20:00 +00:00
Julia Kreger
5afd483346 Set a default endpoint value of None
When using keystone session data, the endpoint information
may be encoded in the keystone session data, which means the
direct definition of an endpoint shouldn't necessarilly be
required to occur, and just results in data that will be
ignored if found in the session data anyway.

Added a default value of None for endpoint values when the
_construct_http_client method is called.

Change-Id: Ib53f604840ec48a987b8192091e8f8159c358893
Closes-Bug: #1498608
2015-09-22 14:08:15 -04:00
Dmitry Tantsur
e4a2fcfdb1 Also retry on connection refused
This is required to completely replace ClientWrapper in nova driver.

Change-Id: Ie98a8929c66ccabfd1a6b60f03ce9d39133ef634
2015-07-27 14:32:28 +02:00
Jenkins
52f4ba68ba Merge "Filtering nodes by provision state" 2015-07-20 18:39:12 +00:00
Zhenguo Niu
32c6c3cfb3 Filtering nodes by provision state
Add support for filtering nodes by provision state in the
node-list command. For provision states with spaces, like
'wait call-back' ironicclient will encode it to %20 in the
uri.

And bump the default version to 1.9.

Closes-Bug: #1468229

Depends-On: Ifcd554de04cdc42bffea1a116307b045f39c8416
Change-Id: I9967ff6124e2e7e9958098b41cc892f2c55df5d2
2015-07-20 10:22:09 +08:00
Lucas Alvares Gomes
c3d38c921e Fix version negotiation
When the python client catch a 406 (Not Acceptable) error talking to
an older version of the Ironic server the client will try to negotiate
and fall back to the minimum supported version. Before the code was
determining the minimum version by using the builtin min() method with
strings but the result doesn't always come correct by doing it, e.g:

In [1]: min('1.10', '1.6')
Out[1]: '1.10'

In [2]: min('1.9', '1.6')
Out[2]: '1.6'

This patch fix this problem with the version negotiation.

Closes-Bug: #1475308
Change-Id: I2c756288d9590d1d18574a787601681b235fb57d
2015-07-16 15:29:27 +01:00
Lucas Alvares Gomes
0d8fa45b4b Allow specifying a set of fields of the Node resource
This patch add a "--fields" parameter to the "node-list", "node-show"
and "node-port-list" commands which the user can specify a subset of
fields that will be returned by the server.

This is supported by the Ironic API version >= 1.8, so this patch also
bumps the default API version to 1.8.

Related-Bug: #1466495
Change-Id: I40654ee9fbd92dd91b41f8596adcd26264634147
2015-07-09 11:27:04 +01:00
Ruby Loo
aea764b451 Expose node's clean_step and bump default version
This exposes the node's clean_step field by bumping the default version
from 1.6 to 1.7 and adding clean_step to various lists.

Change-Id: I2d9f2e58ed198bc8cb5bab67a6f8baf85bbbf972
Closes-Bug: #1466693
2015-07-07 23:08:34 +00:00
Jenkins
e144f4762a Merge "Also retry on HTTP 503 (service unavailable)" 2015-07-06 22:57:55 +00:00
Dmitry Tantsur
24f016b69b Also retry on HTTP 503 (service unavailable)
The API returns this error when we lack free conductor workers.

Change-Id: I19903eb06b79d7f9721060ea1c615e610d40f91f
2015-06-29 15:36:32 +02:00
Michael Davies
44e6949b0c Cache negotiated api microversion for server
If we negotiate an API microversion in the ironiccclient, cache
this value so that we don't need to re-negotiate it again for the
next API call, if the user doesn't specify a version.

We cache the version for a particular ironic instance in a
temporary file, one per server, in a multi-user, multi-server
safe-way - deleting old files once they expire, so only the
latest is kept.

Depends-On: Icb29fdc92ecd54e388b7c16899070572458308da
Change-Id: I0232bc611789fb96491d855020042e23ba0c4fab
Blueprint: version-caching
2015-06-23 08:55:12 +09:30
Jamie Lennox
3f4671a0b7 Cleanup session creation
When using the session object we want to pass through unknown kwargs to
the adapter so that keystoneclient can add new parameters as required.

This requires fixing the old options so that we can restrict what is
passed and showing a warning when there are values that are being
ignored.

Change-Id: Ia795dfc8e16c60a08df1636816daefe2ebbd0b03
2015-06-18 10:05:14 +08:00
John L. Villalovos
2df670cf30 Remove unneeded 'utf-8' coding lines
This is basically a revert of commit:
  af741ec2236619880fa902d68aef4a6ae6cef534

It was decided that only files that need to have the line:
  # -*- coding: utf-8 -*-
Should have the line[1] as a general principle

This patch removes the 'utf-8' coding line from files that consist
entirely of ASCII characters.

[1]
http://eavesdrop.openstack.org/meetings/ironic/2015/ironic.2015-04-20-17.00.html

Partial-bug: #1325193
Change-Id: I88c1c37f7b580aa805eae9d4a1e66d33302a325f
2015-04-21 16:44:47 +00:00
Dmitry Tantsur
28bdd0baeb Implement and enable retries on Conflict
Getting Conflict errors is pretty annoying, especially when writing
automation scripts. Nova and ironic-discoverd already have their
own logic for retrying on such errors.

This patch adds 'max_retries' and 'retry_interval' arguments to
get_client for tuning or disabling retries.

Change-Id: Id9720c87ce3846faec61eb40ccf00970ca798ad2
2015-04-17 16:25:44 +02:00
Devananda van der Veen
8b453ff88a Client should fall back to the lower versions if necessary
The python client should catch 406 Not Acceptable errors when talking to
older versions of the server. If the user did not request a specific
version, the client should negotiate (fall back to) a mutually supported
API version with the server.

If there is no mutually supported version, or if the user specified a
version in which the requested feature is unavailable, the client should
raise an error.

This patch is a partial implementation of the client side of
auto-negotiation. It catches the 406 error and attempts to determine
what version the server is based on the returned headers. It does NOT
actually change what values are sent or returned by the client, aside
from the version headers.

Without this fix, the client fails to connect to any server version
between commit 41595327 (when v1.1 was introduced) and commit 6ecee368
(when v1.6 was introduced), because it is requesting API version 1.6
and not handling the 406 Not Acceptable response.

Note that API server versions prior to commit 32fb6e99 did not return
any version information in the header of a 406 Not Acceptable response.
To work around this, when the client receives a 406 response that does
not contain any version header, the client performs an extra GET request
to the root /v1/ URL to retrieve the supported versions. This allows the
client to work with API services that might be running unreleased
mid-kilo code as well as both stable/juno and the latest kilo code.

Co-Authored-By: Dmitry Tantsur <dtantsur@redhat.com>
Co-Authored-By: John L. Villalovos <john.l.villalovos@intel.com>
Change-Id: Iab6a0814f0db6dd6e7bfc00da28baf8403a6b1db
Blueprint: api-microversions
Partial-bug: #1441170
2015-04-13 10:31:47 -07:00
John L. Villalovos
144e82b163 Fix the final PEP8 errors
Fix PEP8 E126,E127,E128 errors, which were the only ones remaining.

Fix PEP8 errors:
E126: continuation line over-indented for hanging indent
E127: continuation line over-indented for visual indent
E128: continuation line under-indented for visual indent

Remove the ignore= entries for flake8 in tox.ini

Change-Id: I919551121d85d2aab528f4fa5ecdb3cfd940557a
2015-03-10 14:38:30 -07:00
Lin Tan
53095aaa8f Enable ironicclient with --ironic-api-version 1.x
python-ironic-client doesn't recognize API micro-version parameter.
Reuse --ironic-api-version to recognize this.

1. The client accepts '1.x' or 'latest' as valid API version and send
corresponding headers to Ironic.
2. If the user does not specify a version, client will not sent any
extra headers to Ironic. It will use the minimum version.

Closes-Bug: #1417430
Change-Id: I1db6e2f4e57d6d47d86f068018f143d0044b7211
2015-03-06 11:40:33 +08:00
jiangfei
9f919eed63 ironicclient handle faultstring when using SessionClient
When the ironic-api returns an error code 400-600 when,
SessionClient faultstring did not return to the user,
it should return a detailed error message to the user,
not simply bad request.

we use the ironic node-show aa938513a-216a-49dc-b801-08119ebc2b21
SessionClient will get the below message:
"Not Found (HTTP 404)" -->
"Node a938513a-216a-49dc-b801-08119ebc2b21 could not be
found. (HTTP 404)"

Change-Id: If57fd938cdb29d0349b923ca5dc1a804f1accd9d
Closes-Bug: #1402893
2015-01-16 09:50:13 +08:00
Vladyslav Drok
f467415ba9 Fix log_curl_request API version duplication
log_curl_request duplicates API version when logging request (e.g.
http://192.168.122.222:6385/v1/v1/nodes/detail). Trailing API version
should be removed from the ironic endpoint when constructing logged
string.

Closes-bug: #1395740
Change-Id: Ia3fc29ed0ccaf2fbe9fea041098dcf079d711e8f
2014-11-26 13:38:29 +02:00
David Hu
e3d356476b Add keystone v3 CLI support
This change allows user domains and tenant/project domains to
be specified through CLI.  This is necessary because keystone
v2 API is deprecatedas of Icehouse.

Change-Id: I50187a12b73777118ee77590202746b272ecc030
2014-10-06 10:47:06 +00:00
Ghe Rivero
47236e2cf1 Bump hacking version
Current hacking version is incompatible with the one in the
global requirements. Match the hacking module version and made the
necessary changes to pass the tests.

Change-Id: Ie6b13a4ea112084d4c50dc27f97329dfad5777a1
2014-10-02 11:12:53 +00:00
Jim Rollenhagen
a07618e722 Trim trailing slash and version from endpoint
This commit removes trailing slashes and "/v1" from the endpoint
given when initializing the HTTP client, in order to fix the bug
mentioned below. It also removes the rstrip call in
_make_connection_url, since this is done up front now.

Also adds tests for get_connection_params.

Change-Id: If2c2cd766466dca4621e8daa260575fd4f106f06
Closes-Bug: #1342048
2014-08-05 20:25:58 +00:00
Michael Davies
55dd2e45c4 Expose auth_ref in ironicclient client object
To implement token expiry in Nova's Ironic driver, we need
to expose additional information obtained from the keystone
client.

Change-Id: I14aa8aca8b83f6c9a233bb19406d03002a76f139
Partial-bug: #1308171
2014-07-10 10:31:08 +09:30
Martin Geisler
af741ec223 Add UTF-8 coding lines to all Python files
While not strictly necessary for files containing only ASCII
characters, adding a line with "coding: utf-8" can guard against
future SyntaxError's in case someone inserts a Unicode literal.

This commit adds such lines to all .py files. The syntax used by this
commit works with Python (of course). It also works with Emacs, which
will recognize the special "-*-" marker and use the "coding" variable
to correctly decode the file, even in an environment where UTF-8 is
not the default file encoding.

Existing coding lines were normalized to match the new lines added.

Partial-bug: #1325193
Change-Id: I58bf93fea711fd25890356a397e594bd820c99e3
2014-05-31 13:22:44 +02:00
Jenkins
f5f043cbd3 Merge "Sync latest code and reuse exceptions from oslo" 2014-04-24 22:06:27 +00:00
Andrey Kurilin
0f6419015c Sync latest code and reuse exceptions from oslo
Module `ironicclient.exc` contains exceptions which equal to exceptions
from oslo common code.
This patch:
- sync latest code of `apiclient.exceptions`(hash of last commit in oslo
related to apiclient.exceptions: 3570f44d5ccf52c59cc586bed1446b874fc3c07c)
- reuses exceptions from common code
- removes needless exceptions from `ironicclient.exc`

Related to bp common-client-library-2

Change-Id: I784007f36dd6a63fc4c77e0d0f0f000e05eb792f
2014-04-24 12:01:31 +03:00
Dirk Mueller
96a9d788e1 Remove py3kcompat module
Remove use of py3kcompat module, which has been removed from oslo-incubator.
Replace it with six, which is already in the dependencies.

Update common apiclient from Oslo for that. I've updated
to oslo-incubator of commit 04a1abe59ac39890f57d2eed57d3d1b12bb5d757

List of recent changes:

04a1abe Revert "Removed set_loaded() method from Resource class"
86707cd Remove None for dict.get()
6650435 Fix usage of dict.keys in apiclient.exceptions
35dc1d7 py3kcompat: remove

Change-Id: Iab72688ea3ae7ff4c9c707b7939e1a12ff1a72b2
2014-04-15 16:19:47 +02:00
Victor Sergeyev
5585e5a008 Drop python2.5 suport in ironicclient.common.http
json and ssl modules were added in python 2.6 (see [1] [2]), so we should
suppose, that these module always available in python standard library.

[1] http://docs.python.org/2/library/ssl.html
[2] http://docs.python.org/2/library/json.html

Change-Id: I37d0cf7240180b0c2dbed26cfd9b264952ab822e
2014-01-14 09:56:55 +02:00
max_lobur
01c178de83 Let CLI print exception traceback from 'debuginfo'
Response 'debuginfo' is used to carry server traceback in case of
error. If 'debuginfo' is not empty, append it to exception message,
so traceback will be printed together with message.

Change-Id: Id7900b64ec7fc9f906253ef0e2d754c2baa76067
Closes-Bug: #1255590
2013-12-04 12:11:33 +02:00
Ghe Rivero
1b1dd31067 Reorder imports
As per hacking and PEP8, grouping third party libraries in
their own group.

http://www.python.org/dev/peps/pep-0008/#imports

Change-Id: I7a574d311b5171def0c6930162a46ce4c215097d
2013-11-11 18:12:58 +01:00
Ghe Rivero
8fefacfbae Comply with new hacking requirements
Fix some print statements and an import only module issue.

Change-Id: I0bb9cecb5ab03f35e696ee57c3ded05d7fd1725b
2013-11-11 11:44:46 +01:00
Kui Shi
acbe15cbd1 Import urlutils module from oslo
Import urlutils to resovle the urlparse module compatability issue.

Partial implement: blueprint py33-support

Change-Id: Ibc4860e979a2f25bebfbdc3a279ddc837b81b5a5
2013-10-17 17:21:06 +08:00
Kui Shi
b63721f2b3 Import httplib from six.moves
Import httplib from six.moves
Use six.StringIO to replace StringIO

Partial implement: blueprint py33-support

Change-Id: Ic20ce1139d1b296c7cbb666a200b2d9260764636
2013-10-17 17:21:02 +08:00