This patch fixes downloading files to stdout and modifies
_SwiftReader to operate as an iterator that performs file
checks at the end of iteration as well as a context manager.
File verification checks have been removed from __exit__
and added to __iter__.
Change-Id: I3250bdeeef8484a9122c4b5b854756a7c8f8731e
Closes-Bug: 1395922
Closes-Bug: 1387376
Removes an account stat from the object upload path.
This stat fails when user is not account admin even
though the user may have container ACL permission to
write objects.
Reduces the severity of the CLI output message when
upload fails to create the given container (this is
not an error since the container may exist - the user
just does not have permission to PUT or POST the
container).
Changes the 'swift upload' exit return code from 1 to
0 if container PUT fails but object PUT succeeds.
For segment uploads, makes the attempt to create the
segment container conditional on it not being the same
as the manifest container. This avoids an unnecessary
container PUT.
Fixes another bug that became apparent: with segmented
upload a container HEAD may be attempted to determine
the policy to be used for the segment container. When
this failed the result dict has headers=None which was
causing an exception in the shell result handler.
Add unit tests for object upload/download and container
list with --os-storage-url option.
Closes-Bug: #1371650
Change-Id: If1f8a02ee7459ea2158ffa6e958f67d299ec529e
The response dictionary in _delete_segment attach's any error
it encounters to the dict key 'exception', all other response
dict's use 'error' to store the exception.
Changed to make it consistent and added tests
Also added a third branch in st_delete as messages
created in _delete_container where being silently dropped.
Change-Id: Ifbc3b1fae78910fbc6acf4a86cfb0f60bb1aa336
Added the ability to clear the buffers in the
CaptureOutput class so it can be easily used multiple
times in the same context manager.
Also added a option to suppress the SystemExit
associated with printing an error.
Change-Id: Ib59bbbe88256f215eed0a8ebc8282e02181d4377
swiftclient.shell.st_post was ignoring the result dict
returned from SwiftService.post and therefore giving no
indication when posts failed e.g. due to invalid auth
credentials.
This patch ensures that SwiftService always returns a
result_dict from post() and then checks the result dict.
On failure the shell now outputs the ClientException
message and exits with error code 1.
Also adds unit tests and cleans up some unnecessary mocked
return values in existing tests.
Closes-Bug: 1383243
Change-Id: I111150eb3d026c8d01c2cac13d3613ca7304e5b9
Changed the message shown when a user doesn't enter project/tenant
id/name to be more informative.
When attempting to stat a container without supplying project/tenant
name or id, an empty response was being returned instead of an error
being raised.
Changed the error raised in swiftclient.client when no tenant or project
is specified to be more specific.
Add tests for basic regression checking.
Closes-Bug: #1372589
Change-Id: I4eb6964d9f1702db119cc0294edc02841b1ecd5f
SysExit is raised if the OutputManager has non-zero
error_count. However, error_count is incremented in
a print thread, but tested on the main thread.
Currently error_count is tested before the OutputManager
print threads have exited, which results in a race. This race
means that SysExit is not always raised even when an error
has occured.
This change moves the error_count test after the
OutputManager context manager has exited, which ensures that
the OutputManager threads have exited.
Change-Id: I5ef7d9f10057fe2b41f48ab95066a7265b86a3ac
Closes-Bug: #1379229
Instead of always specifying segment size in bytes the user
can now use B,K,M or G as suffixes for the corresponding
size.
Conversion is done with Binary units (1024) rather than SI
units (1000).
e.g
swift upload test_container -S 1073741824 large_file
can now be written
swift upload test_container -S 1G large_file
The change is backwards compatible as it ignores arguments to -S
that don't have a valid suffix.
Updated unit tests and help message.
Change-Id: I6314b4e45cf2fbffde2fe57a02df77a25e911e84
If 'x-timestamp' header is not present in 'swift list' result,
date string cannot be correctly generated. Check for correct
exception to catch this case and return a special string value.
This is just a workaround for faulty RadosGW behavior.
Change-Id: I172843a2668e33efac00924906ff0dca3e790050
Closes-Bug: 1349528
This patch adds a SwiftService class that incorporates the high
level logic from swiftclient/shell.py. It also ports shell.py to
use the new class, and updates the code in swiftclient/multithreading.py
to allow the SwiftService to be used for multiple operations whilst
using only one thread pool.
Currently, code that imports swiftclient has to have its own logic for
things like creating large objects, parallel uploads, and parallel
downloads. This patch adds a SwiftService class that makes that
functionality available in Python code as well as through the shell.
Change-Id: I08c5796b4c01001d79fd571651c3017c16462ffd
Implements: blueprint bin-swift-logic-as-importable-library
If a user creates an object with name ending with a slash, then
downloading such container ends in a traceback like this:
..............
test5g.file [auth 1.516s, headers 1.560s, total 244.565s, 22.089 MB/s]
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/swiftclient/multithreading.py", lin
result = self.func(item, *self.args, **self.kwargs)
File "/usr/lib/python2.6/site-packages/swiftclient/shell.py", line 403, in
fp = open(path, 'wb')
IOError: [Errno 21] Is a directory: 'first-pseudo-folder/'
The proposed fix is not to save this object. Note that the contents of
the object are available with --output option, as before. Only the
crash is fixed.
Even though we do not use the contents, we download the object and
check its Etag, in case. We also create a corresponding directory,
in case the pseudo-directory contains no objects.
The format of printout is changed, so user realizes easier when
pseudo-directory convention is in effect. Note that this is not a
compatibility issue because previously there was crash in such case.
Change-Id: I3352f7a4eaf9970961af0cc84c4706fc1eab281d
Enables swiftclient to authenticate using
the keystone v3 API, allowing user id's, user
domains and tenant/project domains to be
specified.
Since swiftclient imports keystoneclient, the
main changes in swiftclient/client.py are to
selectively import the correct keystoneclient
library version and pass a number of new
options to it via the get_auth() function. In
addition the get_keystoneclient_2_0 method
has been renamed get_auth_keystone to better
reflect its purpose since it now deals with
both v2 and v3 use cases.
In swiftclient/shell.py the new options are
added to the parser. To make the default help
message shorter, help for all the --os-*
options (including the existing v2 options)
is only displayed when explicitly requested
usng a new --os-help option.
A new set of unit tests is added to
test_shell.py to verify the parser. A comment
in tests/sample.conf explains how to
configure the existing functional tests to
run using keystone v3 API.
Note that to use keystone v3
with swift you will need to set
auth_version = v3.0 in the auth_token
middleware config section of
proxy-server.conf.
Change-Id: Ifda0b3263eb919a8c6a1b204ba0a1215ed6f642f
Make it so that swift <cmd> --help will print the info
subcommand help for info and tempurl just like all the
other subcommands.
Also add unit tests to verify subcommand help.
Change-Id: Id3666dcf72a9727fbfda2f74c23293ada1c53aa0
Client already supports -H/--header option when creating container
or uploading objects. This patch extends this option to support
Storage Policy.
e.g.,
swift post con -H 'X-Storage-Policy:p1'
This creates one container 'con' with storage policy 'p1'.
swift upload con obj -H 'X-Storage-Policy:p2'
This creates container 'con' with storage policy 'p2' and uploads
object 'obj' into it.
Also fixes segmented uploading to non-default storage policy container
When uploading large objects with segmentation to container with
non-default storage policy, there will be another 'xxx_segments'
container created, but with the default storage policy. This
results all the segments to be stored with the wrong policy.
This patch is for the Storage Policy feature, and also
compatible with old versions w/o Storage Policy support.
Change-Id: I5c19e90604a0bcf2c85e1732b8a0b97ae6801994
The command descriptions did not include a "." at the end but the
argument description does. Add "." everywhere.
Also capitalize and add "." for parameter of capabilities.
Change-Id: I2355e0d0c38170d669c8e568361faf4b68203d16
To make bin/swift importable for testing it needs to be renamed/moved.
The final idea is to move it to swiftclient/shell.py and add only a stub
in bin/swift to import swiftclient/shell.py.
However, doing this in a single step makes reviewing very hard, because
now there are > 1400 lines deleted from bin/swift and added to
swiftclient/shell.py - Gerrit doesn't detect the moved file.
For example: https://review.openstack.org/#/c/73710/2/
This patch first moves the code to swiftclient/shell.py and uses
setup.py/cfg to create the stub file in bin/swift. A follow up
(https://review.openstack.org/#/c/76489/) will then add the stub itself
in bin/swift (and remove the entry in setup.py).
The change to tox.ini is related to bug 1290562 and can be removed in
the future.
Change-Id: Id86392ccaf09e1d80a5d808fb49827d6d18c2588