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


Python utils.audit_location_generator函数代码示例

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


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

示例1: run_forever

 def run_forever(self):  # pragma: no cover
     """Run the container audit until stopped."""
     reported = time.time()
     time.sleep(random() * self.interval)
     while True:
         begin = time.time()
         all_locs = audit_location_generator(self.devices,
                                             container_server.DATADIR,
                                             mount_check=self.mount_check,
                                             logger=self.logger)
         for path, device, partition in all_locs:
             self.container_audit(path)
             if time.time() - reported >= 3600:  # once an hour
                 self.logger.info(
                     _('Since %(time)s: Container audits: %(pass)s passed '
                       'audit, %(fail)s failed audit'),
                     {'time': time.ctime(reported),
                      'pass': self.container_passes,
                      'fail': self.container_failures})
                 reported = time.time()
                 self.container_passes = 0
                 self.container_failures = 0
         elapsed = time.time() - begin
         if elapsed < self.interval:
             time.sleep(self.interval - elapsed)
开发者ID:edwardt,项目名称:swift,代码行数:25,代码来源:auditor.py

示例2: _one_audit_pass

 def _one_audit_pass(self, reported):
     all_locs = audit_location_generator(
         self.devices, account_server.DATADIR, mount_check=self.mount_check, logger=self.logger
     )
     for path, device, partition in all_locs:
         self.account_audit(path)
         if time.time() - reported >= 3600:  # once an hour
             self.logger.info(
                 _("Since %(time)s: Account audits: " "%(passed)s passed audit," "%(failed)s failed audit"),
                 {"time": time.ctime(reported), "passed": self.account_passes, "failed": self.account_failures},
             )
             self.account_audit(path)
             dump_recon_cache(
                 {
                     "account_audits_since": reported,
                     "account_audits_passed": self.account_passes,
                     "account_audits_failed": self.account_failures,
                 },
                 self.rcache,
                 self.logger,
             )
             reported = time.time()
             self.account_passes = 0
             self.account_failures = 0
     return reported
开发者ID:nitishb,项目名称:swift,代码行数:25,代码来源:auditor.py

示例3: _one_audit_pass

 def _one_audit_pass(self, reported):
     all_locs = audit_location_generator(self.devices,
                                         account_server.DATADIR, '.db',
                                         mount_check=self.mount_check,
                                         logger=self.logger)
     for path, device, partition in all_locs:
         self.account_audit(path)
         if time.time() - reported >= 3600:  # once an hour
             self.logger.info(_('Since %(time)s: Account audits: '
                                '%(passed)s passed audit,'
                                '%(failed)s failed audit'),
                              {'time': time.ctime(reported),
                               'passed': self.account_passes,
                               'failed': self.account_failures})
             dump_recon_cache({'account_audits_since': reported,
                               'account_audits_passed': self.account_passes,
                               'account_audits_failed':
                               self.account_failures},
                              self.rcache, self.logger)
             reported = time.time()
             self.account_passes = 0
             self.account_failures = 0
         self.accounts_running_time = ratelimit_sleep(
             self.accounts_running_time, self.max_accounts_per_second)
     return reported
开发者ID:10389030,项目名称:swift,代码行数:25,代码来源:auditor.py

示例4: run_forever

 def run_forever(self, *args, **kwargs):
     """Run the container audit until stopped."""
     reported = time.time()
     time.sleep(random() * self.interval)
     while True:
         self.logger.info(_('Begin container audit pass.'))
         begin = time.time()
         try:
             all_locs = audit_location_generator(self.devices,
                 container_server.DATADIR, mount_check=self.mount_check,
                 logger=self.logger)
             for path, device, partition in all_locs:
                 self.container_audit(path)
                 if time.time() - reported >= 3600:  # once an hour
                     self.logger.info(
                         _('Since %(time)s: Container audits: %(pass)s '
                           'passed audit, %(fail)s failed audit'),
                         {'time': time.ctime(reported),
                          'pass': self.container_passes,
                          'fail': self.container_failures})
                     reported = time.time()
                     self.container_passes = 0
                     self.container_failures = 0
         except (Exception, Timeout):
             self.logger.exception(_('ERROR auditing'))
         elapsed = time.time() - begin
         if elapsed < self.interval:
             time.sleep(self.interval - elapsed)
         self.logger.info(
             _('Container audit pass completed: %.02fs'), elapsed)
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:30,代码来源:auditor.py

示例5: audit_all_objects

 def audit_all_objects(self, mode='once'):
     self.logger.info(_('Begin object audit "%s" mode (%s)' %
                        (mode, self.auditor_type)))
     begin = reported = time.time()
     self.total_bytes_processed = 0
     self.total_files_processed = 0
     total_quarantines = 0
     total_errors = 0
     files_running_time = 0
     time_auditing = 0
     all_locs = audit_location_generator(self.devices,
                                         object_server.DATADIR,
                                         mount_check=self.mount_check,
                                         logger=self.logger)
     for path, device, partition in all_locs:
         loop_time = time.time()
         self.object_audit(path, device, partition)
         self.logger.timing_since('timing', loop_time)
         self.files_running_time = ratelimit_sleep(
             self.files_running_time, self.max_files_per_second)
         self.total_files_processed += 1
         now = time.time()
         if now - reported >= self.log_time:
             self.logger.info(_(
                 'Object audit (%(type)s). '
                 'Since %(start_time)s: Locally: %(passes)d passed, '
                 '%(quars)d quarantined, %(errors)d errors '
                 'files/sec: %(frate).2f , bytes/sec: %(brate).2f, '
                 'Total time: %(total).2f, Auditing time: %(audit).2f, '
                 'Rate: %(audit_rate).2f') % {
                         'type': self.auditor_type,
                         'start_time': time.ctime(reported),
                         'passes': self.passes, 'quars': self.quarantines,
                         'errors': self.errors,
                         'frate': self.passes / (now - reported),
                         'brate': self.bytes_processed / (now - reported),
                         'total': (now - begin), 'audit': time_auditing,
                         'audit_rate': time_auditing / (now - begin)})
             reported = now
             total_quarantines += self.quarantines
             total_errors += self.errors
             self.passes = 0
             self.quarantines = 0
             self.errors = 0
             self.bytes_processed = 0
         time_auditing += (now - loop_time)
     # Avoid divide by zero during very short runs
     elapsed = (time.time() - begin) or 0.000001
     self.logger.info(_(
         'Object audit (%(type)s) "%(mode)s" mode '
         'completed: %(elapsed).02fs. Total quarantined: %(quars)d, '
         'Total errors: %(errors)d, Total files/sec: %(frate).2f , '
         'Total bytes/sec: %(brate).2f, Auditing time: %(audit).2f, '
         'Rate: %(audit_rate).2f') % {
             'type': self.auditor_type, 'mode': mode, 'elapsed': elapsed,
             'quars': total_quarantines, 'errors': total_errors,
             'frate': self.total_files_processed / elapsed,
             'brate': self.total_bytes_processed / elapsed,
             'audit': time_auditing, 'audit_rate': time_auditing / elapsed})
开发者ID:bn-emailops,项目名称:swift,代码行数:59,代码来源:auditor.py

示例6: _one_crawler_pass

 def _one_crawler_pass(self):
     all_locs = audit_location_generator(self.devices,
                                         account_server.DATADIR, '.db',
                                         mount_check=self.mount_check,
                                         logger=self.logger)
     metaList = []
     for path, device, partition in all_locs:
         metaDict = self.account_crawl(path)
         if metaDict != {}:
             metaList.append(format_metadata(metaDict))
     AccountSender = Sender(self.conf)
     AccountSender.sendData(metaList, 'account_crawler', self.ip, self.port)
开发者ID:ucsc-hp-group,项目名称:swift,代码行数:12,代码来源:crawler.py

示例7: synced_containers_generator

 def synced_containers_generator(self):
     """
     Iterates over the list of synced containers
     yielding the path of the container db
     """
     all_locs = audit_location_generator(
         self.devices, SYNC_DATADIR, ".db", mount_check=self.mount_check, logger=self.logger
     )
     for path, device, partition in all_locs:
         # What we want to yield is the real path as its being used for
         # initiating a container broker. The broker would break if not
         # given the db real path, as it e.g. assumes the existence of
         # .pending in the same path
         yield self._synced_container_to_container_path(path)
开发者ID:unibg-seclab,项目名称:swift,代码行数:14,代码来源:sync_store.py

示例8: _one_audit_pass

 def _one_audit_pass(self, reported):
     all_locs = audit_location_generator(
         self.devices, container_server.DATADIR, mount_check=self.mount_check, logger=self.logger
     )
     for path, device, partition in all_locs:
         self.container_audit(path)
         if time.time() - reported >= 3600:  # once an hour
             self.logger.info(
                 _("Since %(time)s: Container audits: %(pass)s passed " "audit, %(fail)s failed audit"),
                 {"time": time.ctime(reported), "pass": self.container_passes, "fail": self.container_failures},
             )
             reported = time.time()
             self.container_passes = 0
             self.container_failures = 0
     return reported
开发者ID:stevencasey,项目名称:swift,代码行数:15,代码来源:auditor.py

示例9: run_once

 def run_once(self, *args, **kwargs):
     """
     Runs a single container sync scan.
     """
     self.logger.info(_('Begin container sync "once" mode'))
     begin = time()
     all_locs = audit_location_generator(
         self.devices, container_server.DATADIR, ".db", mount_check=self.mount_check, logger=self.logger
     )
     for path, device, partition in all_locs:
         self.container_sync(path)
         if time() - self.reported >= 3600:  # once an hour
             self.report()
     self.report()
     elapsed = time() - begin
     self.logger.info(_('Container sync "once" mode completed: %.02fs'), elapsed)
开发者ID:jettang,项目名称:icehouse,代码行数:16,代码来源:sync.py

示例10: run_forever

 def run_forever(self, *args, **kwargs):
     """
     Runs container sync scans until stopped.
     """
     sleep(random() * self.interval)
     while True:
         begin = time()
         all_locs = audit_location_generator(self.devices, DATADIR, '.db',
                                             mount_check=self.mount_check,
                                             logger=self.logger)
         for path, device, partition in all_locs:
             self.container_sync(path)
             if time() - self.reported >= 3600:  # once an hour
                 self.report()
         elapsed = time() - begin
         if elapsed < self.interval:
             sleep(self.interval - elapsed)
开发者ID:anishnarang,项目名称:gswift,代码行数:17,代码来源:sync.py

示例11: audit_all_objects

 def audit_all_objects(self, mode='once'):
     self.logger.info(_('Begin object audit "%s" mode (%s)' %
                        (mode, self.auditor_type)))
     begin = reported = time.time()
     self.total_bytes_processed = 0
     self.total_files_processed = 0
     files_running_time = 0
     all_locs = audit_location_generator(self.devices,
                                         object_server.DATADIR,
                                         mount_check=self.mount_check,
                                         logger=self.logger)
     for path, device, partition in all_locs:
         self.object_audit(path, device, partition)
         self.files_running_time = ratelimit_sleep(
             self.files_running_time, self.max_files_per_second)
         self.total_files_processed += 1
         if time.time() - reported >= self.log_time:
             self.logger.info(_(
                 'Object audit (%(type)s). '
                 'Since %(start_time)s: Locally: %(passes)d passed, '
                 '%(quars)d quarantined, %(errors)d errors '
                 'files/sec: %(frate).2f , bytes/sec: %(brate).2f') % {
                         'type': self.auditor_type,
                         'start_time': time.ctime(reported),
                         'passes': self.passes,
                         'quars': self.quarantines,
                         'errors': self.errors,
                         'frate': self.passes / (time.time() - reported),
                         'brate': self.bytes_processed /
                                  (time.time() - reported)})
             reported = time.time()
             self.passes = 0
             self.quarantines = 0
             self.errors = 0
             self.bytes_processed = 0
     elapsed = time.time() - begin
     self.logger.info(_(
             'Object audit (%(type)s) "%(mode)s" mode '
             'completed: %(elapsed).02fs. '
             'Total files/sec: %(frate).2f , '
             'Total bytes/sec: %(brate).2f ') % {
                 'type': self.auditor_type,
                 'mode': mode,
                 'elapsed': elapsed,
                 'frate': self.total_files_processed / elapsed,
                 'brate': self.total_bytes_processed / elapsed})
开发者ID:pombredanne,项目名称:swift,代码行数:46,代码来源:auditor.py

示例12: run_once

 def run_once(self, *args, **kwargs):
     """Run the account audit once."""
     self.logger.info('Begin account audit "once" mode')
     begin = reported = time.time()
     all_locs = audit_location_generator(
         self.devices, account_server.DATADIR, mount_check=self.mount_check, logger=self.logger
     )
     for path, device, partition in all_locs:
         self.account_audit(path)
         if time.time() - reported >= 3600:  # once an hour
             self.logger.info(
                 _("Since %(time)s: Account audits: " "%(passed)s passed audit, %(failed)s failed audit"),
                 {"time": time.ctime(reported), "passed": self.account_passes, "failed": self.account_failures},
             )
             reported = time.time()
             self.account_passes = 0
             self.account_failures = 0
     elapsed = time.time() - begin
     self.logger.info('Account audit "once" mode completed: %.02fs', elapsed)
开发者ID:houseurmusic,项目名称:swift,代码行数:19,代码来源:auditor.py

示例13: run_forever

 def run_forever(self, *args, **kwargs):
     """Run the account audit until stopped."""
     reported = time.time()
     time.sleep(random() * self.interval)
     while True:
         begin = time.time()
         all_locs = audit_location_generator(
             self.devices, account_server.DATADIR, mount_check=self.mount_check, logger=self.logger
         )
         for path, device, partition in all_locs:
             self.account_audit(path)
             if time.time() - reported >= 3600:  # once an hour
                 self.logger.info(
                     _("Since %(time)s: Account audits: " "%(passed)s passed audit, %(failed)s failed audit"),
                     {"time": time.ctime(reported), "passed": self.account_passes, "failed": self.account_failures},
                 )
                 reported = time.time()
                 self.account_passes = 0
                 self.account_failures = 0
         elapsed = time.time() - begin
         if elapsed < self.interval:
             time.sleep(self.interval - elapsed)
开发者ID:houseurmusic,项目名称:swift,代码行数:22,代码来源:auditor.py

示例14: relink

def relink(swift_dir='/etc/swift',
           devices='/srv/node',
           skip_mount_check=False,
           logger=logging.getLogger()):
    mount_check = not skip_mount_check
    run = False
    relinked = errors = 0
    for policy in POLICIES:
        policy.object_ring = None  # Ensure it will be reloaded
        policy.load_ring(swift_dir)
        part_power = policy.object_ring.part_power
        next_part_power = policy.object_ring.next_part_power
        if not next_part_power or next_part_power == part_power:
            continue
        logging.info('Relinking files for policy %s under %s',
                     policy.name, devices)
        run = True
        locations = audit_location_generator(
            devices,
            diskfile.get_data_dir(policy),
            mount_check=mount_check)
        for fname, _, _ in locations:
            newfname = replace_partition_in_path(fname, next_part_power)
            try:
                diskfile.relink_paths(fname, newfname, check_existing=True)
                relinked += 1
            except OSError as exc:
                errors += 1
                logger.warning("Relinking %s to %s failed: %s",
                               fname, newfname, exc)

    if not run:
        logger.warning("No policy found to increase the partition power.")
        return 2
    logging.info('Relinked %d diskfiles (%d errors)', relinked, errors)
    if errors > 0:
        return 1
    return 0
开发者ID:chenzhongtao,项目名称:swift,代码行数:38,代码来源:relinker.py

示例15: run_once

 def run_once(self, *args, **kwargs):
     """Run the container audit once."""
     self.logger.info(_('Begin container audit "once" mode'))
     begin = reported = time.time()
     all_locs = audit_location_generator(self.devices,
                                         container_server.DATADIR,
                                         mount_check=self.mount_check,
                                         logger=self.logger)
     for path, device, partition in all_locs:
         self.container_audit(path)
         if time.time() - reported >= 3600:  # once an hour
             self.logger.info(
                 _('Since %(time)s: Container audits: %(pass)s passed '
                   'audit, %(fail)s failed audit'),
                 {'time': time.ctime(reported),
                  'pass': self.container_passes,
                  'fail': self.container_failures})
             reported = time.time()
             self.container_passes = 0
             self.container_failures = 0
     elapsed = time.time() - begin
     self.logger.info(
         _('Container audit "once" mode completed: %.02fs'), elapsed)
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:23,代码来源:auditor.py


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