Test S3 access

You need to write and run a Python test script for verifying S3 access. The S3 access test script will connect to the radosgw, create a new bucket, and list all buckets. The values for aws_access_key_id and aws_secret_access_key are taken from the values of access_key and secret_key returned by the radosgw_admin command.

Prerequisites

  • A running IBM Storage Ceph cluster.

  • Root-level access to the nodes.

Procedure

  1. Enable high availability repository.

  2. Install the python3-boto3 package:

    dnf install python3-boto3
  3. Create the Python script:

    vi s3test.py
  4. Add the following contents to the file:

    Syntax

    import boto3
    
    endpoint = "" # enter the endpoint _URL_ along with the port "http://URL:PORT"
    
    access_key = 'ACCESS'
    secret_key = 'SECRET'
    
    s3 = boto3.client(
            's3',
            endpoint_url=endpoint,
            aws_access_key_id=access_key,
            aws_secret_access_key=secret_key
            )
    
    s3.create_bucket(Bucket='my-new-bucket')
    
    response = s3.list_buckets()
    for bucket in response['Buckets']:
        print("{name}\t{created}".format(
                    name = bucket['Name'],
                    created = bucket['CreationDate']
    ))
    • Replace endpoint with the URL of the host where you have configured the gateway service. That is, the gateway host. Ensure that the host setting resolves with DNS. Replace PORT with the port number of the gateway.

    • Replace ACCESS and SECRET with the access_key and secret_key values

  5. Run the script:

    python3 s3test.py

    The output will be something like the following:

    my-new-bucket 2022-05-31T17:09:10.000Z