Skip to content

Instantly share code, notes, and snippets.

@naototty
Last active March 16, 2017 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naototty/8f40a53f82e130f1a1f4 to your computer and use it in GitHub Desktop.
Save naototty/8f40a53f82e130f1a1f4 to your computer and use it in GitHub Desktop.
ConoHaのVMでUbuntu 14.04を使ってs3qlでSwift Object Storageをマウントする ref: http://qiita.com/naoto_gohko/items/e8b662ae9e19fc1c859a
'''
backends/__init__.py - this file is part of S3QL.
Copyright © 2008 Nikolaus Rath <Nikolaus@rath.org>
This work can be distributed under the terms of the GNU GPLv3.
'''
from . import local, s3, gs, s3c, swift, rackspace, swiftks, conohaswift
#: Mapping from storage URL prefixes to backend classes
prefix_map = { 's3': s3.Backend,
'local': local.Backend,
'gs': gs.Backend,
's3c': s3c.Backend,
'swift': swift.Backend,
'conohaswift': conohaswift.Backend,
'swiftks': swiftks.Backend,
'rackspace': rackspace.Backend }
__all__ = [ 'common', 'pool', 'comprenc' ] + list(prefix_map.keys())
'''
conohaswift.py - this file is part of S3QL.
Copyright © 215 n-gohko
This work can be distributed under the terms of the GNU GPLv3.
'''
from ..logging import logging, QuietError # Ensure use of custom logger class
from . import swiftks
from ..inherit_docstrings import copy_ancestor_docstring
import re
log = logging.getLogger(__name__)
class Backend(swiftks.Backend):
"""A backend to store data in ConoHa swift Object Storage"""
@copy_ancestor_docstring
def _parse_storage_url(self, storage_url, ssl_context):
hit = re.match(r'^conohaswift://' # Backend
r'([^/:]+)' # Region
r'/([^/]+)' # Bucketname
r'(?:/(.*))?$', # Prefix
storage_url)
if not hit:
raise QuietError('Invalid storage URL', exitcode=2)
region = hit.group(1)
containername = hit.group(2)
prefix = hit.group(3) or ''
if ssl_context:
port = 443
else:
port = 80
port = 443
self.hostname = 'identity.tyo1.conoha.io'
self.port = port
self.container_name = containername
self.prefix = prefix
self.region = region
[n-gohko@163-44-112-214] $ swift list --lh s3ql_pool 2>/dev/null | grep '_data_' | head -n 3
116 2015-12-13 12:55:30 s3ql_data_1
746K 2015-12-13 12:55:35 s3ql_data_10
79K 2015-12-13 12:56:36 s3ql_data_100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment