From 5817f00005d2c1761499c3d6e5e0d428ef238c77 Mon Sep 17 00:00:00 2001 From: Cheng Li Date: Sun, 10 Jul 2016 20:33:05 +0800 Subject: [PATCH] make 0 be avaiable value of options value 0 is regard as not available by swift-ring-builder $ swift-ring-builder testring add --region 0 --zone 1 --ip 127.0.0.2 --port 6000 --device sdb --weight 100 Required argument -r/--region not specified. The on-disk ring builder is unchanged. this patch is to make value 0 available. Change-Id: Id941d44d8dbfe438bf921ed905908b838c88a644 Closes-bug: #1547137 --- swift/common/ring/utils.py | 2 +- test/unit/common/ring/test_utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/swift/common/ring/utils.py b/swift/common/ring/utils.py index 830dbfef22..8dd2484fe6 100644 --- a/swift/common/ring/utils.py +++ b/swift/common/ring/utils.py @@ -616,7 +616,7 @@ def build_dev_from_opts(opts): ['port', '-p', '--port'], ['device', '-d', '--device'], ['weight', '-w', '--weight']): - if not getattr(opts, attribute, None): + if getattr(opts, attribute, None) is None: raise ValueError('Required argument %s/%s not specified.' % (shortopt, longopt)) diff --git a/test/unit/common/ring/test_utils.py b/test/unit/common/ring/test_utils.py index fda4cdfdcd..7daa7fb93a 100644 --- a/test/unit/common/ring/test_utils.py +++ b/test/unit/common/ring/test_utils.py @@ -579,7 +579,7 @@ class TestUtils(unittest.TestCase): def test_build_dev_from_opts(self): argv = \ - ["--region", "2", "--zone", "3", + ["--region", "0", "--zone", "3", "--ip", "test.test.com", "--port", "6200", "--replication-ip", "r.test.com", @@ -588,7 +588,7 @@ class TestUtils(unittest.TestCase): "--meta", "some meta data", "--weight", "3.14159265359"] expected = { - 'region': 2, + 'region': 0, 'zone': 3, 'ip': "test.test.com", 'port': 6200,