From: Sage Weil Date: Wed, 4 Mar 2020 17:03:06 +0000 (-0600) Subject: mgr/orch: PlacementSpec: may pretty_str() match input X-Git-Tag: v15.1.1~74^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cf0df5469aea150ff26bf84f00b45417a3ce5450;p=ceph.git mgr/orch: PlacementSpec: may pretty_str() match input Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 88fadadf7eb65..e1fd1af933915 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1275,13 +1275,13 @@ class PlacementSpec(object): def pretty_str(self): kv = [] if self.count: - kv.append('count=%d' % self.count) + kv.append('count:%d' % self.count) if self.label: - kv.append('label=%s' % self.label) + kv.append('label:%s' % self.label) if self.hosts: - kv.append('hosts=%s' % ','.join([str(h) for h in self.hosts])) + kv.append('%s' % ','.join([str(h) for h in self.hosts])) if self.all_hosts: - kv.append('all=true') + kv.append('all:true') return ' '.join(kv) def __repr__(self): diff --git a/src/pybind/mgr/tests/test_orchestrator.py b/src/pybind/mgr/tests/test_orchestrator.py index 08a043b814aa3..be4f89a777145 100644 --- a/src/pybind/mgr/tests/test_orchestrator.py +++ b/src/pybind/mgr/tests/test_orchestrator.py @@ -34,15 +34,15 @@ def test_parse_host_placement_specs(test_input, expected, require_network): "test_input,expected", [ ('', "PlacementSpec()"), - ("3", "PlacementSpec(count=3)"), - ("host1 host2", "PlacementSpec(hosts=host1,host2)"), - ("host1=a host2=b", "PlacementSpec(hosts=host1=a,host2=b)"), - ("host1:1.2.3.4=a host2:1.2.3.5=b", "PlacementSpec(hosts=host1:1.2.3.4=a,host2:1.2.3.5=b)"), - ('2 host1 host2', "PlacementSpec(count=2 hosts=host1,host2)"), - ('label:foo', "PlacementSpec(label=foo)"), - ('3 label:foo', "PlacementSpec(count=3 label=foo)"), - (['*'], 'PlacementSpec(all=true)'), - ('*', 'PlacementSpec(all=true)'), + ("3", "PlacementSpec(count:3)"), + ("host1 host2", "PlacementSpec(host1,host2)"), + ("host1=a host2=b", "PlacementSpec(host1=a,host2=b)"), + ("host1:1.2.3.4=a host2:1.2.3.5=b", "PlacementSpec(host1:1.2.3.4=a,host2:1.2.3.5=b)"), + ('2 host1 host2', "PlacementSpec(count:2 host1,host2)"), + ('label:foo', "PlacementSpec(label:foo)"), + ('3 label:foo', "PlacementSpec(count:3 label:foo)"), + (['*'], 'PlacementSpec(all:true)'), + ('*', 'PlacementSpec(all:true)'), ]) def test_parse_placement_specs(test_input, expected): ret = PlacementSpec.from_strings(test_input)