summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Bodley <cbodley@users.noreply.github.com>2025-01-15 20:25:40 +0100
committerGitHub <noreply@github.com>2025-01-15 20:25:40 +0100
commit2f3c292e213f3544a455fc2df107759437fbb5fe (patch)
treefdea4ba4867d12573c2fa5d7c7053f7d04eaf68a
parentMerge pull request #61211 from yuvalif/wip-yuval-logging-tenant (diff)
parentexamples/rgw: register boto extension for HeadBucket stats (diff)
downloadceph-2f3c292e213f3544a455fc2df107759437fbb5fe.tar.xz
ceph-2f3c292e213f3544a455fc2df107759437fbb5fe.zip
Merge pull request #60847 from cbodley/wip-rgw-boto-headbucket-stats
examples/rgw: register boto extension for HeadBucket stats Reviewed-by: Seena Fallah <seenafallah@gmail.com>
-rwxr-xr-xexamples/rgw/boto3/head_bucket_stats.py27
-rw-r--r--examples/rgw/boto3/service-2.sdk-extras.json31
2 files changed, 57 insertions, 1 deletions
diff --git a/examples/rgw/boto3/head_bucket_stats.py b/examples/rgw/boto3/head_bucket_stats.py
new file mode 100755
index 00000000000..1de40d63f4a
--- /dev/null
+++ b/examples/rgw/boto3/head_bucket_stats.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import boto3
+import sys
+
+if len(sys.argv) != 2:
+ print('Usage: ' + sys.argv[0] + ' <bucket>')
+ sys.exit(1)
+
+# bucket name as first argument
+bucketname = sys.argv[1]
+
+# endpoint and keys from vstart
+endpoint = 'http://127.0.0.1:8000'
+access_key='0555b35654ad1656d804'
+secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
+
+client = boto3.client('s3',
+ endpoint_url=endpoint,
+ aws_access_key_id=access_key,
+ aws_secret_access_key=secret_key)
+
+# reading bucket stats via HeadBucket
+
+response = client.head_bucket(Bucket=bucketname, ReadStats=True)
+
+print('Objects:', response['ObjectCount'], 'Bytes:', response['BytesUsed'])
diff --git a/examples/rgw/boto3/service-2.sdk-extras.json b/examples/rgw/boto3/service-2.sdk-extras.json
index b81667ecd09..4618543d61b 100644
--- a/examples/rgw/boto3/service-2.sdk-extras.json
+++ b/examples/rgw/boto3/service-2.sdk-extras.json
@@ -379,7 +379,36 @@
},
"documentation":"<p>A filter for all log object. Filter for the object by its key (prefix, suffix and regex).</p>",
"locationName":"Filter"
- }
+ },
+ "HeadBucketRequest": {
+ "members": {
+ "ReadStats":{
+ "shape":"ReadStats",
+ "documentation":"<p>Read additional usage statistics for <code>ObjectCount</code> and <code>BytesUsed</code> in the response.</p> <note> <p>This request parameter is a Ceph RGW extension.</p> </note>",
+ "location":"querystring",
+ "locationName":"read-stats"
+ }
+ }
+ },
+ "HeadBucketOutput":{
+ "members":{
+ "ObjectCount":{
+ "shape":"ObjectCount",
+ "documentation": "<p>Total number of objects/versions in the bucket.</p>",
+ "location": "header",
+ "locationName": "x-rgw-object-count"
+ },
+ "BytesUsed":{
+ "shape":"BytesUsed",
+ "documentation": "<p>Total size in bytes of all objects/versions in the bucket.</p>",
+ "location": "header",
+ "locationName": "x-rgw-bytes-used"
+ }
+ }
+ },
+ "ReadStats":{"type":"boolean"},
+ "ObjectCount":{"type":"integer"},
+ "BytesUsed":{"type":"integer"}
},
"documentation":"<p/>"
}