Merge PR #40508 into master

* refs/pull/40508/head:
	mgr/cephadm: fix orch host add with multiple labels and no addr

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2021-04-05 14:14:12 -04:00
commit 91eb165167
3 changed files with 13 additions and 3 deletions

View File

@ -104,7 +104,12 @@ are free form and have no particular meaning by itself and each host
can have multiple labels. They can be used to specify placement
of daemons. See :ref:`orch-placement-by-labels`
To add a label, run::
Labels can be added when adding a host with the ``--labels`` flag::
ceph orch host add my_hostname --labels=my_label1
ceph orch host add my_hostname --labels=my_label1,my_label2
To add a label a existing host, run::
ceph orch host label add my_hostname my_label

View File

@ -1187,13 +1187,13 @@ Please make sure that the host is reachable and accepts connections using the ce
To add the cephadm SSH key to the host:
> ceph cephadm get-pub-key > ~/ceph.pub
> ssh-copy-id -f -i ~/ceph.pub {user}@{host}
> ssh-copy-id -f -i ~/ceph.pub {user}@{addr}
To check that the host is reachable:
> ceph cephadm get-ssh-config > ssh_config
> ceph config-key get mgr/cephadm/ssh_identity_key > ~/cephadm_private_key
> chmod 0600 ~/cephadm_private_key
> ssh -F ssh_config -i ~/cephadm_private_key {user}@{host}'''
> ssh -F ssh_config -i ~/cephadm_private_key {user}@{addr}'''
raise OrchestratorError(msg) from e
except Exception as ex:
self.log.exception(ex)

View File

@ -326,6 +326,11 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule,
def _add_host(self, hostname: str, addr: Optional[str] = None, labels: Optional[List[str]] = None, maintenance: Optional[bool] = False) -> HandleCommandResult:
"""Add a host"""
_status = 'maintenance' if maintenance else ''
# split multiple labels passed in with --labels=label1,label2
if labels and len(labels) == 1:
labels = labels[0].split(',')
s = HostSpec(hostname=hostname, addr=addr, labels=labels, status=_status)
return self._apply_misc([s], False, Format.plain)