コード例 #1
0
ファイル: server.py プロジェクト: sun7shines/Cloudfs
 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
ファイル: server.py プロジェクト: sun3shines/swift-1.7.4
 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
ファイル: server.py プロジェクト: sun3shines/swift-1.7.4
 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
ファイル: ssync_receiver.py プロジェクト: zhangjindou/swift
    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
ファイル: server.py プロジェクト: navidshaikh/swift
 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
ファイル: ssync_receiver.py プロジェクト: allen-yin/swift
    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
ファイル: server.py プロジェクト: Neil-Jubinville/swift
 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
ファイル: server.py プロジェクト: zhangheng1442/openstack
 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
ファイル: server.py プロジェクト: sun3shines/swift-1.7.4
 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
ファイル: server.py プロジェクト: sun3shines/swift-1.7.4
 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
ファイル: server.py プロジェクト: sun3shines/swift-1.7.4
 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
ファイル: server.py プロジェクト: sun7shines/Cloudfs
 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
ファイル: server.py プロジェクト: andrewgaul/swift
 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
ファイル: server.py プロジェクト: sun7shines/Cloudfs
 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
ファイル: server.py プロジェクト: wenxueliu/autodeploy-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')
コード例 #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
ファイル: server.py プロジェクト: sun7shines/Cloudfs
 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
ファイル: server.py プロジェクト: Manasa7/swift-encrypt
 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")
コード例 #28
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:
         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
ファイル: server.py プロジェクト: sun7shines/Cloudfs
 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
ファイル: server.py プロジェクト: HodongHwang/swift
 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
ファイル: server.py プロジェクト: zhangheng1442/openstack
 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
ファイル: server.py プロジェクト: Manasa7/swift-encrypt
 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
ファイル: server.py プロジェクト: wenxueliu/autodeploy-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')
コード例 #37
0
ファイル: server.py プロジェクト: Neil-Jubinville/swift
 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
ファイル: server.py プロジェクト: sun3shines/swift-1.7.4
 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)
コード例 #40
0
 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
ファイル: server.py プロジェクト: HodongHwang/swift
 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
ファイル: server.py プロジェクト: udaykd09/swift-encrypt
 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
コード例 #48
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, 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