52 Commits

Author SHA1 Message Date
Darrell Bishop
1d4d51b218 Allow storage url override for both auth vers.
When --os-storage-url is specified on the command-line to bin/swift, it
will override the used storage URL regardless of authentication for both
authentication version 1 and version 2.  This can be used to bypass a
load-balancer to hit a specific proxy server for testing/debugging
purposes.

Within the client library, this feature is accessed by passing the
desired storage URL into swiftclient.client.Conection.__init__() via the
os_options keyword argument.  For example:

  conn = Connection(auth_url, user, key, os_options={
    'object_storage_url': 'http://overridden.storage.url/AUTH_foo'})

This patch also adds a dependency on mock>=0.8.0, which is the same as
openstack/swift.

Change-Id: Id2a36ed6abffd65e7762b6beea5bbfc6c036e848
2013-07-05 14:12:59 -05:00
Mark Seger
3f66a8ae6b add optional 'response_dict' parameters to many calls into which they'll
return a dictionary of the response status, reason and headers

Change-Id: I35f8824537f0484362dd6646c91789fac02fa075
2013-06-20 11:51:08 +00:00
EdLeafe
7b9f304485 Fixes re-auth flow with expired tokens.
The re-authentication of expired tokens assumed that the 401 would
always occur on the first HTTP at tempt. This fix changes that so that
re-auth is still only attempted once, but no longer has to be on the
first attempt.

Change-Id: I93a1187da3637287a803a59c146256d4f543c9d5
Fixes: bug #1131142
2013-06-13 11:14:28 -05:00
Jenkins
02742e602d Merge "Changed the call to set_tunnel to work in python 2.6 or python 2.7 since its name changed between versions" 2013-06-11 21:25:26 +00:00
Greg Lange
f045f5bec2 Changed the call to set_tunnel to work in python 2.6 or python 2.7 since its name changed between versions
Change-Id: I5550049435002b42c4fea06d41549a1e7254ac02
2013-06-07 20:03:00 +00:00
Stuart McLaren
790f087a67 Add option to disable SSL compression
Allows optionally disabling SSL compression. This can significantly
improve HTTPS upload/download performance in some cases -- in particular
when the object is not compressible and you have very high network
bandwidth.

Implements blueprint ssl-compression.

Change-Id: I1260055f9c2e83cdabfeb51aed11b3899bed4d55
2013-06-04 16:33:18 +00:00
Leah Klearman
7e84b69291 log get_auth request url instead of x-storage-url
because if the request gets a 4xx error, then the url will be None, and that's just confusing.

Change-Id: I62729364b9bd279498909dc5cd0d2a1ec5fcd70d
2013-05-22 18:17:59 -07:00
Jenkins
d5b6d29a30 Merge "Add end_marker and path query parameters" 2013-05-21 04:29:55 +00:00
Jenkins
af4109dd56 Merge "Switch to pbr for setup." 2013-05-15 08:15:39 +00:00
Pete Zaitcev
3196daf992 Eradicate eventlet and fix bug lp:959221
The bug is simple: whenever swift uploads to a Swift with SSL,
it uses 100% CPU. It happens because we use HTTPSConnection from
eventlet that loops like that, while holding the interpreter lock.

Now, it could be fixed in eventlet, but let's try something more
natural: drop the eventlet's HTTP client. We do not use green
threads in the client anymore, so it's not like we need it for that.

Note that in most cases clients do not use the BufferedHTTPConnection
either, because it's only installed on Swift server nodes, not on
workstations. Get rid of that too.

bug: 959221
Change-Id: I1eb932779d4171598b3efaa043f817b9c6c995c4
2013-05-10 21:33:17 -06:00
YUZAWA Takahiko
073cd56218 Add end_marker and path query parameters
Fix Bug 1175057

Change-Id: I1bf65fa7c4d99ddb03dd183fe3862df93455f501
2013-05-05 20:52:02 +09:00
Jenkins
fcb3100b7d Merge "Confirm we have auth creds before clearing preauth" 2013-05-02 18:36:24 +00:00
Monty Taylor
50f32bc803 Switch to pbr for setup.
Change-Id: Ifc2efa2bd7c2f030b51494ccb471f0c3e097c5ce
2013-05-01 12:23:12 -04:00
Monty Taylor
1eb2c29856 Switch to flake8.
Change-Id: Ib9ba1e7eed09c5a90c558a8365d0a87c3f4b5ee5
2013-05-01 12:23:01 -04:00
Dirk Mueller
000e33d021 Improve Python 3.x compatibility
Some mechancical replacement of the deprecated except x,y:
construct with except x as y, which works with any Python
version >= 2.6

Change-Id: Ic245049dc7b408a5c89b9e27dfd2bd7c08acc5b5
2013-04-29 11:08:47 +02:00
David Shrewsbury
9aa52eecb5 Confirm we have auth creds before clearing preauth
If you use the API and supply only preauth values (preauthurl and
preauthtoken), and if either of these are incorrect, a non-descriptive
AttributeError will be thrown and uncaught:

 'NoneType' object has no attribute 'find'

The _retry() will fail on the first pass (getting 401), then try
to reauthenticate with non-preauth values. If those are not given,
particularly the auth url, then the urlparse() call will be supplied
None for the url in http_connection() causing the exception above.

This change makes sure that we have an auth url, user and key before
retrying authentication. Given the situation above, a '401 Unauthorized'
ClientException will now be thrown instead of the AttributeError.

Change-Id: Ie1b5bde1e8ff321aa18c0f23dbd2960d6e482236
2013-04-25 07:43:43 -04:00
David Goetz
2b3d171907 Static large object support.
Also fixed bug with current large objects with segment listing prefixes.

Allow retry for object PUTs when possible.

Change-Id: I0edff127fd5d5c53da33aa7cb76a4f4dc85bf6e6
2013-04-03 09:51:15 -07:00
jola-mirecka
d90b768e50 Enhance put_object to inform when chunk is ignored
Changed documentation for chunk_size parameter to indicate
that it can be used only with file like objects.

Also added a UserWarning when using a string contents to inform
that chunk_size will be ignored.

Added a unit test to check whether the warning is working
correctly.

Fixes: bug #1147232
Change-Id: I618ec45520ba81905ce2ead4d61f192d21ae3489
2013-03-06 15:38:50 +00:00
Flaper Fesp
4ac431a9a2 Print useful message when keystoneclient is not installed
client.py now prints a useful message when trying to use Auth version
2.0 and keystoneclient is not installed.

Fixes bug 1102322

Change-Id: I6ed83610fd6e8c79c2dc5cf05db377a843cab1d5
2013-02-05 10:13:56 +01:00
Jenkins
bf09dd9573 Merge "Update to latest oslo version/setup." 2013-01-21 21:50:21 +00:00
Monty Taylor
8b80285da6 Update to latest oslo version/setup.
Change-Id: I7bd38b950ef9fea8b6eaa1df599085a1c64d8b61
2013-01-14 03:29:22 -08:00
Jenkins
3d04363ba4 Merge "Add env[SWIFTCLIENT_INSECURE]" 2013-01-10 20:10:30 +00:00
You Yamagata
5edb40b442 Add env[SWIFTCLIENT_INSECURE]
Add env[SWIFTCLIENT_INSECURE] as default of --insecure option.
If set to 'true', allow to access insecure keystone server.
The name follows 'NOVACLIENT_INSECURE' in novaclient.

Change-Id: I322674eba9c07e6def97bce339815fa15191a92d
2013-01-10 13:26:53 +09:00
Chmouel Boudjnah
ab4282ebb4 Fix debug feature and add --debug to swift.
- Remove PYTHON_SWIFTCLIENT and use --debug making it more consistents
  with other openstack clients libraries.
- Fix printing the curl command.
- Don't show the body of the GET objects it could get bad on large
  objects and it's an iterator anyway.
- Use -I for showing HEADs (and not -X HEAD).

Change-Id: I954e7d3d795401fc3679725440dec36cdc80af87
2013-01-07 17:59:12 +01:00
Dean Troyer
f65f96bc59 Add --os-cacert
Add support to specify a ca certificate bundle to verify
keystone TLS (https) certificates.  This only verifies
certificates on the keystone connection, swift https
connections are unchanged.

Change-Id: I14351b405af4fd3d1970ba6656c1282a5d0a1082
2012-12-20 14:03:19 -06:00
You Yamagata
6a4dc039ff Add --insecure option to fix bug #1077869
If enable this option , swift CLI is allowed to access a keystone
server with self signed certificate.

Change-Id: I5e219fe875b246b68ac51a077e7ff15e95463adf
2012-12-05 13:26:37 +09:00
Jenkins
0053b4cf0e Merge "Remove unused json_request." 2012-11-16 23:19:59 +00:00
Jenkins
4cd4093bd6 Merge "Force utf-8 encode of HTTPConnection params" 2012-11-16 23:13:09 +00:00
Chmouel Boudjnah
8e63b53a9b Remove unused json_request.
- This has been long delegated to python-keystoneclient for auth 2.0.

Change-Id: I92b1fc2db68192cfeefd623c59882f65a4e4405c
2012-11-16 14:47:27 +10:00
Alessandro Pilotti
7253133837 Fixes setup compatibility issue on Windows
Fixes Bug #1052161

"python setup.py build" fails on Windows due to a hardcoded shell path:
/bin/sh

setup.py updated using openstack-common/update.py

Change-Id: I763dd5613d91a2523087173b196500648c477fa6
2012-11-06 20:08:11 +02:00
Tihomir Trifonov
8b42f8a40c Force utf-8 encode of HTTPConnection params
This patch forces swiftclient to encode to utf-8
all url and headers arguments, to avoid the
UnicodeDecodeError which is raised by '\r\n'.join([])
invoked in htplib.py.

Currently the affected projects are Horizon(upload file
with unicode name) and swiftclient CLI('swift post' with
unicode filename as header)

This is also a follow-up of this review:
    https://review.openstack.org/#/c/14216/

I'd still want to hear what the Swift core devs
think of it. Is it better to create a new
AutoEncodingHTTPConnection? Or to handle the connection
creation and make sure there are no unicode and utf-8
string at the same time. If these unicode checks have to
be added in the calling code(Dashboard, CLI), there are
so many places to be added, and also in all new commands
that might be exposed from the API.

Fixes bug 1008940

Change-Id: Ice2aa29024429d3e6f569a88d5cf8b4202537827
2012-11-02 21:33:32 +02:00
Steven Hardy
656b80bef3 swiftclient Connection : default optional arguments to None
Default the authurl/user/key constructor arguments for the
Connection class to None, as these are not required in the
preauthurl/preauthtoken case

Change-Id: I445a5d365212c365ecc691c0a670a226e2b7954a
2012-10-24 22:40:31 +01:00
Jenkins
57dfd21e1b Merge "Resolves issue with empty os_options for swift-bench & swift-dispersion-report" 2012-09-21 23:31:07 +00:00
Andy McCrae
fe7c535db3 Resolves issue with empty os_options for swift-bench & swift-dispersion-report
Fixes Bug 1044204

Change-Id: I5f0863776bc4e2953548bc7a3958141378a032a0
2012-09-20 10:05:03 +00:00
Donagh McCabe
3265ad5241 Catch authorization failures
Catch the most common authorization exceptions.

Fixes bug 1048560

Change-Id: I81c562d6093e94e827e6583dcb31db8408980476
2012-09-18 09:25:42 +01:00
Mark Washenberger
9b3c4f847d Do not use dictionaries as default parameters
Change-Id: I1e2b7065a7cfad2511fbcee669f666257ef291d0
2012-09-13 05:36:38 +00:00
Donagh McCabe
68d1550f15 Add region_name support
Add --os-region-name (and OS_REGION_NAME env) to bin/swift
Add region_name to the os_options in Connection class.

bug 1019832

Change-Id: Id8515d97e5351638dce10581c7368f61518e1fa7
2012-09-11 09:26:12 +01:00
David Kranz
4b4fbf0dc0 Allow endpoint type to be specified.
Fixes bug 1037690.

Change-Id: I36b3807b2f3234c778316f1e743d27304755aed8
2012-09-04 12:53:18 -04:00
Sam Morrison
29c3af811c Ensure Content-Length header when PUT/POST a container
Fixes bug #951155

Change-Id: Ib1455ddb142137cc0946d50a66540eae6402f598
2012-08-15 15:02:49 +10:00
Jenkins
1f6096e063 Merge "Use keystoneclient for authentication." 2012-08-02 17:42:40 +00:00
Clark Boylan
7618feaeb1 Consume version info from pkg_resources.
Documenation builds specify a version in doc/source/conf.py that is
used in appropriate places through out the documentation. Previously
this value had not been defined properly and documentation builds
failed. Retrieve the version info using pkg_resources and set it
properly.

Use openstack.common.version to consume the generated version information
for documentation. Additional, add a swiftclient.__version__ member which
will return the version of swiftclient being used.

Change-Id: I14f3abdf00da3f9ea7d0651efe76b08f69ddabae
2012-07-11 12:26:14 -05:00
Chmouel Boudjnah
c8163f4112 Use keystoneclient for authentication.
- This allows us to delegate all 2.0 authentication directly to the
  library without reimplementing ourselves.
- Support reusing a token / storage-url without re-authenticating every
  time via the switch os_storage_url os_auth_token.
- Allow auth via tenant_id instead of just tenant_name via the switch
  os_tenant_id.
- Refactor a bit to make it easier in the future to add new OS features
  (i.e: region).
- Implements blueprint use-keystoneclient-for-swiftclient.
- Fixes bug 1016641.

Change-Id: I532f38a68af884de25326aaac05a2050f5ffa1c7
2012-07-06 18:40:45 +00:00
Jenkins
a325aad8a4 Merge "Add post-tag versioning." 2012-07-01 17:57:03 +00:00
Chmouel Boudjnah
2bcfe0b4c8 Allow specify tenant:user in user.
We allow having the syntax tenant:user in user since this would make
things easier when switching from auth 1.0 to auth 2.0 and not having to
specify a tenant_name.

In the feature we should use the auth functions from keystoneclient and
be done with those changes, we could then auth by user/tenant-ID.

Change-Id: Ie49748105a678fb9369494e77d41d934d57a39a7
2012-06-27 19:19:37 +00:00
Monty Taylor
51bceabd18 Add post-tag versioning.
Change-Id: Id921105dd2fa818cac7c66dc620b266fd5639d72
2012-06-26 21:23:25 -05:00
Samuel Merritt
c82773d3d1 Fix pep8 errors w/pep8==1.3.
Also lock down the version of pep8 in
tools/test-requires. python-swiftclient had a passing test suite
yesterday, but today a new and stricter version of pep8 came out, and
the test suite started to fail. Specifying a particular version of
pep8 will prevent that.

Change-Id: I9092d2225c01b99158229918c86b185cdac9d362
2012-06-15 12:18:08 -07:00
Chmouel Boudjnah
dec11f6ec9 Add doc and version in swiftclient.__init__.py
- Add parseable version in swiftclient.__init.py
- Generate rst doc like done for swift.

Change-Id: I408fbc36693772d2ef6f4823757dd1f4c830193f
2012-06-07 12:06:28 +02:00
Dan Prince
b13823ef18 Raise ClientException for invalid auth version.
- Fixes LP Bug #1008667.
- Fix a pep8 error along the way to pass jenkins.
- Update openstack.swift.common to get jenkins passing for 1.2 pep8
  error.

Change-Id: I4ce86a94e1c799807a2ad8e7e1c502b1eb8a51c7
2012-06-06 19:07:08 +02:00
Monty Taylor
7df012329f Add openstack project infrastructure. 2012-05-16 17:30:46 -04:00
Chmouel Boudjnah
a42892c1f9 Add logging.
- If SWIFTCLIENT_DEBUG env is defined then print the full query with curl.
2012-05-09 15:50:17 +01:00