From: Sebastian Wagner Date: Fri, 13 Dec 2019 16:29:35 +0000 (+0100) Subject: mgr/orchestrator: Add __str__ to HostSpec X-Git-Tag: v15.1.0~450^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=074adad5c49479d8fb8e163a0e429baae52cce8c;p=ceph.git mgr/orchestrator: Add __str__ to HostSpec As requested by mypy Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/ansible/module.py b/src/pybind/mgr/ansible/module.py index eaf93b710b3..89df99401d2 100644 --- a/src/pybind/mgr/ansible/module.py +++ b/src/pybind/mgr/ansible/module.py @@ -510,7 +510,7 @@ class Module(MgrModule, orchestrator.Orchestrator): InventoryGroup("rgws", self.ar_client).update(hosts) # Limit playbook execution to certain hosts - limited = ",".join(hosts) + limited = ",".join(str(host) for host in hosts) # Add the settings for this service extravars = {k:v for (k,v) in spec.__dict__.items() if k.startswith('rgw_')} diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 27d3b8f3d35..169e8e2585f 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -34,7 +34,15 @@ except ImportError: logger = logging.getLogger(__name__) -HostSpec = namedtuple('HostSpec', ['hostname', 'network', 'name']) +class HostSpec(namedtuple('HostSpec', ['hostname', 'network', 'name'])): + def __str__(self): + res = '' + res += self.hostname + if self.network: + res += ':' + self.network + if self.name: + res += '=' + self.name + return res def parse_host_specs(host, require_network=True): diff --git a/src/pybind/mgr/tests/test_orchestrator.py b/src/pybind/mgr/tests/test_orchestrator.py index 584c407cb4c..2614cf5f5b2 100644 --- a/src/pybind/mgr/tests/test_orchestrator.py +++ b/src/pybind/mgr/tests/test_orchestrator.py @@ -27,6 +27,7 @@ from orchestrator import parse_host_specs def test_parse_host_specs(test_input, expected, require_network): ret = parse_host_specs(test_input, require_network=require_network) assert ret == expected + assert str(ret) == test_input @pytest.mark.parametrize("test_input", # wrong subnet