diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-09-25 19:10:31 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-09-25 19:10:31 +0000 |
commit | d721871cfaf9cf9ea986cb59eaeddd90e14f4d2a (patch) | |
tree | d8e5aa5ec46811e0dd045820ca740f11a8447aed | |
parent | f90d7f28e504be045e59b395aee0abc057417f8f (diff) | |
parent | 40857cfe4c848e3c6bb19a4f0b3987c87d7810b9 (diff) | |
download | python-swiftclient-d721871cfaf9cf9ea986cb59eaeddd90e14f4d2a.tar.gz |
Merge "Add per policy container count to account stat output"
-rw-r--r-- | swiftclient/command_helpers.py | 8 | ||||
-rw-r--r-- | tests/unit/test_command_helpers.py | 26 |
2 files changed, 34 insertions, 0 deletions
diff --git a/swiftclient/command_helpers.py b/swiftclient/command_helpers.py index 9a78b9b..0822699 100644 --- a/swiftclient/command_helpers.py +++ b/swiftclient/command_helpers.py @@ -45,6 +45,14 @@ def stat_account(conn, options): policies.add(policy_name) for policy in policies: + container_count_header = (POLICY_HEADER_PREFIX + policy + + '-container-count') + if container_count_header in headers: + items.append( + ('Containers in policy "' + policy + '"', + prt_bytes(headers[container_count_header], + options['human']).lstrip()) + ) items.extend(( ('Objects in policy "' + policy + '"', prt_bytes( diff --git a/tests/unit/test_command_helpers.py b/tests/unit/test_command_helpers.py index ad8012e..67e9ac2 100644 --- a/tests/unit/test_command_helpers.py +++ b/tests/unit/test_command_helpers.py @@ -124,6 +124,32 @@ Objects in policy "nada": 1000000 """ self.assertOut(expected) + def test_stat_account_policy_stat_with_container_counts(self): + # stub head_account + stub_headers = { + 'x-account-container-count': 42, + 'x-account-object-count': 1000000, + 'x-account-bytes-used': 2 ** 30, + 'x-account-storage-policy-nada-container-count': 10, + 'x-account-storage-policy-nada-object-count': 1000000, + 'x-account-storage-policy-nada-bytes-used': 2 ** 30, + } + self.conn.head_account.return_value = stub_headers + + with self.output_manager as output_manager: + items, headers = h.stat_account(self.conn, self.options) + h.print_account_stats(items, headers, output_manager) + expected = """ + Account: a + Containers: 42 + Objects: 1000000 + Bytes: 1073741824 +Containers in policy "nada": 10 + Objects in policy "nada": 1000000 + Bytes in policy "nada": 1073741824 +""" + self.assertOut(expected) + def test_stat_container_human(self): self.options['human'] = True # stub head container request |