diff --git a/conf/default.cfg b/conf/default.cfg index 0458b358..f649bce9 100644 --- a/conf/default.cfg +++ b/conf/default.cfg @@ -76,6 +76,10 @@ use = egg:oioswift#main allow_account_management = true account_autocreate = true +# Manage if container should be created if nonexisting +# It must be true if hashedcontainer, regexcontainer, autocontainer or container_hierarchy middleware is used +sds_autocreate = true + [filter:hashedcontainer] use = egg:oioswift#hashedcontainer diff --git a/oioswift/proxy/controllers/obj.py b/oioswift/proxy/controllers/obj.py index 9cc6028d..df97656c 100644 --- a/oioswift/proxy/controllers/obj.py +++ b/oioswift/proxy/controllers/obj.py @@ -427,6 +427,8 @@ def _link_object(self, req): return HTTPUnprocessableEntity(request=req) except (exceptions.ServiceBusy, exceptions.OioTimeout): raise + except (exceptions.NoSuchContainer, exceptions.NotFound): + raise HTTPNotFound(request=req) except exceptions.ClientException as err: # 481 = CODE_POLICY_NOT_SATISFIABLE if err.status == 481: @@ -496,6 +498,8 @@ def _store_object(self, req, data_source, headers): return HTTPUnprocessableEntity(request=req) except (exceptions.ServiceBusy, exceptions.OioTimeout): raise + except (exceptions.NoSuchContainer, exceptions.NotFound): + raise HTTPNotFound(request=req) except exceptions.ClientException as err: # 481 = CODE_POLICY_NOT_SATISFIABLE if err.status == 481: diff --git a/oioswift/server.py b/oioswift/server.py index e7d64a48..159d4889 100644 --- a/oioswift/server.py +++ b/oioswift/server.py @@ -21,6 +21,7 @@ from oioswift.proxy.controllers.obj import ObjectControllerRouter from oio import ObjectStorageApi from swift.proxy.server import Application as SwiftApplication +from swift.common.utils import config_true_value import swift.common.utils import swift.proxy.server @@ -80,6 +81,16 @@ def __init__(self, conf, memcache=None, logger=None, account_ring=None, sds_conf.pop('namespace') # removed to avoid unpacking conflict # Loaded by ObjectStorageApi if None sds_proxy_url = sds_conf.pop('proxy_url', None) + # Fix boolean parameter + if 'autocreate' in sds_conf and not ( + hasattr(ObjectStorageApi, 'EXTRA_KEYWORDS') or + 'autocreate' in ObjectStorageApi.EXTRA_KEYWORDS): + logger.error('autocreate parameter is not available with current ' + 'OpenIO SDS') + else: + sds_conf['autocreate'] = config_true_value( + sds_conf.get('autocreate', 'true')) + self.storage = storage or \ ObjectStorageApi(sds_namespace, endpoint=sds_proxy_url, **sds_conf)