made cssh also work with ssh config host ids (complete fix)
eg ```sh cssh monitoring.tunnel ``` fixes [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=4405]
This commit is contained in:
parent
4d6a14f4e2
commit
34568ed949
|
|
@ -451,7 +451,7 @@ def parse_ssh_config(ssh_config_file_path) -> SshConfig:
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.INFO)
|
||||||
arg_parser = argparse.ArgumentParser('cssh (colored ssh) opens a terminal window with a background color that depends on the fully qualified domain name of the target machine')
|
arg_parser = argparse.ArgumentParser('cssh (colored ssh) opens a terminal window with a background color that depends on the fully qualified domain name of the target machine')
|
||||||
arg_parser.add_argument('ssh_target', help='eg root@alambix50.ipr.univ-rennes.fr')
|
arg_parser.add_argument('ssh_target', help='eg root@alambix50.ipr.univ-rennes.fr')
|
||||||
args = arg_parser.parse_args()
|
args = arg_parser.parse_args()
|
||||||
|
|
@ -459,15 +459,16 @@ def main():
|
||||||
ssh_target = SshTarget(args.ssh_target) # eg 'root@alambix50.ipr.univ-rennes.fr'
|
ssh_target = SshTarget(args.ssh_target) # eg 'root@alambix50.ipr.univ-rennes.fr'
|
||||||
|
|
||||||
ssh_config_file_path: Path = Path(os.getenv('HOME')) / '.ssh' / 'config'
|
ssh_config_file_path: Path = Path(os.getenv('HOME')) / '.ssh' / 'config'
|
||||||
host_real_name = ssh_target.host_id
|
host_real_name = None
|
||||||
if ssh_config_file_path.exists():
|
if ssh_config_file_path.exists():
|
||||||
ssh_config = parse_ssh_config(ssh_config_file_path)
|
ssh_config = parse_ssh_config(ssh_config_file_path)
|
||||||
hn = ssh_config.get_host_name(ssh_target.host_id)
|
hn = ssh_config.get_host_name(ssh_target.host_id)
|
||||||
if hn:
|
if hn:
|
||||||
host_real_name = hn
|
host_real_name = hn
|
||||||
|
if host_real_name is None:
|
||||||
|
host_real_name = get_host_real_fqdn(ssh_target.host_id)
|
||||||
|
|
||||||
logging.debug('host_real_name = %s', host_real_name)
|
logging.debug('host_real_name = %s', host_real_name)
|
||||||
ssh_target.host_id = get_host_real_fqdn(host_real_name)
|
|
||||||
logging.debug('ssh_target.host_id = %s', ssh_target.host_id)
|
logging.debug('ssh_target.host_id = %s', ssh_target.host_id)
|
||||||
# AS_ROOT='false'
|
# AS_ROOT='false'
|
||||||
# if [ "$(echo $@ | grep '^root@' > /dev/null)" ]
|
# if [ "$(echo $@ | grep '^root@' > /dev/null)" ]
|
||||||
|
|
@ -512,7 +513,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f'unhandled os : "{os_name}"')
|
raise NotImplementedError(f'unhandled os : "{os_name}"')
|
||||||
|
|
||||||
proc = subprocess.run(['make_color.py', ssh_target.host_id, str(color_value), str(color_saturation), 'linux'], check=True, stdout=subprocess.PIPE)
|
proc = subprocess.run(['make_color.py', host_real_name, str(color_value), str(color_saturation), 'linux'], check=True, stdout=subprocess.PIPE)
|
||||||
bg_color_as_str = proc.stdout.decode('utf8').strip()
|
bg_color_as_str = proc.stdout.decode('utf8').strip()
|
||||||
match = re.match(r'\((?P<red>[0-9]+), (?P<green>[0-9]+), (?P<blue>[0-9]+)\)', bg_color_as_str)
|
match = re.match(r'\((?P<red>[0-9]+), (?P<green>[0-9]+), (?P<blue>[0-9]+)\)', bg_color_as_str)
|
||||||
assert match, f'unexpected color as string: {bg_color_as_str}'
|
assert match, f'unexpected color as string: {bg_color_as_str}'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue