Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasabi Hot Cloud Storage auto get url #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ You need to specify a YAML config file such as following: ::
aws_access_key_id: mykey # Drivers params
aws_secret_access_key: mysecrect
endpoint_url: https://sos-ch-dk-2.exo.io

my_wasabi:
driver: wasabi
aws_access_key_id: <access_key>
aws_secret_access_key: <secret_key>
region_name: <region_name>

In command line, ``--config-file`` and ``--config-raw`` can be used to make the
choice, else ``~/.osb.yml``, then ``/etc/osb.yml`` will be used.
Expand Down
15 changes: 14 additions & 1 deletion docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@ Drivers configuration are stored as a YAML file containing one or several profil
aws_secret_access_key: MySecret
endpoint_url: https://sos-ch-vie-1.exo.io

This file provides two profiles for an Exoscale benchmark, on in DK-2 and the other one in CH-VIE-1.
my_wasabi_east:
driver: wasabi
aws_access_key_id: <access_key>
aws_secret_access_key: <secret_key>
region_name: us-east-1

my_wasabi_west:
driver: wasabi
aws_access_key_id: <access_key>
aws_secret_access_key: <secret_key>
region_name: us-west-1

This file provides two profiles for an Exoscale benchmark, on in DK-2 and the other one in CH-VIE-1
as well as two profiles for Wasabi Hot Cloud Storage, one on the East Coast, USA, and the other on the West Coast, USA.

File choice
-----------
Expand Down
34 changes: 23 additions & 11 deletions os_benchmark/drivers/wasabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,42 @@
driver: wasabi
aws_access_key_id: <your_ak>
aws_secret_access_key: <your_sk>
region_name: <your_region>

Possible region IDs are the following:
Possible region IDs available at the following urls:

- ``us-east-1``: US East 1 (N. Virginia)
- ``us-east-2``: US East 2 (N. Virginia)
- ``us-west-1``: US West 1 (Oregon)
- ``eu-central-1``: EU Central 1 (Amsterdam)
- https://s3.wasabisys.com/?describeRegions
- https://wasabi-support.zendesk.com/hc/en-us/articles/360015106031

.. _boto3: https://github.com/boto/boto3
"""
import xml.dom.minidom
from urllib.parse import urljoin

import urllib3.exceptions

from os_benchmark.drivers import s3


class Driver(s3.Driver):
"""Wasabi S3 Driver"""
id = 'wasabi'
describe_regions_url = 'https://s3.wasabisys.com/?describeRegions'
endpoint_url = 'https://s3.wasabisys.com'
endpoint_urls = {
'us-east-1': 'https://s3.us-east-1.wasabisys.com',
'us-east-2': 'https://s3.us-east-2.wasabisys.com',
'us-west-1': 'https://s3.us-west-1.wasabisys.com',
'eu-central-1': 'https://s3.eu-central-1.wasabisys.com',
}
endpoint_urls = {}

try:
http = urllib3.PoolManager()
r = http.request('GET', describe_regions_url)
doc = xml.dom.minidom.parseString(r.data)
for item in doc.getElementsByTagName('item'):
region = item.getElementsByTagName('Region')[0].firstChild.data
endpoint = item.getElementsByTagName('Endpoint')[0].firstChild.data
endpoint_urls[region] = "https://%s" % endpoint
except xml.parsers.expat.ExpatError as err:
raise Exception("Unable parse Wasabi describeRegions XML payload.")
except urllib3.exceptions.HTTPError as err:
raise Exception("Unable connect to %s and verify Wasabi Regions." % describe_regions_url)

default_kwargs = {
'endpoint_url': endpoint_url,
Expand Down