Skip to content

Refactor input/ssh and input/scp into SSHBase#3721

Merged
robertcheramy merged 6 commits intomasterfrom
feat/3597-refactor-ssh-scp
Jan 13, 2026
Merged

Refactor input/ssh and input/scp into SSHBase#3721
robertcheramy merged 6 commits intomasterfrom
feat/3597-refactor-ssh-scp

Conversation

@robertcheramy
Copy link
Collaborator

Pre-Request Checklist

  • Passes rubocop code analysis (try rubocop --auto-correct)
  • Tests added or adapted (try rake test)
  • Changes are reflected in the documentation
  • User-visible changes appended to CHANGELOG.md

Description

Closes #3597

  • Refactors duplicate code in SSH and SCP into a common parent class SSHBase.
  • SSH#disconnect directly calls @ssh.close, as #close waits for the channels to be closed anyway. This should work the same way as calling @ssh.loop and @ssh.close after a timeout. I don't expect a regression here, but there might be side effects, the Net::SSH library is complex.

Smaller Changes:

  • RESCUE_FAIL handling had to be refactored as it only worked with direct subclasses from Input. I changed it to an object oriented behavior.
  • Input::CLI was included by all classes, so I moved the include into Input directly
  • scp get the same make_ssh_opts as ssh, which does more, but should also work for scp
  • add net-tftp as an optional (development) dependency and fix a tftp timeout creating a crashfile

Note that implementing sftp [which is the protocol used in modern scp, the old scp protocol is deprecated] should be easy (roughly: duplicate scp.rb and rename scp to sftp) if someone has the need for it. I need to keep the old scp protocol because APC Network Management Cards (apc_aos.rb) works only with old scp.

- Change RESCUE_FAIL format to {exception => level}
- Introduce inheritable .rescue_fail class method
- Simplify Node#run_input exception handling
- Prepare for shared SSHBase input class for ssh and scp
- Remove unused RESCUE_FAIL in ftp and telnet
- closes #3597
- move 'include CLI' to input.rb as all input classes need and include it ('get' is mandatory)
- add net-tftp as an optional (development) dependency
- scp get the same make_ssh_opts as ssh, which does more, but should also work for scp
- implementing sftp should be a simple as the SCP class.
- SSH#disconect may be refactored into SSHBase#disconect, as @ssh.close waits for the channels to close, so we might not need to call @ssh.loop to close the channels.
SSH#disconnect directly calls @ssh.close, as #close waits for the channels to be closed anyway.
This should work the same way as calling @ssh.loop and @ssh.close after a timeout.
As SSH#disconnect now calls @ssh.close, we have to implement it in the SSH simulation.
@robertcheramy robertcheramy merged commit e62e12b into master Jan 13, 2026
12 checks passed
@robertcheramy robertcheramy deleted the feat/3597-refactor-ssh-scp branch January 13, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor input/ssh and input/scp

1 participant