Commit Graph

128 Commits

Author SHA1 Message Date
Jenkins d4196325eb Merge "Revert "Don't update tags every time"" 2016-08-20 19:16:37 +00:00
Steve Martinelli b78285761d Revert "Don't update tags every time"
This reverts commit e77322c179.

Change-Id: Ida826a2aa888beeb76dbe657b2ccd6cb088157ed
2016-08-19 06:10:14 +00:00
Jenkins 5de07c3395 Merge "Fix warlock model creation" 2016-08-12 15:15:46 +00:00
Jenkins 7936f173c0 Merge "Don't update tags every time" 2016-08-08 09:09:22 +00:00
Sirushti Murugesan 376037d371 py3: Fix encoding and use sys.stdin.buffer
* 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
2016-07-25 20:13:08 +05:30
Jenkins 7e17c30dad Merge "Update docs URL" 2016-07-14 05:42:08 +00:00
KATO Tomoyuki b660d3247a Update docs URL
Change-Id: Id8b1b97a85534c4398b3c49648c6e2f2df3ee20e
Related:-Bug: #1602266
2016-07-13 09:00:24 +09:00
Sabari Kumar Murugesan d7db97c926 Fix warlock model creation
Commands like glance md-namespace-show <namespace> fail because
of a breaking change in warlock 1.3.0's model creation factory
method.

Warlock introduced a new kwarg 'resolver' in model_factory method
but changed its position with the 'base_class' kwarg. Since we
were calling the model_factory method with positional arg, this
broke the model creation.

Closes-Bug: #1596573

Change-Id: Ic7821f4fdb1b752e0c7ed2bc486299a06bf485c1
2016-07-06 18:18:42 -07:00
Stuart McLaren 7ed22a91d3 image-download: tests to catch stray output
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
2016-06-29 16:08:30 +00:00
zhengyao1 c3de38ed53 Use correct order of arguments to assertEqual
The correct order of arguments to assertEqual that is expected by
testtools is (expected, observed).

This patch fixes the inverted usage of arguments in some places
that have cropped up since the last fix of this bug.

Change-Id: If8c0dcb58496bc2fcf4c635f384522a1f7d2b2af
Closes-Bug: #1259292
2016-06-29 03:46:30 +00:00
kairat_kushaev 2ab2678140 Remove deprecated construct method from session init
construct method is marked as deprecated and might be deleted
in one of future releases. So glanceclient need to be aware of
that and initialize sesssion from command line arguments directly.

Change-Id: Ie81b62b7e70bb177f178caadc41554ae88e51b05
2016-06-09 19:31:02 +00:00
Mike Fedosin e77322c179 Don't update tags every time
This code removes unnecessary PATCH requests
for tags updating if they were not modified.

Change-Id: I8eced32f39d0c98e0b26014e7b2341ab6580ff01
Closes-bug: 1587999
2016-06-01 21:02:29 +03:00
Jenkins 6f2fae7a19 Merge "Fix "Codec can't encode characters"" 2016-05-23 14:31:04 +00:00
Jenkins 2e6f60502e Merge "Get endpoint if os_image_url is not set" 2016-05-19 16:57:27 +00:00
Darja Shakhray 9329ef0bc4 Fix "Codec can't encode characters"
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
2016-05-19 16:48:03 +00:00
Jenkins 7150ceee1a Merge "Add last_request_id member to HTTPClient and SessionClient" 2016-05-18 21:44:53 +00:00
Niall Bunting a862196cfb Get endpoint if os_image_url is not set
If env['OS_IMAGE_URL'] is not set then None is returned. This is then
used ignoring the endpoint_type, service_type and region_name. This
patch will use those values if the endpoint is None.

Change-Id: I76cc527b05d2be75d3dbc33123a0d71be97fe25c
Closes-bug: #1579768
2016-05-12 12:47:35 +00:00
Jenkins 9ffebbb25e Merge "Enable hacking checks" 2016-04-20 17:13:16 +00:00
Jenkins 12e92558e5 Merge "Re-enable stacktracing when --debug is used" 2016-04-18 17:04:57 +00:00
Tin Lam cd5925bc60 Enable hacking checks
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
2016-04-18 16:23:59 +00:00
Stuart McLaren d0ec3a7ebb Re-enable stacktracing when --debug is used
Commit 1f89beb609 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
2016-04-07 15:42:51 +00:00
Jenkins 09e9272c59 Merge "Update auth_token before sending request" 2016-04-05 22:23:12 +00:00
Jenkins 8eaefe90a9 Merge "Fix v2 so that you can see the default help info" 2016-04-04 22:25:43 +00:00
Cao ShuFeng 9e532db8b0 Add last_request_id member to HTTPClient and SessionClient
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
2016-03-30 13:56:27 +00:00
zwei 444ffbeaa9 Fix v2 so that you can see the default help info
you can see the default help informatiion is v2
subcommand information if input glance command

Co-Authored-By: Stuart McLaren <stuart.mclaren@hp.com>

Closes-bug: #1563649
Change-Id: I7d227f3e68aa555b2e25848618f76df4872af35d
2016-03-30 12:37:28 +00:00
kairat_kushaev 2561e4061c Update auth_token before sending request
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
2016-03-30 13:33:19 +03:00
Cao ShuFeng 87c8c933bd Fix missing of debug info after we use session
After the introduce of this patch set[1], cli user can't get debug
info even --debug is passed. With the patch set[1], the request
action will be performed in keystoneclient.session.Session.
However the default log level of keystoneclient module is WARNING,
so user can't get debug info from keystoneclient.session.Session.

This change set the root log level to DEBUG when --debug is
passed.

[1]: https://review.openstack.org/#/c/262220/

Change-Id: I0db0fd7ab07a0d61082b86829a671d8dbc0f2963
Closes-bug: 1551076
2016-03-28 04:34:57 +00:00
wangxiyuan d3de9ed16a Ship the default metadata schema in the client
Now the help message of namespace and resource_type are wrong,
we could see a <unavailable> error when try to get the help
information, such as "glance help md-namespace-create".

See the patch[1] to get more information. the patch[1] added
image schema, but the metadata schema are needed as well.

This patch adds the current metadata schema into client, so that
help text can't be rendered when there schema is not available in
the system.

[1]: https://review.openstack.org/#/c/209536/3

Change-Id: I2ab94d8768114a7e5c475310ba094af653627658
Closes-Bug: #1536430
2016-03-24 09:04:20 +00:00
Jenkins d59e341a4c Merge "Fix location update" 2016-03-11 22:52:56 +00:00
Fei Long Wang 8b6dbb2065 Fix location update
After commit Ieb03aaba887492819f9c58aa67f7acfcea81720e, the command
location-update is totally broken now. This patch removes the updating
for an image from non-empty to empty since it's not supported now.
And also removing the default value of metadata for location-update
cli command because now the only purpose of location-update is updating
the location's metadata, so it doesn't make sense to give it a default
value which may update existing metadata by mistake.

Closes-Bug: #1537626

Change-Id: I9ce98e6c63996bbfdbc56761055e37a871f9d3e2
2016-03-11 12:51:13 +00:00
Danny Al-Gaaf 860908c517 Catch InUseByStore case in do_image_delete
In case do_image_delete() is called on an image that is
in use and can't be deleted by the driver a HTTPConflict
error is raised in glance. Catch this error and print a
propper error message.

Closes-Bug: #1551037

Change-Id: Id17098f27511df8e05e56b8df21e748921223bd9
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2016-03-09 23:27:02 +01:00
Jenkins 22a03fd475 Merge "Test: use assert_has_calls() instead" 2016-02-29 19:21:41 +00:00
Jenkins 6aaa6f2f8c Merge "Handle 403 forbidden on download" 2016-02-29 13:04:08 +00:00
Stuart McLaren 5b9f21b38b Handle 403 forbidden on download
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
2016-02-24 18:31:38 +00:00
Chaozhe.Chen d28ccb37ff Test: use assert_has_calls() instead
Some of the assertions in glanceclient test are sequential, we should
better use assert_has_calls() instead of assert_any_call().
And assert_has_calls() provides more clear messages in case of failure.

Change-Id: Ie45e7c56b1c859916a1f31636c639422f1ffef28
2016-02-24 22:54:00 +08:00
Jenkins c58b4cc984 Merge "Auto-generated squash commit" 2016-02-12 00:10:58 +00:00
Flavio Percoco e91d8ec4b8 Auto-generated squash commit
Fix misspellings

Upstream-Change-Id: Ie7ecbe4b33dd0e1ef94b0be85ec3af790cc6fcd7

Correct spelling mistake

Change interable to iterable.

Upstream-Change-Id: I468a87a3df9ed00ed82f1ba0d6abbbc6944cf613

Change-Id: I4de8426cd19ef0bc7c00fe57f8bc3303d0a4f8a4
Co-Authored-by: venkatamahesh <venkatamaheshkotha@gmail.com>
Co-Authored-by: Irina <yuyuesh@cn.ibm.com>
2016-02-11 12:26:55 -04:30
Jenkins 7f9c6d62a5 Merge "v2 - "readOnly" key should be used in schemas" 2016-02-08 10:16:32 +00:00
zwei 22e3bf0234 v2 - "readOnly" key should be used in schemas
If it has a value of boolean true,
    this keyword indicates that the instance property SHOULD NOT be changed,
    and attempts by a user agent to modify the value of this property are expected to be rejected by a server.
    The value of this keyword MUST be a boolean.
    The default value is false.

    Further link for reference: http://json-schema.org/latest/json-schema-hypermedia.html#anchor15

Closes-Bug: #1521581
Depends-On: I279fba4099667d193609a31259057b897380d6f0
Change-Id: I96717506259c0d28500b8747369c47029b1dd9b6
2016-02-04 15:06:13 +08:00
kairat_kushaev 69ada31fbd Fix client initialization in shell tests
Shell tests initialized glanceclient with force_auth parameter
but this parameter doesn't exist at all.
The patch fixes this behavior and modifies client mocking to
prevent from these errors in future.

Change-Id: If4b469cf8da8105204a7f1f6e80ae19b86c7daee
2016-02-01 17:56:34 +03:00
Jenkins 185255a5c4 Merge "Fixed TestHTTPSVerifyCert failure messages" 2016-02-01 02:17:25 +00:00
Jenkins 95df686d35 Merge "Use session when not specified token or endpoint" 2016-02-01 01:48:26 +00:00
kairat_kushaev a8d7ded8fb Enhance description of instance-uuid option for image-create
Current description of instance-uuid may confuse users because
they may think that instance-uuid can serve as basis for image
but it just stores instance-uuid as image-metadata.
So we need to enhance the description in glanceclient.

Change-Id: I55829d106c9d25374df6538b3071104ee5f215f2
Closes-Bug: #1496822
2016-01-18 12:41:17 +03:00
David Sariel f2eab45c33 Fixed TestHTTPSVerifyCert failure messages
Due to the change in python versions greater then 2.7.8, messages
that SSL certificate handling module is producing are different
from the error messages produced in earlier versions of py27.

Fixed how the following test cases of TestHTTPSVerifyCert class
are handling erroneous SSL certification messages:

- test_v2_requests_valid_cert_no_key
- test_v2_requests_bad_cert
- test_v2_requests_bad_ca

Closes-Bug:1499355
Change-Id: I3b939292ba0042bced5cc91a26e2593450f9cafe
2016-01-15 12:21:36 +02:00
Jenkins 0b7a6d2379 Merge "Remove location check from V2 client" 2016-01-15 05:27:21 +00:00
kairat_kushaev cea67763c9 Remove location check from V2 client
Glance client has a custom check that generates exception if
location has not been returned by image-get request.
This check should on server side and it should be managed by
policy rules when do location-add action.
That also allows to increase possibility of migrating Heat
to v2[1].

NOTE: After this patch, we'll raise a HTTPBadRequest from
server side instead of HTTPConflict when a user adds a
duplicate location.

[1]: https://review.openstack.org/#/c/240450/

Co-Authored-By: wangxiyuan <wangxiyuan@huawei.com>

Change-Id: I778ad2a97805b4d85eb0430c603c27a0a1c148e0
Closes-bug: #1493026
2016-01-15 01:24:48 +00:00
Darja Shakhray bda34034eb Use session when not specified token or endpoint
When no token or endpoint, it creates a session and from there
taken the necessary values.
This commit proposes to transfer a session in such cases.
This will avoid unnecessary actions and some of the problems.

Change-Id: Idc874b6c01e915e52904604d59e8e0b460e71621
Partial-bug: #1519546
2016-01-14 17:32:30 +00:00
Jenkins 2db882c41c Merge "Add docker to image_schema on glance v2 cli" 2016-01-14 15:24:07 +00:00
Nicolas Simonds 214dbffc92 Skip schema validation on GET /v2/images/%s
These are server-generated, not user-generated, and schema validation
should not be necessary.

Rework a unit test that enforces this; bad data should be blocked
at ingest, not blocked on reads.

Co-authored-by: Stuart McLaren <stuart.mclaren@hp.com>
Change-Id: Ib1926fec0e858b6eed43c7931a6d6c3a1708e70e
Closes-Bug: 1501046
2016-01-12 11:30:52 +00:00
LiuNanke c7fc0d6b1d Change assertTrue(isinstance()) by optimal assert
assertTrue(isinstance(A, B)) or assertEqual(type(A), B) in tests
should be replaced by assertIsInstance(A, B) provided by testtools.


Change-Id: I7135d3b7fe15b16c17b7581e553ce5d289b58f43
Related-bug: #1268480
2016-01-06 17:07:41 +00:00