@@ -73,7 +73,7 @@ class FilesystemBackend(Backend):
|
||||
except OSError:
|
||||
raise exception.NotAuthorized("You cannot delete file %s" % fn)
|
||||
else:
|
||||
raise exception.NotFound("File %s does not exist" % fn)
|
||||
raise exception.NotFound("File %s does not exist" % fn)
|
||||
|
||||
|
||||
def get_backend_class(backend):
|
||||
|
||||
@@ -114,12 +114,12 @@ class FilesystemBackend(glance.store.Backend):
|
||||
|
||||
:retval The location that was written, with file:// scheme prepended
|
||||
"""
|
||||
|
||||
|
||||
datadir = FLAGS.filesystem_store_datadir
|
||||
|
||||
if not os.path.exists(datadir):
|
||||
os.makedirs(datadir)
|
||||
|
||||
|
||||
filepath = os.path.join(datadir, str(id))
|
||||
|
||||
if os.path.exists(filepath):
|
||||
|
||||
@@ -19,6 +19,7 @@ import httplib
|
||||
|
||||
import glance.store
|
||||
|
||||
|
||||
class HTTPBackend(glance.store.Backend):
|
||||
""" An implementation of the HTTP Backend Adapter """
|
||||
|
||||
@@ -35,11 +36,12 @@ class HTTPBackend(glance.store.Backend):
|
||||
elif parsed_uri.scheme == "https":
|
||||
conn_class = httplib.HTTPSConnection
|
||||
else:
|
||||
raise glance.store.BackendException("scheme '%s' not supported for HTTPBackend")
|
||||
|
||||
raise glance.store.BackendException(
|
||||
"scheme '%s' not supported for HTTPBackend")
|
||||
|
||||
conn = conn_class(parsed_uri.netloc)
|
||||
conn.request("GET", parsed_uri.path, "", {})
|
||||
|
||||
|
||||
try:
|
||||
return glance.store._file_iter(conn.getresponse(), cls.CHUNKSIZE)
|
||||
finally:
|
||||
|
||||
@@ -29,14 +29,14 @@ class SwiftBackend(glance.store.Backend):
|
||||
@classmethod
|
||||
def get(cls, parsed_uri, expected_size, conn_class=None):
|
||||
"""
|
||||
Takes a parsed_uri in the format of:
|
||||
swift://user:password@auth_url/container/file.gz.0, connects to the
|
||||
swift instance at auth_url and downloads the file. Returns the generator
|
||||
resp_body provided by get_object.
|
||||
Takes a parsed_uri in the format of:
|
||||
swift://user:password@auth_url/container/file.gz.0, connects to the
|
||||
swift instance at auth_url and downloads the file. Returns the
|
||||
generator resp_body provided by get_object.
|
||||
"""
|
||||
(user, key, authurl, container, obj) = \
|
||||
cls._parse_swift_tokens(parsed_uri)
|
||||
|
||||
|
||||
# TODO(sirp): snet=False for now, however, if the instance of
|
||||
# swift we're talking to is within our same region, we should set
|
||||
# snet=True
|
||||
@@ -50,9 +50,10 @@ class SwiftBackend(glance.store.Backend):
|
||||
|
||||
obj_size = int(resp_headers['content-length'])
|
||||
if obj_size != expected_size:
|
||||
raise glance.store.BackendException("Expected %s byte file, Swift has %s bytes"
|
||||
% (expected_size, obj_size))
|
||||
|
||||
raise glance.store.BackendException(
|
||||
"Expected %s byte file, Swift has %s bytes" %
|
||||
(expected_size, obj_size))
|
||||
|
||||
return resp_body
|
||||
|
||||
@classmethod
|
||||
@@ -62,7 +63,7 @@ class SwiftBackend(glance.store.Backend):
|
||||
"""
|
||||
(user, key, authurl, container, obj) = \
|
||||
cls._parse_swift_tokens(parsed_uri)
|
||||
|
||||
|
||||
# TODO(sirp): snet=False for now, however, if the instance of
|
||||
# swift we're talking to is within our same region, we should set
|
||||
# snet=True
|
||||
@@ -76,7 +77,7 @@ class SwiftBackend(glance.store.Backend):
|
||||
|
||||
# TODO(jaypipes): What to return here? After reading the docs
|
||||
# at swift.common.client, I'm not sure what to check for...
|
||||
|
||||
|
||||
@classmethod
|
||||
def _parse_swift_tokens(cls, parsed_uri):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user