Commit Graph

79 Commits

Author SHA1 Message Date
Thomas Leaman 822cd64c07 Fix SSL certificate CNAME checking
Currently, accessing a host via ip address will pass SSL verification;
the CNAME is not checked as intended as part of verify_callback.

'preverify_ok is True' will always return false (int/bool comparison).
preverify_ok will be 1 if preverification has passed.

Fixes bug 1192229

Change-Id: Ib651548ab4289295a9b92ee039b2aff2d08aba5f
2013-07-15 08:50:17 +00:00
Jenkins 8427208015 Merge "Rename invalid domain name to be RFC compliant." 2013-07-08 16:16:21 +00:00
Venkatesh Sampath b9c1df8dfc Enable client V2 to update/delete tags for a given image.
Added the CLI option image-tag-update to associate a tag to an image via API V2.
Added the CLI option image-tag-delete to delete a tag associated with an image via API V2.

Related to bp glance-client-v2

Change-Id: I76060e1982223770a6c2c0bd9376d568af0df456
2013-07-02 21:32:49 +05:30
Monty Taylor bd0880cc94 Rename invalid domain name to be RFC compliant.
http://tools.ietf.org/html/rfc6761 and
http://tools.ietf.org/html/rfc2606 define invalid domain names to
be used in contexts such as this. It's good to be compliant with RFCs.

Change-Id: Ibb7f9ee12c0c4331f8a33470def74c3a136ef6d9
2013-06-30 23:33:07 -04:00
Dirk Mueller 62579fbb21 Start using Pyflakes and Hacking
Instead of globally ignoring pyflakes and
hacking warnings, only blacklist those that trigger
very frequently so far, in order to clean them
up in followup commits. Fix and start gating
on the rest already.

Change-Id: Ied7c7250061e3bf379e8286e8ce3b9e4af817faf
2013-06-22 16:00:26 +02:00
Kevin McDonald d8a537c7fe Removes extra slash on endpoints without a path
Change-Id: I5ce54117c5ac276fb9629c71eb16db88e078c947
Fixes: bug #1179984
2013-06-19 15:49:05 +00:00
Jenkins c120aff87f Merge "Fix problem where image data is not read from a pipe." 2013-06-18 12:47:31 +00:00
Flaper Fesp 7818387d4a Replace utils.ensure_(str|unicode) with strutils.safe(decode|encode)
Glanceclient implemented both functions before they landed into oslo.
Since both functions are already in oslo, it is now possible to pull
them in.

There's a small difference between glance's implementation and oslo's,
that is the later does not convert non-str objects - int, bool - to str
before trying to decode / encode them. This patch takes care of that
where necessary, more precisely, while encoding headers before doing a
new request.

Fixes bug: #1172253

Change-Id: I9a0dca31140bae28d8ec6aede515c5bb852b701b
2013-06-04 00:42:32 +02:00
Flaper Fesp 7daa976d14 Do not decode headers in v1/images.py
v1.images._image_meta_to_headers currently encodes headers as a way to
ensure they're an instance of basestring. This is not necessary since
headers will be encoded later during the request. Also, all data within
the client should be already decoded.

Fixes bug: #1187013

Change-Id: I80525adbc6e9e576cfad5b576090ef9ee574c1cf
2013-06-04 00:41:24 +02:00
Hugh Saunders 9fda0dc815 Fix problem where image data is not read from a pipe.
For image-updae and image-create commands, glanceclient attempts to
determine whether image data should be uploaded based on the presence
of data on stdin. Unforunately it is difficult to determine if data is
available, especially when standard in is from a pipe.

This is especially problematic for update operations, where data must
only be uploaded if the image is in queued state. For example data may
be uploaded when the user only wants to rename an image, but the rename
will be rejected because data cannot be uploaded to an unqueued image.

This patch removes the check that attempts to determine if data is
available to read as it didn't work for pipes. It also re-introduces a
check for image state in the update operation, so that glanceclient only
attempts to read data if the image being updated is in queued state.

The image state check is part of the original patchset that was removed
so the patchset could have a single focus [1]

This patch also removes a test for handling empty stdin, and adds a test
for reading stdin from a pipe.

[1] https://review.openstack.org/#/c/27536/3/glanceclient/v1/shell.py

Fixes: bug 1184566
Related to: bug 1173044

Change-Id: I8d37f6412a0bf9ca21cbd75cde6a4d5a174e5545
2013-06-03 18:01:58 +01:00
Flaper Fesp 81e88344fb Add tests for encodings
The patch adds tests for headers encodings, incoming data decoding,
outgoing meta encoding and filters encoding.

Fixes bug: #1187013

Change-Id: I7e59bf6c44b9d188bd3faf32fc09f309f3ad67d3
2013-06-03 17:40:50 +02:00
Hugh Saunders a3585ef62d Don't attempt to read stdin if it is empty.
* Check for available data size in v1/shell.py/_set_data_field, don't
   read if 0.
 * Add test_shell.py including tests for 3x stdin scenarios:
	* closed
 	* open and empty
	* open with data

Change-Id: I6ff65b0e226be509de9cd3f021560081529283b0
Fixes: bug #1173044
2013-05-23 13:37:09 +01:00
Jenkins 985c06bea1 Merge "Improve unit tests for python-glanceclient.glanceclient.common.base" 2013-05-22 23:40:25 +00:00
Zhi Yan Liu 8c70c5b08d Convert non-ascii characters within image property to unicode
Convert non-ascii characters within image property (key/value pair) to
unicode but utf-8 to prevent provisioning failure when cloud using qpid
backend.
This change also make the image property encoding consistency between
the image updating and the receiving. Before this, image property
updating use unicode, but receiving (get) result is utf-8.

Fixes: Bug #1180377

Change-Id: I010760c598a7e008c79f1240255708265352cdb5
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2013-05-21 00:03:31 +08:00
Tatyana Leontovich 8451a94822 Add test for glanceclient shells
Add unittests for the following modules:
* glanceclient.shell
* glanceclient.v1.shell
* glanceclient.v1.legacy_shell
* glanceclient.v2.shell
Also add mock library to the tools/test-requires

Implements: blueprint glanceclient-shells-unittests
Change-Id: I5ec527c5efff3726932d234d7c67e08149643f89
2013-05-17 19:46:07 +03:00
Tatyana Leontovich ab36778ec3 Improve unit tests for python-glanceclient.glanceclient.common.base
Add several tests for glanceclient.common.base module

Fixes: bug #1144158
Change-Id: Ifc288075c79849ee1384f09f513874ee08cd0248
2013-05-15 17:59:43 +03:00
iccha-sethi 18795f590a Image Members for glance v2 api
Lists, creates, deletes, updates image members using glance
v2 api.

Related to bp glance-api-v2-image-members

Change-Id: Ic018a265a1676bb0a5638a55e70a527ce6b447fc
2013-05-09 10:54:12 +00:00
Jenkins 4bbc7b8a9b Merge "Improve Python 3.x compatibility" 2013-04-24 16:38:25 +00:00
Dirk Mueller 45feb672af Improve Python 3.x compatibility
Some mechanical translation of the deprecated
except x,y construct. Should work with Python >= 2.6
just fine

Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
2013-04-22 16:38:55 +02:00
John Bresnahan 2178120e9a Test that copy_from is used properly in old API
This adds a test to verify that the copy from attribute is used
properly.  It tests for bug 1167899.  This submission depends on
the review here: https://review.openstack.org/#/c/26740/

Change-Id: Ied14fb29887b7cbbecbab51bd384cf0f640c9e18
2013-04-12 10:59:28 -10:00
Tatyana Leontovich 0995045f2a Improve unit tests for python-glanceclient.glanceclient.common.http
Add several tests for glanceclient.common.http module

Fixes: bug #1149445
Change-Id: I6a47c64e11cefea276163777dcd559316fc8e0ad
2013-04-04 15:06:57 +03:00
Jenkins 6a8a66120c Merge "Filter images list by public=True|False" 2013-04-02 16:11:27 +00:00
John Bresnahan a8f7de2afd Filter images list by public=True|False
When running the image-list command the user should have the option
to list images according to whether or not the image is was set
to public.  A new test is included to verify this behavior.

Change-Id: If645e7390fcf850648cda780a04ea37a26d855a2
Fixes bug: 1118799
2013-03-30 21:26:35 -10:00
Jenkins 16208485bb Merge "Allow for prettytable 0.7.x as well" 2013-03-21 22:48:35 +00:00
Dirk Mueller 31960f0a85 Allow for prettytable 0.7.x as well
Relax requirements to >= 0.6, < 0.8, as 0.7.x seems to
work as well. Added testcase to ensure this.

Change-Id: I1a1a709e6053451b1256a0d78f8fe8562fb10e62
2013-03-15 17:38:04 +01:00
Brian Rosmaita 552a68d2bf Implements filters: visibility, owner, member_status.
Includes tests.

Related to bp glance-api-v2-image-members

Change-Id: Ic48f54639fec4dc9b48819a8ffb1f0097001894c
2013-03-08 14:01:34 +00:00
Stanislaw Pitucha 7f7c9a1d85 Report name resolution errors properly
Errors in name resolution have been logged previously with the url path
rather than the hostname. That resulted in incorrect errors like:

InvalidEndpoint: Error finding address for
/v1/images/detail?is_public=none&limit=20: [Errno -2]
Name or service not known

rather than one mentioning hostname itself. This patch changes the log
message to fit the situation.

Change-Id: I1eecbcb22d41b1341c214937b9cbfd046fd301a0
2013-02-19 17:22:55 +00:00
Jenkins d831b5eb27 Merge "Decode input and encode output" 2013-02-18 18:58:14 +00:00
Flaper Fesp 55cb4f4473 Decode input and encode output
Currently glanceclient doesn't support non-ASCII characters for images
names and properties (names and values as well). This patch introduces 2
functions (utils.py) that will help encoding and decoding strings in a
more "secure" way.

About the ensure_(str|unicode) functions:

    They both try to use first the encoding used in stdin (or python's
    default encoding if that's None) and fallback to utf-8 if those
    encodings fail to decode a given text.

About the changes in glanceclient:

    The major change is that all inputs will be decoded and will kept as
    such inside the client's functions and will then be encoded before
    being printed / sent out the client.

    There are other small changes, all related to encoding to str,
    around in order to avoid fails during some conversions. i.e: quoting
    url encoded parameters.

Fixes bug: 1061150

Change-Id: I5c3ea93a716edfe284d19f6291d4e36028f91eb2
2013-02-13 21:53:11 +01:00
Brian Waldon 00ba17965a Add library support for v2 image update
Related to bp glance-client-v2

Change-Id: Ia6fe16e462ce8827175577cbed8e15c326bf8ad3
2013-02-13 10:06:25 -08:00
Anita Kuno a6ef8ed7da Adds image-delete functionality.
Change-Id: Ic10433f6eb484a4760f3e61f040e903e86b95d91
2013-01-29 15:39:46 +00:00
Monty Taylor 1d461a6496 Use testtools instead of unittest.
Part of blueprint grizzly-testtools

Change-Id: Ie914fd8f59cddb1a480566ec4eff908bfb51921c
2013-01-02 15:20:36 -08:00
Dean Troyer 4781da7007 Support --os-cacert
* Rename --ca-file to --os-cacert (--ca-file deprecated for
  backward compatibility)
* Add cacert to keystoneclient initialization to verify the
  keystone server certificate

This aligns glanceclient with keystoneclient for option naming
and the use of TLS for the keystone auth connection.  It does not
change the use of TLS/SSL for the glance connection.

Change-Id: If8b05655aea5f3c62612d77bf947dd790f77eddf
2012-12-11 14:46:33 -08:00
Jenkins b66e6faac0 Merge "Add --sort-key and --sort-dir to image-list" 2012-11-30 21:22:23 +00:00
Brian Waldon 4da8b287b4 Add --sort-key and --sort-dir to image-list
The --sort-key and --sort-dir CLI options allow users to control the
field and direction by which their images are sorted in an image-list
operation. The previous default sort behavior of sorting by ID asc has
been preserved.

Fixes bug 1082957.

Change-Id: I1d3664219c275b0379fe176f8288d6ffae0dffbe
2012-11-28 09:46:32 -08:00
Jenkins 59b8ac198b Merge "Verify that host matches certificate" 2012-11-26 23:20:16 +00:00
Chuck Short c0ec97f310 Pin pep8 to 1.3.3
Standardize pep8 to 1.3.3 and cleared up any errors
found by pep8 tests.

Change-Id: Ib7eb97d0789556d1676ccad58b5d3364065b7d15
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2012-11-25 11:34:56 -05:00
Stuart McLaren 7a5946fd87 Verify that host matches certificate
When using https verify that the Common Name (CN) or
the Subject Alternative Name listed in the server's
certificate match the host we are connected to.

Addresses LP bug 1079692.

Change-Id: I24ea1511a2cbdb7c34ce72ac704d7b5e7d57cec2
2012-11-20 09:56:00 +00:00
Brian Waldon fe17d35174 Simplify human-readable size output
* Limit human-readable sizes to a single decimal
* Drop trailing zero
* Step one suffix further in the case of a size being 1024

Change-Id: I2eb8ac0571d3d08b52f62155912863870573a37c
2012-11-19 10:35:04 -08:00
Christian Berendt b24832c22a Make image sizes more readable for humans
By introducing the parameter --human-readable for several functions
(image-list, image-show, image-update, image-create) it's possible
to convert the size in bytes to something more readable like
9.309MB or 1.375GB.

Change-Id: I4e2654994361dcf330ed6d681dbed73388f159cb
2012-11-19 10:15:19 -08:00
Jenkins 3576336cb9 Merge "Handle create/update of images with unknown size" 2012-10-13 02:17:31 +00:00
Stuart McLaren 556082cd66 Implement blueprint ssl-connect-rework
Use pyOpenSSL for HTTPS connections.

This allows:

* Neater loading of system CA files
* Optional disabling of SSL compression

The performance gain from disabling SSL compression is significant
in cases where the image being uploaded/downloaded is in an already
compressed format (eg qcow2).

Related to bp ssl-connect-rework.

Change-Id: I0568b6c95c5fc7b8eafdbd0284e24c453660a55a
2012-10-08 13:51:41 +00:00
Stuart McLaren 727aadbc25 Handle create/update of images with unknown size
It may not be possible to know in advance the total
size of image data which is to be uploaded, for example
if the data is being piped to stdin.

To handle this we use HTTP Transfer-Encoding: chunked
and do not set any image size headers.

Various subtly different cases needed to be handled for
both image-create and image-update, including:

 * input from named pipe
 * piped input of zero size
 * regular file of zero length

Fix for bug 1056220.

Change-Id: I0c7f0a64d883e058993b954a1c465c5b057f2bcf
2012-10-08 11:16:18 +00:00
Brian Waldon 11e6aadf19 Add happy path tests for ResponseBodyIterator
Change-Id: I5e971b57a0591752e7fca76d0df78ce139308db5
2012-10-02 09:19:37 -07:00
Andrew Laski 8cee48b1dd Make ConnectionRefused error more informative.
When the server refuses the connection the error message displayed now
lists the endpoint that refused the connection.

Fixes: bug 1043067
Change-Id: I62797106732bbb6eec8c99e491fd38850ad58ff8
2012-09-12 16:51:55 -04:00
Unmesh Gurjar 30d8e1b97c Specified Content-Length in update request header
While uploading a Volume to an image, the HTTPConnection's request method does
not set the Content-Length header (since the volume file is a sym link i.e. the
os.fstat call returns a st_size of 0). This causes Volume uploads to Glance
fail (since the image data is ignored as no content-length is specified).
Therefore setting the Content-Length from update( ) method if the image data is
provided.

Fixes LP: #1045824

Change-Id: If259fc5a338e3e90214a52b773132ed901691c0f
2012-09-06 00:41:08 -07:00
Brian Lamar d64876424e Ensure v1 'limit' query parameter works correctly.
The tests were present but were not asserting list results.

page_size was overriding the absolute limit so limits were
not working if they were less than the page_size.

Fixes bug 1037233

Change-Id: If102824212e3846bc65d3f7928cf7aa2e48aaa63
2012-08-15 14:50:11 -04:00
Brian Waldon a5b8165d7d Allow 'deleted' to be passed through image update
The legacy client allowed users to pass 'deleted' through an
update call. This is breaking some clients of this library because
they expect to be be able to still do that.

Fixes bug 1036315

Change-Id: I9ae20a5e4579240c7d5e86316d6d1e927755dbf5
2012-08-13 10:56:27 -07:00
Brian Waldon 8f0d5c4f2c Cast is_public, protected, deleted to bool
To keep a consistent view of an image, is_public, protected, and
deleted need to be cast to a bool when being parsed from headers.

Fix bug 1036299

Change-Id: I2730a0f2d705d26ebc0ba883e99c1caf44d70b51
2012-08-13 10:55:43 -07:00
Brian Waldon 1e539dfdbe Return known int values as int, not str
Cast size, min_ram, min_disk to integers before returning them
to the user from the v1 API.

Fixes bug 1036297

Change-Id: Ib1e2a3bf931e433b6311cc8a1a5219168b50be97
2012-08-13 10:18:51 -07:00