示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
文件: server.py 项目: DylanYu/swift
 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)
示例#5
0
文件: server.py 项目: schatt/swift
 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")
示例#6
0
    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']
示例#7
0
 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)
示例#8
0
    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']
示例#9
0
 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)
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
 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)
示例#13
0
 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) 
示例#14
0
文件: server.py 项目: DylanYu/swift
 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)
示例#15
0
 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) 
示例#16
0
 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)
示例#17
0
 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")
示例#18
0
 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) 
示例#19
0
 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)
示例#20
0
 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')
示例#21
0
文件: server.py 项目: UshF/swift
 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)
示例#22
0
 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)
示例#23
0
文件: server.py 项目: schatt/swift
 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
示例#24
0
 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')
示例#25
0
文件: server.py 项目: waiterZen/swift
 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)
示例#26
0
文件: server.py 项目: DylanYu/swift
 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)
示例#27
0
文件: server.py 项目: schatt/swift
 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')
示例#29
0
 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)
示例#30
0
 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
示例#31
0
 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) 
示例#32
0
 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)
示例#33
0
 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)
示例#34
0
 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')
示例#35
0
 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')
示例#36
0
 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')
示例#37
0
 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)
示例#38
0
 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)
示例#39
0
 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
示例#41
0
 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)
示例#42
0
 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)
示例#43
0
 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')
示例#44
0
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')
示例#45
0
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')
示例#46
0
 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)
示例#47
0
    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