summaryrefslogtreecommitdiff
path: root/glanceclient/common
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Move old oslo-incubator code out of openstack/commonAbhishek Kekane2016-11-081-35/+0
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of the first community-wide goal, teams were asked to remove the openstack/common package of their projects if one existed. This was a byproduct of the old oslo-incubator form of syncing common functionality. Package openstack/common/apiclient is moved to glanceclient/v1 package as it is used by v1 api only. NOTE: Removed glanceclient/common/base.py as it is deprecated and not used anywhere. Closes-Bug: #1639487 Change-Id: Ib3ac09743ce761ab0186e99e1c9de02517f89510
* | switch from keystoneclient to keystoneauthItisha Dewan2016-09-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | move glanceclient to keystoneauth as keystoneclient's auth session, plugins and adapter code has been deprecated. refer to [1] for more information. 1: https://github.com/openstack/python-keystoneclient/commit/1a84e24fa4ce6d3169b59e385f35b2a63f2257f0 implements bp: use-keystoneauth Co-Authored-By: Itisha <ishadewan07@gmail.com> Change-Id: I88fb327628e1bec48dc391f50d66b3deab4a8ab9
* | Merge "Fix string interpolation to delayed to be handled by the logging code"Jenkins2016-07-301-1/+1
|\ \
| * | Fix string interpolation to delayed to be handled by the logging codehaobing12016-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String interpolation should be delayed to be handled by the logging code, rather than being done at the point of the logging call. See the oslo i18n guideline. * http://docs.openstack.org/developer/oslo.i18n/guidelines.html Change-Id: If06663076e4081c6268ba88c157513723b734b31 Closes-Bug: #1596829
* | | Merge "Log request-id before exceptions raised"Jenkins2016-07-301-10/+10
|\ \ \
| * | | Log request-id before exceptions raisedAbhishek Kekane2016-07-181-10/+10
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of now request-id is not logged if an excpetion is raised. Rearranged code so that request-id is logged even in case of an exception. Change-Id: Iee0398404ee752c0d880edf3054207c35862e71a Closes-Bug: #1603863
* | | py3: Fix encoding and use sys.stdin.bufferSirushti Murugesan2016-07-252-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | * exc.py: Encode body in response before calling replace over it. * http.py: prepend the bytes literal to the empty string or else we hit bug 1342080 again in python 3. * utils.py: Use sys.stdin.buffer in python 3. Change-Id: Ieefb8c633658e507486438e5518c5d53e819027d
* | | Merge "Add comment about workaround for py3"Jenkins2016-07-201-0/+2
|\ \ \ | |/ / |/| |
| * | Add comment about workaround for py3Louis Taylor2016-07-131-0/+2
| | | | | | | | | | | | Change-Id: Ibe8720c14e8ec401bc0d595915cbb962f4021bcb
* | | Merge "Log request-id for each api call"Jenkins2016-07-151-0/+10
|\ \ \ | |/ / |/| |
| * | Log request-id for each api callAbhishek Kekane2016-06-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support to log 'X-Openstack-Request-Id' for each api call. If glanceclient is used from command line then following log will be logged on console if --debug flag is used. DEBUG:glanceclient.common.http:GET call to glance-api for http://172.26.88.20:9292/v2/schemas/image used request id req-e0c7c97a-8fc0-4ce3-a669-d0b1eb5d7aae If python-glanceclient is used in applications (e.g. Nova) then following log message will be logged in service logs. DEBUG glanceclient.common.http [req-be074f1e-1c17-4786-b703-2a221751c8f4 demo demo] GET call to glance-api for http://172.26.88.20:9292/v1/images/detail?is_public=none&limit=20 used request id req-9b1dd929-df30-46b2-a8f2-dfd6ffbad3fc DocImpact: To use this feature user need to set 'default_log_levels' in third party application. For example nova uses glance then in nova.conf 'default_log_levels' should be set as below: default_log_levels = glanceclient=DEBUG Implements: blueprint log-request-id Change-Id: Ib04a07bac41ad2a5e997348f3b0bccc640169dc9
* | | image-download: tests to catch stray outputStuart McLaren2016-06-291-4/+2
|/ / | | | | | | | | | | | | | | | | | | Add unit tests to ensure that any stray output (eg print statements) during image-download cause a test failure. Regression test for bug 1488914. Change-Id: Ic19ba5693d059bf7c283702e7c333672a878a1a1 Partial-bug: 1488914
* | Remove unused skip_authentication decoratorkairat_kushaev2016-06-021-15/+0
| | | | | | | | | | | | | | | | skip_authentication is not used as decorator for glanceclient methods. So this method can be safely removed from glance codebase because it is artifact from old implementation. Change-Id: I235b4c6b835c75266d8fae1bb603685aa17ad497
* | Merge "Fix "Codec can't encode characters""Jenkins2016-05-231-16/+16
|\ \
| * | Fix "Codec can't encode characters"Darja Shakhray2016-05-191-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Headers were encoded in HTTPClient, but when glance client started to use SessionClient this functionality was lost. This commit replaces static method "encode_headers" from HTTPClient and makes it a common function, that SessionClient can use when converting image meta to headers. Change-Id: If9f8020220d2a0431b4241b38b9c83c09c0d75cb Closes-bug: #1574587
* | | Merge "Add last_request_id member to HTTPClient and SessionClient"Jenkins2016-05-181-0/+4
|\ \ \ | |/ / |/| / | |/
| * Add last_request_id member to HTTPClient and SessionClientCao ShuFeng2016-03-301-0/+4
| | | | | | | | | | | | | | | | | | apiclient.base.Resource.get method requires manager.client to have last_request_id member. Otherwise get operation fails with AttributeError exception. Change-Id: I0ece85e3f61f2a7f176520ddf3ebee7792e51993 Closes-bug: 1552533
* | Merge "Enable hacking checks"Jenkins2016-04-203-17/+15
|\ \
| * | Enable hacking checksTin Lam2016-04-183-17/+15
| |/ | | | | | | | | | | | | | | | | | | Enabled following hacking checks from tox.ini: - H233 Python 3.x incompatible use of print operator - H303 no wildcard import - H404 multi line docstring should start with a summary Change-Id: I2553bcd3e80c00acc08d135a1d2dadfb6cda49fe Partial-Bugs: #1475054
* | Merge "Re-enable stacktracing when --debug is used"Jenkins2016-04-181-0/+8
|\ \
| * | Re-enable stacktracing when --debug is usedStuart McLaren2016-04-071-0/+8
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1f89beb6098f4f6a8d8c2912392b273bc068b2e3 introduced the behaviour that a stacktrace is printed if an exception is encountered. This helped make the client more supportable: $ glance --debug image-list . . . File "glanceclient/common/http.py", line 337, in get_http_client xxx NameError: global name 'xxx' is not defined global name 'xxx' is not defined The behaviour was lost at some point. This patch re-enables it. Change-Id: I25fc8624797909d606590747f54b9cf649ade079 Closes-bug: 1563830
* | Fix typos in docstrings and commentsDao Cong Tien2016-04-111-3/+3
| | | | | | | | | | | | Update a comment to be more meaningful Change-Id: Ie1aa46917c1a253db92a0dc819803a1d3e795b07
* | Update auth_token before sending requestkairat_kushaev2016-03-301-4/+4
|/ | | | | | | | | | | | | | Previously auth_token was initialized once in __init__ method. After that we stored token in session headers. So to refresh token users need to instantiate a new session inside http client or re-create client itself. In order to provide possibility to refresh token we need to add token header before sending the request. So users can just update auth_token attribute in the HTTPClient to refresh user token. Change-Id: Ifebe9011870bbddc46fc6d6a26563641d5559e97 Closes-Bug: #1563495
* Merge "Handle 403 forbidden on download"Jenkins2016-02-291-1/+1
|\
| * Handle 403 forbidden on downloadStuart McLaren2016-02-241-1/+1
| | | | | | | | | | | | | | | | | | | | A download of a deactivated image may result in a 403. The cli should catch this error rather than stack trace. We also catch other unexpected http responses. Change-Id: If33fbc3a56cdb02b3ab32a6479a67fff20b4b1a9 Closes-bug: 1523612
* | Remove code needed for python2.5kairat_kushaev2016-02-011-6/+0
| | | | | | | | | | | | | | | | glance has a code specific for python2.5. We need to delete this code cause glanceclient doesn't support neither python2.5 or python2.6. Change-Id: I17e4905b6e02fcfff033a6cde03324e2a47bfce2
* | Remove monkey-patching for getsockoptkairat_kushaev2016-01-151-5/+0
| | | | | | | | | | | | | | | | | | Not getsocketopts is presented in GreenSocket for Linux. See the bug for the info. So we don't need to patch it anymore. Closes-Bug: #1348269 Change-Id: Ie2211238656eddfb0af5f3ef84ab638f6248a10a
* | Fix image-download to stdout on Python 3.xAndy Botting2015-12-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | Glance image-download to stdout fails on Python3 due to sys.stdout.write not allowing bytes to be written directly. A good description of the issue is listed at http://bugs.python.org/issue18512 Closes-Bug: #1528083 Change-Id: I2963914e2e0744410267b5735ff77939413916d4
* | Remove broken try/except workaround for old requestsMonty Taylor2015-12-151-5/+1
|/ | | | | | | | | Not only is this code broken on the requests we require on distro-provided requests, it's not needed anymore. Remove it. Closes-bug: 1526254 Change-Id: I47a07bf9910f118392785fc20e015f036a2e8a7c
* Ensure that identity token in header is not an unicode stringVincent Untz2015-11-172-3/+3
| | | | | | | | | | | | | We need all the headers to be safe strings so they can be joined together and not become an unicode string in doing so. This fixes a bug when creating an image with non-ascii characters in the name. This is required for python 2.6 compatibility. Change-Id: I66ebc27edf4ccd8f903399da58705711c372536d Closes-Bug: 1448080
* Fix the missing help descripiton of "image-create"wangxiyuan2015-10-271-0/+2
| | | | | | | | Now, when use "glance help" to show the help message, the description of 'image-create' is missing. Change-Id: I748209222c540e0024580dccac850ea465d176b4 Closes-bug: #1510340
* Import i18n functions directlykairat_kushaev2015-10-161-2/+1
| | | | | | | | | | As stated in i18n guide it is normal to import i18n functions (_, _LW..) directly and we can include i18n functions in hacking exceptions. Also there is no need to make exceptions for six moves because pep8 passes correctly without it. Change-Id: I9c9aa490f1447bb7ae221809df7bc110c27d1336
* Merge "Add support for setting Accept-Language header"Jenkins2015-10-141-0/+4
|\
| * Add support for setting Accept-Language headerFrode Nordahl2015-10-141-0/+4
| | | | | | | | | | | | DocImpact Closes-Bug: 1480529 Change-Id: I35a37d55edb700a5993bd5cc352335a87a15e47a
* | Support image deletion in batches in v2wangxiyuan2015-10-101-0/+4
| | | | | | | | | | | | | | | | Client doesn't support image deletion in batches in v2 now. It's useful. So it's need to add it. Change-Id: Idf5a6890b3fd01a65fecab2033b21367c30bc6b1 Closes-bug:#1485407
* | Merge "Fix Typos in comments"Jenkins2015-09-301-1/+1
|\ \
| * | Fix Typos in commentsrahulram2015-08-261-1/+1
| | | | | | | | | | | | Change-Id: Ib66ec89f6e556093ab00d3f7fb8ad0f3d9912461
* | | Merge "Replace exception_to_str with oslo.utils function"Jenkins2015-09-301-12/+0
|\ \ \
| * | | Replace exception_to_str with oslo.utils functionkairat_kushaev2015-09-221-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The oslo.utils function has exception_to_unicode that can replace glance util function exception_to_str. So we don't to have this exception_to_str function in glance anymore. Change-Id: I332bc55558087920fdd6ae2d822bece5166f5ba6
* | | | Merge "Fix human readable when size is None"Jenkins2015-09-281-1/+3
|\ \ \ \ | |/ / / |/| | |
| * | | Fix human readable when size is NoneStuart McLaren2015-09-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If an image size is null don't stack trace when listing. Change-Id: Iba18470edbe032d1d01380372d57fa17adef5f7e Closes-bug: 1495632
* | | | Merge "Add parsing the endpoint URL"Jenkins2015-09-161-4/+7
|\ \ \ \ | |/ / / |/| | |
| * | | Add parsing the endpoint URLTakashi NATSUME2015-09-081-4/+7
| |/ / | | | | | | | | | | | | | | | | | | | | | Add parsing the endpoint URL and check the path string only in order to decide the API version. Change-Id: Ib0a035f3bed31e2162a1231a5f5dcc3907d37243 Closes-Bug: #1489727
* | | Merge "Check if v2 is available and fallback"Jenkins2015-09-081-1/+4
|\ \ \
| * | | Check if v2 is available and fallbackFlavio Percoco2015-09-041-1/+4
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a basic implementation for a fallback mechanism that will use v1 rather than v2 when downloading schema files from glance-api fails. However, this is not sound. If the schemas are cached already, we won't check if v2 is available and fail to fallback. This patch fixes the aforementioned issue by getting the list of available versions from the server only when the API versions was not explicitly specified through the CLI. That is, for all commands that don't pass `--os-image-api-version 2`, we'll check v2's availability and we'll fallback to v1 if it isn't available. This patch also changes how we handle `/versions` calls in the client. The server has been, incorrectly, replying to requests to `/version` with a 300 error, which ended up in the client re-raising such exception. While I think 300 shouldn't raise an exception, I think we should handle that in a spearate patch. Therefore, this patch just avoids raising such exception when `/version` is explicitly called. This fallback behaviour and the check on `/versions` will be removed in future versions of the client. The later depends on this bug[0] being fixed. [0] https://bugs.launchpad.net/glance/+bug/1491350 Closes-bug: #1489381 Change-Id: Ibeba6bc86db2a97b8a2b4bd042248464cd792e5e
* | | check for None value in utils.safe_headerDavid Edery2015-09-081-1/+1
|/ / | | | | | | | | | | | | | | | | In case that a sensetive header (that should be obscured by its SHA1 hash) is None, the safe_header throws an exception which fails the calling process and by that may harm the functionality. Change-Id: I56944a382fd546eba0a6dd6d6b1cecf83b1dc106 Closes-Bug: #1491311
* | Remove custom SSL compression handlingStuart McLaren2015-08-262-25/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Custom SSL handling was introduced because disabling SSL layer compression provided an approximately five fold performance increase in some cases. Without SSL layer compression disabled the image transfer would be CPU bound -- with the CPU performing the DEFLATE algorithm. This would typically limit image transfers to < 20 MB/s. When --no-ssl-compression was specified the client would not negotiate any compression algorithm during the SSL handshake with the server which would remove the CPU bottleneck and transfers could approach wire speed. In order to support '--no-ssl-compression' two totally separate code paths exist depending on whether this is True or False. When SSL compression is disabled, rather than using the standard 'requests' library, we enter some custom code based on pyopenssl and httplib in order to disable compression. This patch/spec proposes removing the custom code because: * It is a burden to maintain Eg adding new code such as keystone session support is more complicated * It can introduce additional failure modes We have seen some bugs related to the 'custom' certificate checking * Newer Operating Systems disable SSL for us. Eg. While Debian 7 defaulted to compression 'on', Debian 8 has compression 'off'. This makes both servers and client less likely to have compression enabled. * Newer combinations of 'requests' and 'python' do this for us Requests disables compression when backed by a version of python which supports it (>= 2.7.9). This makes clients more likely to disable compression out-of-the-box. * It is (in principle) possible to do this on older versions too If pyopenssl, ndg-httpsclient and pyasn1 are installed on older operating system/python combinations, the requests library should disable SSL compression on the client side. * Systems that have SSL compression enabled may be vulnerable to the CRIME (https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-4929) attack. Installations which are security conscious should be running the Glance server with SSL disabled. Full Spec: https://review.openstack.org/#/c/187674 Blueprint: remove-custom-client-ssl-handling Change-Id: I7e7761fc91b0d6da03939374eeedd809534f6edf
* | Require disk and container format on image-createGorka Eguileor2015-08-141-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently glanceclient doesn't enforce disk-format or container-format presence in the command line on image-create when providing image data (with --file, --location, --copy-from), which means that the POST request is made with the whole image and error is reported by Glance API. This post enforces presence of those arguments when image data is provided so we can get the error quicker and avoid sending unnecessary data over the network. Change-Id: I5914fa9cfef190a028b374005adbf3a804b1b677 Closes-Bug: #1309272
* | Merge "Add unicode support for properties values in v2 shell"Jenkins2015-08-031-1/+1
|\ \ | |/ |/|
| * Add unicode support for properties values in v2 shellDarja Shakhray2015-08-031-1/+1
| | | | | | | | | | | | This code allows to set unicode values to v2 properties. Change-Id: I5f9c29a3e458808dd95375c7557dfce0c4f09038 Closes-bug: #1475769