Skip to content

Commit

Permalink
Dev: bootstrap: Refactor qdevice user parsing and founding
Browse files Browse the repository at this point in the history
Try to reuse the existing functions
  • Loading branch information
liangxin1300 committed Mar 6, 2024
1 parent 17fd341 commit 75ad525
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions crmsh/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,7 @@ def initialize_qdevice(self):
"""
if not self.qnetd_addr:
return
parts = self.qnetd_addr.split('@', 2)
if len(parts) == 2:
ssh_user = parts[0]
qnetd_host = parts[1]
else:
ssh_user = None
qnetd_host = self.qnetd_addr
ssh_user, qnetd_host = utils.parse_user_at_host(self.qnetd_addr)
self.qdevice_inst = qdevice.QDevice(
qnetd_host,
port=self.qdevice_port,
Expand Down Expand Up @@ -1568,27 +1562,7 @@ def init_qdevice():
utils.fatal("corosync-qdevice.service is not available on {}".format(node))
qdevice_inst = _context.qdevice_inst
qnetd_addr = qdevice_inst.qnetd_addr
local_user = None
ssh_user = None
if qdevice_inst.ssh_user is not None:
# if the remote user is specified explicitly, use it
ssh_user = qdevice_inst.ssh_user
try:
local_user = UserOfHost.instance().user_of(utils.this_node())
except UserNotFoundError:
local_user = ssh_user
else:
try:
# if ssh session has ready been available, use that
local_user, ssh_user = UserOfHost.instance().user_pair_for_ssh(qnetd_addr)
except UserNotFoundError:
pass
if ssh_user is None:
try:
local_user = UserOfHost.instance().user_of(utils.this_node())
except UserNotFoundError:
local_user = userdir.getuser()
ssh_user = local_user
local_user, ssh_user, _ = _select_user_pair_for_ssh_for_secondary_components(qnetd_addr)
# Configure ssh passwordless to qnetd if detect password is needed
if UserOfHost.instance().use_ssh_agent():
logger.info("Adding public keys to authorized_keys for user root...")
Expand Down

0 comments on commit 75ad525

Please sign in to comment.