From 92d5af3b749942dd32ad850275dac3cff4f7127b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 4 Mar 2020 11:05:20 -0600 Subject: [PATCH] mgr/orch: PlacementSpec: allow 'count:123' Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator/_interface.py | 8 ++++++++ src/pybind/mgr/tests/test_orchestrator.py | 1 + 2 files changed, 9 insertions(+) diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index e1fd1af933915..8d83c9acbdf62 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1360,6 +1360,14 @@ class PlacementSpec(object): strings = strings[1:] except ValueError: pass + for s in strings: + if s.startswith('count:'): + try: + count = int(s[6:]) + strings.remove(s) + break + except ValueError: + pass all_hosts = False if '*' in strings: diff --git a/src/pybind/mgr/tests/test_orchestrator.py b/src/pybind/mgr/tests/test_orchestrator.py index be4f89a777145..7bf176980f5d0 100644 --- a/src/pybind/mgr/tests/test_orchestrator.py +++ b/src/pybind/mgr/tests/test_orchestrator.py @@ -34,6 +34,7 @@ def test_parse_host_placement_specs(test_input, expected, require_network): "test_input,expected", [ ('', "PlacementSpec()"), + ("count:2", "PlacementSpec(count:2)"), ("3", "PlacementSpec(count:3)"), ("host1 host2", "PlacementSpec(host1,host2)"), ("host1=a host2=b", "PlacementSpec(host1=a,host2=b)"), -- 2.39.5