Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
salt.26144
update-target-fix-for-salt-ssh-to-process-targe...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File update-target-fix-for-salt-ssh-to-process-targets-li.patch of Package salt.26144
From 74d3d43d09c692ba41138278f34d2a2e2ef83dd8 Mon Sep 17 00:00:00 2001 From: Victor Zhestkov <35733135+vzhestkov@users.noreply.github.com> Date: Fri, 9 Apr 2021 16:01:32 +0300 Subject: [PATCH] Update target fix for salt-ssh to process targets list (bsc#1179831) (#336) * Update target fix for salt-ssh to process targets list (bsc#1179831) * Improvement for fixing (bsc#1179831) Regression fix of salt-ssh on processing targets (#353) --- salt/client/ssh/__init__.py | 46 +++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py index 564d622ab5..37faa869bc 100644 --- a/salt/client/ssh/__init__.py +++ b/salt/client/ssh/__init__.py @@ -327,7 +327,7 @@ class SSH: if not self.opts.get("ssh_cli_tgt"): self.opts["ssh_cli_tgt"] = self.opts.get("tgt", "") hostname = self.opts.get("ssh_cli_tgt", "") - if "@" in hostname: + if isinstance(hostname, str) and "@" in hostname: user, hostname = hostname.split("@", 1) else: user = self.opts.get("ssh_user") @@ -378,7 +378,7 @@ class SSH: self.__parsed_rosters[self.ROSTER_UPDATE_FLAG] = False return - def _update_roster(self): + def _update_roster(self, hostname=None, user=None): """ Update default flat roster with the passed in information. :return: @@ -392,8 +392,8 @@ class SSH: " host: {hostname}\n user: {user}\n passwd: {passwd}\n".format( s_user=getpass.getuser(), s_time=datetime.datetime.utcnow().isoformat(), - hostname=self.opts.get("tgt", ""), - user=self.opts.get("ssh_user", ""), + hostname=hostname if hostname else self.opts.get("tgt", ""), + user=user if user else self.opts.get("ssh_user", ""), passwd=self.opts.get("ssh_passwd", ""), ) ) @@ -410,20 +410,32 @@ class SSH: Uptade targets in case hostname was directly passed without the roster. :return: """ - hostname = self.parse_tgt["hostname"] + hosts = self.parse_tgt["hostname"] user = self.parse_tgt["user"] - if hostname == "*": - hostname = "" - - if salt.utils.network.is_reachable_host(hostname): - self.opts["tgt"] = hostname - self.targets[hostname] = { - "passwd": self.opts.get("ssh_passwd", ""), - "host": hostname, - "user": user, - } - if self.opts.get("ssh_update_roster"): - self._update_roster() + + if not isinstance(hosts, (list, tuple)): + hosts = list([hosts]) + _hosts = list() + for hostname in hosts: + _user = user + if "@" in hostname: + _user, hostname = hostname.split("@", 1) + if hostname == "*": + continue + if salt.utils.network.is_reachable_host(hostname): + _hosts.append(hostname) + self.targets[hostname] = { + "passwd": self.opts.get("ssh_passwd", ""), + "host": hostname, + "user": _user, + } + if self.opts.get("ssh_update_roster"): + self._update_roster(hostname=hostname, user=_user) + + if self.tgt_type == "list": + self.opts["tgt"] = _hosts + elif _hosts: + self.opts["tgt"] = _hosts[0] def get_pubkey(self): """ -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor