当前位置: 首页>>代码示例>>Python>>正文


Python base.clear_info_cache函数代码示例

本文整理汇总了Python中swift.proxy.controllers.base.clear_info_cache函数的典型用法代码示例。如果您正苦于以下问题:Python clear_info_cache函数的具体用法?Python clear_info_cache怎么用?Python clear_info_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了clear_info_cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PUT

 def PUT(self, req):
     """HTTP PUT request handler."""
     error_response = self.clean_acls(req) or check_metadata(req, "container")
     if error_response:
         return error_response
     if len(self.container_name) > MAX_CONTAINER_NAME_LENGTH:
         resp = HTTPBadRequest(request=req)
         resp.body = "Container name length of %d longer than %d" % (
             len(self.container_name),
             MAX_CONTAINER_NAME_LENGTH,
         )
         return resp
     account_partition, accounts, container_count = self.account_info(self.account_name, req)
     if not accounts and self.app.account_autocreate:
         self.autocreate_account(req.environ, self.account_name)
         account_partition, accounts, container_count = self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     if (
         self.app.max_containers_per_account > 0
         and container_count >= self.app.max_containers_per_account
         and self.account_name not in self.app.max_containers_whitelist
     ):
         resp = HTTPForbidden(request=req)
         resp.body = "Reached container limit of %s" % self.app.max_containers_per_account
         return resp
     container_partition, containers = self.app.container_ring.get_nodes(self.account_name, self.container_name)
     headers = self._backend_requests(req, len(containers), account_partition, accounts)
     clear_info_cache(self.app, req.environ, self.account_name, self.container_name)
     resp = self.make_requests(req, self.app.container_ring, container_partition, "PUT", req.path_info, headers)
     return resp
开发者ID:zaitcev,项目名称:swift-lfs,代码行数:31,代码来源:container.py

示例2: POST

    def POST(self, req):
        """HTTP POST request handler."""
        # container元数据参数检查
        error_response = \
            self.clean_acls(req) or check_metadata(req, 'container')
        if error_response:
            return error_response
        if not req.environ.get('swift_owner'):
            for key in self.app.swift_owner_headers:
                req.headers.pop(key, None)

        # 获取account的元数据信息,分区、节点、以及container数量
        account_partition, accounts, container_count = \
            self.account_info(self.account_name, req)
        # 如果account不存在,则报错
        if not accounts:
            return HTTPNotFound(request=req)

        # 通过ring环计算分区、container所在节点
        container_partition, containers = self.app.container_ring.get_nodes(
            self.account_name, self.container_name)
        # 生成创建container请求的header
        headers = self.generate_request_headers(req, transfer=True)
        # 清除本地缓存account和container的元数据信息
        clear_info_cache(self.app, req.environ,
                         self.account_name, self.container_name)
        # 发送请求到所有container节点,更新container元数据请求
        resp = self.make_requests(
            req, self.app.container_ring, container_partition, 'POST',
            req.swift_entity_path, [headers] * len(containers))
        return resp
开发者ID:sunzz679,项目名称:swift-2.4.0--source-read,代码行数:31,代码来源:container.py

示例3: POST

 def POST(self, req):
     """HTTP POST request handler."""
     error_response = \
         self.clean_acls(req) or check_metadata(req, 'container')
     if error_response:
         return error_response
     if not req.environ.get('swift_owner'):
         for key in self.app.swift_owner_headers:
             req.headers.pop(key, None)
     if req.environ.get('reseller_request', False) and \
             'X-Container-Sharding' in req.headers:
         req.headers[get_sys_meta_prefix('container') + 'Sharding'] = \
             str(config_true_value(req.headers['X-Container-Sharding']))
     account_partition, accounts, container_count = \
         self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     container_partition, containers = self.app.container_ring.get_nodes(
         self.account_name, self.container_name)
     headers = self.generate_request_headers(req, transfer=True)
     clear_info_cache(self.app, req.environ,
                      self.account_name, self.container_name)
     resp = self.make_requests(
         req, self.app.container_ring, container_partition, 'POST',
         req.swift_entity_path, [headers] * len(containers))
     return resp
开发者ID:openstack,项目名称:swift,代码行数:26,代码来源:container.py

示例4: PUT

    def PUT(self, req):
        """HTTP PUT request handler."""
	print 'in PUT function of accountcontroller class'
        if not self.app.allow_account_management:
            return HTTPMethodNotAllowed(
                request=req,
                headers={'Allow': ', '.join(self.allowed_methods)})
        error_response = check_metadata(req, 'account')
	print 'error_response'
        if error_response:
            return error_response
        if len(self.account_name) > constraints.MAX_ACCOUNT_NAME_LENGTH:
            resp = HTTPBadRequest(request=req)
            resp.body = 'Account name length of %d longer than %d' % \
                        (len(self.account_name),
                         constraints.MAX_ACCOUNT_NAME_LENGTH)
            return resp
        account_partition, accounts = \
            self.app.account_ring.get_nodes(self.account_name)
	print ' account_partition, accounts',account_partion,accounts
        headers = self.generate_request_headers(req, transfer=True)
	print 'headers',headers
        clear_info_cache(self.app, req.environ, self.account_name)
        resp = self.make_requests(
            req, self.app.account_ring, account_partition, 'PUT',
            req.swift_entity_path, [headers] * len(accounts))
	print 'resp',resp
        self.add_acls_from_sys_metadata(resp)
	print 'in PUT function of accountcontroller class END'
        return resp
开发者ID:jannatunnoor,项目名称:test_swift,代码行数:30,代码来源:account.py

示例5: POST

 def POST(self, req):
     """HTTP POST request handler."""
     if len(self.account_name) > constraints.MAX_ACCOUNT_NAME_LENGTH:
         resp = HTTPBadRequest(request=req)
         resp.body = 'Account name length of %d longer than %d' % \
                     (len(self.account_name),
                      constraints.MAX_ACCOUNT_NAME_LENGTH)
         return resp
     error_response = check_metadata(req, 'account')
     if error_response:
         return error_response
     account_partition, accounts = \
         self.app.account_ring.get_nodes(self.account_name)
     headers = self.generate_request_headers(req, transfer=True)
     clear_info_cache(self.app, req.environ, self.account_name)
     resp = self.make_requests(
         req, self.app.account_ring, account_partition, 'POST',
         req.swift_entity_path, [headers] * len(accounts))
     if resp.status_int == HTTP_NOT_FOUND and self.app.account_autocreate:
         self.autocreate_account(req, self.account_name)
         resp = self.make_requests(
             req, self.app.account_ring, account_partition, 'POST',
             req.swift_entity_path, [headers] * len(accounts))
     self.add_acls_from_sys_metadata(resp)
     return resp
开发者ID:Ahiknsr,项目名称:swift,代码行数:25,代码来源:account.py

示例6: DELETE

    def DELETE(self, req):
        """HTTP DELETE request handler."""
        account_partition, accounts, container_count = \
            self.account_info(self.account_name, req)
        if not accounts:
            return HTTPNotFound(request=req)

        policy_index = self._convert_policy_to_index(req)
        if policy_index is None:
            policy_index = int(POLICIES.default)
        cloud_ring = CloudRing(self.container_name, POLICIES.get_by_index(policy_index))

        container_partition, containers = self.app.container_ring.get_nodes(
            self.account_name, self.container_name)
        headers = self._backend_requests(req, len(containers),
                                         account_partition, accounts)
        clear_info_cache(self.app, req.environ,
                         self.account_name, self.container_name)
        resp = self.make_requests(
            req, self.app.container_ring, container_partition, 'DELETE',
            req.swift_entity_path, headers)
        # Indicates no server had the container
        if resp.status_int == HTTP_ACCEPTED:
            return HTTPNotFound(request=req)
        return_flag, _info = cloud_ring.delete_containers()
        if not return_flag:
            msg = 'Failed:' + str(_info)
            raise DELETECloudContainerException(msg)
        return resp
开发者ID:kun--hust,项目名称:sdscloud,代码行数:29,代码来源:container.py

示例7: PUT

    def PUT(self, req):
        """HTTP PUT request handler."""
        error_response = \
            self.clean_acls(req) or check_metadata(req, 'container')
        if error_response:
            return error_response
        policy_index = self._convert_policy_to_index(req)
        if policy_index is None:
            policy_index = int(POLICIES.default)
        if not req.environ.get('swift_owner'):
            for key in self.app.swift_owner_headers:
                req.headers.pop(key, None)
        if len(self.container_name) > constraints.MAX_CONTAINER_NAME_LENGTH:
            resp = HTTPBadRequest(request=req)
            resp.body = 'Container name length of %d longer than %d' % \
                        (len(self.container_name),
                         constraints.MAX_CONTAINER_NAME_LENGTH)
            return resp
        account_partition, accounts, container_count = \
            self.account_info(self.account_name, req)
        if not accounts and self.app.account_autocreate:
            self.autocreate_account(req, self.account_name)
            account_partition, accounts, container_count = \
                self.account_info(self.account_name, req)
        if not accounts:
            return HTTPNotFound(request=req)
        if self.app.max_containers_per_account > 0 and \
                container_count >= self.app.max_containers_per_account and \
                self.account_name not in self.app.max_containers_whitelist:
            container_info = \
                self.container_info(self.account_name, self.container_name,
                                    req)
            if not is_success(container_info.get('status')):
                resp = HTTPForbidden(request=req)
                resp.body = 'Reached container limit of %s' % \
                    self.app.max_containers_per_account
                return resp
        container_partition, containers = self.app.container_ring.get_nodes(
            self.account_name, self.container_name)
        headers = self._backend_requests(req, len(containers),
                                         account_partition, accounts,
                                         policy_index)
        clear_info_cache(self.app, req.environ,
                         self.account_name, self.container_name)
        resp = self.make_requests(
            req, self.app.container_ring,
            container_partition, 'PUT', req.swift_entity_path, headers)

        cloud_ring = CloudRing(self.container_name, POLICIES.get_by_index(policy_index))
        return_flag, _info = cloud_ring.create_containers()
        if not return_flag:
            msg = 'Failed:' + str(_info)
            raise PUTCloudContainerException(msg)

        return resp
开发者ID:kun--hust,项目名称:sdscloud,代码行数:55,代码来源:container.py

示例8: PUT

 def PUT(self, req):
     """HTTP PUT request handler."""
     #container元数据参数检查
     error_response = \
         self.clean_acls(req) or check_metadata(req, 'container')
     if error_response:
         return error_response
     policy_index = self._convert_policy_to_index(req)
     if not req.environ.get('swift_owner'):
         for key in self.app.swift_owner_headers:
             req.headers.pop(key, None)
     if len(self.container_name) > constraints.MAX_CONTAINER_NAME_LENGTH:
         resp = HTTPBadRequest(request=req)
         resp.body = 'Container name length of %d longer than %d' % \
                     (len(self.container_name),
                      constraints.MAX_CONTAINER_NAME_LENGTH)
         return resp
     #获取account的元数据信息,分区、节点、以及container数量
     account_partition, accounts, container_count = \
         self.account_info(self.account_name, req)
     #如果account不存在,则创建account
     if not accounts and self.app.account_autocreate:
         self.autocreate_account(req, self.account_name)
         account_partition, accounts, container_count = \
             self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     #检查account里面container超过上限值,则报错
     if self.app.max_containers_per_account > 0 and \
             container_count >= self.app.max_containers_per_account and \
             self.account_name not in self.app.max_containers_whitelist:
         container_info = \
             self.container_info(self.account_name, self.container_name,
                                 req)
         if not is_success(container_info.get('status')):
             resp = HTTPForbidden(request=req)
             resp.body = 'Reached container limit of %s' % \
                 self.app.max_containers_per_account
             return resp
     #通过ring环计算分区、container所在节点
     container_partition, containers = self.app.container_ring.get_nodes(
         self.account_name, self.container_name)
     #生成创建container请求的header
     headers = self._backend_requests(req, len(containers),
                                      account_partition, accounts,
                                      policy_index)
     #清除本地缓存account和container的元数据信息
     clear_info_cache(self.app, req.environ,
                      self.account_name, self.container_name)
     #发送请求到所有container节点,创建container
     resp = self.make_requests(
         req, self.app.container_ring,
         container_partition, 'PUT', req.swift_entity_path, headers)
     return resp
开发者ID:sunzz679,项目名称:swift-2.4.0--source-read,代码行数:54,代码来源:container.py

示例9: DELETE

 def DELETE(self, req):
     """HTTP DELETE request handler."""
     account_partition, accounts, container_count = \
         self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     clear_info_cache(self.app, req.environ,
                      self.account_name, self.container_name)
     resp = self.get_container_delete_resp(req)
     if resp.status_int == HTTP_ACCEPTED:
         return HTTPNotFound(request=req)
     return resp
开发者ID:fvennetier,项目名称:oio-swift,代码行数:12,代码来源:container.py

示例10: DELETE

 def DELETE(self, req):
     """HTTP DELETE request handler."""
     account_partition, accounts, container_count = self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     container_partition, containers = self.app.container_ring.get_nodes(self.account_name, self.container_name)
     headers = self._backend_requests(req, len(containers), account_partition, accounts)
     clear_info_cache(self.app, req.environ, self.account_name, self.container_name)
     resp = self.make_requests(req, self.app.container_ring, container_partition, "DELETE", req.path_info, headers)
     # Indicates no server had the container
     if resp.status_int == HTTP_ACCEPTED:
         return HTTPNotFound(request=req)
     return resp
开发者ID:zaitcev,项目名称:swift-lfs,代码行数:13,代码来源:container.py

示例11: PUT

 def PUT(self, req):
     """HTTP PUT request handler."""
     error_response = \
         self.clean_acls(req) or check_metadata(req, 'container')
     if error_response:
         return error_response
     policy_index = self._convert_policy_to_index(req)
     if not req.environ.get('swift_owner'):
         for key in self.app.swift_owner_headers:
             req.headers.pop(key, None)
     if req.environ.get('reseller_request', False) and \
             'X-Container-Sharding' in req.headers:
         req.headers[get_sys_meta_prefix('container') + 'Sharding'] = \
             str(config_true_value(req.headers['X-Container-Sharding']))
     length_limit = self.get_name_length_limit()
     if len(self.container_name) > length_limit:
         body = 'Container name length of %d longer than %d' % (
             len(self.container_name), length_limit)
         resp = HTTPBadRequest(request=req, body=body)
         return resp
     account_partition, accounts, container_count = \
         self.account_info(self.account_name, req)
     if not accounts and self.app.account_autocreate:
         if not self.autocreate_account(req, self.account_name):
             return HTTPServiceUnavailable(request=req)
         account_partition, accounts, container_count = \
             self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     if 0 < self.app.max_containers_per_account <= container_count and \
             self.account_name not in self.app.max_containers_whitelist:
         container_info = \
             self.container_info(self.account_name, self.container_name,
                                 req)
         if not is_success(container_info.get('status')):
             body = 'Reached container limit of %s' % (
                 self.app.max_containers_per_account, )
             resp = HTTPForbidden(request=req, body=body)
             return resp
     container_partition, containers = self.app.container_ring.get_nodes(
         self.account_name, self.container_name)
     headers = self._backend_requests(req, len(containers),
                                      account_partition, accounts,
                                      policy_index)
     resp = self.make_requests(
         req, self.app.container_ring,
         container_partition, 'PUT', req.swift_entity_path, headers)
     clear_info_cache(self.app, req.environ,
                      self.account_name, self.container_name)
     return resp
开发者ID:openstack,项目名称:swift,代码行数:50,代码来源:container.py

示例12: POST

 def POST(self, req):
     """HTTP POST request handler."""
     error_response = self.clean_acls(req) or check_metadata(req, "container")
     if error_response:
         return error_response
     account_partition, accounts, container_count = self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     container_partition, containers = self.app.container_ring.get_nodes(self.account_name, self.container_name)
     headers = self.generate_request_headers(req, transfer=True)
     clear_info_cache(self.app, req.environ, self.account_name, self.container_name)
     resp = self.make_requests(
         req, self.app.container_ring, container_partition, "POST", req.path_info, [headers] * len(containers)
     )
     return resp
开发者ID:zaitcev,项目名称:swift-lfs,代码行数:15,代码来源:container.py

示例13: DELETE

 def DELETE(self, req):
     """HTTP DELETE request handler."""
     # Extra safety in case someone typos a query string for an
     # account-level DELETE request that was really meant to be caught by
     # some middleware.
     if req.query_string:
         return HTTPBadRequest(request=req)
     if not self.app.allow_account_management:
         return HTTPMethodNotAllowed(request=req, headers={"Allow": ", ".join(self.allowed_methods)})
     account_partition, accounts = self.app.account_ring.get_nodes(self.account_name)
     headers = self.generate_request_headers(req)
     clear_info_cache(self.app, req.environ, self.account_name)
     resp = self.make_requests(
         req, self.app.account_ring, account_partition, "DELETE", req.swift_entity_path, [headers] * len(accounts)
     )
     return resp
开发者ID:anishnarang,项目名称:gswift-multinode,代码行数:16,代码来源:account.py

示例14: PUT

 def PUT(self, req):
     """HTTP PUT request handler."""
     if not self.app.allow_account_management:
         return HTTPMethodNotAllowed(request=req, headers={"Allow": ", ".join(self.allowed_methods)})
     error_response = check_metadata(req, "account")
     if error_response:
         return error_response
     if len(self.account_name) > MAX_ACCOUNT_NAME_LENGTH:
         resp = HTTPBadRequest(request=req)
         resp.body = "Account name length of %d longer than %d" % (len(self.account_name), MAX_ACCOUNT_NAME_LENGTH)
         return resp
     account_partition, accounts = self.app.account_ring.get_nodes(self.account_name)
     headers = self.generate_request_headers(req, transfer=True)
     clear_info_cache(self.app, req.environ, self.account_name)
     resp = self.make_requests(
         req, self.app.account_ring, account_partition, "PUT", req.path_info, [headers] * len(accounts)
     )
     return resp
开发者ID:Dieterbe,项目名称:swift,代码行数:18,代码来源:account.py

示例15: PUT

 def PUT(self, req):
     """HTTP PUT request handler."""
     error_response = \
         self.clean_acls(req) or check_metadata(req, 'container')
     if error_response:
         return error_response
     policy_index = self._convert_policy_to_index(req)
     if not req.environ.get('swift_owner'):
         for key in self.app.swift_owner_headers:
             req.headers.pop(key, None)
     if len(self.container_name) > constraints.MAX_CONTAINER_NAME_LENGTH:
         resp = HTTPBadRequest(request=req)
         resp.body = 'Container name length of %d longer than %d' % \
                     (len(self.container_name),
                      constraints.MAX_CONTAINER_NAME_LENGTH)
         return resp
     account_partition, accounts, container_count = \
         self.account_info(self.account_name, req)
     if not accounts and self.app.account_autocreate:
         self.autocreate_account(req.environ, self.account_name)
         account_partition, accounts, container_count = \
             self.account_info(self.account_name, req)
     if not accounts:
         return HTTPNotFound(request=req)
     if self.app.max_containers_per_account > 0 and \
             container_count >= self.app.max_containers_per_account and \
             self.account_name not in self.app.max_containers_whitelist:
         resp = HTTPForbidden(request=req)
         resp.body = 'Reached container limit of %s' % \
                     self.app.max_containers_per_account
         return resp
     container_partition, containers = self.app.container_ring.get_nodes(
         self.account_name, self.container_name)
     headers = self._backend_requests(req, len(containers),
                                      account_partition, accounts,
                                      policy_index)
     clear_info_cache(self.app, req.environ,
                      self.account_name, self.container_name)
     resp = self.make_requests(
         req, self.app.container_ring,
         container_partition, 'PUT', req.swift_entity_path, headers)
     return resp
开发者ID:701,项目名称:swift,代码行数:42,代码来源:container.py


注:本文中的swift.proxy.controllers.base.clear_info_cache函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。