This is Swift 2.3.0
swift-ring-builder 1.3
When listing multiple devices and their weights on the same command line, it seems to misparse the intent. set_info works fine, but set_weight does not.
-[/etc/swift:$]- swift-ring-builder test.builder set_weight d0 4000 d1 4000 d2 4000 d3 4000 d4 4000 d5 4000 d6 0 d7 4000
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 4000.0
Matched more than one device:
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_""
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_""
Are you sure you want to update the weight for these 2 devices? (y/N) y
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 4000.0
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_"" weight set to 4000.0
Matched more than one device:
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_""
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_""
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_""
Are you sure you want to update the weight for these 3 devices? (y/N) y
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 4000.0
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_"" weight set to 4000.0
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_"" weight set to 4000.0
Matched more than one device:
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_""
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_""
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_""
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_""
Are you sure you want to update the weight for these 4 devices? (y/N) y
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 4000.0
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_"" weight set to 4000.0
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_"" weight set to 4000.0
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_"" weight set to 4000.0
Matched more than one device:
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_""
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_""
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_""
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_""
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_""
Are you sure you want to update the weight for these 5 devices? (y/N) y
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 4000.0
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_"" weight set to 4000.0
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_"" weight set to 4000.0
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_"" weight set to 4000.0
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_"" weight set to 4000.0
Matched more than one device:
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_""
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_""
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_""
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_""
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_""
d5r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F02_""
Are you sure you want to update the weight for these 6 devices? (y/N) y
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 4000.0
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_"" weight set to 4000.0
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_"" weight set to 4000.0
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_"" weight set to 4000.0
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_"" weight set to 4000.0
d5r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F02_"" weight set to 4000.0
Matched more than one device:
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_""
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_""
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_""
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_""
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_""
d5r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F02_""
d6r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F03_""
Are you sure you want to update the weight for these 7 devices? (y/N) y
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 0.0
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_"" weight set to 0.0
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_"" weight set to 0.0
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_"" weight set to 0.0
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_"" weight set to 0.0
d5r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F02_"" weight set to 0.0
d6r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F03_"" weight set to 0.0
Matched more than one device:
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_""
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_""
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_""
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_""
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_""
d5r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F02_""
d6r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F03_""
d7r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F04_""
Are you sure you want to update the weight for these 8 devices? (y/N) y
d0r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F01_"" weight set to 4000.0
d1r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F02_"" weight set to 4000.0
d2r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F03_"" weight set to 4000.0
d3r1z1-[2001:db8:f1f6::806:1]:6000R[2001:db8:f1f6::806:1]:6000/F04_"" weight set to 4000.0
d4r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F01_"" weight set to 4000.0
d5r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F02_"" weight set to 4000.0
d6r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F03_"" weight set to 4000.0
d7r1z1-[2001:db8:f1f6::809:1]:6000R[2001:db8:f1f6::809:1]:6000/F04_"" weight set to 4000.0
So if you've got some perl that's trying to update a bunch of (device, weight) pairs explicitly this bulk syntax can definitely be useful.
FWIW, the obvious `devs =` instead of `devs.extend` seemed to do the right thing [1]
The attached is just a failing unittest - it'd be nice to have a couple of tests like that to cover the behaviors we care about when the "devstr" matches multiple devices or whatever...
1. https:/ /github. com/openstack/ swift/blob/ b4c1517ddd0d57f 556721caf587c11 3e4abc0498/ swift/cli/ ringbuilder. py#L230