diff --git a/bin/swift-object-reconstructor b/bin/swift-object-reconstructor index ee4c5d6..2226376 100755 --- a/bin/swift-object-reconstructor +++ b/bin/swift-object-reconstructor @@ -27,5 +27,8 @@ if __name__ == '__main__': parser.add_option('-p', '--partitions', help='Reconstruct only given partitions. ' 'Comma-separated list') + parser.add_option('-P', '--policies', + help='Reconstruct only given policies. ' + 'Comma-separated list of names.') conf_file, options = parse_options(parser=parser, once=True) run_daemon(ObjectReconstructor, conf_file, **options) diff --git a/swift/obj/reconstructor.py b/swift/obj/reconstructor.py index 06e2a97..9860763 100644 --- a/swift/obj/reconstructor.py +++ b/swift/obj/reconstructor.py @@ -793,16 +793,20 @@ class ObjectReconstructor(Daemon): return jobs def collect_parts(self, override_devices=None, - override_partitions=None): + override_partitions=None, + override_policies=None): """ Helper for yielding partitions in the top level reconstructor """ override_devices = override_devices or [] override_partitions = override_partitions or [] + override_policies = override_policies or [] ips = whataremyips(self.bind_ip) for policy in POLICIES: if policy.policy_type != EC_POLICY: continue + if override_policies and policy.name not in override_policies: + continue self._diskfile_mgr = self._df_router[policy] self.load_object_ring(policy) data_dir = get_data_dir(policy) @@ -949,9 +953,11 @@ class ObjectReconstructor(Daemon): override_devices = list_from_csv(kwargs.get('devices')) override_partitions = [int(p) for p in list_from_csv(kwargs.get('partitions'))] + override_policies = list_from_csv(kwargs.get('policies')) self.reconstruct( override_devices=override_devices, - override_partitions=override_partitions) + override_partitions=override_partitions, + override_policies=override_policies) total = (time.time() - start) / 60 self.logger.info( _("Object reconstruction complete (once). (%.02f minutes)"), total)