521 Commits

Author SHA1 Message Date
Joel Wright
3c0289844f Log and report trace on service operation fails
This patch adds exception logging to the swift service API. Each
operation that results in failure of any operation will now log
the exception as well as report a timestamp and full stack trace
in the results returned by the service API calls.

Change-Id: I7336b28354e7740ea7d048bdf355e3c1a1b4436c
2015-08-31 22:03:26 +01:00
Jenkins
e52df5d8a5 Merge "Reduce memory usage for download/delete and add --no-shuffle option to st_download" 2015-08-28 00:48:52 +00:00
Jenkins
b4b9254bc3 Merge "Add minimal working service token support." 2015-08-25 02:02:51 +00:00
Stuart McLaren
1789c2654d Add minimal working service token support.
Add client changes to allow accessing alternative
reseller_prefixes via a service token.

ie client changes for this server side spec:
 https://review.openstack.org/#/c/105228

We assume that the service storage url has been passed in
as a preauthurl.

We rely on get_auth preserving this url.

Change-Id: I1cfda178f0b6c8add46cfebd6bf38440caae2036
2015-08-24 10:54:15 +01:00
Hiroshi Miura
38a82e9035 flake8 ignores same hacks as swift
- blacklisted flake8 hacking
- fix against E122 continuation line missing
  indentation or outdented

Closes-bug: #1475516

Change-Id: I708d0a3466a1f85c84e478873e142821ce0774cb
Signed-off-by: Hiroshi Miura <miurahr@nttdata.co.jp>
2015-08-18 19:19:22 -07:00
Jenkins
3c65652354 Merge "Update mock to get away from env markers" 2015-08-14 01:36:36 +00:00
Jenkins
e9147ca0e0 Merge "change deprecated assertEquals to assertEqual" 2015-08-11 15:19:07 +00:00
Jenkins
4f9e0891d8 Merge "make Connection.get_auth set url and token attributes on self" 2015-08-06 23:14:50 +00:00
Christian Schwede
7c7f46a33d Update mock to get away from env markers
Closes-Bug: 1476585

Bug has been reproduced on a fresh installed SAIO using
https://github.com/swiftstack/vagrant-swift-all-in-one.

Change-Id: I0300319baf7e2d8c27d1c19957894396505caeb8
2015-08-06 14:51:10 -07:00
Hiroshi Miura
be0f1aad8a change deprecated assertEquals to assertEqual
fix against H234: assertEquals() logs a DeprecationWarning
in Python3.x. use assertEqual() instead.

Closes-bug: #1480776

Change-Id: Iffda6bb5f2616d4af4567eeea37bb26531e34371
Signed-off-by: Hiroshi Miura <miurahr@nttdata.co.jp>
2015-08-06 18:50:33 +09:00
Hiroshi Miura
a056f1b374 fix old style class definition(H238)
Change-Id: Ib5be06fa544f5eb3061c6a3077a3b9986382ecfe
Signed-off-by: Hiroshi Miura <miurahr@nttdata.co.jp>
2015-08-04 11:34:51 +09:00
Jenkins
161e08df10 Merge "Block comment PEP8 fix." 2015-08-01 21:33:21 +00:00
Jenkins
9c640ae58d Merge "Test auth params together with --help option." 2015-07-31 17:33:17 +00:00
Jenkins
207e80c65c Merge "swiftclient: add short options to help message" 2015-07-31 04:54:13 +00:00
Ondrej Novy
847f135f97 Block comment PEP8 fix.
Change-Id: I999425902a5c82f7af129a8a1b6998d80edb225a
2015-07-30 09:55:51 +02:00
Ondrej Novy
1c644d8dc1 Test auth params together with --help option.
Change-Id: I2691739cc14bb8d384cc7ef0f8a3e73d1b898f88
2015-07-30 09:48:00 +02:00
Zack M. Davis
3cd1faa7af make Connection.get_auth set url and token attributes on self
When a Connection is first __init__ialized (without providing a
preauthurl or preauthtoken), the url and token attributes are None; they
get set (to be reused on future requests) after one of the wrapper
methods internally using _retry (head_account, get_container,
put_object, and similar friends) is called. However, this had not been
the case for get_auth, much to the momentary confusion and
disappointment of programmers using swiftclient who expected to be able
to get the token or storage URL off the Connection object after calling
get_auth (perhaps in order to make an unusual kind of request that
swiftclient doesn't already have a function for). This commit makes
get_auth set the url and token attributes as one might expect.

Change-Id: I0d9593eb5b072c8e3fa84f7d5a4c948c0bc6037a
2015-07-24 10:57:29 -07:00
Joel Wright
a8c4df98ee Reduce memory usage for download/delete and add --no-shuffle option to st_download
The current code builds a full object listing before performing either a multiple
download or delete operation (and also shuffles this complete list in the case of
a download). This patch removes the creation of the full object list and adds the
ability to turn off shuffle for files when downloading. Also added is a limit on
the number of list results that can be queued by a single call to service.list
without consuming results (reduces memory overhead for large listings).

Some tests added for service.py download and list.

Change-Id: Ie737cbb7f8b1fa8a79bbb88914730b05aa7f2906
2015-07-20 20:44:51 +01:00
Hiroshi Miura
7442f0dcc8 swiftclient: add short options to help message
- add usage strings for short option such as '-a' for '--all'
  This add all short options  to usage text.
- add missing --header usage help for download command
- some cometic changes

Closes-bug: #1475511

Change-Id: Ibfecac8764669540fa025787548133a50fa50b10
Signed-off-by: Hiroshi Miura <miurahr@nttdata.co.jp>
2015-07-17 16:03:39 +09:00
Jenkins
63998b481c Merge "Python 3: Replacing unicode with six.text_type for py3 compatibility" 2015-07-16 19:18:33 +00:00
Jenkins
a56eac13b1 Merge "Always decode command-line arguments as UTF-8" 2.5.0 2015-07-16 11:27:31 +00:00
Jenkins
c3b57f431c Merge "Properly test raw writes in Python 3" 2015-07-16 11:25:36 +00:00
Jenkins
dd45ae542b Merge "add tempurl command to swift.1 man page" 2015-07-13 23:47:35 +00:00
Zack M. Davis
ca70dd9e15 add tempurl command to swift.1 man page
Change-Id: Ifccc7f6dc049ca0ac2c53c00b1704cff4d1a770f
Closes-Bug: #1450606
2015-07-13 11:38:58 -07:00
Jenkins
de3fe02ba7 Merge "Correct the help message of swift tempurl" 2015-07-11 06:47:09 +00:00
Jenkins
605ec92507 Merge "Add some bash helpers for auth stuff" 2015-07-11 06:41:45 +00:00
Jenkins
0b592caabf Merge "Add ability to download objects to particular folder." 2015-07-11 06:21:40 +00:00
Tim Burke
87c0a83988 Update mock requirements
The last version supporting python 2.6 was 1.0.1.

Change-Id: Ib7d51157f9654d240cdd67a0a1e6fcb14a70c84a
2015-07-10 13:56:48 -07:00
Charles Hsu
d5d3127744 Add ability to download objects to particular folder.
This patch adds "--output-dir" and "--remove-prefix" options
to the "download" command and unit tests for it.

Example:

    $ swift list example --prefix swift2.2
    swift2.2/bin/swift-object-auditor
    swift2.2/bin/swift-object-expirer
    swift2.2/bin/swift-object-info
    swift2.2/bin/swift-object-replicator
    swift2.2/bin/swift-object-server
    swift2.2/bin/swift-object-updater

When given "--output-dir <directory>", client downloads objects to <directory>.

    $ swift download example --prefix swift2.2 \
                    --output-dir new/swift/dir

    The folder structure:
    .
    └── new
        └── swift
            └── dir
                └── swift2.2
                    └── bin
                        ├── swift-object-auditor
                        ├── swift-object-expirer
                        ├── swift-object-info
                        ├── swift-object-replicator
                        ├── swift-object-server
                        └── swift-object-updater

When given "--remove-prefix", client downloads objects without <prefix>.

    $ swift download example --prefix swift2.2 \
                    --remove-prefix \
                    --output-dir swift

    The folder structure:
    .
    └── swift
        └── bin
            ├── swift-object-auditor
            ├── swift-object-expirer
            ├── swift-object-info
            ├── swift-object-replicator
            ├── swift-object-server
            └── swift-object-updater

Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Change-Id: I7463fe2941cc94f9a50a4756a97c2ccdf946294d
Implements: blueprint swiftclient-download-pseudo-folder-to-specific-target
2015-07-08 14:23:05 +08:00
Tim Burke
bb252130ac Always decode command-line arguments as UTF-8
There was always an implicit assumption that they were UTF-8 before, and
by converting them to unicode we close another hole allowing raw bytes
to appear in user-facing messages.

Closes-Bug: #1431866
Change-Id: If2e41d9a592c3ad02818e9c6f0959fd4b73cd0e0
2015-07-07 15:39:55 -07:00
Tim Burke
cf0b6c03df Properly test raw writes in Python 3
Previously we were trying to test writing bytes in Python 3 using only
native (unicode) string objects. That doesn't test what we thought we
were testing.

Change-Id: I10a0a38143d7f7d850ab9a7005ad87f5d314c375
2015-07-07 15:39:02 -07:00
Jenkins
92b8277752 Merge "SwiftClient object upload beginning with / or "./"" 2015-07-07 22:21:38 +00:00
Jenkins
249dd1a393 Merge "Added check for negative segment-size" 2015-07-07 01:36:50 +00:00
Jenkins
2a62dd88ff Merge "Document missing functional test config option" 2015-07-02 02:39:43 +00:00
Jenkins
795476e013 Merge "Run functional tests using keystone auth options" 2015-07-02 00:14:41 +00:00
Jenkins
f5fa154f6d Merge "Add passenv to tox.ini to make functests run with tempauth" 2015-07-02 00:14:38 +00:00
Jenkins
29e5c5656e Merge "Add connection release test" 2015-07-02 00:04:52 +00:00
Jenkins
0df888ea55 Merge "Remove all DLO segments on upload of replacement" 2015-07-02 00:04:50 +00:00
Tim Burke
70afe207cf Bump hacking in test-requirements
The gate-swiftclient-dsvm-functional job takes updates from
openstack/requirements and tries to run functional tests against them.
However, the global requirements recently added environment markers
(like "futures>=3.0;python_version=='2.7' or python_version=='2.6'")
which require pbr>=1.2. pbr was getting capped at 1.0 by hacking<0.9, so
bump it to get newer pbr.

Change-Id: I10af36602d23db78c2863d84c0012835b310bbdd
2015-07-01 11:11:53 -07:00
YangLei
91855bd912 Correct the help message of swift tempurl
correct the help message of swift tempurl
use <> instead of [] in Positional arguments.

Change-Id: Ib60ce97cef03e0423082c497604525eba2300fa9
2015-06-30 15:10:44 +08:00
janonymous
ef467ddee4 Python 3: Replacing unicode with six.text_type for py3 compatibility
The "unicode" type was renamed to "str" in Python 3.
Use six.text_type to make swiftclient compatible with Python 3.

For more information about changes needed for py3
compatibility, see:
https://wiki.openstack.org/wiki/Python3

Change-Id: Ic65607a69935652a1874340928f626fbcc35c014
2015-06-28 07:40:26 +05:30
Pradeep Kumar Singh
e596489020 Added check for negative segment-size
Closes-Bug: #1453135

Change-Id: Ia9c2b27d998e6ac1889cc74c12e456c06ecd84d9
2015-06-23 10:50:34 +09:00
Clint Byrum
7c716997a8 Fix docstring typo for SwiftService.upload
The option from argparse in shell is 'header' and that is what is used
in the code.

Change-Id: I5c889192ef7c46c299dc0ec7cbc7c4d027dae6d5
2015-06-18 09:04:33 -07:00
Pradeep Kumar Singh
794b125e76 SwiftClient object upload beginning with / or "./"
Currently SwiftClient populate response dictionary before
removing "./" or "/" at begining of object name. This patch
fixes that by changing that order.

Closes-bug: #1412425
Change-Id: I80222754caba5d42a468f4677ac539e46682dd31
2015-06-17 12:27:43 +05:30
Clay Gerrard
17feec709c Add some bash helpers for auth stuff
Change-Id: If61ac9a050e7a115f37dbf4e74b904ac5dfd2052
2015-06-15 12:38:21 -07:00
Andreas Jaeger
e48f487335 Fix inconsistent usage of "Positional argument"
All help texts uses "Positional argument" with the exception of tempurl.
Update tempurl to use this as well so that the formatting tools work
fine and can show this nicely on
http://docs.openstack.org/cli-reference/content/swiftclient_commands.html#swiftclient_subcommand_tempurl
like it's done for other options.

Change-Id: Ib5502c23b236986bea5a4d4a63a46fca411a8494
Closes-Bug: #1463081
2015-06-08 20:20:21 +02:00
Christian Schwede
7f2ee7322b Add connection release test
This patch adds a small test to ensure a connection
is released after all chunks have been consumed.

It's a follow up to commit 8756591b and added to ensure
there will be no regression in the future (this test
fails also with that patch not applied).

Change-Id: I6a6fcd26879eb2070f418c8770a395ff6c30aa51
2015-06-05 07:17:31 +00:00
Alistair Coles
f0aad4c364 Run functional tests using keystone auth options
Makes the existing functional tests run using three
auth modes: tempauth (v1), keystone v2 and keystone v3.
The latter uses an account in a non-default domain
(which exists in devstack setup).

This should help avoid regressions in handling different
auth options.

Change-Id: Ifee6a4fa418242892bf73eda5e2cad7b803b1bee
2015-06-04 12:54:43 +00:00
Jenkins
ec3e2ab3a0 Merge "Allow reading from object body on download" 2015-06-04 12:08:07 +00:00
Alistair Coles
259b434ae2 Add passenv to tox.ini to make functests run with tempauth
Since tox version 2.0.0 env vars are not passed to the test
env, which means that the SWIFT_TEST_CONFIG_FILE var is not
passed in to tox -e func env. That means that both times
tox -e func runs it is using keystone auth, and never using
tempauth.

Related-Bug: 1455102

Co-Authored-By: Christian Schwede <cschwede@redhat.com>

Change-Id: I23dcdbcde0bf8adc9429eb2d294a2c778005d136
2015-06-03 17:45:14 +01:00