Commit Graph

141 Commits

Author SHA1 Message Date
Jenkins 99cbde26ac Merge "Add support for community images" 2017-01-23 22:19:37 +00:00
Jenkins a76fdcd20a Merge "Add request id to returned objects" 2017-01-23 22:19:31 +00:00
Ravi Jethani 610177a779 Add request id to returned objects
Adding two classes RequestIdProxy and GeneratorProxy derived from
wrapt.ObjectProxy to wrap objects returned from the API.

GeneratorProxy class is used to wrap generator objects returned
by cases like images.list() etc. whereas RequestIdProxy class is
used to wrap non-generator object cases like images.create() etc.

In all cases the returned object will have the same behavior as
the wrapped(original) object. However now the returned objects
will have an extra property 'request_ids' which is a list of
exactly one request id.

For generator cases the request_ids property will be an empty list
until the underlying generator is invoked at-least once.

Co-Authored-By: Abhishek Kekane <abhishek.kekane@nttdata.com>

Closes-Bug: #1525259
Blueprint: return-request-id-to-caller
Change-Id: If8c0e0843270ff718a37ca2697afeb8da22aa3b1
2017-01-20 14:50:42 +05:30
Evgeny Antyshev 6ab6a740ff Add ploop in disk_format
"ploop" image format is supported in upstream Glance
https://review.openstack.org/341633

And similar patch has been added in python-openstackclient:
https://review.openstack.org/411405

Co-Authored-By: yuyafei <yu.yafei@zte.com.cn>
Change-Id: I1471224df97cf5fecfe7f02e549855af81c45848
Related-Bug: 1650342
2017-01-19 14:31:01 +00:00
Jenkins 8f8df1cced Merge "Handle formatting of subcommand name in error output" 2017-01-13 19:35:35 +00:00
Ian Cordasco 81039a1e36 Handle formatting of subcommand name in error output
On Python 2, decoding all arguments leads to the possibility that users
that use the wrong command or mistype the name will see error output
with a unicode string's representation instead of one without it. To
avoid this we try and find the first non-option string in the argument
list and replace it with an string that is not text only on Python 2. If
we encoded the string at all times, then users installing glanceclient
on Python 3 would see b'invalid-subcommand' instead. That's as bad as
seeing u'invalid-subcommand' on Python 2.

Closes-bug: 1533090
Change-Id: I018769e159a607ebb233902cbeb13b95ca417190
2017-01-11 07:33:34 -06:00
Li Wei efb5e2aa32 Add vhdx in disk_format
vhdx is also a format of the disk valid value in v2 version,
so add it in disk_format.

Related-Bug: 1635518
Co-Authored-By: Stuart McLaren <stuart.mclaren@hpe.com>
Change-Id: I7d82d4a4bdb180a53e86552f6f6b3bed908e6dc0
2017-01-10 07:41:02 +00:00
Jenkins 8b96bbc34c Merge "Revert "Add last_request_id member to HTTPClient and SessionClient"" 2016-12-14 17:35:22 +00:00
Alexander Bashmakov 20ab7b8201 Add support for community images
This patch adds support for community images retrieval and
creation in the Glance client.

Depends-On: I94bc7708b291ce37319539e27b3e88c9a17e1a9f
Change-Id: I81e83eab5a9d30643c354f0cb6df425cf7a7bae3
2016-11-10 22:55:33 +00:00
Abhishek Kekane c2898998a7 Move old oslo-incubator code out of openstack/common
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
2016-11-08 11:33:09 +05:30
Cao Xuan Hoang 47e289bec2 Replace 'assertTrue(a not in b)' with 'assertNotIn(a, b)'
trivialfix

Change-Id: I4d05a8bbcf99794c02261a9f9136e1c6f2c561a6
2016-09-28 11:52:29 +07:00
Itisha Dewan a9115b4cd8 switch from keystoneclient to keystoneauth
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
2016-09-03 03:22:04 +00:00
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
Abhishek Kekane 7d106c677a Revert "Add last_request_id member to HTTPClient and SessionClient"
This reverts commit 9e532db8b0.

If glanceclient is used in multi-threaded environment, then there is a
possibility of getting invalid/wrong last request-id. To avoid this,
need to use thread local storage to store last-request-id and add
public method to return this request-id to caller.

http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html#alternatives

Change-Id: I08d8d87fc0cc291f1b930b2c0cfc110ec8394131
2016-05-23 14:14:55 +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