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


Python utils.config_true_value函数代码示例

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


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

示例1: __init__

 def __init__(self, app, conf, logger=None):
     self.app = app
     self.logger = logger or get_logger(conf, log_route='read_only')
     self.read_only = config_true_value(conf.get('read_only'))
     self.write_methods = {'COPY', 'POST', 'PUT'}
     if not config_true_value(conf.get('allow_deletes')):
         self.write_methods.add('DELETE')
开发者ID:jgmerritt,项目名称:swift,代码行数:7,代码来源:read_only.py

示例2: __init__

 def __init__(self, idx, name="", is_default=False, is_deprecated=False, object_ring=None):
     # do not allow BaseStoragePolicy class to be instantiated directly
     if type(self) == BaseStoragePolicy:
         raise TypeError("Can't instantiate BaseStoragePolicy directly")
     # policy parameter validation
     try:
         self.idx = int(idx)
     except ValueError:
         raise PolicyError("Invalid index", idx)
     if self.idx < 0:
         raise PolicyError("Invalid index", idx)
     if not name:
         raise PolicyError("Invalid name %r" % name, idx)
     # this is defensively restrictive, but could be expanded in the future
     if not all(c in VALID_CHARS for c in name):
         raise PolicyError(
             "Names are used as HTTP headers, and can not "
             "reliably contain any characters not in %r. "
             "Invalid name %r" % (VALID_CHARS, name)
         )
     if name.upper() == LEGACY_POLICY_NAME.upper() and self.idx != 0:
         msg = "The name %s is reserved for policy index 0. " "Invalid name %r" % (LEGACY_POLICY_NAME, name)
         raise PolicyError(msg, idx)
     self.name = name
     self.is_deprecated = config_true_value(is_deprecated)
     self.is_default = config_true_value(is_default)
     if self.policy_type not in BaseStoragePolicy.policy_type_to_policy_cls:
         raise PolicyError("Invalid type", self.policy_type)
     if self.is_deprecated and self.is_default:
         raise PolicyError("Deprecated policy can not be default.  " "Invalid config", self.idx)
     self.ring_name = _get_policy_string("object", self.idx)
     self.object_ring = object_ring
开发者ID:iloveyou416068,项目名称:swift-1,代码行数:32,代码来源:storage_policy.py

示例3: __init__

    def __init__(self, conf, logger=None):
        """
        Creates a new WSGI application for the Swift Object Server. An
        example configuration is given at
        <source-dir>/etc/object-server.conf-sample or
        /etc/swift/object-server.conf-sample.
        """
        super(ObjectController, self).__init__(conf)
        self.logger = logger or get_logger(conf, log_route='object-server')
        self.node_timeout = int(conf.get('node_timeout', 3))
        self.conn_timeout = float(conf.get('conn_timeout', 0.5))
        self.client_timeout = int(conf.get('client_timeout', 60))
        self.disk_chunk_size = int(conf.get('disk_chunk_size', 65536))
        self.network_chunk_size = int(conf.get('network_chunk_size', 65536))
        self.log_requests = config_true_value(conf.get('log_requests', 'true'))
        self.max_upload_time = int(conf.get('max_upload_time', 86400))
        self.slow = int(conf.get('slow', 0))
        self.keep_cache_private = \
            config_true_value(conf.get('keep_cache_private', 'false'))

        default_allowed_headers = '''
            content-disposition,
            content-encoding,
            x-delete-at,
            x-object-manifest,
            x-static-large-object,
        '''
        extra_allowed_headers = [
            header.strip().lower() for header in conf.get(
                'allowed_headers', default_allowed_headers).split(',')
            if header.strip()
        ]
        self.allowed_headers = set()
        for header in extra_allowed_headers:
            if header not in DATAFILE_SYSTEM_META:
                self.allowed_headers.add(header)
        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)
        # Initialization was successful, so now apply the network 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 the primary motivation for this is to optimize how data
        # is written back to the proxy server, we could use the value from the
        # disk_chunk_size parameter. However, it affects all created sockets
        # using this class so we have chosen to tie it to the
        # network_chunk_size parameter value instead.
        socket._fileobject.default_bufsize = self.network_chunk_size

        # Provide further setup specific to an object server implementation.
        self.setup(conf)
开发者ID:kun--hust,项目名称:sdscloud,代码行数:60,代码来源:server.py

示例4: __init__

 def __init__(self, conf):
     """
     :param conf: configuration object obtained from ConfigParser
     :param logger: logging object
     """
     self.conf = conf
     self.logger = get_logger(conf, log_route="object-replicator")
     self.devices_dir = conf.get("devices", "/srv/node")
     self.mount_check = config_true_value(conf.get("mount_check", "true"))
     self.vm_test_mode = config_true_value(conf.get("vm_test_mode", "no"))
     self.swift_dir = conf.get("swift_dir", "/etc/swift")
     self.port = int(conf.get("bind_port", 6000))
     self.concurrency = int(conf.get("concurrency", 1))
     self.stats_interval = int(conf.get("stats_interval", "300"))
     self.ring_check_interval = int(conf.get("ring_check_interval", 15))
     self.next_check = time.time() + self.ring_check_interval
     self.reclaim_age = int(conf.get("reclaim_age", 86400 * 7))
     self.partition_times = []
     self.run_pause = int(conf.get("run_pause", 30))
     self.rsync_timeout = int(conf.get("rsync_timeout", 900))
     self.rsync_io_timeout = conf.get("rsync_io_timeout", "30")
     self.rsync_bwlimit = conf.get("rsync_bwlimit", "0")
     self.http_timeout = int(conf.get("http_timeout", 60))
     self.lockup_timeout = int(conf.get("lockup_timeout", 1800))
     self.recon_cache_path = conf.get("recon_cache_path", "/var/cache/swift")
     self.rcache = os.path.join(self.recon_cache_path, "object.recon")
     self.conn_timeout = float(conf.get("conn_timeout", 0.5))
     self.node_timeout = float(conf.get("node_timeout", 10))
     self.sync_method = getattr(self, conf.get("sync_method") or "rsync")
     self.network_chunk_size = int(conf.get("network_chunk_size", 65536))
     self.headers = {"Content-Length": "0", "user-agent": "object-replicator %s" % os.getpid()}
     self.rsync_error_log_line_length = int(conf.get("rsync_error_log_line_length", 0))
     self.handoffs_first = config_true_value(conf.get("handoffs_first", False))
     self.handoff_delete = config_auto_int_value(conf.get("handoff_delete", "auto"), 0)
     self._diskfile_mgr = DiskFileManager(conf, self.logger)
开发者ID:steveruckdashel,项目名称:swift,代码行数:35,代码来源:replicator.py

示例5: __init__

    def __init__(self, conf, logger=None):
        # location/directory of the metadata database (meta.db)
        self.location = conf.get('location', '/srv/node/sdb1/metadata/')
        # path the the actual file
        self.db_file = os.path.join(self.location, 'meta.db')
        self.logger = logger or get_logger(conf, log_route='metadata-server')
        self.root = conf.get('devices', '/srv/node')
        self.mount_check = config_true_value(conf.get('mount_check', 'true'))
        self.node_timeout = int(conf.get('node_timeout', 3))
        self.conn_timeout = float(conf.get('node_timeout', 3))
        replication_server = conf.get('replication_server', None)
        if replication_server is not None:
            replication_server = config_true_value(replication_server)
        self.replication_server = replication_server
        self.allowed_sync_hosts = [
            h.strip()
            for h in conf.get('allowed_sync_hosts', '127.0.0.1').split(',')
            if h.strip()
        ]
        self.replicator_rpc = ReplicatorRpc(
            self.root,
            DATADIR,
            MetadataBroker,
            self.mount_check,
            logger=self.logger
        )

        if config_true_value(conf.get('allow_versions', 'f')):
            self.save_headers.append('x-versions-location')

        swift.common.db.DB_PREALLOCATION = config_true_value(
            conf.get('db_preallocation', 'f'))
开发者ID:ucsc-hp-group,项目名称:swift,代码行数:32,代码来源:server.py

示例6: __init__

 def __init__(self, conf):
     self.logger = get_logger(conf, log_route='container-server')
     self.root = conf.get('devices', '/srv/node/')
     self.mount_check = config_true_value(conf.get('mount_check', 'true'))
     self.node_timeout = int(conf.get('node_timeout', 3))
     self.conn_timeout = float(conf.get('conn_timeout', 0.5))
     replication_server = conf.get('replication_server', None)
     if replication_server is None:
         allowed_methods = ['DELETE', 'PUT', 'HEAD', 'GET', 'REPLICATE',
                            'POST']
     else:
         replication_server = config_true_value(replication_server)
         if replication_server:
             allowed_methods = ['REPLICATE']
         else:
             allowed_methods = ['DELETE', 'PUT', 'HEAD', 'GET', 'POST']
     self.replication_server = replication_server
     self.allowed_methods = allowed_methods
     self.allowed_sync_hosts = [
         h.strip()
         for h in conf.get('allowed_sync_hosts', '127.0.0.1').split(',')
         if h.strip()]
     self.replicator_rpc = ReplicatorRpc(
         self.root, DATADIR, ContainerBroker, self.mount_check,
         logger=self.logger)
     self.auto_create_account_prefix = \
         conf.get('auto_create_account_prefix') or '.'
     if config_true_value(conf.get('allow_versions', 'f')):
         self.save_headers.append('x-versions-location')
     swift.common.db.DB_PREALLOCATION = \
         config_true_value(conf.get('db_preallocation', 'f'))
开发者ID:DrLeonard,项目名称:swift,代码行数:31,代码来源:server.py

示例7: __init__

 def __init__(self, conf, logger=None):
     """
     :param conf: configuration object obtained from ConfigParser
     :param logger: logging object
     """
     self.conf = conf
     self.logger = logger or get_logger(
         conf, log_route='object-reconstructor')
     self.devices_dir = conf.get('devices', '/srv/node')
     self.mount_check = config_true_value(conf.get('mount_check', 'true'))
     self.swift_dir = conf.get('swift_dir', '/etc/swift')
     self.port = int(conf.get('bind_port', 6000))
     self.concurrency = int(conf.get('concurrency', 1))
     self.stats_interval = int(conf.get('stats_interval', '300'))
     self.ring_check_interval = int(conf.get('ring_check_interval', 15))
     self.next_check = time.time() + self.ring_check_interval
     self.reclaim_age = int(conf.get('reclaim_age', 86400 * 7))
     self.partition_times = []
     self.run_pause = int(conf.get('run_pause', 30))
     self.http_timeout = int(conf.get('http_timeout', 60))
     self.lockup_timeout = int(conf.get('lockup_timeout', 1800))
     self.recon_cache_path = conf.get('recon_cache_path',
                                      '/var/cache/swift')
     self.rcache = os.path.join(self.recon_cache_path, "object.recon")
     # defaults subject to change after beta
     self.conn_timeout = float(conf.get('conn_timeout', 0.5))
     self.node_timeout = float(conf.get('node_timeout', 10))
     self.network_chunk_size = int(conf.get('network_chunk_size', 65536))
     self.disk_chunk_size = int(conf.get('disk_chunk_size', 65536))
     self.headers = {
         'Content-Length': '0',
         'user-agent': 'obj-reconstructor %s' % os.getpid()}
     self.handoffs_first = config_true_value(conf.get('handoffs_first',
                                                      False))
     self._df_router = DiskFileRouter(conf, self.logger)
开发者ID:Dynavisor,项目名称:swift,代码行数:35,代码来源:reconstructor.py

示例8: filter_factory

def filter_factory(global_conf, **local_conf):
    """
    Returns the WSGI filter for use with paste.deploy.

    Parameters in config:

    # value to prepend to the account in order to compute the trash location
    trash_prefix = ".trash-"
    # how long, in seconds, trash objects should live before expiring. Set to 0
    # to keep trash objects forever.
    trash_lifetime = 7776000  # 90 days
    # whether to block trash objects from being deleted
    block_trash_deletes = no
    # whether to enable undelete functionality by default. Administrators may
    # explicitly enable or disable per account or container via the
    # X-Undelete-Enabled header. Set this header to 'default' to resume default
    # behavior.
    enable_by_default = yes
    """
    conf = global_conf.copy()
    conf.update(local_conf)

    trash_prefix = conf.get("trash_prefix", DEFAULT_TRASH_PREFIX)
    trash_lifetime = int(conf.get("trash_lifetime", DEFAULT_TRASH_LIFETIME))
    block_trash_deletes = utils.config_true_value(
        conf.get('block_trash_deletes', 'no'))
    enable_by_default = utils.config_true_value(
        conf.get('enable_by_default', 'yes'))

    def filt(app):
        return UndeleteMiddleware(app, trash_prefix=trash_prefix,
                                  trash_lifetime=trash_lifetime,
                                  block_trash_deletes=block_trash_deletes,
                                  enable_by_default=enable_by_default)
    return filt
开发者ID:caiobrentano,项目名称:swift_undelete,代码行数:35,代码来源:middleware.py

示例9: __init__

 def __init__(self, conf, logger=None):
     """
     :param conf: configuration object obtained from ConfigParser
     :param logger: logging object
     """
     self.conf = conf
     self.logger = logger or get_logger(conf, log_route="object-reconstructor")
     self.devices_dir = conf.get("devices", "/srv/node")
     self.mount_check = config_true_value(conf.get("mount_check", "true"))
     self.swift_dir = conf.get("swift_dir", "/etc/swift")
     self.bind_ip = conf.get("bind_ip", "0.0.0.0")
     self.servers_per_port = int(conf.get("servers_per_port", "0") or 0)
     self.port = None if self.servers_per_port else int(conf.get("bind_port", 6000))
     self.concurrency = int(conf.get("concurrency", 1))
     self.stats_interval = int(conf.get("stats_interval", "300"))
     self.ring_check_interval = int(conf.get("ring_check_interval", 15))
     self.next_check = time.time() + self.ring_check_interval
     self.reclaim_age = int(conf.get("reclaim_age", 86400 * 7))
     self.partition_times = []
     self.interval = int(conf.get("interval") or conf.get("run_pause") or 30)
     self.http_timeout = int(conf.get("http_timeout", 60))
     self.lockup_timeout = int(conf.get("lockup_timeout", 1800))
     self.recon_cache_path = conf.get("recon_cache_path", "/var/cache/swift")
     self.rcache = os.path.join(self.recon_cache_path, "object.recon")
     # defaults subject to change after beta
     self.conn_timeout = float(conf.get("conn_timeout", 0.5))
     self.node_timeout = float(conf.get("node_timeout", 10))
     self.network_chunk_size = int(conf.get("network_chunk_size", 65536))
     self.disk_chunk_size = int(conf.get("disk_chunk_size", 65536))
     self.headers = {"Content-Length": "0", "user-agent": "obj-reconstructor %s" % os.getpid()}
     self.handoffs_first = config_true_value(conf.get("handoffs_first", False))
     self._df_router = DiskFileRouter(conf, self.logger)
开发者ID:helen5haha,项目名称:swift,代码行数:32,代码来源:reconstructor.py

示例10: __init__

 def __init__(self, conf):
     self.conf = conf
     self.logger = get_logger(conf, log_route='container-updater')
     self.devices = conf.get('devices', '/srv/node')
     self.mount_check = config_true_value(conf.get('mount_check', 'true'))
     self.swift_dir = conf.get('swift_dir', '/etc/swift')
     self.interval = int(conf.get('interval', 300))
     self.account_ring = None
     self.concurrency = int(conf.get('concurrency', 4))
     self.slowdown = float(conf.get('slowdown', 0.01))
     self.node_timeout = float(conf.get('node_timeout', 3))
     self.conn_timeout = float(conf.get('conn_timeout', 0.5))
     self.no_changes = 0
     self.successes = 0
     self.failures = 0
     self.account_suppressions = {}
     self.account_suppression_time = \
         float(conf.get('account_suppression_time', 60))
     self.new_account_suppressions = None
     swift.common.db.DB_PREALLOCATION = \
         config_true_value(conf.get('db_preallocation', 'f'))
     self.recon_cache_path = conf.get('recon_cache_path',
                                      '/var/cache/swift')
     self.rcache = os.path.join(self.recon_cache_path, "container.recon")
     self.user_agent = 'container-updater %s' % os.getpid()
开发者ID:ISCAS-VDI,项目名称:swift-base,代码行数:25,代码来源:updater.py

示例11: __init__

 def __init__(self, conf, logger=None):
     """
     :param conf: configuration object obtained from ConfigParser
     :param logger: logging object
     """
     self.conf = conf
     self.logger = logger or get_logger(conf, log_route='object-replicator')
     self.devices_dir = conf.get('devices', '/srv/node')
     self.mount_check = config_true_value(conf.get('mount_check', 'true'))
     self.swift_dir = conf.get('swift_dir', '/etc/swift')
     self.bind_ip = conf.get('bind_ip', '0.0.0.0')
     self.servers_per_port = int(conf.get('servers_per_port', '0') or 0)
     self.port = None if self.servers_per_port else \
         int(conf.get('bind_port', 6000))
     self.concurrency = int(conf.get('concurrency', 1))
     self.stats_interval = int(conf.get('stats_interval', '300'))
     self.ring_check_interval = int(conf.get('ring_check_interval', 15))
     self.next_check = time.time() + self.ring_check_interval
     self.reclaim_age = int(conf.get('reclaim_age', 86400 * 7))
     self.partition_times = []
     self.interval = int(conf.get('interval') or
                         conf.get('run_pause') or 30)
     self.rsync_timeout = int(conf.get('rsync_timeout', 900))
     self.rsync_io_timeout = conf.get('rsync_io_timeout', '30')
     self.rsync_bwlimit = conf.get('rsync_bwlimit', '0')
     self.rsync_compress = config_true_value(
         conf.get('rsync_compress', 'no'))
     self.rsync_module = conf.get('rsync_module', '').rstrip('/')
     if not self.rsync_module:
         self.rsync_module = '{replication_ip}::object'
         if config_true_value(conf.get('vm_test_mode', 'no')):
             self.logger.warn('Option object-replicator/vm_test_mode is '
                              'deprecated and will be removed in a future '
                              'version. Update your configuration to use '
                              'option object-replicator/rsync_module.')
             self.rsync_module += '{replication_port}'
     self.http_timeout = int(conf.get('http_timeout', 60))
     self.lockup_timeout = int(conf.get('lockup_timeout', 1800))
     self.recon_cache_path = conf.get('recon_cache_path',
                                      '/var/cache/swift')
     self.rcache = os.path.join(self.recon_cache_path, "object.recon")
     self.conn_timeout = float(conf.get('conn_timeout', 0.5))
     self.node_timeout = float(conf.get('node_timeout', 10))
     self.sync_method = getattr(self, conf.get('sync_method') or 'rsync')
     self.network_chunk_size = int(conf.get('network_chunk_size', 65536))
     self.default_headers = {
         'Content-Length': '0',
         'user-agent': 'object-replicator %s' % os.getpid()}
     self.rsync_error_log_line_length = \
         int(conf.get('rsync_error_log_line_length', 0))
     self.handoffs_first = config_true_value(conf.get('handoffs_first',
                                                      False))
     self.handoff_delete = config_auto_int_value(
         conf.get('handoff_delete', 'auto'), 0)
     if any((self.handoff_delete, self.handoffs_first)):
         self.logger.warn('Handoff only mode is not intended for normal '
                          'operation, please disable handoffs_first and '
                          'handoff_delete before the next '
                          'normal rebalance')
     self._diskfile_mgr = DiskFileManager(conf, self.logger)
开发者ID:heemanshu,项目名称:swift_liberty,代码行数:60,代码来源:replicator.py

示例12: __init__

 def __init__(self, conf, logger=None):
     self.conf = conf
     self.logger = logger or get_logger(conf, log_route='replicator')
     self.root = conf.get('devices', '/srv/node')
     self.mount_check = config_true_value(conf.get('mount_check', 'true'))
     self.port = int(conf.get('bind_port', self.default_port))
     concurrency = int(conf.get('concurrency', 8))
     self.cpool = GreenPool(size=concurrency)
     swift_dir = conf.get('swift_dir', '/etc/swift')
     self.ring = ring.Ring(swift_dir, ring_name=self.server_type)
     self._local_device_ids = set()
     self.per_diff = int(conf.get('per_diff', 1000))
     self.max_diffs = int(conf.get('max_diffs') or 100)
     self.interval = int(conf.get('interval') or
                         conf.get('run_pause') or 30)
     self.vm_test_mode = config_true_value(conf.get('vm_test_mode', 'no'))
     self.node_timeout = int(conf.get('node_timeout', 10))
     self.conn_timeout = float(conf.get('conn_timeout', 0.5))
     self.reclaim_age = float(conf.get('reclaim_age', 86400 * 7))
     swift.common.db.DB_PREALLOCATION = \
         config_true_value(conf.get('db_preallocation', 'f'))
     self._zero_stats()
     self.recon_cache_path = conf.get('recon_cache_path',
                                      '/var/cache/swift')
     self.recon_replicator = '%s.recon' % self.server_type
     self.rcache = os.path.join(self.recon_cache_path,
                                self.recon_replicator)
     self.extract_device_re = re.compile('%s%s([^%s]+)' % (
         self.root, os.path.sep, os.path.sep))
开发者ID:anishnarang,项目名称:gswift,代码行数:29,代码来源:db_replicator.py

示例13: filter_factory

def filter_factory(global_conf, **local_config):
    conf = global_conf.copy()
    conf.update(local_config)

    ns = conf.get('sds_namespace')
    acct = conf.get('sds_default_account')
    proxy = conf.get('sds_proxy_url')

    if ns is None:
        raise ConfigurationException('No OIO-SDS namespace configured')
    if acct is None:
        raise ConfigurationException('No OIO-SDS account configured')
    if proxy is None:
        raise ConfigurationException('No OIO-SDS proxy URL configured')

    strip_v1 = config_true_value(local_config.pop('strip_v1', False))
    account_first = config_true_value(local_config.pop('account_first', False))
    skip_metadata = config_true_value(local_config.pop('skip_metadata', False))

    def factory(app):
        return HashedContainerMiddleware(app, ns, acct, proxy,
                                         strip_v1=strip_v1,
                                         account_first=account_first,
                                         skip_metadata=skip_metadata,
                                         **local_config)
    return factory
开发者ID:jfsmig,项目名称:oio-swift,代码行数:26,代码来源:hashedcontainer.py

示例14: __init__

 def __init__(self, conf, logger=None):
     self.conf = conf
     self.logger = logger or get_logger(conf, log_route='account-reaper')
     self.devices = conf.get('devices', '/srv/node')
     self.mount_check = config_true_value(conf.get('mount_check', 'true'))
     self.interval = int(conf.get('interval', 3600))
     self.swift_dir = conf.get('swift_dir', '/etc/swift')
     self.account_ring = None
     self.container_ring = None
     self.object_ring = None
     self.node_timeout = float(conf.get('node_timeout', 10))
     self.conn_timeout = float(conf.get('conn_timeout', 0.5))
     self.myips = whataremyips(conf.get('bind_ip', '0.0.0.0'))
     self.bind_port = int(conf.get('bind_port', 6202))
     self.concurrency = int(conf.get('concurrency', 25))
     self.container_concurrency = self.object_concurrency = \
         sqrt(self.concurrency)
     self.container_pool = GreenPool(size=self.container_concurrency)
     swift.common.db.DB_PREALLOCATION = \
         config_true_value(conf.get('db_preallocation', 'f'))
     self.delay_reaping = int(conf.get('delay_reaping') or 0)
     reap_warn_after = float(conf.get('reap_warn_after') or 86400 * 30)
     self.reap_not_done_after = reap_warn_after + self.delay_reaping
     self.start_time = time()
     self.reset_stats()
开发者ID:jgmerritt,项目名称:swift,代码行数:25,代码来源:reaper.py

示例15: __init__

 def __init__(self, idx, name='', is_default=False, is_deprecated=False,
              object_ring=None):
     try:
         self.idx = int(idx)
     except ValueError:
         raise PolicyError('Invalid index', idx)
     if self.idx < 0:
         raise PolicyError('Invalid index', idx)
     if not name:
         raise PolicyError('Invalid name %r' % name, idx)
     # this is defensively restrictive, but could be expanded in the future
     if not all(c in VALID_CHARS for c in name):
         raise PolicyError('Names are used as HTTP headers, and can not '
                           'reliably contain any characters not in %r. '
                           'Invalid name %r' % (VALID_CHARS, name))
     if name.upper() == LEGACY_POLICY_NAME.upper() and self.idx != 0:
         msg = 'The name %s is reserved for policy index 0. ' \
             'Invalid name %r' % (LEGACY_POLICY_NAME, name)
         raise PolicyError(msg, idx)
     self.name = name
     self.is_deprecated = config_true_value(is_deprecated)
     self.is_default = config_true_value(is_default)
     if self.is_deprecated and self.is_default:
         raise PolicyError('Deprecated policy can not be default.  '
                           'Invalid config', self.idx)
     self.ring_name = _get_policy_string('object', self.idx)
     self.object_ring = object_ring
开发者ID:701,项目名称:swift,代码行数:27,代码来源:storage_policy.py


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