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


Python POLICIES.get_policy_info方法代码示例

本文整理汇总了Python中swift.common.storage_policy.POLICIES.get_policy_info方法的典型用法代码示例。如果您正苦于以下问题:Python POLICIES.get_policy_info方法的具体用法?Python POLICIES.get_policy_info怎么用?Python POLICIES.get_policy_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swift.common.storage_policy.POLICIES的用法示例。


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

示例1: test_swift_info

# 需要导入模块: from swift.common.storage_policy import POLICIES [as 别名]
# 或者: from swift.common.storage_policy.POLICIES import get_policy_info [as 别名]
 def test_swift_info(self):
     # the deprecated 'three' should not exist in expect
     expect = [{'default': True, 'name': 'zero'},
               {'name': 'two'},
               {'name': 'one'}]
     swift_info = POLICIES.get_policy_info()
     self.assertEquals(sorted(expect, key=lambda k: k['name']),
                       sorted(swift_info, key=lambda k: k['name']))
开发者ID:igusher,项目名称:swift,代码行数:10,代码来源:test_storage_policy.py

示例2: __init__

# 需要导入模块: from swift.common.storage_policy import POLICIES [as 别名]
# 或者: from swift.common.storage_policy.POLICIES import get_policy_info [as 别名]

#.........这里部分代码省略.........
            conf.get('auto_create_account_prefix') or '.')
        self.expiring_objects_account = self.auto_create_account_prefix + \
            (conf.get('expiring_objects_account_name') or 'expiring_objects')
        self.expiring_objects_container_divisor = \
            int(conf.get('expiring_objects_container_divisor') or 86400)
        self.max_containers_per_account = \
            int(conf.get('max_containers_per_account') or 0)
        self.max_containers_whitelist = [
            a.strip()
            for a in conf.get('max_containers_whitelist', '').split(',')
            if a.strip()]
        self.deny_host_headers = [
            host.strip() for host in
            conf.get('deny_host_headers', '').split(',') if host.strip()]
        self.log_handoffs = config_true_value(conf.get('log_handoffs', 'true'))
        self.cors_allow_origin = [
            a.strip()
            for a in conf.get('cors_allow_origin', '').split(',')
            if a.strip()]
        self.strict_cors_mode = config_true_value(
            conf.get('strict_cors_mode', 't'))
        self.node_timings = {}
        self.timing_expiry = int(conf.get('timing_expiry', 300))
        self.sorting_method = conf.get('sorting_method', 'shuffle').lower()
        self.max_large_object_get_time = float(
            conf.get('max_large_object_get_time', '86400'))
        value = conf.get('request_node_count', '2 * replicas').lower().split()
        if len(value) == 1:
            rnc_value = int(value[0])
            self.request_node_count = lambda replicas: rnc_value
        elif len(value) == 3 and value[1] == '*' and value[2] == 'replicas':
            rnc_value = int(value[0])
            self.request_node_count = lambda replicas: rnc_value * replicas
        else:
            raise ValueError(
                'Invalid request_node_count value: %r' % ''.join(value))
        try:
            self._read_affinity = read_affinity = conf.get('read_affinity', '')
            self.read_affinity_sort_key = affinity_key_function(read_affinity)
        except ValueError as err:
            # make the message a little more useful
            raise ValueError("Invalid read_affinity value: %r (%s)" %
                             (read_affinity, err.message))
        try:
            write_affinity = conf.get('write_affinity', '')
            self.write_affinity_is_local_fn \
                = affinity_locality_predicate(write_affinity)
        except ValueError as err:
            # make the message a little more useful
            raise ValueError("Invalid write_affinity value: %r (%s)" %
                             (write_affinity, err.message))
        value = conf.get('write_affinity_node_count',
                         '2 * replicas').lower().split()
        if len(value) == 1:
            wanc_value = int(value[0])
            self.write_affinity_node_count = lambda replicas: wanc_value
        elif len(value) == 3 and value[1] == '*' and value[2] == 'replicas':
            wanc_value = int(value[0])
            self.write_affinity_node_count = \
                lambda replicas: wanc_value * replicas
        else:
            raise ValueError(
                'Invalid write_affinity_node_count value: %r' % ''.join(value))
        # swift_owner_headers are stripped by the account and container
        # controllers; we should extend header stripping to object controller
        # when a privileged object header is implemented.
        swift_owner_headers = conf.get(
            'swift_owner_headers',
            'x-container-read, x-container-write, '
            'x-container-sync-key, x-container-sync-to, '
            'x-account-meta-temp-url-key, x-account-meta-temp-url-key-2, '
            'x-container-meta-temp-url-key, x-container-meta-temp-url-key-2, '
            'x-account-access-control')
        self.swift_owner_headers = [
            name.strip().title()
            for name in swift_owner_headers.split(',') if name.strip()]
        # Initialization was successful, so now apply the client chunk size
        # parameter as the default read / write buffer size for the network
        # sockets.
        #
        # NOTE WELL: This is a class setting, so until we get set this on a
        # per-connection basis, this affects reading and writing on ALL
        # sockets, those between the proxy servers and external clients, and
        # those between the proxy servers and the other internal servers.
        #
        # ** Because it affects the client as well, currently, we use the
        # client chunk size as the govenor and not the object chunk size.
        socket._fileobject.default_bufsize = self.client_chunk_size
        self.expose_info = config_true_value(
            conf.get('expose_info', 'yes'))
        self.disallowed_sections = list_from_csv(
            conf.get('disallowed_sections', 'swift.valid_api_versions'))
        self.admin_key = conf.get('admin_key', None)
        register_swift_info(
            version=swift_version,
            strict_cors_mode=self.strict_cors_mode,
            policies=POLICIES.get_policy_info(),
            allow_account_management=self.allow_account_management,
            account_autocreate=self.account_autocreate,
            **constraints.EFFECTIVE_CONSTRAINTS)
开发者ID:Coffeedude,项目名称:swift,代码行数:104,代码来源:server.py

示例3: __init__

# 需要导入模块: from swift.common.storage_policy import POLICIES [as 别名]
# 或者: from swift.common.storage_policy.POLICIES import get_policy_info [as 别名]

#.........这里部分代码省略.........
        self.trans_id_suffix = conf.get("trans_id_suffix", "")
        self.post_quorum_timeout = float(conf.get("post_quorum_timeout", 0.5))
        self.error_suppression_interval = int(conf.get("error_suppression_interval", 60))
        self.error_suppression_limit = int(conf.get("error_suppression_limit", 10))
        self.recheck_container_existence = int(conf.get("recheck_container_existence", 60))
        self.recheck_account_existence = int(conf.get("recheck_account_existence", 60))
        self.allow_account_management = config_true_value(conf.get("allow_account_management", "no"))
        self.object_post_as_copy = config_true_value(conf.get("object_post_as_copy", "true"))
        self.container_ring = container_ring or Ring(swift_dir, ring_name="container")
        self.account_ring = account_ring or Ring(swift_dir, ring_name="account")
        # ensure rings are loaded for all configured storage policies
        for policy in POLICIES:
            policy.load_ring(swift_dir)
        self.obj_controller_router = ObjectControllerRouter()
        self.memcache = memcache
        mimetypes.init(mimetypes.knownfiles + [os.path.join(swift_dir, "mime.types")])
        self.account_autocreate = config_true_value(conf.get("account_autocreate", "no"))
        self.auto_create_account_prefix = conf.get("auto_create_account_prefix") or "."
        self.expiring_objects_account = self.auto_create_account_prefix + (
            conf.get("expiring_objects_account_name") or "expiring_objects"
        )
        self.expiring_objects_container_divisor = int(conf.get("expiring_objects_container_divisor") or 86400)
        self.max_containers_per_account = int(conf.get("max_containers_per_account") or 0)
        self.max_containers_whitelist = [
            a.strip() for a in conf.get("max_containers_whitelist", "").split(",") if a.strip()
        ]
        self.deny_host_headers = [host.strip() for host in conf.get("deny_host_headers", "").split(",") if host.strip()]
        self.log_handoffs = config_true_value(conf.get("log_handoffs", "true"))
        self.cors_allow_origin = [a.strip() for a in conf.get("cors_allow_origin", "").split(",") if a.strip()]
        self.strict_cors_mode = config_true_value(conf.get("strict_cors_mode", "t"))
        self.node_timings = {}
        self.timing_expiry = int(conf.get("timing_expiry", 300))
        self.sorting_method = conf.get("sorting_method", "shuffle").lower()
        self.concurrent_gets = config_true_value(conf.get("concurrent_gets"))
        self.concurrency_timeout = float(conf.get("concurrency_timeout", self.conn_timeout))
        value = conf.get("request_node_count", "2 * replicas").lower().split()
        if len(value) == 1:
            rnc_value = int(value[0])
            self.request_node_count = lambda replicas: rnc_value
        elif len(value) == 3 and value[1] == "*" and value[2] == "replicas":
            rnc_value = int(value[0])
            self.request_node_count = lambda replicas: rnc_value * replicas
        else:
            raise ValueError("Invalid request_node_count value: %r" % "".join(value))
        try:
            self._read_affinity = read_affinity = conf.get("read_affinity", "")
            self.read_affinity_sort_key = affinity_key_function(read_affinity)
        except ValueError as err:
            # make the message a little more useful
            raise ValueError("Invalid read_affinity value: %r (%s)" % (read_affinity, err.message))
        try:
            write_affinity = conf.get("write_affinity", "")
            self.write_affinity_is_local_fn = affinity_locality_predicate(write_affinity)
        except ValueError as err:
            # make the message a little more useful
            raise ValueError("Invalid write_affinity value: %r (%s)" % (write_affinity, err.message))
        value = conf.get("write_affinity_node_count", "2 * replicas").lower().split()
        if len(value) == 1:
            wanc_value = int(value[0])
            self.write_affinity_node_count = lambda replicas: wanc_value
        elif len(value) == 3 and value[1] == "*" and value[2] == "replicas":
            wanc_value = int(value[0])
            self.write_affinity_node_count = lambda replicas: wanc_value * replicas
        else:
            raise ValueError("Invalid write_affinity_node_count value: %r" % "".join(value))
        # swift_owner_headers are stripped by the account and container
        # controllers; we should extend header stripping to object controller
        # when a privileged object header is implemented.
        swift_owner_headers = conf.get(
            "swift_owner_headers",
            "x-container-read, x-container-write, "
            "x-container-sync-key, x-container-sync-to, "
            "x-account-meta-temp-url-key, x-account-meta-temp-url-key-2, "
            "x-container-meta-temp-url-key, x-container-meta-temp-url-key-2, "
            "x-account-access-control",
        )
        self.swift_owner_headers = [name.strip().title() for name in swift_owner_headers.split(",") if name.strip()]
        # Initialization was successful, so now apply the client chunk size
        # parameter as the default read / write buffer size for the network
        # sockets.
        #
        # NOTE WELL: This is a class setting, so until we get set this on a
        # per-connection basis, this affects reading and writing on ALL
        # sockets, those between the proxy servers and external clients, and
        # those between the proxy servers and the other internal servers.
        #
        # ** Because it affects the client as well, currently, we use the
        # client chunk size as the govenor and not the object chunk size.
        socket._fileobject.default_bufsize = self.client_chunk_size
        self.expose_info = config_true_value(conf.get("expose_info", "yes"))
        self.disallowed_sections = list_from_csv(conf.get("disallowed_sections", "swift.valid_api_versions"))
        self.admin_key = conf.get("admin_key", None)
        register_swift_info(
            version=swift_version,
            strict_cors_mode=self.strict_cors_mode,
            policies=POLICIES.get_policy_info(),
            allow_account_management=self.allow_account_management,
            account_autocreate=self.account_autocreate,
            **constraints.EFFECTIVE_CONSTRAINTS
        )
开发者ID:harrisonfeng,项目名称:swift,代码行数:104,代码来源:server.py

示例4: test_swift_info

# 需要导入模块: from swift.common.storage_policy import POLICIES [as 别名]
# 或者: from swift.common.storage_policy.POLICIES import get_policy_info [as 别名]
 def test_swift_info(self):
     # the deprecated 'three' should not exist in expect
     expect = [{"default": True, "name": "zero"}, {"name": "two"}, {"name": "one"}, {"name": "ten"}]
     swift_info = POLICIES.get_policy_info()
     self.assertEquals(sorted(expect, key=lambda k: k["name"]), sorted(swift_info, key=lambda k: k["name"]))
开发者ID:dencaval,项目名称:swift,代码行数:7,代码来源:test_storage_policy.py


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