relinker: Allow multiple policies to be specified
Change-Id: I6805f0466f0200a58abe79cbb8ed3e6d2fd82d62
This commit is contained in:
parent
31e27a168a
commit
3a41cbe670
@ -463,9 +463,10 @@ def main(args):
|
||||
'Path to config file with [object-relinker] section'))
|
||||
parser.add_argument('--swift-dir', default=None,
|
||||
dest='swift_dir', help='Path to swift directory')
|
||||
parser.add_argument('--policy', default=None, dest='policy',
|
||||
type=policy,
|
||||
help='Policy to relink (default: all)')
|
||||
parser.add_argument(
|
||||
'--policy', default=[], dest='policies',
|
||||
action='append', type=policy,
|
||||
help='Policy to relink; may specify multiple (default: all)')
|
||||
parser.add_argument('--devices', default=None,
|
||||
dest='devices', help='Path to swift device directory')
|
||||
parser.add_argument('--user', default=None, dest='user',
|
||||
@ -516,7 +517,7 @@ def main(args):
|
||||
'files_per_second': (
|
||||
args.files_per_second if args.files_per_second is not None
|
||||
else non_negative_float(conf.get('files_per_second', '0'))),
|
||||
'policies': POLICIES if args.policy is None else [args.policy],
|
||||
'policies': set(args.policies) or POLICIES,
|
||||
'partitions': set(args.partitions),
|
||||
})
|
||||
|
||||
|
@ -349,7 +349,7 @@ class TestRelinker(unittest.TestCase):
|
||||
'files_per_second': 2.2,
|
||||
'log_level': 'DEBUG',
|
||||
'log_name': 'test-relinker',
|
||||
'policies': [POLICIES[1]],
|
||||
'policies': {POLICIES[1]},
|
||||
'partitions': {123, 456},
|
||||
}, mock.ANY, device='sdx')
|
||||
|
||||
@ -372,16 +372,23 @@ class TestRelinker(unittest.TestCase):
|
||||
|
||||
with mock.patch('swift.cli.relinker.relink') as mock_relink, \
|
||||
mock.patch('logging.basicConfig') as mock_logging_config:
|
||||
relinker.main(['relink', '--device', 'sdx', '--debug',
|
||||
'--swift-dir', 'cli-dir', '--devices', 'cli-devs',
|
||||
'--skip-mount-check'])
|
||||
relinker.main([
|
||||
'relink', '--debug',
|
||||
'--swift-dir', 'cli-dir',
|
||||
'--devices', 'cli-devs',
|
||||
'--device', 'sdx',
|
||||
'--skip-mount-check',
|
||||
'--policy', '0',
|
||||
'--policy', '1',
|
||||
'--policy', '0',
|
||||
])
|
||||
mock_relink.assert_called_once_with({
|
||||
'swift_dir': 'cli-dir',
|
||||
'devices': 'cli-devs',
|
||||
'mount_check': False,
|
||||
'files_per_second': 0.0,
|
||||
'log_level': 'DEBUG',
|
||||
'policies': POLICIES,
|
||||
'policies': set(POLICIES),
|
||||
'partitions': set(),
|
||||
}, mock.ANY, device='sdx')
|
||||
# --debug is now effective
|
||||
|
Loading…
x
Reference in New Issue
Block a user