379 Commits

Author SHA1 Message Date
Jenkins
70c90b2243 Merge "Add additional headers for HEAD/GET/DELETE requests." 2016-11-08 19:30:40 +00:00
Jenkins
cb922f4dc6 Merge "Add v1password keystoneauth plugin" 2016-11-08 18:35:50 +00:00
Charles Hsu
6cf2bd6626 Add additional headers for HEAD/GET/DELETE requests.
Change-Id: I69276ba711057c122f97deac412e492e313c34dd
Closes-Bug: 1615830
2016-11-07 13:18:29 +08:00
Tim Burke
481f74caf1 Low-level API: Don't log just before raising an exception
The only logging we should do is when we've encountered a problem *and
we've dealt with it ourselves*. When we're raising an exception, it
should be up to the caller to decide whether to log anything about it.

Anything else is just rude.

Change-Id: I1c96b76d90a78b7a10ffe63e4a7440c8f579147c
Closes-Bug:  1213179
Related-Bug: 1202229
2016-10-28 17:37:37 +02:00
Jenkins
e9887703d0 Merge "Adding keystoneauth sessions support" 2016-10-26 11:41:21 +00:00
Tim Burke
a38efb6031 Add v1password keystoneauth plugin
This lets us use Keystone sessions against endpoints like swauth and
tempauth with code like:

    import keystoneauth1.loading
    import keystoneauth1.session
    import swiftclient

    loader = keystoneauth1.loading.get_plugin_loader('v1password')
    auth_plugin = loader.load_from_options(
        auth_url='http://saio:8080/auth/v1.0',
        username='test:tester',
        password='testing')
    keystone_session = keystoneauth1.session.Session(auth_plugin)

    conn = swiftclient.Connection(session=keystone_session)

The plugin includes an optional project_name option, which may be used
to override the swift account from the storage url that was returned.
Additionally, it includes enough infrastructure to support some commands
in python-openstackclient>=3.0:

    export OS_AUTH_TYPE=v1password
    export OS_AUTH_URL=http://saio:8080/auth/v1.0
    export OS_PROJECT_NAME=AUTH_test2
    export OS_USERNAME=test:tester
    export OS_PASSWORD=testing

    openstack token issue
    openstack catalog list
    openstack catalog show object-store
    openstack object store account show
    openstack container list
    openstack container create <container>
    openstack container save <container>
    openstack container show <container>
    openstack container delete <container>
    openstack object list <container>
    openstack object create <container> <file>
    openstack object save <container> <object>
    opsentack object show <container> <object>
    openstack object delete <container> <object>

Change-Id: Ia963dc44415f72a6518227e86d9528a987e07491
2016-10-24 01:52:37 +02:00
Anh Tran
bb3160a42c Remove redundant space in docstring
TrivialFix

Change-Id: I7012fb7bbbedfba30b8e0450a449787e9076f4ef
2016-09-28 11:25:56 +07:00
Anh Tran
ab7a8b2453 TrivialFix: Removed redundant 'the'
Change-Id: I3b3c0e7e4d5c8a1934378e2083a64bb686754f18
2016-09-27 16:10:14 +07:00
Jenkins
27f9178ec8 Merge "Update help text around container ACL syntax" 2016-09-19 21:24:50 +00:00
Jenkins
0ec6b7b162 Merge "Make tempurl subcommand insist on whole number seconds" 2016-09-15 02:34:01 +00:00
Mohit Motiani
371f0e3482 Update help text around container ACL syntax
The patch add the information about the syntax of provding read and
write access to the users within a project.

The current status is:
account:* does not work with tempauth
account does not work with keystoneauth

Furthermore, the concept of "account" is fuzzy. It could be a
"project", but even that doesn't distinguish between a project
id and a project name.

Change-Id: I4462230fe05aa4a742e825f5b6312deb93bc1170
Closes-Bug: #1587677
2016-09-14 17:13:12 -07:00
Jenkins
b679959d35 Merge "Make object option dependent on container in usage strings" 2016-09-14 20:46:52 +00:00
Jenkins
cacb3a3a15 Merge "Make tempurl command check for valid object path" 2016-09-14 20:45:43 +00:00
Alistair Coles
e41158d79e Make tempurl subcommand insist on whole number seconds
Previously the tempurl subcommand would dump a traceback
due to a TypeError if the seconds option was not an int
value. With this patch it will now return the same
error message as if the seconds option were negative or not
a number.

Also changes the error message to state that the seconds
option should be a "whole number" rather than a "positive
integer", since 0 is a valid value.

Change-Id: Ie940d470f2be8006aa8eb7fe242f092457aeae21
Closes-Bug: #1621817
2016-09-14 18:17:40 +01:00
Alistair Coles
4c955751d3 Make tempurl command check for valid object path
If the supplied path is not of the form /v1/a/c/o then
swift tempurl subcommand will now return an error message.

Also removes redundant check for seconds parameter being an int
from shell.py because the same check is made when calling
utils.generate_temp_url.

Drive-by fix for missing param definition for generate_temp_url.

Change-Id: I41f4389948b01fadaa5fc4939ea12e0ed2167345
Related-Change: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
2016-09-14 16:24:22 +01:00
Jenkins
2737fae96e Merge "Make options arguments truely optional" 2016-09-08 14:33:05 +00:00
Alistair Coles
cb0cdca7aa Make object option dependent on container in usage strings
In usage messages, it only makes sense to have an
object option if the container option has been specified.
Fixes the parentheses to indicate this.

Change-Id: I550ba99879ea6ce5489617a94cec36b66be270c8
Related-Change: Ie84a90eb0278dd2cdf5775948572bb140f8d2c4b
2016-09-08 11:09:25 +01:00
Nandini Tata
aa88677018 Fixed inconsistent positional arguments naming
When printing the help menu for Swift commands, it is confusing to see
both positional arguments and options not distinguished. The
positional arguments are supposed to be enclosed in angular braces <>,
options in square braces [] and optional positional arguments in [<>].

Change-Id: Ie84a90eb0278dd2cdf5775948572bb140f8d2c4b
2016-09-07 21:09:41 +00:00
Christian Schwede
89ff29e788 Make options arguments truely optional
Currently the options help, info and debug must exist in the options
dictionary; however it might be that this is not the case if a method is
imported externally. This patch fixes this.

Also support using a storage URL or path as an argument for tempurl, and
adding a test to verify correct output in both cases.

Related-Bug: 1607519
Related-Bug: 1607523
Closes-Bug: 1607521
Change-Id: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
2016-09-06 07:38:08 +00:00
Jenkins
92544c58c5 Merge "Accept gzip-encoded API responses" 2016-09-01 03:18:18 +00:00
Jenkins
98085c961f Merge "Convert numeric and boolean header values to strings" 2016-08-31 00:58:02 +00:00
Tim Burke
f728027bed Accept gzip-encoded API responses
Previously, we would accept gzip-encoded responses, but only because we
were letting requests decode *all* responses (even object data). This
restores the previous capability, but with tighter controls about which
requests will accept gzipped responses and where the decoding happens.

Change-Id: I4fd8b97207b9ab01b1bcf825cc16efd8ad46344a
Related-Bug: 1282861
Related-Bug: 1338464
2016-08-30 15:38:55 -07:00
Jenkins
20e0c515bf Merge "client: renew token on 401 even if retries is 0" 2016-08-26 17:37:41 +00:00
Clay Gerrard
96f0031e64 boolean logic cleanup in service.Swift[Copy|Post]Object
Change-Id: I07e74536502ec2479b22a825f684703d65924563
2016-08-25 13:15:44 -07:00
Tim Burke
ab60e08e2e Convert numeric and boolean header values to strings
Recently, requests got a bit more picky about what types of data it will
accept as header values [1]. The reasons for this are generally sound;
str()ing arbitrary objects just before pushing them out a socket may not
do what the developer wanted/expected.

However, there are a few standard types that developers may be sending
that we should convert for them as a convenience. Now, we'll convert all
int, float, and bool values to strings before sending them on to
requests.

Change-Id: I6c2f451009cb03cb78812f54e4ed8566076de821
Closes-Bug: 1614932
2016-08-25 11:32:08 -07:00
Jenkins
5acefd27e4 Merge "Strip leading/trailing whitespace from headers" 2016-08-25 04:24:16 +00:00
Jenkins
b57044a853 Merge "Add copy object method" 2016-08-24 23:59:34 +00:00
Marek Kaleta
4a2465fb12 Add copy object method
Implement copy object method in swiftclient Connection, Service and CLI.

Although COPY functionality can be accomplished with 'X-Copy-From'
header in PUT request, using copy is more convenient especially when
using copy for updating object metadata non-destructively.

Closes-Bug: 1474939
Change-Id: I1338ac411f418f4adb3d06753d044a484a7f32a4
2016-08-23 14:37:11 -07:00
Tim Burke
8fbe118cea Strip leading/trailing whitespace from headers
New versions of requests will raise an InvalidHeader error otherwise.

Change-Id: Idf3bcd8ac359bdda9a847bf99a78988943374134
Closes-Bug: #1614280
Closes-Bug: #1613814
2016-08-19 19:53:11 +00:00
Jenkins
2766744ba1 Merge "Fix unicode issues in tempurl command" 2016-08-07 23:43:13 +00:00
Tim Burke
335570e511 Add --json option to swift capabilities / swift info
This lets us do things like:

    $ swift info --json | jq '[.swift.policies[].name]'
    [
      "Standard-Replica",
      "EC"
    ]

Also, escape more dashes in the man page, so they won't be
misinterpreted as hyphens.

Change-Id: Ic7690bdbcfc55f55e5dde9bc11bb0644085973ce
2016-08-02 16:18:44 -07:00
Tim Burke
dca4ea5fd6 Fix unicode issues in tempurl command
Previously, we weren't encoding paths and keys as UTF-8, which would
trigger a UnicodeEncodeError on py27.

Change-Id: I2fad428369406c2ae32343a5e943ffb2cd1ca6ef
2016-07-19 12:52:51 -07:00
Jenkins
07c960d46f Merge "Query string functionality for containers" 2016-06-14 19:36:45 +00:00
Andrew Welleck
439330cb9c Query string functionality for containers
Added functionality for arbitrary query strings to be passed into container
functions. Additionally a minor typo correction in the README. Added unit
tests for query string functionality.

Closes-Bug: #1542459
Change-Id: Ica2cb3ea439632588388e748d8d2e944e9ed4fa4
2016-06-09 13:51:26 -05:00
Julien Danjou
a62b7ee06c client: renew token on 401 even if retries is 0
Gnocchi uses a client with retries=0 to maximize throughtput and not retry N
times on e.g. 404 when checking existence of an object. However, this as the
side effect of never renewing the token since there' no retry on 401 either.

This patches change the behavior so that 401 errors are always retried,
whatever the retries value is.

Closes-Bug: #1589926
Change-Id: Ie06adf4cf17ea4592b5bbd7bbde9828e5e134e3e
2016-06-07 16:58:26 +02:00
Jenkins
c91c8d575e Merge "Add an option: disable etag check on downloads" 2016-06-06 10:33:25 +00:00
Cheng Li
69bf4634b9 Add an option: disable etag check on downloads
This patch is to add an option of disable etag
check on downloads.

Change-Id: I9ad389dd691942dea6db470ca3f0543eb6e9703e
Closes-bug: #1581147
2016-06-02 22:53:18 +08:00
Tim Burke
ff505d72cd Suppress InsecureRequestWarning when using --insecure
The user already knows this is insecure, there's no point in bringing it
up again and again.

See also: https://github.com/kennethreitz/requests/issues/2214

Change-Id: I7991b2e568407269f84138bc03711147ed080c9c
2016-06-01 18:57:38 -07:00
Paulo Ewerton
73e4296a38 Adding keystoneauth sessions support
This patch allows authentication in swiftclient with a keystonauth
session.

Co-Authored-By: Tim Burke <tim@swiftstack.com>

Change-Id: Ia3fd947ff619c11ff0ce474897533dcf7b49d9b3
Closes-Bug: 1518938
2016-05-19 17:27:31 -07:00
Jenkins
f9d0657e70 Merge "Support client certificate/key" 2016-05-19 22:20:17 +00:00
Jenkins
8ffc5c11ae Merge "Use application/directory content-type for dir markers" 2016-05-19 08:53:50 +00:00
Kota Tsuyuzaki
0225950c2a Correct doc string for http_conn argument
Previous doc string describes "http_conn" for a bunch of functions as
"HTTPConnection object" but it is actually "a tuple of (parsed_url,
HTTPConnection object)" so now this patch correct the mis-consistency.

Change-Id: I6ff90a941e6df6a1b3b5dc74fd5f4262654c9f0a
2016-05-12 21:39:14 -07:00
Jenkins
3a6c14981d Merge "Check responses when retrying bodies" 2016-05-11 07:52:47 +00:00
Tim Burke
fd5579a154 Check responses when retrying bodies
Previously, if a Range request came back 200 OK (rather than 206 Partial
Content), we would mangle the response body. This could happen if there
was a middleware that would silently drop Range headers, for example.

Now, if the response does not include a Content-Range header, we will
log a warning and seek to our previous position in the stream. If the
Content-Range header has an unexpected value, we will raise an exception.

Change-Id: I94d4536cc1489968d45a2b6ba7edd70c85800275
2016-05-04 15:21:26 -07:00
Tim Burke
67f629cdeb Default to v3 auth if we find a (user|project)-domain-(name|id) option
Change-Id: I4616492752b620de0bf90672142f1071ec9bac83
2016-05-03 14:41:07 -07:00
Tim Burke
c3766319b9 Pull option processing out to service.py
...because it seems silly that we do nearly the same thing in two
different places

Change-Id: Iafafe3c553d00652adb91ceefd0de1479cbcb5da
2016-05-03 14:18:34 -07:00
Tim Burke
5b714f104d Parse options to dict
This is a first step toward unifying the options parsing magic between
shell.py and service.py

Change-Id: If001e07978c0bae729ac0cd9b2c2934092c98447
2016-05-03 14:03:15 -07:00
Jenkins
6b065dd4a6 Merge "Identify segments uploaded via swiftclient" 2016-05-02 10:35:20 +00:00
Jenkins
38af5b1733 Merge "Add new doc structure and contents for swiftclient" 2016-04-29 20:18:32 +00:00
Joel Wright
3a5a25fe98 Add new doc structure and contents for swiftclient
As a result of the Hackathon we have produced a new
documentation structure for the python-swiftclient.
This patch introduces the new structure and adds the
required content.

The intention is to document the CLI, the SwiftService
and Connection API. Importantly, we also provide
guidance on important considerations when using a swift
object store, such as which aspect of the python-swiftclient
to use for various use cases, common authentication patterns
and some useful examples.

Co-Authored-By: Alexandra Settle <alexandra.settle@rackspace.com>
Co-Authored-By: Mohit Motiani <mohit.motiani@intel.com>
Co-Authored-By: Hisashi Osanai <osanai.hisashi@jp.fujitsu.com>

Change-Id: I9eb41f8e9137efa66cead67dc264a76a3c03fbda
2016-04-29 19:21:36 +01:00