]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: Add __str__ to HostSpec
authorSebastian Wagner <sebastian.wagner@suse.com>
Fri, 13 Dec 2019 16:29:35 +0000 (17:29 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 13 Dec 2019 16:29:35 +0000 (17:29 +0100)
As requested by mypy

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/ansible/module.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/tests/test_orchestrator.py

index eaf93b710b34be3f8d59eea72101e4b93f3e054b..89df99401d2c477f656e87602aeefebb2f2079b8 100644 (file)
@@ -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_')}
index 27d3b8f3d35bf831d00f1ae179e68a702cafe25b..169e8e2585f9a96f2659511e04e1c4dee8e9c743 100644 (file)
@@ -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):
index 584c407cb4cfc964db8f763aedaea63dada94d24..2614cf5f5b214cbc1d2578c2231dcae9cf545c54 100644 (file)
@@ -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