From: Sage Weil Date: Wed, 17 Mar 2021 19:38:57 +0000 (-0400) Subject: mgr/cephadm: make DaemonPlacement print nicer X-Git-Tag: v16.2.0~73^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a8742aaff4e545738738cac9b3d60dd70751f312;p=ceph.git mgr/cephadm: make DaemonPlacement print nicer 'host(ip:port)' or 'host(*:port)' so we can show it to a user. Signed-off-by: Sage Weil (cherry picked from commit 98fa727cad7b90b0325c51d75fac657ac6aa456c) --- diff --git a/src/pybind/mgr/cephadm/schedule.py b/src/pybind/mgr/cephadm/schedule.py index 914f178f3ca..c7774167068 100644 --- a/src/pybind/mgr/cephadm/schedule.py +++ b/src/pybind/mgr/cephadm/schedule.py @@ -25,10 +25,8 @@ class DaemonPlacement(NamedTuple): other.append(f'network={self.network}') if self.name: other.append(f'name={self.name}') - if self.ip: - other.append(f'ip={self.ip}') if self.port: - other.append(f'port={self.port}') + other.append(f'{self.ip or "*"}:{self.port}') if other: res += '(' + ' '.join(other) + ')' return res diff --git a/src/pybind/mgr/cephadm/tests/test_scheduling.py b/src/pybind/mgr/cephadm/tests/test_scheduling.py index f149066fc15..2a2c6a1d79f 100644 --- a/src/pybind/mgr/cephadm/tests/test_scheduling.py +++ b/src/pybind/mgr/cephadm/tests/test_scheduling.py @@ -534,10 +534,10 @@ class NodeAssignmentTest(NamedTuple): PlacementSpec(count=6, label='foo'), 'host1 host2 host3'.split(), [], - ['host1(port=80)', 'host2(port=80)', 'host3(port=80)', - 'host1(port=81)', 'host2(port=81)', 'host3(port=81)'], - ['host1(port=80)', 'host2(port=80)', 'host3(port=80)', - 'host1(port=81)', 'host2(port=81)', 'host3(port=81)'], + ['host1(*:80)', 'host2(*:80)', 'host3(*:80)', + 'host1(*:81)', 'host2(*:81)', 'host3(*:81)'], + ['host1(*:80)', 'host2(*:80)', 'host3(*:80)', + 'host1(*:81)', 'host2(*:81)', 'host3(*:81)'], [] ), # label + count_per_host + ports (+ xisting) @@ -550,10 +550,10 @@ class NodeAssignmentTest(NamedTuple): DaemonDescription('rgw', 'b', 'host2', ports=[80]), DaemonDescription('rgw', 'c', 'host1', ports=[82]), ], - ['host1(port=80)', 'host2(port=80)', 'host3(port=80)', - 'host1(port=81)', 'host2(port=81)', 'host3(port=81)'], - ['host1(port=80)', 'host3(port=80)', - 'host2(port=81)', 'host3(port=81)'], + ['host1(*:80)', 'host2(*:80)', 'host3(*:80)', + 'host1(*:81)', 'host2(*:81)', 'host3(*:81)'], + ['host1(*:80)', 'host3(*:80)', + 'host2(*:81)', 'host3(*:81)'], ['rgw.c'] ), # cephadm.py teuth case @@ -753,12 +753,12 @@ class NodeAssignmentTest4(NamedTuple): 'host3': {'192.168.0.0/16': ['192.168.0.1']}, }, [], - ['host1(ip=10.0.0.1 port=80)', 'host2(ip=10.0.0.2 port=80)', - 'host1(ip=10.0.0.1 port=81)', 'host2(ip=10.0.0.2 port=81)', - 'host1(ip=10.0.0.1 port=82)', 'host2(ip=10.0.0.2 port=82)'], - ['host1(ip=10.0.0.1 port=80)', 'host2(ip=10.0.0.2 port=80)', - 'host1(ip=10.0.0.1 port=81)', 'host2(ip=10.0.0.2 port=81)', - 'host1(ip=10.0.0.1 port=82)', 'host2(ip=10.0.0.2 port=82)'], + ['host1(10.0.0.1:80)', 'host2(10.0.0.2:80)', + 'host1(10.0.0.1:81)', 'host2(10.0.0.2:81)', + 'host1(10.0.0.1:82)', 'host2(10.0.0.2:82)'], + ['host1(10.0.0.1:80)', 'host2(10.0.0.2:80)', + 'host1(10.0.0.1:81)', 'host2(10.0.0.2:81)', + 'host1(10.0.0.1:82)', 'host2(10.0.0.2:82)'], [] ), ])