Commit Graph

99 Commits

Author SHA1 Message Date
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
Stuart McLaren 37caf870ac Use system CA certificate file
When SSL is being used and the --ca-file option is
not specified use an available system CA file to
verify the server's certificate.

Change-Id: Id5c9fda6fd9bd05cde3c2a9160a6e72cef086a44
2012-08-13 09:52:29 +00:00
Chris Behrens a214d983c2 socket errors and timeouts should be CommunicationErrors
Also include extra information about socket errors within the exceptions.

Change-Id: I9464a484460d40be5727e18ca6f057df9076766e
2012-08-10 21:13:21 +00:00
Brian Waldon 3997f977fa Handle communication failures cleanly
Expand exceptions to cover more failures cases. This adds
CommunicationFailure to represent any failures while attempting
to communicate with the remote endpoint. This also adds a new base
exception class BaseException which should be used for all non-HTTP
related failures.

Change-Id: Ie3e1d45c520d816a3f491a85fde94a6c4edf295e
2012-08-10 13:30:13 -07:00
Jenkins 4b59f66494 Merge "Client-side SSL Connection" 2012-08-10 19:40:09 +00:00
Jenkins 392dfd6d0d Merge "SSL Certificate Validation" 2012-08-10 18:35:33 +00:00
Lars Gellrich 137b3cf975 Enable client V2 to download images
Added the CLI option image-download to download an image via API V2.
Added utility function to save an image.
Added common iterator to validate the checksum.

Related to bp glance-client-v2

Change-Id: I0247f5a3462142dc5e9f3dc16cbe00c8e3d42f42
2012-08-09 17:14:22 +00:00
Brian Waldon 354c98b087 Refactor HTTP-related exceptions
* Refactor helper function that builds the map of http status codes
  to local http exceptions - now we don't have to explicitly list
  every single exception name
* Add several exceptions to represent http status codes that were not
  previously represented
* Improve consistency of exceptions naming by prepending 'HTTP' to
  necessary exception names
* Use HTTPException instead of ClientException
* Deprecate old http exceptions (those that aren't prefixed with HTTP)
* Deprecate ClientException
* Deprecate unused NoTokenLookupException and EndpointNotFound
* Add test module to spot-check the from_response helper

Change-Id: Ibc7fef9e2a5b24bd001d183d377901f302d650a9
2012-08-08 11:29:17 -07:00
Brian Waldon 3a68f75b95 Simplify v2 schema lookup
We don't need to look at the container of available schemas in order
to get the one we want. Remove glanceclient.exc.SchemaNotFound as it can
no longer be raised.

Change-Id: Ib49ad58c4fdfc9bc9f535115674d92040a97db65
2012-08-08 11:28:31 -07:00
Jenkins 127463e14d Merge "Add missing copyright headers" 2012-08-08 17:55:22 +00:00
Brian Waldon 62098527b9 legacy_shell.py shouldn't be executable
Change-Id: Ife6e9e47ece3971a3872e781a39e30bcb38e3bf7
2012-08-07 20:30:20 -07:00
Brian Waldon 227d166109 Client-side SSL Connection
This allows a user to pass a cert and a key to use in HTTPS
connections. The flags --cert-file and --key-file are added
to the CLI.

Addiionally, update the debug curl logging to print --cacert and
-k when ca_file and insecure are set.

Related to bp glance-client-parity.

Change-Id: Ibaea51419a903afb7939a6b5b848f7a6667893bf
2012-08-04 12:14:11 -07:00
Brian Waldon ff34cfc50f SSL Certificate Validation
This adds support for validation of ssl certs returned by remote
servers over SSL. The --ca-file param represents the CA cert used
to sign the remote server's cert. Use --insecure if the remote
server is using a self-signed cert or you don't have the CA cert.

Related to bp glance-client-parity

Change-Id: I45253a6e2d88da599addfcc464571e62ae920166
2012-08-04 12:09:49 -07:00
Jenkins 18543b1a46 Merge "Allow CLI opts to override auth token and endpoint" 2012-08-03 00:29:25 +00:00
Brian Waldon 13d80a7e8f Add missing copyright headers
A few files were missing copyright headers:
* glanceclient/common/http.py
* glanceclient/v1/__init__.py
* glanceclient/exc.py

Change-Id: Ibbd53cd49f9367994de66a30601b3aefe1a8d6ee
2012-08-02 14:34:26 -07:00
Brian Waldon a511e6a05e Add legacy compat layer to v1 shell
All legacy CLI commands should work as expected with a few
minor exceptions:
- no upload animation
- no interactive pagination
- help/usage output has changed

Deprecated options are indicated as such in their usage info. Deprecated
commands have descriptions that label them as such.

Related to bp glance-client-parity

Change-Id: I584b2447361967228bea332e14880e18db12fca8
2012-08-01 22:21:27 -07:00
Brian Waldon 2541f3ce84 Allow CLI opts to override auth token and endpoint
Previously, both --os-auth-token and --os-image-url had to be
provided in order for either of them to be used in any API requests.
This breaks the tie between them and allows a user to override
either the auth token or the endpoint returned by Keystone independently
of one another.

Fixes bug 1029586

Change-Id: I8b81be723286c546d9cbd97c8b7d7aa89c03b2d4
2012-08-01 20:41:41 -07:00
Jenkins 5f5d8ee212 Merge "Refactor http request/response logging" 2012-08-02 00:19:01 +00:00
Jenkins dc7f7817ca Merge "Add exceptions for 500 and 503 HTTP status codes" 2012-08-01 23:58:19 +00:00
Brian Waldon c24ea3f848 Stop looking for v2 image in container
The v2 API no longer returns images in JSON containers like
'{"image": {...}}', so stop trying to decode the responses
as if it does.

Fix bug 1031185

Change-Id: I5209fe76445d4195b12944146a0ef190883f363f
2012-07-30 20:54:23 -07:00
Jenkins bb0b59bda1 Merge "Honor '--insecure' commandline flag also for keystone authentication" 2012-07-31 03:38:44 +00:00
Brian Waldon 1f44aff399 Add exceptions for 500 and 503 HTTP status codes
Add glance.exc.InternalServerError and .ServiceUnavailable to
represent HTTP statuses 500 and 503. Users will definitely see
these from Glance, so let's be nice and map them to handy
exception classes.

Change-Id: I8e8fcda532455793ea4d0f08a23f7c92b68c186c
2012-07-29 23:11:00 -07:00
Brian Waldon 6c8e0342c0 Refactor http request/response logging
Using the --debug flag or the GLANCECLIENT_DEBUG env var, a user will
see http requests and responses in great detail. Requests are formed
into proper curl commands while responses are printed just as they would
as if the curl request provided were executed. Response bodies will not
be printed if they are application/octet-stream.

Change-Id: I9c9c5d6ec9f481091c944e596d073da3739795b6
2012-07-29 22:27:13 -07:00
Brian Waldon 158f7ccd74 Fix --debug CLI option
The --debug argument has been ignored since httplib2 was replaced
with httplib. This re-enables the --debug flag as an equivalent
to the env var GLANCECLIENT_DEBUG.

Fixes bug 1030700

Change-Id: Ib653049eea2f18c4cc2f8f8aac7884245afd0f04
2012-07-29 21:21:29 -07:00
Sascha Peilicke bb282936a0 Honor '--insecure' commandline flag also for keystone authentication
Currently, keystone auth fails with self-signed certificates.

Change-Id: Ice89bcd0662038260bc4bd12058972bb35e61e3b
2012-07-26 15:48:23 +02:00
Brian Waldon 1e744f162e Replace httplib2 with httplib as http driver
* This allows us to send truly chunked responses to users
* Handle bad connection url schemes with a new InvalidEndpoint exception
* Fixes bug 1023240

Change-Id: I34500987f51d4e0c6e1f89ecf93853de3fcbb1c3
2012-07-23 13:52:12 -07:00
Sascha Peilicke 71a0caece8 Clarify usage of --insecure flag
Change-Id: If19a7aab92350fb68e447a0ffe8a97e079d762e4
2012-07-20 10:18:23 +02:00
Brian Waldon 0f628b19cb Add pagination to v1 image-list
* Use recursive generator function to make subsequent requests
  to the v1 detailed images resource
* 'limit' continues to act as the absolute limit of images to return
  from a list call
* 'page_size' indicates how many images to ask for in each subsequent
  pagination request
* Expose --page-size through the cli
* Convert v1 images tests to use strict url comparison
* Drop strict_url_check from FakeAPI kwargs - now the functionality
  is always active and tests must directly match fixture urls
* Fix bug 1024614

Change-Id: Ifa7874d88360e03b5c8aa95bfb9d5e6dc6dc927e
2012-07-19 13:26:37 -07:00
Jenkins 570e64d91f Merge "Wrap image data in iterator" 2012-07-19 20:19:30 +00:00
Brian Waldon d88d8fc462 Add pagination to v2 image-list
* Use a recursive generator function to iterate over the image
  container. The presence of next links are indicators to
  continue pagination while their value drives the location of
  the next page.
* A user can pass in --page-size on the command line, or page_size
  when using the controller directly, to control how many images
  are requested with each subsequent paginated request. Default page
  size is 20.
* Add a flag (strict_url_check) for the FakeAPI class to control
  whether it chops off query params when trying to match a request
  to a fixture.
* Related to bp glance-client-v2.

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a12
2012-07-13 20:12:06 -07:00
Brian Waldon 95a7f9dffe Prevent links from being printed in v2 CLI
Nobody wants to see links in a human interface. This prevents the
file, access, self and schema links from being printed when calling
image-show or explain.

Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a11
2012-07-13 20:12:00 -07:00
Brian Waldon 8bf9e11244 Align print_dict to the left
Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a10
2012-07-13 20:11:52 -07:00
Brian Waldon e5f038b62a Convert v2 images list method to generator
We will want this to be a generator as soon as we implement
pagination. Let's establish the interface now.

Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a07
2012-07-13 18:38:41 -07:00
Brian Waldon c398af18b0 Replace static v2 Image model with warlock model
* Add warlock v0.1.0 as a dependency
* Generate a pythonic, self-validating Image model using warlock
* Add raw method to Schema model
* Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a04
2012-07-13 18:38:41 -07:00
Brian Waldon b6cef9d145 Add support for viewing a single image through v2
* Add image-create command
* Add tests for Image model, Controller.get, and Controller.list
* Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a06
2012-07-13 18:38:40 -07:00
Brian Waldon f0445a1b44 Rewrite link parsing for finding v2 schemas
What we called 'links' are no longer returned in a container of
objects, they are top-level entity attribtues. This fixes the
parsing of the entities to look in the correct place when trying
to locate a specific schema.

Add a helper for printing to stderr and exiting with a non-zero
exit code.

Map 'name' to 'Attribute' when explaining a schema.

Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a05
2012-07-13 18:38:40 -07:00
Brian Waldon 53acf1a0ca Establish the supported importable interface
* Consumers of this client should not depend on being able to import
  any module other than glanceclient and glanceclient
* The only attributs of the glanceclient module are Client
  and __version__
* The attributes of the glanceclient.exc modules have yet to be
  locked down
* glanceclient.common.exceptions was replaced with a placeholder
  module until consumers of it are updated

Change-Id: Iea9648cd06906d65764987c1f2ee5a88ebeee748
2012-07-13 18:38:15 -07:00
Brian Waldon 49bc6f94f2 Add --is-public to image-create
This moves image-create closer to image-update by adding
--is-public and hiding the help output of --public. The
--public option will be removed once devstack no longer
depends on it.

Fix bug 1023632

Change-Id: I2c58655ba56eef1fa486246618c4fb5bd3c6c8cf
2012-07-13 08:12:45 -07:00
Jenkins c097432828 Merge "Translate is_protected to protected" 2012-07-12 22:55:10 +00:00
Jenkins 1a8ab3c3f2 Merge changes I02ddeb59,Ife231377
* changes:
  Change --protected to --is-protected in create
  Properly map boolean-like arguments to True/False
2012-07-12 22:55:02 +00:00
Jenkins 4e9bac2d0a Merge "Remove AuthorizationFailure exception" 2012-07-12 19:42:38 +00:00
Brian Waldon da360462a5 Wrap image data in iterator
This is establishing the API for a future optimization. We want to
be able to offer true socket-level caching, but can't do that with
httplib2 right now. For now, we will just fake the optimization
by returning an iterator over the image body, which happens to already
be fully loaded into a string.

Change-Id: I2d36e3cdd45b26d7c7c27ba050bf6a4b5765df6c
2012-07-11 19:55:02 -07:00
Brian Waldon b7f476e211 Translate is_protected to protected
When creating or updating an image, translate the 'is_protected'
argument into the proper 'protected' image attribute.

Fix bug 1023653

Change-Id: Icfe6c38e4fda098ce3f90fd94c8fbbc18be2f4a8
2012-07-11 16:37:28 -07:00
Brian Waldon d8433ee40a Change --protected to --is-protected in create
Make image-create match image-update when specifying a specific
value for 'protected'.

Fix bug 1023650

Change-Id: I02ddeb59c1f6882b206279a71f7af8889ce4602c
2012-07-11 16:28:24 -07:00
Brian Waldon db1fabed11 Properly map boolean-like arguments to True/False
--is-public and --is-protected are now evaluated as True and False

Fix bug 1023652

Change-Id: Ife2313770eebc176e7744711956aed20f16576a5
2012-07-11 16:25:13 -07:00
Monty Taylor a814c15465 Add ability to get version information in python
* A user can access glanceclient.__version__ to get a string
  representing the version of the installed library.
* Add openstack-common's 'version' module.

Change-Id: Ib14c561d8ac0b126617a20acfbd5fdb61c54f2c7
2012-07-11 14:04:09 -07:00
Monty Taylor c315c5274f Latest setup goodness.
Upgrade the common setup code to the latest versions, and use setuptools-git
for sdist tarball generation.

Change-Id: I81eca9199b7d330ef8ec80482565a75f8475a78c
2012-07-11 12:21:29 -05:00
Brian Waldon d2ab65255f Remove AuthorizationFailure exception
The AuthorizationFailure exception isn't used anywhere, so
remove it.

Fix bug 1015940.

Change-Id: Ie6da74b63e3d1658c8ae26c272222f00f1209e38
2012-07-10 21:10:40 -07:00