def DELETE_RECYCLE(self, req): try: device, partition, account, src_container, src_obj = split_path( unquote(req.path), 4, 5, True) validate_device_partition(device, partition) except ValueError, err: return jresponse('-1', 'bad request', req,400)
def DELETE_RECYCLE(self, req): try: drive, part, account, src_container, src_direr = split_path( unquote(req.path), 4, 5, True) validate_device_partition(drive, part) except ValueError, err: return jresponse('-1', str(err), req,400)
def GET(self, req): try: drive, part, account, container, direr = split_path( unquote(req.path), 4, 5, True) validate_device_partition(drive, part) except ValueError, err: return jresponse('-1', 'bad request', req,400)
def POST(self, req): """Handle HTTP POST request.""" try: drive, part, account, container = split_path(unquote(req.path), 4) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type="text/plain", request=req)
def DELETE(self, request): """Handle HTTP DELETE requests for the Swift Object Server.""" try: device, partition, account, container, obj = split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, e: return HTTPBadRequest(body=str(e), request=request, content_type="text/plain")
def initialize_request(self): """ Basic validation of request and mount check. This function will be called before attempting to acquire a replication semaphore lock, so contains only quick checks. """ # This environ override has been supported since eventlet 0.14: # https://bitbucket.org/eventlet/eventlet/commits/ \ # 4bd654205a4217970a57a7c4802fed7ff2c8b770 self.request.environ['eventlet.minimum_write_chunk_size'] = 0 self.device, self.partition, self.policy = \ request_helpers.get_name_and_placement(self.request, 2, 2, False) self.frag_index = self.node_index = None if self.request.headers.get('X-Backend-Ssync-Frag-Index'): self.frag_index = int( self.request.headers['X-Backend-Ssync-Frag-Index']) if self.request.headers.get('X-Backend-Ssync-Node-Index'): self.node_index = int( self.request.headers['X-Backend-Ssync-Node-Index']) if self.node_index != self.frag_index: # a primary node should only receive it's own fragments raise swob.HTTPBadRequest( 'Frag-Index (%s) != Node-Index (%s)' % (self.frag_index, self.node_index)) utils.validate_device_partition(self.device, self.partition) self.diskfile_mgr = self.app._diskfile_router[self.policy] if not self.diskfile_mgr.get_dev_path(self.device): raise swob.HTTPInsufficientStorage(drive=self.device) self.fp = self.request.environ['wsgi.input']
def GET(self, req): """Handle HTTP GET request.""" try: drive, part, account, container, obj = req.split_path(4, 5, True) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type="text/plain", request=req)
def initialize_request(self): """ Basic validation of request and mount check. This function will be called before attempting to acquire a replication semaphore lock, so contains only quick checks. """ # This environ override has been supported since eventlet 0.14: # https://bitbucket.org/eventlet/eventlet/commits/ \ # 4bd654205a4217970a57a7c4802fed7ff2c8b770 self.request.environ['eventlet.minimum_write_chunk_size'] = 0 self.device, self.partition, self.policy = \ request_helpers.get_name_and_placement(self.request, 2, 2, False) self.frag_index = self.node_index = None if self.request.headers.get('X-Backend-Ssync-Frag-Index'): self.frag_index = int( self.request.headers['X-Backend-Ssync-Frag-Index']) if self.request.headers.get('X-Backend-Ssync-Node-Index'): self.node_index = int( self.request.headers['X-Backend-Ssync-Node-Index']) if self.node_index != self.frag_index: # a primary node should only recieve it's own fragments raise swob.HTTPBadRequest( 'Frag-Index (%s) != Node-Index (%s)' % ( self.frag_index, self.node_index)) utils.validate_device_partition(self.device, self.partition) self.diskfile_mgr = self.app._diskfile_router[self.policy] if not self.diskfile_mgr.get_dev_path(self.device): raise swob.HTTPInsufficientStorage(drive=self.device) self.fp = self.request.environ['wsgi.input']
def DELETE(self, req): """Handle HTTP DELETE request.""" try: drive, part, account = req.split_path(3) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def PUT(self, req): """Handle HTTP PUT request.""" try: drive, part, account, container = req.split_path(3, 4) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def GET(self, req): """Handle HTTP GET request.""" try: drive, part, account, container, obj = req.split_path(4, 5, True) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def HEAD(self, req): """Handle HTTP HEAD request.""" try: drive, part, account, container = split_path(unquote(req.path), 3, 4) validate_device_partition(drive, part) except ValueError, err: return jresponse('-1', 'bad request', req,400)
def DELETE(self, req): """Handle HTTP DELETE request.""" try: drive, part, account = split_path(unquote(req.path), 3) validate_device_partition(drive, part) except ValueError, err: return jresponse('-1', 'bad request',req,400)
def DELETE(self, req): """Handle HTTP DELETE request.""" try: drive, part, account = split_path(unquote(req.path), 3) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def PUT(self, request): try: device, partition, account, src_container, src_link = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: return jresponse('-1', 'bad request', request,400)
def DELETE(self, request): """Handle HTTP DELETE requests for the Swift Object Server.""" start_time = time.time() try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, e: return jresponse('-1', 'bad request', request,400)
def GET(self, request): """Handle HTTP GET requests for the Swift Object Server.""" start_time = time.time() try: device, partition, account, container, obj = split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: self.logger.increment("GET.errors") return HTTPBadRequest(body=str(err), request=request, content_type="text/plain")
def POST(self, req): """Handle HTTP POST request.""" start_time = time.time() try: drive, part, account, container = split_path(unquote(req.path), 4) validate_device_partition(drive, part) except ValueError, err: return jresponse('-1', 'bad request', req,400)
def POST(self, req): """Handle HTTP POST request.""" try: drive, part, account, container = split_path(unquote(req.path), 4) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def DELETE(self, request): """Handle HTTP DELETE requests for the Swift Object Server.""" try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, e: return HTTPBadRequest(body=str(e), request=request, content_type='text/plain')
def HEAD(self, req): """Handle HTTP HEAD request.""" try: drive, part, account, container, obj = split_path( unquote(req.path), 4, 5, True) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def GET(self, request): # request is global , can not be modify # response can be modify start_time = time.time() try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: return jresponse('-1', 'bad request', request,400)
def HEAD(self, request): """Handle HTTP HEAD requests for the Swift Object Server.""" try: device, partition, account, container, obj = split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: resp = HTTPBadRequest(request=request) resp.content_type = "text/plain" resp.body = str(err) return resp
def POST(self, request): """Handle HTTP POST requests for the Swift Object Server.""" start_time = time.time() try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: return HTTPBadRequest(body=str(err), request=request, content_type='text/plain')
def DELETE(self, req): """Handle HTTP DELETE request.""" start_time = time.time() try: drive, part, account = split_path(unquote(req.path), 3) validate_device_partition(drive, part) except ValueError, err: self.logger.increment('DELETE.errors') return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def REPLICATE(self, req): """ Handle HTTP REPLICATE request (json-encoded RPC calls for replication.) """ try: post_args = split_path(unquote(req.path), 3) drive, partition, hash = post_args validate_device_partition(drive, partition) except ValueError, err: return HTTPBadRequest(body=str(err), content_type="text/plain", request=req)
def REPLICATE(self, request): """ Handle REPLICATE requests for the Swift Object Server. This is used by the object replicator to get hashes for directories. """ try: device, partition, suffix = split_path(unquote(request.path), 2, 3, True) validate_device_partition(device, partition) except ValueError, e: return HTTPBadRequest(body=str(e), request=request, content_type="text/plain")
def DELETE(self, request): """Handle HTTP DELETE requests for the Swift Object Server.""" start_time = time.time() try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, e: self.logger.increment('DELETE.errors') return HTTPBadRequest(body=str(e), request=request, content_type='text/plain')
def GET(self, req): """Handle HTTP GET request.""" start_time = time.time() try: drive, part, account, container, obj = split_path( unquote(req.path), 4, 5, True) validate_device_partition(drive, part) except ValueError, err: self.logger.increment('GET.errors') return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def HEAD(self, request): """Handle HTTP HEAD requests for the Swift Object Server.""" try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: resp = HTTPBadRequest(request=request) resp.content_type = 'text/plain' resp.body = str(err) return resp
def POST(self, request): """Handle HTTP POST requests for the Swift Object Server.""" start_time = time.time() try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: self.logger.increment('POST.errors') return jresponse('-1', 'bad request', request,400)
def REPLICATE(self, req): """ Handle HTTP REPLICATE request (json-encoded RPC calls for replication.) """ try: post_args = req.split_path(3) drive, partition, hash = post_args validate_device_partition(drive, partition) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def GET(self, request): """Handle HTTP GET requests for the Swift Object Server.""" start_time = time.time() try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: self.logger.increment('GET.errors') return HTTPBadRequest(body=str(err), request=request, content_type='text/plain')
def PUT(self, request): """Handle HTTP PUT requests for the Swift Object Server.""" start_time = time.time() key_id = request.headers.get('x-object-meta-key-id') try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) self.key_manager.validate_key_id(key_id) except ValueError, err: return HTTPBadRequest(body=str(err), request=request, content_type='text/plain')
def REPLICATE(self, request): """ Handle REPLICATE requests for the Swift Object Server. This is used by the object replicator to get hashes for directories. """ try: device, partition, suffix = split_path( unquote(request.path), 2, 3, True) validate_device_partition(device, partition) except ValueError, e: return HTTPBadRequest(body=str(e), request=request, content_type='text/plain')
def REPLICATE(self, req): """ Handle HTTP REPLICATE request. Handler for RPC calls for account replication. """ try: post_args = req.split_path(3) drive, partition, hash = post_args validate_device_partition(drive, partition) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def PUT(self, req): """Handle HTTP PUT request.""" if req.body: return jresponse('-1', 'param error', req,400) start_time = time.time() try: drive, part, account, container, obj = split_path( unquote(req.path), 4, 5, True) validate_device_partition(drive, part) except ValueError, err: return jresponse('-1', 'bad request', req,400)
def REPLICATE(self, req): """ Handle HTTP REPLICATE request (json-encoded RPC calls for replication.) """ start_time = time.time() try: post_args = split_path(unquote(req.path), 3) drive, partition, hash = post_args validate_device_partition(drive, partition) except ValueError, err: self.logger.increment('REPLICATE.errors') return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def HEAD(self, request): """Handle HTTP HEAD requests for the Swift Object Server.""" start_time = time.time() try: device, partition, account, container, obj = \ split_path(unquote(request.path), 5, 5, True) validate_device_partition(device, partition) except ValueError, err: self.logger.increment('HEAD.errors') resp = HTTPBadRequest(request=request) resp.content_type = 'text/plain' resp.body = str(err) return resp
def REPLICATE(self, req): """ Handle HTTP REPLICATE request. Handler for RPC calls for account replication. """ try: post_args = split_path(unquote(req.path), 3) drive, partition, hash = post_args validate_device_partition(drive, partition) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def _parse_path(request, minsegs=5, maxsegs=5): """ Utility function to split and validate the request path. :returns: result of split_path if everything's okay :raises: HTTPBadRequest if something's not okay """ try: segs = split_path(unquote(request.path), minsegs, maxsegs, True) validate_device_partition(segs[0], segs[1]) return segs except ValueError as err: raise HTTPBadRequest(body=str(err), request=request, content_type='text/plain')
def split_and_validate_path(request, minsegs=1, maxsegs=None, rest_with_last=False): """ Utility function to split and validate the request path. :returns: result of :meth:`~swift.common.utils.split_path` if everything's okay, as native strings :raises HTTPBadRequest: if something's not okay """ try: segs = request.split_path(minsegs, maxsegs, rest_with_last) validate_device_partition(segs[0], segs[1]) return [wsgi_to_str(seg) for seg in segs] except ValueError as err: raise HTTPBadRequest(body=str(err), request=request, content_type='text/plain')
def HEAD(self, req): """Handle HTTP HEAD request.""" # TODO(refactor): The account server used to provide a 'account and # container existence check all-in-one' call by doing a HEAD with a # container path. However, container existence is now checked with the # container servers directly so this is no longer needed. We should # refactor out the container existence check here and retest # everything. try: drive, part, account, container = split_path( unquote(req.path), 3, 4) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', request=req)
def initialize_request(self): """ Basic validation of request and mount check. This function will be called before attempting to acquire a replication semaphore lock, so contains only quick checks. """ # The following is the setting we talk about above in _ensure_flush. self.request.environ['eventlet.minimum_write_chunk_size'] = 0 self.device, self.partition = utils.split_path( urllib.unquote(self.request.path), 2, 2, False) utils.validate_device_partition(self.device, self.partition) if self.app._diskfile_mgr.mount_check and \ not constraints.check_mount( self.app._diskfile_mgr.devices, self.device): raise swob.HTTPInsufficientStorage(drive=self.device) self.fp = self.request.environ['wsgi.input'] for data in self._ensure_flush(): yield data
def initialize_request(self): """ Basic validation of request and mount check. This function will be called before attempting to acquire a replication semaphore lock, so contains only quick checks. """ # The following is the setting we talk about above in _ensure_flush. self.request.environ['eventlet.minimum_write_chunk_size'] = 0 self.device, self.partition, self.policy = \ request_helpers.get_name_and_placement(self.request, 2, 2, False) if 'X-Backend-Ssync-Frag-Index' in self.request.headers: self.frag_index = int( self.request.headers['X-Backend-Ssync-Frag-Index']) else: self.frag_index = None utils.validate_device_partition(self.device, self.partition) self.diskfile_mgr = self.app._diskfile_router[self.policy] if self.diskfile_mgr.mount_check and not constraints.check_mount( self.diskfile_mgr.devices, self.device): raise swob.HTTPInsufficientStorage(drive=self.device) self.fp = self.request.environ['wsgi.input'] for data in self._ensure_flush(): yield data