363 Commits

Author SHA1 Message Date
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
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
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
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
Jenkins
a56eac13b1 Merge "Always decode command-line arguments as UTF-8" 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
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
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
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
Pradeep Kumar Singh
e596489020 Added check for negative segment-size
Closes-Bug: #1453135

Change-Id: Ia9c2b27d998e6ac1889cc74c12e456c06ecd84d9
2015-06-23 10:50:34 +09: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
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
f0cc3be2ac Make default get_auth timeout be None
Setting timeout to a default of False in get_auth()
results in a requests timeout of 0.0 in keystoneclient,
which causes a connection failure.

This bug will cause func tests to not run when using
keystoneauth.

Added unit tests to verify correct default timeout is set
in get_auth().

Drive-by: remove what seems like a stale TODO comment

Change-Id: I17c781ce160a682b1768d315422ade0cdd2df198
2015-06-03 12:03:30 +01:00
Alistair Coles
71a1835193 Document missing functional test config option
Adds doc for account_username option to sample test.conf.
This option was added in [1].

[1] change id Ic484e9a0c186c9283c4012c6a2fa77b96b8edf8a

Change-Id: Ic86b274e9d954822da521360981f796d61efaad9
2015-06-02 11:13:38 +01:00
Tim Burke
ff0b3b02f0 Compare each chunk of large objects when downloading
This allows the use of --skip-identical when downloading SLOs and DLOs,
while still only requiring one request for normal objects.

Change-Id: I237ec5a8cc4d1119b6d3f166db81a977a50a4e4e
Related-Bug: #1379252
2015-05-27 17:40:24 -04:00
Tim Burke
317df7e527 Remove simplejson dependency
In addition to removing an unnecessary dependency, this closes another
hole that was allowing raw bytes to appear in user-facing messages.

Change-Id: Ia0b76426a38e5a5c368c4c7e7ba2aef286758aca
2015-05-20 18:14:53 -07:00
Jenkins
52b849217f Merge "Add tests for uploads deleting DLO segments" 2015-05-21 00:47:28 +00:00
Jenkins
53432b5739 Merge "Add test for timeout being passed to keystone client" 2015-05-21 00:44:51 +00:00
Jenkins
1aebb7ccc5 Merge "Use a socket timeout in get_auth" 2015-05-04 19:28:15 +00:00
Jenkins
766cf73247 Merge "Compare each chunk of large objects when uploading" 2015-04-30 18:48:59 +00:00
Alistair Coles
a39e18ff5a Add test for timeout being passed to keystone client
Extends existing unit test for timeout being passed to get_auth
to cover v2.0 auth when keystone client should get the timeout
kwarg.

Related-Bug: 1447847
Change-Id: Ie9cfc86fa2156b94b45d290ac12e3f71b20d6c4f
2015-04-28 16:58:23 +01:00
Pete Zaitcev
e2f41a6635 Use a socket timeout in get_auth
A previous change added socket timeouts, but they weren't plumbed
through to the get_auth code path. Make sure we're passing them along
everywhere.

Original-Author: Monty Taylor <mordred@inaugust.com>
Change-Id: I398241898248e66d1f8c436c8ed2ec7a0e9387f6
Closes-bug: 1447847
2015-04-26 01:37:15 -06:00
Jenkins
ea6d2bf74d Merge "Add socket-level read timeout parameter" 2015-04-24 01:18:49 +00:00
Jenkins
3105cdc4f8 Merge "Include unsupported url scheme with ClientException" 2015-03-31 22:18:44 +00:00
Monty Taylor
f5a473edfc Add socket-level read timeout parameter
The underlying requests library supports a timeout input parameter. The
other python-*client libraries support passing it in, so while working
on shade, it seemed like a great idea to be able to pass in timeout to
swiftclient too. For reference, there's a change in shade:
I095c1240693abf024bda2315dd77f4400b24a45b that shows interaction with
the other libs, and a tentative patch that would consume this one.

Change-Id: I699ebb1e092aa010af678de7ba15712da6ed5315
2015-03-30 17:01:02 -04:00
Stuart McLaren
b6457e0f95 Allow reading from object body on download
Currently, get_object returns a generator. This allows access to the
object's data in multiples of 'resp_chunk_size'.

This patch adds a read function to also allow accessing the object data
using read(size).

This allows, for example, the consumer of an object (where no byte range
has been specified) to read up to certain boundaries while streaming to
a new Large Object with segments of a specified size.

Reading and chunking can be safely mixed.

Related-Bug: 1367925
Co-Authored-By: Clay Gerrard <clay.gerrard@gmail.com>
Change-Id: I1cfb67f45afc7015fd896f1a89bebae048871769
2015-03-24 10:45:33 +00:00
Tim Burke
a4fb70ece1 Compare each chunk of large objects when uploading
Previously, we compared the ETag from Swift against the MD5 of the
entire large object. However, the ETag for large objects is generally
the MD5 of the concatenation of the ETags for each segment, unless the
object is a DLO whose segments span more than one page of a container
listing. Rather than worry about ETags, just compare each chunk of the
segmented file. This allows the use of --skip-identical when uploading
SLOs and DLOs.

Additionally, there are several test-related improvements:
 * The default arguments for OutputManager are now evaluated on
   construction, rather than on definition, so that
   TestOutputManager.test_instantiation will succeed when using nosetest
   as a test runner. (See also: bug 1251507)
 * An account_username option is now available in the functional tests
   config file for auth systems that do not follow the account:username
   format.
 * CaptureOutput no longer writes to the captured stream, and
   MockHttpTest now captures output. These were polluting test output
   unnecessarily. (See also: bug 1201376)

Change-Id: Ic484e9a0c186c9283c4012c6a2fa77b96b8edf8a
Closes-Bug: #1201376
Closes-Bug: #1379252
Related-Bug: #1251507
2015-03-23 18:35:45 -07:00
Tim Burke
d931ec1381 Remove all DLO segments on upload of replacement
Previously, only the first container-listing's worth of segments was
deleted, which would leave behind orphaned segments when the object was
very large with small segments or the server's container_listing_limit
was small.

In addition, process DLO and SLO deletions on the segment thread pool,
rather than the object thread pool.

Change-Id: I1587375261a6237fa55a9cb96bda8dae918cc795
Related-Bug: #1418007
2015-03-23 12:11:47 -07:00
Daniel Wakefield
13780f37c3 Add improvements to MD5 validation.
With MD5Sum checking being added, a concern was brought up that It was
a change with no possibility of reverting to the old behaviour.
This change adds the flag '--ignore-checksum' to the upload subcommand
allowing the checks to be turned off.

Changed occurrences of the magic string for a null md5 to use a descriptive
constant instead.

Updated Error messages generated when validation fails. They should now be more descriptive
and not output a literal newline sequence.

Change-Id: Id1756cbb6700bb7e38f0ee0e75bc535e37f777ed
2015-03-04 14:01:55 +00:00
Alistair Coles
dcf2124d41 Add tests for uploads deleting DLO segments
This patch adds unit tests to verify that
uploads overwriting an existing DLO manifest
will delete any segments pointed to by the
manifest, unless --leave-segments is specified.

Also test the --leave-segments option with an
existing SLO manifest.

Related-Bug: 1418007

Change-Id: I54e8eb138976269bb36392a811089c33c1ace4d3
2015-02-25 16:52:23 +00:00
Jenkins
771383145b Merge "Fix crash when stat'ing objects with non-ascii names" 2015-02-25 13:10:56 +00:00
Alistair Coles
47f089fbca Include unsupported url scheme with ClientException
This was an attempt to reveal some more info about failing
jenkins jobs such as here [1] where glance_store is
receiving a swiftclient exception because of 'unsupported
scheme in url'. It seems worth merging the more helpful
exception message.

[1] http://logs.openstack.org/91/155291/7/check/gate-tempest-dsvm-neutron-src-python-swiftclient/4adac1e/

Change-Id: I0f3411efd42d045b07d6d1000f59a06865d8034b
2015-02-23 19:10:32 +00:00
Daniel Wakefield
f0300e3714 Verify MD5 of uploaded objects.
Changed existing code to calculate the MD5 of the object
during the upload stream. Checks this MD5 against the etag
returned in the response.
An exception is raised if they do not match.

Closes-Bug: 1379263

Change-Id: I6c8bc1366dfb591a26d934a30cd21c9e6b9a04ce
2015-02-19 11:21:32 +00:00
Joel Wright
cac21e3cff Fix crash when stat'ing objects with non-ascii names
This patch fixes a crash and stack trace in stat when an object
name contains non-ascii characters.

Change-Id: Ib6dc686771e593243de56cafc100b17e51d9d9d5
Closes-Bug: 1411665
2015-02-17 14:52:35 +00:00