def block_connection_factory(url):
if url.startswith('s3:'):
try:
from parsec.core.block_s3 import S3BlockConnection
_, region, bucket, key_id, key_secret = url.split(':')
except ImportError as exc:
raise SystemExit('Parsec needs boto3 to support S3 block storage (error: %s).' %
exc)
except ValueError:
raise SystemExit('Invalid s3 block store '
' (should be `s3:<region>:<bucket>:<id>:<secret>`.')
return S3BlockConnection(region, bucket, key_id, key_secret)
elif url.startswith('http://'):
return RESTBlockConnection(url)
else:
raise SystemExit('Unknown block store `%s`.' % url)
评论列表
文章目录