⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
rgw
All Projects
Ceph
»
rgw
Overview
Activity
Roadmap
Issues
Spent time
Gantt
Download (941 Bytes)
Bug #19587
ยป rgw-lifecycle-repro.py
Ben Hines
, 04/12/2017 05:07 AM
#!/usr/bin/python
import
boto3
import
botocore
access_key
=
'
<accesskey>
'
secret_key
=
'
<secretkey>
'
bucket
=
'
<bucketname>
'
hostname
=
'
<rgwurl>
'
endpoint_url
=
'
http://{}:{}
'
.
format
(
hostname
,
80
)
config
=
botocore
.
client
.
Config
(
s3
=
{
'
addressing_style
'
:
'
path
'
,
'
signature_version
'
:
'
s3
'
})
session
=
boto3
.
session
.
Session
(
aws_access_key_id
=
access_key
,
aws_secret_access_key
=
secret_key
)
client
=
session
.
client
(
'
s3
'
,
endpoint_url
=
endpoint_url
,
config
=
config
)
s3
=
session
.
resource
(
'
s3
'
,
endpoint_url
=
endpoint_url
,
config
=
config
)
bucket_lifecycle
=
s3
.
BucketLifecycle
(
bucket
)
print
(
bucket_lifecycle
)
response
=
client
.
put_bucket_lifecycle_configuration
(
Bucket
=
bucket
,
LifecycleConfiguration
=
{
'
Rules
'
:
[
{
#'Prefix': '',
'
Expiration
'
:
{
'
Days
'
:
1
,
},
'
ID
'
:
'
0
'
,
'
Status
'
:
'
Enabled
'
,
},
]
}
)
print
response
(1-1/1)
Loading...