Commit Graph

41 Commits

Author SHA1 Message Date
David Edery 75ec9033c2 check for None value in utils.safe_header
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
2015-09-08 00:24:36 +03:00
Flavio Percoco 1e2274aef0 Password should be prompted once
There's a corner case where password may be requested twice. In a fresh
environment, when schemas have not be downloaded for v2, the client will
ask for a password to download the schemas and then it'll ask for the
password again to run the actual command. This happens because we parse
the CLI arguments twice to make sure we're parsing them for the right
client version.

This patch checks if the password is unset in the newly parsed arguments
and if it's been set in the previously parsed ones. In this case it
keeps the set password. I believe this approach is safer than re-using
the already parsed arguements which may have been parsed for a different
API version (might happen because we fallback to v1 if v2 is not
available).

Change-Id: I080253170e3e84a90363e5bb494cf137895fe2e7
Closes-bug: #1488892
2015-09-01 18:03:41 +02:00
Stuart McLaren 618637a5bd Remove custom SSL compression handling
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
2015-08-26 12:26:21 +00:00
Jenkins 17375a422c Merge "V2: Do not validate image schema when listing" 2015-08-20 17:28:21 +00:00
Gorka Eguileor 8d118ccedc Require disk and container format on image-create
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
2015-08-14 09:59:17 +02:00
Jenkins 13af690396 Merge "Use API v2 as default" 2015-08-13 23:43:59 +00:00
Jenkins 89b2dc58da Merge "Ship the default image schema in the client" 2015-08-12 11:49:45 +00:00
Flavio Percoco 3949e0e918 Ship the default image schema in the client
Now that we have stable branches for clients, it's easier to keep track
of the current default image's schema in Glance and update it
respectively. This patch adds the current image schema, including the
schema-properties.

One good reason to do this is to be able to react when a running Glance
instance is not around to be introspected. It's really unfortunate that
things like help text can't be rendered when there image schema is not
available in the system.

We could keep the schema in a json file but rather than shipping data
files with glanceclient we can just have it in the python modules.

Change-Id: I9b8cc1d18d6717ccf991fb8149ab13c06d653ee4
Closes-bug: #1481729
2015-08-12 11:10:54 +02:00
Fei Long Wang 181131ef2e Use API v2 as default
Now we have claimed v2 is the current API version of Glance,
we should change the Glance client as well to be consistent
with Glance server.

DocImpact

Change-Id: I09c9e409d149e2d797785591183e06c13229b7f7
2015-08-11 14:01:28 +12:00
Stuart McLaren 43769d6cc7 V2: Do not validate image schema when listing
Previously when listing images via v2, the first image of each batch
was validated against the v2 schema.

This could lead to unpredictable behaviour where a particular image
which failed the schema check may or may not be the first of a batch.

In some cases it also meant that operation by one user could affect the
ability of another other to list images.

Change-Id: I22974a3e3d9cbdd254099780752ae45ff2a557af
Closes-bug: 1477910
2015-08-10 10:24:57 +00:00
Jenkins 8af084d5a3 Merge "Support for Metadata Definition Catalog for Tags" 2015-08-06 16:08:04 +00:00
Jenkins 6d28b513e3 Merge "Add unicode support for properties values in v2 shell" 2015-08-03 23:20:19 +00:00
Darja Shakhray 22868aa9bb Add unicode support for properties values in v2 shell
This code allows to set unicode values to v2 properties.

Change-Id: I5f9c29a3e458808dd95375c7557dfce0c4f09038
Closes-bug: #1475769
2015-08-03 13:09:43 +00:00
Jenkins 4712765689 Merge "Fix failure to create glance https connection pool" 2015-07-29 20:39:37 +00:00
Haikel Guemar c41dcc9f43 Fix failure to create glance https connection pool
Due to a typo in an attribute named, an Attribute error is raised
causing failure in connection to glance through HTTPS

Urllib3 PoolManager class has a connection_pool_kw attribute
but not connection_kw

Closes-Bug: #1479020
Change-Id: Id4d6a5bdcf971d09e80043fd2ab399e208fd931c
2015-07-28 17:53:09 +02:00
Darja Shakhray ec0f2dfd85 Enable flake8 checks
This commit enables new flake8 checks:
* E265  block comment should start with '# '
* H405  multi line docstring summary not separated with an empty line
* E123  closing bracket does not match indentation of opening bracket's line
* H238  old style class declaration, use new style (inherit from `object`)
* E128  continuation line under-indented for visual indent
and makes related changes in the code.

Change-Id: Ie993afc930f6b74d7a990bcaa9fc0e9f5ba1585c
2015-07-21 17:08:27 +03:00
Kamil Rykowski d9d586942b Extend unittests coverage for v2 tasks module
Add new tests for v2 tasks module to cover following cases:
- getting list of tasks using the marker
- getting list of tasks using sort_key & sort_dir keys

Change-Id: Ic126999ebb16e51cc472fe8f86dfe1fced0bc016
Closes-Bug: 1433637
2015-07-20 07:25:45 +00:00
Wayne Okuma c0e90fa2bd Support for Metadata Definition Catalog for Tags
This set provides API and shell commands support for:
- CRUD on metadef_tags;

Change-Id: I09bdf43edee6fff615d223f1a6df7c15a1e40565
Implements: blueprint metadefs-tags-cli
DocImpact
2015-07-16 14:00:50 -07:00
wangxiyuan b48ff98e16 Fix exception message in Http.py
In common.http.py, the exception RequestTimeout has
wrong message.This patch fixed it.

Change-Id: Ie8ff188b9c82ce424cb8177278f36e4d1275b306
2015-07-14 09:01:12 +08:00
Jenkins 16ab18b64d Merge "Fix an issue with broken test on ci" 2015-07-13 21:34:19 +00:00
Mike Fedosin e240bddd5a Fix an issue with broken test on ci
Several tests with cert verification are broken. This
code fixes it by setting right imports. Also some typos
are fixed too.

Change-Id: Ie014f90714c3dabee65459fd704dd11b1770c7de
Closed-Bug: #1472234
2015-07-13 17:54:41 +03:00
rico.lin e976032a95 Remove usage of assert_called_once on Mock objects
mock 1.1.0 was released on 10 July 2015 which prevents users from using
non-existent assertion methods. This broke the test in the diff.

Co-Authored-By: Ian Cordasco <graffatcolmingov@gmail.com>
Closes-Bug: #1473454
Change-Id: I162b76bbd7d96c96787a8dd8f9642ca1c80c596a
2015-07-10 15:57:51 -05:00
Corey Bryant 1b93adc8fb Account for dictionary order in test_shell.py
Change-Id: Id15f3d642e8fcbd663f12b32f52b6014e32574a5
Closes-Bug: 1468485
2015-06-29 10:22:13 -04:00
Jenkins cc38f51086 Merge "Add v2 support for the marker attribute" 2015-06-22 04:52:27 +00:00
Brad Pokorny ea01f13be2 Add v2 support for the marker attribute
The v2 Glance client implementation ignores the marker attribute if
it's passed to the client as part of the kwargs.  Include support
for the attribute, as the v1 client supports it and it makes it
easier to work with the Glance client.

Change-Id: Ifaa59129bc4178212b890ea591673cb154e0f110
Closes-bug: 1465373
2015-06-19 15:03:37 -07:00
Cindy Pallares 997c12d3ab Import only modules and update tox.ini
As stated in the OpenStack Hacking Guidelines, it is prefered
that only modules should be imported.

Also updated tox.ini to ignore opestack/common among others.

Change-Id: I2f0a603c31052eadee581c11880c0ec6bd392829
2015-06-17 10:56:37 -05:00
Jenkins 71d8528364 Merge "Close iterables at the end of iteration" 2015-06-16 19:01:18 +00:00
Jenkins 0d22e821f9 Merge "Add parameter 'changes-since' for image-list of v1" 2015-06-15 18:11:27 +00:00
Robert Collins 43621dc1ac Close iterables at the end of iteration
This fixes a bug where if iteration is interrupted, we're stuck until
the iterable is garbage collected, which can be a very long time (e.g. if
the iterable is held in an exception stack frame).

Co-authored-by: Stuart McLaren <stuart.mclaren@hp.com>

Change-Id: Ibe9990e8c337c117a978b1cd8ec388c4bc6d3b4b
Closes-bug: 1461678
2015-06-11 18:11:39 +00:00
Jamie Lennox 5ce9c7dc96 Make glanceclient accept a session object
To make this work we create a different HTTPClient that extends the
basic keystoneclient Adapter. The Adapter is a standard set of
parameters that all clients should know how to use like region_name and
user_agent. We extend this with the glance specific response
manipulation like loading and sending iterables.

Implements: bp session-objects
Change-Id: Ie8eb4bbf7d1a037099a6d4b272cab70525fbfc85
2015-06-11 13:11:56 +00:00
Jenkins d80c70e58a Merge "Improve import related error handling" 2015-05-26 18:20:16 +00:00
Jenkins 064822181a Merge "Fix Metadef Object update issue with python-glanceclient" 2015-05-26 14:59:51 +00:00
Jenkins 85078098e7 Merge "Use assertIn instead of assertTrue in tests" 2015-05-26 09:55:18 +00:00
Jenkins 0bf3bfe94f Merge "Unorder compare in tests" 2015-05-26 01:29:03 +00:00
Cindy Pallares 6cb26fc2bf Include owner and status option in v2 image list
Show the owner and status information when adding -v or --verbose
to the image-list command.

Closes-bug: #1381514
Change-Id: I90bf622147b12ed157072fad0823af58223caf91
2015-05-22 01:56:42 -05:00
Lakshmi N Sampath 5d933b0dd5 Fix Metadef Object update issue with python-glanceclient
Disallowed fields(schema, created_at and updated_at) were
getting deleted from Metadef namespace instead of Metadef object.

Change-Id: Id80e204c7af1ac6926c66627d290a15c4e6b00d9
Closes-Bug: #1433884
2015-05-18 13:49:52 +02:00
Stuart McLaren 1f89beb609 Improve import related error handling
If there was a problem importing a library we would incorrectly raise
an unsupported version error:

  $ glance --os-image-api-version 1 image-list
  "1" is not a supported API version. Example values are "1" or "2".

We should change this to provide information on the failed import, eg:

  $ glance --os-image-api-version 1 image-list
  No module named badimport

We also now raise the full stacktrace in this case if '--debug' is passed
on the command line.

Change-Id: I1c687ae6c5da239090b0b7a4a855b3271a9076da
Related-bug: 1402632
2015-05-08 12:51:02 +00:00
Fei Long Wang 116fac8ae8 Add parameter 'changes-since' for image-list of v1
Now Glance /images/detail API of v1 supports parameter
'changes-since' to query deleted images. But it's missed
in client. This patch will add the parameter.

Related-Bug: #1432701

Change-Id: Id38e3a78b4b2ef680ea04d35e32beb4b9c8efa00
2015-05-06 14:58:44 +12:00
Kamil Rykowski bf413a6539 Use assertIn instead of assertTrue in tests
Since `assertIn` is provided for checking if value exists in given
container, it is not formal to use `assertTrue` for it.

Change-Id: Ie1392839b5ca436957463bb29f2784d48cfcbf75
2015-04-29 10:31:22 +02:00
Jamie Lennox 6431fae545 Unorder compare in tests
On occassion the values from schema are presented in a different order.
Compare them in an unordered way as we only care that both are present.

Change-Id: Ib2d44587196f43c73f4b0a3796fac9f4dc20f20f
2015-04-29 04:12:35 +10:00
Stuart McLaren f2a8a520e7 Move unit tests to standard directory
This patch moves the glanceclient unit tests to the standard directory
(xxxclient/tests/unit) in preparation for adding functional gate tests
'check-glanceclient-dsvm-functional' in the same vein as existing client
tests for other projects, eg:

* check-novaclient-dsvm-functional
* check-keystoneclient-dsvm-functional
* check-neutronclient-dsvm-functional

Change-Id: I29d4b9e3a428c851575ee9afde40d6df583456c4
2015-04-18 17:42:20 +00:00