Commit Graph

803 Commits

Author SHA1 Message Date
Dougal Matthews b7442c5694 Replace 'raise StopIteration' with 'return'
With PEP 479, the behaviour of StopIteration is changing. Raising it to
stop a generator is considered incorrect and from Python 3.7 this will
cause a RuntimeError. The PEP recommends using the return statement.

More details: https://www.python.org/dev/peps/pep-0479/#examples-of-breakage

Change-Id: Ia067940066a5666926dcf61136b03d721a87666e
2018-06-29 14:31:51 +01:00
Doug Hellmann e484311923 update shell tests to not rely on the serialization order of a dict
Under python 3 with ordering randomized we cannot depend on the JSON
output matching exactly. Instead we de-serialize the data structure
that was written and compare the structures, which will always match.

Change-Id: I134b62413a7cde25f3efda6a2452c1e3d11d41d0
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-06-07 17:51:28 -04:00
Cyril Roelandt abfe0f4bf3 Image show: print human readable string when the virtual size is unknown
Currently, when the virtual size of an image is not known, "None" is displayed.
To a regular user, it feels like a programming error. We try and make things
clearer by using a "human readable" string instead.

Change-Id: Id7b8799356857d9bc58cc8a3677024fe1a7f4f56
Partial-Bug: #1665037
2018-05-31 18:52:20 +02:00
Zuul 1ef5e5d169 Merge "Removes unicode 'u' response from "glance image-tag-update"" 2018-05-18 16:23:20 +00:00
Brian Rosmaita ee029a9b92 Handle HTTP headers per RFC 8187
According to RFC 8187, HTTP headers should use 7-bit ASCII encoding.
The glanceclient was encoding them as UTF-8, which can leave the 8th
bit nonzero when representing unicode, and which presents problems
for any recipient following the standard and decoding the headers as
ASCII.

This change requires keystoneauth1 3.6.2, which has a fix for a
bug that made it unable to handle bytes in headers.  The dependency
is a patch bumping the keystoneauth1 version in upper-constraints.

Depends-on: https://review.openstack.org/#/c/569138/

Change-Id: I0d14974126fcb20e23a37347f4f1756c323cf2f5
Closes-bug: #1766235
2018-05-17 15:53:34 -04:00
Zuul 94aa58e89e Merge "Split glanceclient functional tests" 2018-04-12 17:17:19 +00:00
Zuul 939e532a3a Merge "Update local copy of image schema for 2.6" 2018-04-11 04:34:37 +00:00
Zuul 6b6def6182 Merge "Make image-import fail faster" 2018-04-09 13:17:57 +00:00
Zuul 3ceba79042 Merge "Fix python 3.6 escape char warning" 2018-04-09 13:17:56 +00:00
Brian Rosmaita e89fcae346 Update local copy of image schema for 2.6
Update the local copy of the image schema to reflect Image API 2.6.

Change-Id: Ib0e56027927880d0fa198ffd8ea4b57e39f9d0fe
Closes-bug: #1762044
Depends-on: https://review.openstack.org/#/c/559501/
2018-04-08 14:48:36 -04:00
Brian Rosmaita 46dd4dd60f Make image-import fail faster
Add checks to image-import command so that it provides better user
feedback in failure situations.

Change-Id: I8b6b32c3d1d1a745aa68ff8dc629419dff9bb130
Closes-bug: #1758718
2018-04-04 14:36:13 -04:00
Brian Rosmaita 79543a67ed Make image-create-via-import fail faster
Add checks to the image-create-via-import commmand so that it provides
better user feedback and doesn't begin the import workflow unless the
input has a chance of succeeding.  Preserves backward compatibility
with the current image-create command by (1) allowing an image record
only to be created when no import-method is specified AND no data is
supplied, and (2) doing the glance-direct workflow when no import-
method is specified AND data is provided.  Also adds the ability for
the import-method to be set as an env var OS_IMAGE_IMPORT_METHOD.

Change-Id: I0a225f5471a9311217b5d90ebb5fd415c369129a
Closes-bug: #1758149
2018-04-04 13:51:40 -04:00
Brian Rosmaita dc3ee4aedb Fix intermittent v2 shell unit test failures
The do_image_download code has a check to make sure that there's
a place to put the data (either filename or stdout redirect) before
initiating the download.  The location of this check was moved by
change I841bebeda38814235079429eca0b1e5fd2f04dae to happen at the
beginning of the function.  The two intermittently failing tests
do not explicitly address the check condition, and as a result the
tests do exit early, but before they can check what they're supposed
to be testing.

Closes-bug: #1759951

Change-Id: I3c85bb358f669504b364d55618c21382b7a2a66b
2018-03-29 17:28:44 -04:00
Brian Rosmaita 32b8307819 Split glanceclient functional tests
Prepare for the Image API v1 to be removed from glance during Rocky
by splitting the functional tests that hit v1 from the tests that hit
v2.  Introduce a new job that runs the functional-v1 tests against a
devstack running glance stable/queens, and configure this job for both
check and gate for the glanceclient.  The v2 functional tests
continue to be run for both check and gate against a devstack running
glance master.

Change-Id: Ifa98ada26a84e4cca3ea8c98173f61a6174cca27
2018-03-28 22:32:44 -04:00
Zuul bf820a1896 Merge "Remove usage of ordereddict" 2018-03-26 16:10:27 +00:00
Zuul 3142c9ab14 Merge "Update properties URL" 2018-03-22 19:14:59 +00:00
Brian Rosmaita 6cd537e274 Check for container,disk_format on web-download
Fail image-create-via-import requests for the web-download import
method that don't include values for container_format or disk_format.

Closes-bug: #1757927

Change-Id: Ic5c81916823ff32f2dbddd32b40e825de0697dc9
2018-03-22 01:16:41 -04:00
Brian Rosmaita 0661da1ee9 Update properties URL
Help text for some image properties (architecture, os_distro) is
pulled from the glanceclient's local version of the image schema.
The URL for those property definitions has gotten out of sync with
Glance.  This patch updates the URL to be the same as that given
in the Glance image-schema response.

Change-Id: I4e46e78525fe5c00e031a98c47cacc17e5693d53
Closes-bug: #1757918
2018-03-21 22:30:29 -04:00
PranaliD aedabec9e4 Add support for web-download import method
This change adds support for 'web-download' import method
to 'image-import' and 'create-image-via-import' call.
To use this 'web-download' import method, user needs to pass
--uri option 'a valid uri to external image to import in glance'
to 'image-import' and 'create-image-via-imaport' calls.

Co-authored-by: Pranali Deore <pdeore@redhat.com>
Co-authored-by: Erno Kuvaja <jokke@usr.fi>

Change-Id: I0e1d18844f64723608288de473e97710798eb602
2018-03-21 15:09:13 +00:00
Dirk Mueller 5916702cb2 Remove usage of ordereddict
This was only needed for Python < 2.7, but glanceclient's setup.cfg
already declares compatibility only with 2.7.

Change-Id: I80d42abf5dd5565da424a90a93545ba82ef7a58d
2018-03-08 10:30:31 +01:00
Abijitha Nadagouda 195add500b Removes unicode 'u' response from "glance image-tag-update"
"glance image-tag-update" command returns unicoded response
for lists. Therefore it requires print_list method from util
class to handle such case. Added unicode_key_value_to_string()
method to remove extra 'u' from lists and dictionaries. This
fix is inspired from cinderclient's implementation.

Change-Id: I16a04e8d34f7629f72fe389456001ca1db9335ea
Closes-bug: #1534046
2018-02-02 10:36:27 +05:30
Rui Yuan Dou 8e862b6018 Remove deprecated ssl options
Old deprecated ssl options block the new keystoneauth parser get the
correct value, should be removed.

Change-Id: Ie080f9a8fa7f4407b1fcbb7fb7c763152c5ec295
Closes-Bug: 1697163
2018-01-17 08:50:57 +08:00
Stephen Finucane 4dcbc30e31 Compare against 'RequestIdProxy.wrapped'
Due to the 'glanceclient.common.utils.add_req_id_to_object' decorator,
an instance of 'glanceclient.common.utils.RequestIdProxy' is returned
for most calls in glanceclient. If we wish to compare to None, we have
to compare the contents of this wrapper and not the wrapper itself.

Unit tests are updated to highlight this.

Change-Id: I7dadf32d37ac2bda33a92c71d5882e9f23e38a82
Closes-Bug: #1736759
2018-01-02 11:36:02 +00:00
Brian Rosmaita bb0911910e Revise functional testing README file
Clarifies the location of clouds.yaml for functional testing.

Change-Id: Ib0b8e84579bca72e791229752df14542358e21b7
2017-12-15 16:03:45 -05:00
Brian Rosmaita c0e63d977f Migrate dsvm functional test jobs to project repo
Migrate legacy dsvm functional test jobs for python-glanceclient
to the project repository as zuul3 jobs using the devstack
functional base job.

Co-authored-by: Monty Taylor <mordred@inaugust.com>
Co-authored-by: Brian Rosmaita <rosmaita.fossdev@gmail.com>

Needed-By: I0b974bf60da6bafabeb037a75ac10654e2a6406c
Needed-By: I0271a1430843ef546e991a7a3c4b572b3e404963
Depends-On: I84de60181cb88574e341ff83cd4857cce241f2dd
Change-Id: I1977ee0d348645987107c2efb5b454d7f8b81adf
2017-12-14 15:39:26 +00:00
Brian Rosmaita 79d0051655 Add domain info to functional test clients
Keystone wants domain info, so pass it on.

Change-Id: Ie99f79b61e5f8d469695fa19ad99d919fa23ae8e
Closes-bug: #1737583
2017-12-11 11:58:58 -05:00
Jenkins b90236eef8 Merge "image-create-via-import fails with ValueError" 2017-08-24 19:54:41 +00:00
Abhishek Kekane 335f1e9447 image-create-via-import fails with ValueError
CLI image-create-via-import fails with ValueError. The reason
is create command returns RequestIdWrapper object and not image
and response.

Further it fails with AttributeError: 'Namespace' object has
no attribute 'import_method'. The reason is do_import_image() call
requires 'import_method' as input which is not provided at the
moment.

Change-Id: Ic4c4d1f3c5d290b584840e8f9047fb53611a5748
Closes-bug: #1711511
2017-08-24 14:29:37 +00:00
Jenkins b956f48078 Merge "Fix image-import call" 2017-08-24 09:17:30 +00:00
Brian Rosmaita e5b69eff69 Fix image-import call
Change the request body sent from the client to be the format
that the API expects for the image-import call.

Depends-On:  I08783e28719e63b5a4b2115b8fce135e55be460a
Change-Id: I5e34d772d561306c6f103c859740658a825dd189
Closes-bug: #1711259
2017-08-18 15:12:04 +00:00
Abhishek Kekane 0e50837a37 stage call fails with TypeError
image-stage call fails with TypeError saying 'stage() takes exactly
3 arguments (4 given). The reason is stage() also accepts image_size
as a argument which is not provided.

Further it raises 'NoneType' object has no attribute 'headers'. The
reason is stage() internally calls upload method which
returns a object of RequestIdWrapper on body (which is None) and
response. In stage call it again tries to add request id which requires
response object but instead it has a RequestIdWrapper which fails to
retrieve headers.

Change-Id: I4de4be7a55f35c3533b53acd48042c7c95b4bdc0
Closes-bug: #1711090
2017-08-17 11:37:20 +05:30
Eric Harney 1868200e9c Fix python 3.6 escape char warning
In python 3.6, escape sequences that are not
recognized in string literals issue DeprecationWarnings.

Convert these to raw strings.

Change-Id: I508a9147b932e219069eeee756bcbc43c7e961c5
2017-07-31 11:58:41 -04:00
Erno Kuvaja 52eb529b97 Add missing docstring
Adding missing docstring for image-import command.

Change-Id: Ide95056797230963e9ef63c1cb72d42e697023e7
2017-07-27 21:09:05 +00:00
Jenkins 083931f87f Merge "Add image import features to client" 2017-07-27 21:04:08 +00:00
Erno Kuvaja c0753bdde6 Add image import features to client
This change adds availability of the features introduced on Image
Import Refactoring work. Including:
Discovery call to discover what Import modes are available
Staging call to stage the image for import in 'glance-direct'
Import call to trigger the actual Image Import task
EXPERIMENTAL: Image creation with the new workflow

Change-Id: I2d10ac0cc951c933c3594837b490638e38ff0b12
2017-07-27 18:07:50 +00:00
Jenkins 982857abc8 Merge "Validate input args before trying image download" 2017-07-26 14:15:35 +00:00
Jenkins ca9ae01841 Merge "Make --profile load from environment variables" 2017-07-26 04:33:49 +00:00
Jenkins c9730bfcc6 Merge "help text for container_format, disk_format" 2017-07-25 18:06:19 +00:00
PranaliD 28c003dc11 Removed the --no-ssl-compression parameter which is deprecated
--no-ssl-compression is deprecated and no longer used. So, it is
removed from the help message.

Change-Id: I2b886671a568ed191ee380cf16335ccd9ae85062
Closes-Bug: #1583919
2017-07-25 18:51:38 +05:30
Jenkins 7ad13b648a Merge "Fix 'UnicodeEncodeError' for unicode values in url" 2017-07-24 14:36:17 +00:00
Ravi Shekhar Jethani 1df55dd952 Validate input args before trying image download
Currently client is contacting glance service even if the
caller has niether specified any redirection nor '--file'
option. This unnecessary request although isn't causing
any critical issues but can be avoided by simply doing
input validation first.

TrivialFix

Change-Id: I841bebeda38814235079429eca0b1e5fd2f04dae
2017-07-24 14:54:57 +05:30
Tovin Seven c0f88d5fc0 Make --profile load from environment variables
--profile argument can be loaded from OS_PROFILE environment variables
to avoid repeating --profile in client commands.

Correct/update help text.

Co-Authored-By: Hieu LE <hieulq@vn.fujitsu.com>
Change-Id: I67c1e4b859b972e380eb658c98ceae4fbef5c254
2017-07-24 13:30:29 +07:00
M V P Nitesh 4d0a3c309e help text for container_format, disk_format
Updated the container_format and disk_format in v1 help text.

Change-Id: I4ebe4982c179450defe8ad5703999f4074ae32f8
Closes-Bug: #1659010
2017-07-06 13:09:44 +05:30
Jenkins a53b302764 Merge "Replace assertTrue(isinstance()) with assertIsInstance()" 2017-06-30 21:03:45 +00:00
Doug Hellmann c859380718 turn on warning-is-error in sphinx build
Fix a formatting error in one docstring and turn on the flag to ensure
that future warnings in the doc build trigger a build failure.

Change-Id: I7159b985d1690a8ae61ff885408da4623c105952
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-06-28 12:25:32 -04:00
Doug Hellmann d6e936cd14 add explicit dependency on pyopenssl
The library is used in glanceclient/common/https.py and the
documentation build for the API fails without the dependency.

Update the error handling so that when OpenSSL reports an error it is
converted to a client communication error.

Change-Id: I0c0fb3139bb848d0cbaf88ae6a767a730bea74eb
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-06-28 12:24:48 -04:00
Jenkins 05453b19b2 Merge "Replace six.iteritems() with .items()" 2017-06-28 14:49:38 +00:00
Doug Hellmann c8a7a5d56d allow unhandled exceptions to cause test errors
Hiding the unhandled exception in the test with a failure makes it
harder to debug the problem. Let them pass unhandled so the test reports
an ERROR instead of FAILURE.

Change-Id: I4e435a6d276fdf161dac28f08c2c7efedd1d6385
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-06-26 10:59:29 -04:00
Jenkins 4682d403d2 Merge "Remove log translations" 2017-06-19 19:13:08 +00:00
Van Hung Pham 7791110b2f Replace assertTrue(isinstance()) with assertIsInstance()
Some of tests use different method of assertTrue(isinstance(A, B))
or assertEqual(type(A), B). The correct way is to use
assertIsInstance(A, B) provided by test tools.

Change-Id: Ibb5e5f848c5632f7c1895c47b8c1a938f2c746c3
2017-06-14 11:03:10 +07:00