141 Commits

Author SHA1 Message Date
Clay Gerrard
936631eac6 Optionally display listings in raw json
Symlinks have recently added some new keys to container listings.  It's
very convenient to be able to see and reason about the extra information
in container listings.

Allowing raw json output is similar with what the client already does
for the info command, and it's forward compatible with any listing
enhancements added by future middleware development.

Change-Id: I88fb38529342ac4e4198aeccd2f10c69c7396704
2019-07-09 13:25:52 -07:00
Zuul
4b3e33b3c2 Merge "Clean up warnings from newer flake8" 2019-06-28 08:13:46 +00:00
Tim Burke
9021a58c24 Fix SLO re-upload
Previously, if you uploaded a file as an SLO then re-uploaded it
with the same segment size and mtime, the second upload would
go delete the segments it just (re)uploaded. This was due to
us tracking old_slo_manifest_paths and new_slo_manifest_paths
in different formats; one would have a leading slash while the
other would not.

Now, normalize to the stripped-slash version so we stop deleting
segments we just uploaded.

Change-Id: Ibcbed3df4febe81cdf13855656e2daaca8d521b4
2019-06-27 21:45:10 -07:00
Tim Burke
3b21157a84 Clean up warnings from newer flake8
Change-Id: I18a6327b3acdd4db5ae80097080c043f7c20c353
2019-06-27 21:43:46 -07:00
ZhijunWei
2ff36fde57 Update hacking version
1. update hacking version to latest
2. fix pep8 failed

Change-Id: Ifc3bfeff4038c93d8c8cf2c9d7814c3003e73504
2019-01-03 13:09:22 +08:00
Tim Burke
d1e1f8d8d6 Stop lazy importing keystoneclient
There were two basic problems:

  - We'd try to import on every attempt at getting auth, even when we
    already know keystoneclient isn't available.
  - Sometimes devs would hit some crazy import race involving (some
    combination of?) greenthreads and OS threads.

So let's just try the imports *once*, at import time, and have None
sentinels if it fails. Try both versions separately to decouple
failures; this should let us support a wider range of keystoneclient
versions.

Change-Id: I2367310aac74f1b7c5ea0cb1a822a491e4ba8e68
2018-09-07 16:56:13 -07:00
Zuul
d80f24f2fd Merge "Back out some version bumps" 2018-07-24 23:12:51 +00:00
Tim Burke
da362a653e Back out some version bumps
I'm giving up on trying to back out all of the test-requirements
up-revs, but let's try to stay compatibile with old requests/six.

As part of that, only disable some requests warnings on new-enough requests.

Note that we should now be compatible with distro packages back to
Ubuntu 16.04 and CentOS 6. Our six is still too new for Trusty, but
hey, there's less than a year left on that anyway, right?

Change-Id: Iccb23638393616f9ec3da660dd5e39ea4ea94220
Related-Change: I2a8f465c8b08370517cbec857933b08fca94ca38
2018-07-11 13:09:00 -07:00
mmcardle
47fb18c41b Add ability to generate a temporary URL with an
IP range restriction

Change-Id: I4734599886e4f4a563162390d0ff3bb1ef639db4
2018-07-10 15:23:30 +01:00
Alistair Coles
33ad9fd4cc Add option for user to enter password
Add the --prompt option for the CLI which will cause the user to be
prompted to enter a password. Any password otherwise specified by
--key, --os-password or an environment variable will be ignored.

The swift client will exit with a warning if the password cannot be
entered without its value being echoed.

Closes-Bug: #1357562
Change-Id: I513647eed460007617f129691069c6fb1bfe62d7
2018-06-11 17:25:21 +01:00
Zuul
cde257de5c Merge "Allow --meta on upload" 2017-12-08 19:51:05 +00:00
Timur Alperovich
0982791db2 Allow for uploads from standard input.
If "-" is passed in for the source, python-swiftclient will upload
the object by reading the contents of the standard input. The object
name option must be set, as well, and this cannot be used in
conjunction with other files.

This approach stores the entire contents as one object. A follow on
patch will change this behavior to upload from standard input as SLO,
unless the segment size is larger than the content size.

Change-Id: I1a8be6377de06f702e0f336a5a593408ed49be02
2017-07-26 17:04:19 -07:00
Tim Burke
638d7c789c Buffer reads from disk
Otherwise, Python defaults to 8k reads which seems kinda terrible.

Change-Id: I3160626e947083af487fd1c3cb0aa6a62646527b
Closes-Bug: #1671621
2017-07-11 17:04:49 -07:00
Tim Burke
484d7ee9b2 Allow --meta on upload
Previously, the --meta option was only allowed on post or copy subcommands.

Change-Id: I87bf0338c34b5e89aa946505bee68dbeb37d784c
Closes-Bug: #1616238
2017-07-06 12:43:11 -07:00
Jenkins
4515002d78 Merge "Stop sending X-Static-Large-Object headers" 2017-06-14 23:35:32 +00:00
Jenkins
6d5e87a183 Merge "ISO 8601 timestamps for tempurl" 2017-05-18 14:37:17 +00:00
John Dickinson
0cc4d8af18 respect bulk delete page size and fix logic error
Previously, using SwiftService to delete "many" objects would use
bulk delete if available, but it would not respect the bulk delete
page size. If the number of objects to delete exceeded the bulk delete
page size, SwiftService would ignore the error and nothing would be
deleted.

This patch changes _should_bulk_delete() to be _bulk_delete_page_size();
instead of returning a simple True/False, it returns the page size for
the bulk deleter, or 1 if objects should be deleted one at a time.
Delete SDK calls are then spread across multiple bulk DELETEs if the
requested number of objects to delete exceeds the returned page size.

Fixed the logic in _should_bulk_delete() so that if the object list
is exactly 2x the thread count, it will not bulk delete. This is the
natural conclusion following the logic that existed previously: if
the delete request can be satisfied by every worker thread doing one
or two tasks, don't bulk delete. But if it requires a worker thread
to do three or more tasks, do a bulk delete instead. Previously, the
logic would mean that if every worker thread did exactly two tasks, it
would bulk delete. This patch changes a "<" to a "<=".

Closes-Bug: 1679851
Change-Id: I3c18f89bac1170dc62187114ef06dbe721afcc2e
2017-04-20 09:41:53 -07:00
Tim Burke
aaaed55cd4 Stop sending X-Static-Large-Object headers
If we were to include this in a normal PUT, it would 400, but only if
slo is actually in the pipeline. If it's *not*, we'll create a normal
Swift object and the header sticks.

- This is really confusing for users; see the related bug.
- If slo is later enabled in the cluster, Swift starts responding 500
  with a KeyError because the client and on-disk formats don't match!

Change-Id: I1d80c76af02f2ca847123349224ddc36d2a6996b
Related-Change: I986c1656658f874172860469624118cc63bff9bc
Related-Bug: #1680083
2017-04-10 15:40:35 -07:00
Christopher Bartz
8e08931b9f ISO 8601 timestamps for tempurl
Client-side implementation for ISO 8601 timestamp
support of tempurl middleware. Please see

https://review.openstack.org/#/c/422679/

Change-Id: I76da28b48948475ec1bae5258e0b39a316553fb7
2017-03-29 14:27:39 -04:00
Christopher Bartz
3934bd606a prefix-based tempurls support
Implements client-side functionality for
prefix-based tempurls.

Please see: https://review.openstack.org/#/c/274048/

Change-Id: I8d7701daee888ed1120271a96c0660b01543ca2d
2017-01-19 16:34:26 +01:00
Jenkins
39a0eda486 Merge "modify 'swift <sub_command> —help' display" 2016-12-13 23:00:01 +00:00
Shashirekha Gundur
41666d60c8 modify 'swift <sub_command> —help' display
In python swiftclient:  swift <sub_command> —help will now
display st_<sub_command>_options + st_<sub_command>_help texts
e.g. http://paste.openstack.org/show/589752/

Change-Id: I34e4b2ac29ef395f8ca474ce7a82f59a1fd8c7f4
Closes-Bug: #1621415
2016-12-13 13:41:08 +00:00
Jenkins
70c90b2243 Merge "Add additional headers for HEAD/GET/DELETE requests." 2016-11-08 19:30:40 +00:00
Charles Hsu
6cf2bd6626 Add additional headers for HEAD/GET/DELETE requests.
Change-Id: I69276ba711057c122f97deac412e492e313c34dd
Closes-Bug: 1615830
2016-11-07 13:18:29 +08:00
Anh Tran
a71c0d5a30 Replace assertTrue(a in b) with assertIn(a, b)
Change-Id: I9726c9c051eea9264200ab27b3e556c68d5c927f
2016-10-03 09:35:59 +07:00
Jenkins
714bf0cd4b Merge "Fix intermittent test failure" 2016-09-14 20:46:57 +00:00
Alistair Coles
4c955751d3 Make tempurl command check for valid object path
If the supplied path is not of the form /v1/a/c/o then
swift tempurl subcommand will now return an error message.

Also removes redundant check for seconds parameter being an int
from shell.py because the same check is made when calling
utils.generate_temp_url.

Drive-by fix for missing param definition for generate_temp_url.

Change-Id: I41f4389948b01fadaa5fc4939ea12e0ed2167345
Related-Change: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
2016-09-14 16:24:22 +01:00
Christian Schwede
89ff29e788 Make options arguments truely optional
Currently the options help, info and debug must exist in the options
dictionary; however it might be that this is not the case if a method is
imported externally. This patch fixes this.

Also support using a storage URL or path as an argument for tempurl, and
adding a test to verify correct output in both cases.

Related-Bug: 1607519
Related-Bug: 1607523
Closes-Bug: 1607521
Change-Id: I0fb2ce125fe12d660e4deb778265016bdd5ff31b
2016-09-06 07:38:08 +00:00
Tim Burke
209677e6a8 Fix intermittent test failure
The mock needs to be initialized before calling main, or we get a race
to create it between all the uu_threads

Change-Id: If7649da13ed9276d7f0e005e999770e09c022a3f
2016-09-01 11:18:16 -07:00
Jenkins
b57044a853 Merge "Add copy object method" 2016-08-24 23:59:34 +00:00
Marek Kaleta
4a2465fb12 Add copy object method
Implement copy object method in swiftclient Connection, Service and CLI.

Although COPY functionality can be accomplished with 'X-Copy-From'
header in PUT request, using copy is more convenient especially when
using copy for updating object metadata non-destructively.

Closes-Bug: 1474939
Change-Id: I1338ac411f418f4adb3d06753d044a484a7f32a4
2016-08-23 14:37:11 -07:00
Tim Burke
335570e511 Add --json option to swift capabilities / swift info
This lets us do things like:

    $ swift info --json | jq '[.swift.policies[].name]'
    [
      "Standard-Replica",
      "EC"
    ]

Also, escape more dashes in the man page, so they won't be
misinterpreted as hyphens.

Change-Id: Ic7690bdbcfc55f55e5dde9bc11bb0644085973ce
2016-08-02 16:18:44 -07:00
Jenkins
c91c8d575e Merge "Add an option: disable etag check on downloads" 2016-06-06 10:33:25 +00:00
Cheng Li
69bf4634b9 Add an option: disable etag check on downloads
This patch is to add an option of disable etag
check on downloads.

Change-Id: I9ad389dd691942dea6db470ca3f0543eb6e9703e
Closes-bug: #1581147
2016-06-02 22:53:18 +08:00
Tim Burke
ff505d72cd Suppress InsecureRequestWarning when using --insecure
The user already knows this is insecure, there's no point in bringing it
up again and again.

See also: https://github.com/kennethreitz/requests/issues/2214

Change-Id: I7991b2e568407269f84138bc03711147ed080c9c
2016-06-01 18:57:38 -07:00
Jenkins
f9d0657e70 Merge "Support client certificate/key" 2016-05-19 22:20:17 +00:00
Jenkins
3faa99bac1 Merge "Tighten up testing for sloppy auth version" 2016-05-08 22:21:10 +00:00
Alistair Coles
a0d65e4ccd Tighten up testing for sloppy auth version
The existing test that os-identity-api-version=2 would
result in the correct auth_version=2.0 (note 2 -> 2.0)
does not verify the sloppy version handling code path.
When auth, key and user options are all missing the
auth version is always set to 2.0 so the test will always
pass. Adding auth, key and user options to the test command
will cause the test to verify that the os-identity-api-version
option was used and mapped to 2.0.

Change-Id: Ifa10cd2b8bf81c082d5e3fa846f993871194fea0
2016-05-05 15:25:16 +01:00
Tim Burke
67f629cdeb Default to v3 auth if we find a (user|project)-domain-(name|id) option
Change-Id: I4616492752b620de0bf90672142f1071ec9bac83
2016-05-03 14:41:07 -07:00
Tim Burke
c3766319b9 Pull option processing out to service.py
...because it seems silly that we do nearly the same thing in two
different places

Change-Id: Iafafe3c553d00652adb91ceefd0de1479cbcb5da
2016-05-03 14:18:34 -07:00
Tim Burke
5b714f104d Parse options to dict
This is a first step toward unifying the options parsing magic between
shell.py and service.py

Change-Id: If001e07978c0bae729ac0cd9b2c2934092c98447
2016-05-03 14:03:15 -07:00
Jenkins
c26dec66f6 Merge "Add tests for thread option validation" 2016-05-02 21:11:57 +00:00
Cedric Brandily
450f505c35 Support client certificate/key
This change enables to specify a client certificate/key with:
 * usual CLI options (--os-cert/--os-key)
 * usual environment variables ($OS_CERT/$OS_KEY)

Closes-Bug: #1565112
Change-Id: I12e151adcb6084d801c6dfed21d82232a3259aea
2016-04-10 23:20:49 +02:00
Jenkins
015903e383 Merge "Port from optparse to argparse" 2016-04-08 09:36:31 +00:00
Tim Burke
17aa6c789e Port from optparse to argparse
Why now?

* argparse was introduced in Python 3.2 and back-ported to Python 2.7.
  Until we dropped Python 2.6 support, we were stuck on optparse.

* keystoneauth.loading.cli provides register_argparse_arguments and
  load_from_argparse_arguments helper methods. Now that we're moving
  toward Keystone Session support, argparse seems required.

Closes-Bug: 1553030
Change-Id: I5139fb64a8631a3010680090fd04345f95c55c7b
2016-04-06 14:20:27 -07:00
Jenkins
39e017d807 Merge "Initialize delete_object mock *before* creating all the threads" 2016-03-18 10:43:09 +00:00
Tim Burke
d2bd2f0859 Initialize delete_object mock *before* creating all the threads
Previously, we'd occasionally get spurious failures like

    FAIL: test_delete_account (tests.unit.test_shell.TestShell)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File ".../mock/mock.py", line 1721, in _inner
        return f(*args, **kw)
      File ".../mock/mock.py", line 1305, in patched
        return func(*args, **keywargs)
      File ".../tests/unit/test_shell.py", line 788, in test_delete_account
        response_dict={})], any_order=True)
      File ".../mock/mock.py", line 983, in assert_has_calls
        ), cause)
      File ".../six.py", line 718, in raise_from
        raise value
    AssertionError: (call(u'container', u'object', query_string=None,
                          response_dict={}),)
    not all found in call list

Related-Bug: #1539536
Related-Bug: #1480223
Change-Id: I810894545ca74d3b2f2dbde2d0388eb69c2ba710
2016-03-17 15:43:45 -07:00
Jenkins
c4ce65f2d2 Merge "Include response headers in ClientExceptions" 2016-03-17 22:20:35 +00:00
Tim Burke
f5224a696e Add tests for thread option validation
Change-Id: If84714c7ea6be1c95c5898a82db2d4b6c9637242
2016-03-17 12:39:44 -07:00
Min Min Ren
965fd4d3fc Initialise delete_object mock before it's called
Fix the linked bug. delete_object mock should be before it's
called by swiftclient.shell.main function.
Related: https://review.openstack.org/221219

Change-Id: I52143a93c129764c02bba05267f3563c824e82cb
Partial-Bug: #1480223
2016-03-05 03:05:23 +08:00