Merge "swift-ring-builder can't select id=0"
This commit is contained in:
commit
e15be1e6ec
@ -540,10 +540,12 @@ def validate_args(argvish):
|
||||
format or not.
|
||||
"""
|
||||
opts, args = parse_args(argvish)
|
||||
new_cmd_format = opts.id or opts.region or opts.zone or \
|
||||
opts.ip or opts.port or \
|
||||
# id can be 0 (swift starts generating id from 0),
|
||||
# also zone, region and weight can be set to zero.
|
||||
new_cmd_format = opts.id is not None or opts.region is not None or \
|
||||
opts.zone is not None or opts.ip or opts.port or \
|
||||
opts.replication_ip or opts.replication_port or \
|
||||
opts.device or opts.weight or opts.meta
|
||||
opts.device or opts.weight is not None or opts.meta
|
||||
return (new_cmd_format, opts, args)
|
||||
|
||||
|
||||
|
@ -468,6 +468,7 @@ class TestUtils(unittest.TestCase):
|
||||
self.assertEqual(opts.change_device, "sdb3")
|
||||
self.assertEqual(opts.change_meta, "some meta data for change")
|
||||
|
||||
def test_validate_args_new_cmd_format(self):
|
||||
argv = \
|
||||
["--id", "0", "--region", "0", "--zone", "0",
|
||||
"--ip", "",
|
||||
@ -484,17 +485,17 @@ class TestUtils(unittest.TestCase):
|
||||
"--change-device", "",
|
||||
"--change-meta", ""]
|
||||
new_cmd_format, opts, args = validate_args(argv)
|
||||
self.assertFalse(new_cmd_format)
|
||||
self.assertTrue(new_cmd_format)
|
||||
|
||||
argv = \
|
||||
["--id", "0", "--region", "0", "--zone", "0",
|
||||
["--id", None, "--region", None, "--zone", None,
|
||||
"--ip", "",
|
||||
"--port", "0",
|
||||
"--replication-ip", "",
|
||||
"--replication-port", "0",
|
||||
"--device", "",
|
||||
"--meta", "",
|
||||
"--weight", "0",
|
||||
"--weight", None,
|
||||
"--change-ip", "change.test.test.com",
|
||||
"--change-port", "6001",
|
||||
"--change-replication-ip", "change.r.test.com",
|
||||
@ -504,6 +505,23 @@ class TestUtils(unittest.TestCase):
|
||||
new_cmd_format, opts, args = validate_args(argv)
|
||||
self.assertFalse(new_cmd_format)
|
||||
|
||||
argv = \
|
||||
["--id", "0"]
|
||||
new_cmd_format, opts, args = validate_args(argv)
|
||||
self.assertTrue(new_cmd_format)
|
||||
argv = \
|
||||
["--region", "0"]
|
||||
new_cmd_format, opts, args = validate_args(argv)
|
||||
self.assertTrue(new_cmd_format)
|
||||
argv = \
|
||||
["--zone", "0"]
|
||||
new_cmd_format, opts, args = validate_args(argv)
|
||||
self.assertTrue(new_cmd_format)
|
||||
argv = \
|
||||
["--weight", "0"]
|
||||
new_cmd_format, opts, args = validate_args(argv)
|
||||
self.assertTrue(new_cmd_format)
|
||||
|
||||
def test_parse_args(self):
|
||||
argv = \
|
||||
["--id", "1", "--region", "2", "--zone", "3",
|
||||
|
Loading…
Reference in New Issue
Block a user