Skip to content

Commit 2f3c292

Browse files
authored
Merge pull request ceph#60847 from cbodley/wip-rgw-boto-headbucket-stats
examples/rgw: register boto extension for HeadBucket stats Reviewed-by: Seena Fallah <[email protected]>
2 parents 6f7f22b + 0f55c17 commit 2f3c292

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/python
2+
3+
import boto3
4+
import sys
5+
6+
if len(sys.argv) != 2:
7+
print('Usage: ' + sys.argv[0] + ' <bucket>')
8+
sys.exit(1)
9+
10+
# bucket name as first argument
11+
bucketname = sys.argv[1]
12+
13+
# endpoint and keys from vstart
14+
endpoint = 'http://127.0.0.1:8000'
15+
access_key='0555b35654ad1656d804'
16+
secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
17+
18+
client = boto3.client('s3',
19+
endpoint_url=endpoint,
20+
aws_access_key_id=access_key,
21+
aws_secret_access_key=secret_key)
22+
23+
# reading bucket stats via HeadBucket
24+
25+
response = client.head_bucket(Bucket=bucketname, ReadStats=True)
26+
27+
print('Objects:', response['ObjectCount'], 'Bytes:', response['BytesUsed'])

examples/rgw/boto3/service-2.sdk-extras.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,36 @@
379379
},
380380
"documentation":"<p>A filter for all log object. Filter for the object by its key (prefix, suffix and regex).</p>",
381381
"locationName":"Filter"
382-
}
382+
},
383+
"HeadBucketRequest": {
384+
"members": {
385+
"ReadStats":{
386+
"shape":"ReadStats",
387+
"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>",
388+
"location":"querystring",
389+
"locationName":"read-stats"
390+
}
391+
}
392+
},
393+
"HeadBucketOutput":{
394+
"members":{
395+
"ObjectCount":{
396+
"shape":"ObjectCount",
397+
"documentation": "<p>Total number of objects/versions in the bucket.</p>",
398+
"location": "header",
399+
"locationName": "x-rgw-object-count"
400+
},
401+
"BytesUsed":{
402+
"shape":"BytesUsed",
403+
"documentation": "<p>Total size in bytes of all objects/versions in the bucket.</p>",
404+
"location": "header",
405+
"locationName": "x-rgw-bytes-used"
406+
}
407+
}
408+
},
409+
"ReadStats":{"type":"boolean"},
410+
"ObjectCount":{"type":"integer"},
411+
"BytesUsed":{"type":"integer"}
383412
},
384413
"documentation":"<p/>"
385414
}

0 commit comments

Comments
 (0)