Commit Graph

529 Commits

Author SHA1 Message Date
Jenkins a8f31ccfbf Merge "Fix v2 requests to non-bleeding edge servers" 2014-09-13 07:36:36 +00:00
Jenkins 128ea59bea Merge "Work toward Python 3.4 support and testing" 2014-09-13 07:19:29 +00:00
Jenkins e4417169a6 Merge "Import missing gettextutils._ in shell.py" 2014-09-13 00:54:26 +00:00
Lakshmi N Sampath 97b1506bdb Fix v2 requests to non-bleeding edge servers
In the case where v2 requests are sent to a server which is not running
head of tree which includes the v2 metadef code some 404 cases need to
be handled to enable standard requests to complete.

This patch aslo improves fetching schemas -- they are now only
fetched as needed.

Change-Id: I8c871f11b909337bd7df19b77e606772dbc634b2
Closes-bug: #1367326
2014-09-12 09:12:49 +00:00
Jenkins fde99a0a4d Merge "Fix indentation in tox.ini" 2014-09-07 23:39:23 +00:00
Jeremy Stanley 9fbc313719 Work toward Python 3.4 support and testing
Change-Id: I0498fcfdf9eee399e29de5b034fd6010682ca4b6
2014-09-03 19:05:27 +00:00
Pawel Koniszewski 33dcea81b2 Support for Metadata Definitions Catalog API
API calls and shell commands added in this patch:
- CRUD for metadefs namespaces;
- CRUD for metadefs objects;
- CRUD for metadefs properites;
- CRD for metadefs resource types and resource type associations.

Change-Id: I6d15f749038e8fd24fc651f0b314df5be7c673ef
Implements: blueprint metadata-schema-catalog-support
Co-Authored-By: Facundo Maldonado <facundo.n.maldonado@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
Co-Authored-By: Lakshmi N Sampath <lakshmi.sampath@hp.com>
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
2014-09-03 11:45:57 -06:00
Pawel Koniszewski 16077d91dd Catch new urllib3 exception: ProtocolError
The new version of requests (2.4.0) has updated underlying urllib3
to version 1.9. Unfortunately urllib3 introduced new exception
ProtocolError. Because of that unit tests in glance are failing:
ProtocolError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

To solve this problem new urllib3 exception is caught in the same place
that the old one was. Unfortunately both exception are still in use so
I couldn't remove the old one.

Change-Id: I55eef98e734c59b9b627f182768a633b2b701e43
Closes-Bug: #1364893
2014-09-03 23:44:39 +08:00
Matthew Booth d97f03e099 Import missing gettextutils._ in shell.py
Closes-Bug: #1355252

Change-Id: I3aef19235735b3b374b92985f142712cb0f37a35
2014-09-02 15:32:07 +01:00
Louis Taylor 6dda6f306f Fix error when logging http response with python 3
Python 3 changed the semantics of dict.items() [0], which now returns a
iterable 'view' instead of a list of tuples. This has the repercussion
that you can no longer check for membership of a key using:

    key in dict.items()

This patch simply replaces that check with a test for the key existing
in the dict itself, rather than the items.

[0] http://legacy.python.org/dev/peps/pep-3106/

Closes-Bug: 1359880

Change-Id: I7c59b0432725b660c9fa7270cde2e07bf3ea77db
2014-08-26 18:23:23 +00:00
Louis Taylor 4631b76550 Fix indentation in tox.ini
Previously, a tab was used to indent a line with a block of code which
otherwise uses eight spaces, causing it to display strangely in text
editors which do not have tabstop=8 set.

TrivialFix

Change-Id: I99a432373beebac912df88e6685db26e738bf654
2014-08-26 15:41:25 +00:00
Jenkins 6987295884 Merge "Update theme for docs" 2014-08-21 06:58:58 +00:00
Jenkins e13ac922f9 Merge "Add a tox job for generating docs" 2014-08-20 01:17:14 +00:00
Jenkins 43d9440e83 Merge "Enable osprofiler interface in glanceclient shell" 2014-08-20 00:50:26 +00:00
Stuart McLaren d6498b602f Ensure server's SSL cert is validated
A bug was introduced which meant that the server SSL certificate was
not being verified. Here we make sure that it is checked (unless
the --insecure flag is used).

Helps guard against man-in-the-middle attack.

Change-Id: I08f30bf3906b6580c871729311343fa8eefda91b
Closes-bug: #1357430
2014-08-19 11:59:49 +00:00
Zhi Yan Liu 9a53c1fdcb Enable osprofiler interface in glanceclient shell
To help end user uses profiling by glanceclient CLI directly, the
change added '--profile <HMAC_KEY>' argument to the shell.

This change also fixed a function regression, it was used to pass
necessary trace info to glance server via http header:
https://github.com/openstack/python-glanceclient/commit/dbb242b776908ca50ed8557ebfe7cfcd879366c8#diff-740dd7d9149f46fe4c01ef0ab7eb3bfbL196

In addition:
1. If client app want to enable profiling feature for glanceclient
object, please see: http://paste.openstack.org/show/85722/
2. Afer adding more trace point into Client object, as fundamental
requirement of osprofiler, what we need to notice caller is providing
correct messaging notifier in the context code.

The relevant change for glance server is ready at:
I45a19f5eb5304c2b78a9e12cbc0744941a807304

DocImpact

Change-Id: If42b69b2695a5f88536ecbc2c1b3592d9dbd880a
Signed-off-by: Zhi Yan Liu <lzy.dev@gmail.com>
2014-08-19 03:20:22 +04:00
Jenkins c59ba203dd Merge "Hide stderr noise in test output" 2014-08-18 13:48:01 +00:00
Jenkins fa6eca8645 Merge "Normalize glanceclient requested service url" 2014-08-18 12:40:32 +00:00
Louis Taylor 69361a146e Hide stderr noise in test output
Previously, some tests caused the usage options for glance to be printed out to
stderr. This patch redirects the stderr output for those unnecessarily verbose
test functions.

Change-Id: I781d35a16a97c9c093cb17288ebd96d3e1a2e4e9
Closes-Bug: #1334655
2014-08-18 09:08:42 +00:00
Cindy Pallares 1dfce5301c Remove deprecated commands from shell
Remove all deprecated commands from the shell
since they are no longer used and to keep
the command line menu from looking cluttered.

Closes-bug: #1314218

Change-Id: I66e82872988e3835e4f290f48dfc80538271426c
2014-08-12 05:30:59 -05:00
Jenkins 558ebf7bb7 Merge "Add support for Keystone v3" 2014-08-07 23:49:53 +00:00
Zhi Yan Liu 867e4cae27 Normalize glanceclient requested service url
Some proxy or gateway softwares, e.g. jumpgate [0], use url-pattern
based approach to match which hanlding logic needs to be triggered for
particular service calling when it received a http(s) call as a
middleman. The change fixed an issue which caused glanceclient send out
the request to a dis-normal url, which contains duplicated "/".

The change removed a wrong and duplicated code snippet from curl logging
function as well.

[0] http://goo.gl/yt52X1

Change-Id: Ic8b3920e11d400771ead7f9c44b615f10b4a5cef
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-08-07 13:04:25 +08:00
Sudipta Biswas 44948533e1 Fix glance-client to work with IPv6 controllers
Currently the glance client can't operate on IPv6 address based
openstack controller IPs. The reason for this is the absence of
creation of a IPv6 socket in the glance client code (in https.py).
The glance client is trying to create sockets from the AF_INET
socket family but this will lead to errors when glance client makes
a call on the IPv6 IP addresses.

In order to fix this limitation, we ensure that if the hostname
resolves to IPv6 or an explicit IPv6 address is used to configure
the openstack controller - glance client shall be able to detect
that and then create a AF_INET6 socket family. In all other cases
a AF_INET socket is created. We default to IPv4 sockets in all
other cases.

Change-Id: I7d5a09675cd5dab2e39f0faeaa7c169291eedac6
Closes-bug: #1348030
2014-08-06 22:19:22 +05:30
Bob Thyne f15dc6b82f Add support for Keystone v3
This enables glanceclient to authenticate using Keystone v3
API and includes the addition of several new CLI arguments.

DocImpact

Change-Id: I863ba08d312363dc1ce4fc7822fb21ef53df1a4f
2014-08-05 11:05:09 -07:00
Jenkins d833006bd4 Merge "Use immutable arg rather mutable arg" 2014-08-03 13:51:14 +00:00
Steve Martinelli 7736349b1e Update theme for docs
The current developer docs theme used is out of sync with the other
openstack projects. This patch will update the docs to provide a more
consistent look and feel when using developer docs

Change-Id: I4a59f194bd0fc8c86c6d3c6b8cadb839a5158935
2014-07-24 20:42:56 -04:00
Steve Martinelli e79031b70a Add a tox job for generating docs
Add a tox job to make it easier for developers to generate their
own docs before submitting a patch.

Change-Id: I1897407d0db901c61360a196b365b0661eb65b66
2014-07-24 17:44:37 -04:00
Matt Riedemann 68c1d1fbc6 Don't stream non-binary requests
Setting stream=True with requests can lead to issues
with not closing the connection so the urllib3 connection
pool is not freed up, so only set stream=True if making
a request with application/octet-stream content-type.

See the body-content-workflow and keep-alive sections
in the requests docs here for more information:

http://docs.python-requests.org/en/latest/user/advanced/

Note that commit dbb242b changed the response body_iter
code to potentially return a six.StringIO object rather
than the old ResponseBodyIterator class and since the
images client code is not converting the body_iter into
a dict using json.loads, we have to do that directly
in the _request method where the body_iter is
constructed.

Co-authored-by: Flavio Percoco <fpercoco@redhat.com>

Change-Id: I86572b69c4511f933c9676108190271874346302
Partial-Bug: #1341777
2014-07-16 02:14:07 -07:00
Stuart McLaren f75a81000e Use a correctly formatted example location in help
Change-Id: Iea1ebc13979a61d7bed397fb79e2b2a85f00c400
Closes-bug: 1342753
2014-07-16 15:05:37 +00:00
AmalaBasha dbb242b776 Replace old httpclient with requests
This review implements blueprint python-request and replaces the old
http client implementation in favor of a new one based on
python-requests.

Major changes:
* raw_request and json_request removed since everything is now being
  handled by the same method "_request"
* New methods that match HTTP's methods were added:
    - get
    - put
    - post
    - head
    - patch
    - delete
* Content-Type is now being "inferred" based on the data being sent:
    - if it is file-like object it chunks the request
    - if it is a python type not instance of basestring then it'll try
      to serialize it to json
    - Every other case will keep the incoming content-type and will send
      the data as is.
* Glanceclient's HTTPSConnection implementation will be used if
  no-compression flag is set to True.

Co-Author:  Flavio Percoco<flaper87@gmail.com>
Change-Id: I09f70eee3e2777f52ce040296015d41649c2586a
2014-07-10 13:22:05 +05:30
ChangBo Guo(gcb) 1db17aaad9 Enable F841
F841 detects local variable is assigned to but never used.
This commit fixes the violations and enables F841 in gate.

Change-Id: Ic4dcac2733dfe334009327ac17aa3952cafaa63a
2014-07-09 14:10:23 +08:00
Jenkins d613adc434 Merge "Add profiling support to glanceclinet" 2014-07-08 20:53:00 +00:00
Zhi Yan Liu 797d101a64 Resolving the performance issue for image listing of v2 API
According to my diagnosis [1], currently v2 API client consumed a lot
of CPU times by JSON schema validation on image model initialization
stage for image listing case. Because each image entry will triggers
one validation operation which spent most CPU clocks. (My test env has
1002 image entries now, so it's O(N) logic obviously).

This fix changed the original logic, it doesn't validate each image
entry but do it only on first image entry for each page. This approach
is a trade-off, it balanced the data validity and performance.

As comparison [3], under the fixed new logic, the execution time of
image listing is about four times as fast as old logic.

[1]
Clock type: CPU
Ordered by: totaltime, desc
name                                  ncall ttot
..nt/v2/images.py:34 Controller.list  1003  12.08480
../warlock/core.py:30 image.__init__  1002  11.91074
..warlock/model.py:28 image.__init__  1002  11.90463
..arlock/model.py:130 image.validate  1002  11.73838
..nschema/validators.py:388 validate  1002  11.73682

[2]
name                                  ncall ttot
..nt/v2/images.py:35 Controller.list  1003  1.100710
..nceclient/v2/images.py:45 paginate  256.. 1.099965
../warlock/core.py:30 image.__init__  1002  0.944762
..warlock/model.py:28 image.__init__  1002  0.939725
..arlock/model.py:130 image.validate  51    0.779653
..nschema/validators.py:388 validate  51    0.779431

[3]
$ time glance --os-image-api-version 2 image-list | grep 'test-' | wc -l
1000
real	0m16.606s
user	0m10.629s
sys	0m2.540s

$ time glance --os-image-api-version 2 image-list | grep 'test-' | wc -l
1000
real	0m4.151s
user	0m1.080s
sys	0m0.092s

Change-Id: Ia6598d3c06a5ff516277053c2b6fa5db744fe9cf
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-07-08 15:21:07 +08:00
Boris Pavlovic e305dad557 Add profiling support to glanceclinet
To be able to create profiling traces for Glance, client should be
able to send special HTTP header that contains trace info.
This patch is as well important to be able to make cross project
traces. (Typical case nova calls glance via python client, if
profiler is initialized in nova, glance client will add extra
header, that will be parsed by special osprofiler middleware in glance
api)
Don't worry no security issue here, trace information is signed by HMAC
key that is setted in api-paste.ini. So only person that knows HMAC key
is able to send proper header.

Change-Id: Ib13084fbe9b33c2f3dee165f7d6c778546cce6ca
2014-07-06 12:53:47 +04:00
liuqing 9b9f3befed Use immutable arg rather mutable arg
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None.

Change-Id: I78323383c8b6a9a516a2a217303124870822418b
2014-07-03 15:10:54 +08:00
liuqing 1c46c769e8 Add CONTRIBUTING.rst
There is no CONTRIBUTING.rst file, so i add it.

Change-Id: Icaafaf86c3b4314e2e20611e5e08956f1ea993ea
2014-07-01 15:01:36 +08:00
Flavio Percoco caa1a54fd9 Added release notes for 0.13.0
Change-Id: I51374661a5ce58cd2a970a75893b1251ab6e176b
2014-06-30 11:33:34 +02:00
Jenkins abd0812d05 Merge "Add wheels section to the setup.cfg" 2014-06-30 08:52:38 +00:00
Jenkins 6d4a4b7ecb Merge "Add missing classifiers" 2014-06-30 08:52:36 +00:00
Jenkins 4ea01682da Merge "Add license to setup.cfg" 2014-06-30 08:52:33 +00:00
Jenkins 195384223f Merge "Fix CA certificate handling" 2014-06-30 08:52:31 +00:00
Flavio Percoco 438bfa3b9c Add wheels section to the setup.cfg
Glance client's setup.cfg was missing the wheels section. This commit
adds it and makes the client's setup.cfg consistent with other clients.

Change-Id: I16030c0379dae3c3c07bd73f09798c2160310811
2014-06-30 08:53:29 +02:00
Flavio Percoco 50dc35991c Add missing classifiers
This commit adds 2 more classifiers to setup.cfg. An environment
classifier that specifies glanceclient is a console tool and a
development classifier that specifies it is production ready.

Change-Id: Ia60ea76798503b0a729c384298f1a633d695a1ab
2014-06-30 08:52:29 +02:00
Flavio Percoco 7b19682984 Add license to setup.cfg
Glance client's setup.cfg was missing the license attribute. This commit
adds it to make it consistent with other clients and server libraries.
The value of the license attribute reflects the license in the LICENSE
file.

Change-Id: Ia2e8c3be4fe7eaf0db5eb397646068c83076c2ff
2014-06-30 08:51:11 +02:00
Stuart McLaren 6626f38cda Fix CA certificate handling
If --os-cacert was passed to the cli the following error was
triggered: "cafile must be None or a byte string". This is
because 'load_verify_locations' requires a byte string to
be passed in.

We fix this by explicitly converting the argument to a byte
string.

We do this in 'VerifiedHTTPSConnection' rather than sooner, eg
during arg handling, as it will no longer be required should we
move to a different http library (eg requests).

Fixes bug 1301849.

Change-Id: I9014f5d040cae9f0b6f03d8f13de8419597560cb
2014-06-25 13:45:46 +00:00
Longgeek eca5fc22ca Add the six module dependency
Change-Id: Ie57c4e8bad2934acb5217a88713099374c20dde9
Closes-Bug: #1333872
2014-06-25 09:17:45 +00:00
Jenkins e62ed4d267 Merge "Set purge-props header correctly in image update" 2014-06-24 15:00:22 +00:00
Jenkins e82f773385 Merge "Prepend '/' to the delete url for the v2 client" 2014-06-24 13:21:00 +00:00
Jenkins 37cf7178a9 Merge "Change assertTrue(isinstance()) by optimal assert" 2014-06-24 04:01:09 +00:00
Manuel Desbonnet a945b3d448 Prepend '/' to the delete url for the v2 client
... and update tests to match.

The missing slash results in a non-absolute DELETE request
being sent to the API.
E.g.
DELETE v2/images/62fac489-23b4-4929-87af-2e7236e8542b HTTP/1.1

This is not strictly valid http/1.1 - rfc2616 specifies that the path must
be absolute.
This doesn't cause a problem for the API server, but this can cause
problems if the API server is fronted by something else (see #133161).

It also means that the curl command logged in debug mode has a
bad url.
E.g.
curl -i -X DELETE ... http://10.0.0.13:9292v2/images/...

Change-Id: Ib0c749dedbfcf07303fcddae4512db61b0f3fd78
Closes-bug: #1327101
2014-06-23 15:22:57 +01:00