Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage run_session for SFTP #381

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

ghost
Copy link

@ghost ghost commented Oct 10, 2018

This PR leverages the run_session method to get a Net::SSH::Connection::Session object that can be used to access the SFTP subsystem. This standardize connection via SSH.

@ghost
Copy link
Author

ghost commented Oct 10, 2018

@miq-bot add-reviewer carbonin

@miq-bot miq-bot requested a review from carbonin October 10, 2018 10:26
$log.debug "MiqSshUtil::get_file - Copying file #{@host}:#{from} to #{to}." if $log
data = sftp.download!(from, to)
data = ssh.sftp.download!(from, to)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an odd change, and I can't find documentation for getting to an sftp connection using the ssh session object and also this:

[7] pry(main)> Net::SSH::Connection::Session.instance_methods.include?(:sftp)
=> false
[8] pry(main)> Net::SSH::Connection::Session.methods.include?(:sftp)
=> false

I trust that you've tested this, but I'm not comfortable making this change which doesn't really bring any upside when I can't find this behavior documented anywhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, if you can find the documentation for this, then this looks good to me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I needed to also require 'net/sftp' because it patches.

[2] pry(main)> require 'net/ssh'
=> true
[3] pry(main)> Net::SSH::Connection::Session.instance_methods.include?(:sftp)
=> false
[4] pry(main)> require 'net/sftp'
=> true
[5] pry(main)> Net::SSH::Connection::Session.instance_methods.include?(:sftp)
=> true

Makes sense to me then 👍

@carbonin carbonin self-assigned this Oct 10, 2018
@carbonin carbonin merged commit df0db54 into ManageIQ:master Oct 10, 2018
@carbonin
Copy link
Member

@fdupont-redhat is there anything that needs this change for the Hammer branch? I'm not sure that this actually adds any functionality, so I'm tempted to label hammer/no.

@carbonin carbonin added this to the Sprint 97 Ending Oct 22, 2018 milestone Oct 10, 2018
@ghost
Copy link
Author

ghost commented Oct 10, 2018

@carbonin AFAIK, there's no code depending on that change in Hammer. So ok for hammer/no.

@ghost ghost deleted the sshutil_refactor_getfile branch October 10, 2018 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants