537 Commits

Author SHA1 Message Date
Zack M. Davis
6b3638ecec enable autodocumentation for utils module; docstring fixes
This commit adds the utils module to those for which Sphinx
automatically generates documentation from docstrings. (Many of the
functions here may be of little interest to users, but
`generate_temp_url`, at least, definitely deserves to be in the
documentation; in this way, this commit can be seen as a spiritual
companion to ca70dd9e.)

Also, a few markup errors and perceived infelicities in existing
docstrings are amended.

Change-Id: I8c66a23cb359d7dd9302a16459fad9825fedb690
2015-09-10 15:19:26 -07:00
Doug Hellmann
a2c84e0c93 Add links for release notes tool
The automated release note tool expects to find links to the bug
tracker, documentation, and source using a specific regex. This change
adds the links using the expected format so they are found and included
in the release announcements.

Change-Id: I5fa24f60c7d705593996194b865ffb2c47870808
2015-09-08 09:40:36 -07:00
Alistair Coles
1841bd6010 Initialise delete_object mock before it is called
Attempt to fix the linked bug by initialising the mock instance for
Connection.delete_object before calling the SwiftService upload
method, so that the delete_object mock already exists before the
delete_segments jobs that run in multiple threads call it.  Otherwise
there is a risk that the delete_segment job threads could race while
creating either the delete_object mock or the
delete_object.return_value mock, resulting in each thread getting a
different instance. That would explain the intermittent test failures
reported in the bug.

Change-Id: Ia82697c093529076b0bbcc6bccd577afdf0839e1
Partial-Bug: #1480223
2015-09-08 10:22:32 +01:00
John Dickinson
7cd2a01cda updated changelog for 2.6.0 release
Instead of a 2.5.1 release, add in the absolute tempurl option to the release and bump it to 2.6.0

Change-Id: Ie8335a737aac3211a240c25d88501f8f5dbccbea
2.6.0
2015-09-07 08:20:14 -07:00
Jenkins
fa7ffdd292 Merge "absolute expiry option for tempURL generation" 2015-09-05 20:16:38 +00:00
Zack M. Davis
52d39bebc1 absolute expiry option for tempURL generation
The `tempurl` subcommand's second positional argument is called
`seconds` and has heretofore interpreted as the number of seconds for
which the tempURL should be valid, counting from the moment of running
the command. This is indeed a common, if not the most common,
use-case. But some users, occasionally, might want to generate a tempURL
that expires at some particular ("absolute") time, rather than a
particular amount of time relative to the moment of happening to run the
command. (One might make an analogy to the way in which Swift's expiring
object support supports an `X-Delete-At` header in addition to
`X-Delete-After`—and it's the former that must be regarded as
ontologically prior.) Thus, this commit adds an `--absolute` optional
argument to the `tempurl` subcommand; if present, the `seconds` argument
will be interpreted as a Unix timestamp of when the tempURL should be
expire, rather than a duration for which the tempURL should be valid
starting from "now".

Change-Id: If9ded96f2799800958d5063127f3de812f50ef06
2015-09-04 14:57:30 -07:00
John Dickinson
9ef4c97de2 do hand-curated authors/changelog files
Change-Id: I1a264c9ce1d137b18a6dc62623a282e4a2fe839c
2015-09-04 18:29:30 +01:00
Jenkins
93666bb84a Merge "Log and report trace on service operation fails" 2015-09-04 01:46:18 +00:00
Jenkins
ff073ab34a Merge "Increase httplib._MAXHEADERS to 256." 2015-09-03 08:37:00 +00:00
Jenkins
996f672955 Merge "Cleanup and improve tests for download" 2015-09-03 07:43:56 +00:00
Jenkins
8cbbbeb7a8 Merge "Drop flake8 ignores for already-passing tests" 2015-09-03 02:19:09 +00:00
Jenkins
e0ce24dd43 Merge "Stop Connection class modifying os_options parameter" 2015-09-03 01:18:10 +00:00
Alistair Coles
d5eb818228 Cleanup and improve tests for download
Some improvements to the tests for staggered download
that were added in [1].

[1] Ie737cbb7f8b1fa8a79bbb88914730b05aa7f2906

Change-Id: Ib999bc7bd198c1d9c217c57501f751e854d4c6ad
2015-09-02 13:06:13 +01:00
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
Charles Hsu
4b627327c9 Increase httplib._MAXHEADERS to 256.
By default Swift increase the number of max metadata count to 90
and extra header count to 32. That mean we can put 90 metadata to
Account/Container/Object by default, when user put 90 metadata to a
Account, the Account header count is close or more than 100. The
swift client unable to access Account and get an error likes,

('Connection aborted.', HTTPException('got more than 100 headers',))

So the default _MAXHEADERS(100) won't enough.

Change-Id: I5ffc4eb5d3e1ebc3dbdd7dc69376919ae3e1c5a8
2015-08-27 00:01:22 +08:00
Alistair Coles
4b310083df Stop Connection class modifying os_options parameter
When a caller passes an os_options dict to the Connection class
constructor, the constructor may modify the os_options dict,
which can surprise the caller if they re-use the os_options
dict. Specifically the os_options tenant_name and object_storage_url
may be modified, and the changed values would then leak through to a
subsequent Connection constructed using the same os_options dict.

This fix simply constructs a new dict from the supplied os_options.
The patch also adds a test that covers this and also verifies that
a preauth_url passed as a keyword arg to Connection() will take
precedence over any object_storage_url in an os_options parameter.

Closes-Bug: 1488070
Change-Id: Ic6b5cf3ac68c505de155619f2610be9529e15432
2015-08-25 09:47:09 +01: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
Tim Burke
91d82aff25 Drop flake8 ignores for already-passing tests
Change-Id: I5fb349b2f7808a3f97d95fc7db6b5cf5842a9f7c
2015-08-19 14:54:03 -07: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