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

Add methods to extract v2v log from conversion host. #17333

Merged
merged 1 commit into from
Apr 26, 2018

Conversation

lfu
Copy link
Member

@lfu lfu commented Apr 23, 2018

To download v2v logs.

@miq-bot assign @gmcculloug
@miq-bot add_label enhancement, transformation

cc @bzwei

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1564244

Copy link
Member

@gmcculloug gmcculloug left a comment

Choose a reason for hiding this comment

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

@lfu This is looking pretty good. I think we should be using transformation instead of v2v to be consistent with the naming being used on the backend.

Net::SCP::download!(host.ipaddress, userid, logfile, nil, :ssh => {:password => password})
rescue => scp_err
_log.error("Download of v2v log for #{description} with ID [#{id}] failed with error: #{scp_err}")
raise MiqException::Error, scp_err.to_s, scp_err.backtrace
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to create an MiqException::Error here or can we just re-raise the original error?

raise MiqException::Error, msg
end

userid, password = host.auth_user_pwd(:default)
Copy link
Member

Choose a reason for hiding this comment

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

This should have :remote as the parameter which will fallback to :default if no "Remote" credentials are configured.

Example: https://github.com/ManageIQ/manageiq/blob/master/app/models/host.rb#L1024

:state => MiqTask::STATE_FINISHED,
:status => MiqTask::STATUS_ERROR,
:message => msg
).id
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to pull this into a separate method.

@lfu lfu force-pushed the v2v_log_extraction branch 2 times, most recently from d2e81b4 to b0beff3 Compare April 24, 2018 16:29

# Intend to be called by UI to display transformation log. The log is stored in MiqTask#task_results
# Since the task_results may contain a large block of data, it is desired to remove the task upon receiving the data
def transformation_log_queue(userid)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like we should figure out userid up front and then pass that into create_error_status_task or queue_options instead of making both do the || 'system' logic.

What do you think about userid being set set from User.current_user instead of being passed in? If we keep the parameter I suggest defaulting it since you are handling the 'nil' case.

begin
require 'net/scp'
Net::SCP::download!(host.ipaddress, userid, logfile, nil, :ssh => {:password => password})
rescue => scp_err
Copy link
Member

Choose a reason for hiding this comment

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

Per Rubocop I think we should be rescuing Net::SCP::Error error types here.

Also, is the Net::SCP::download! form of the call the only one that downloads into a local buffer or does Net::SCP.download! do it as well?

Reference: https://github.com/net-ssh/net-scp#synopsis


userid, password = host.auth_user_pwd(:remote)
if userid.blank? || password.blank?
msg = "Host credential is required: userid [#{userid}], password [#{password}]. Download of transformation log aborted."
Copy link
Contributor

Choose a reason for hiding this comment

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

should not log userid/password. Something like Credential was not found for host #{host.name}".

@miq-bot
Copy link
Member

miq-bot commented Apr 25, 2018

Checked commit lfu@4389006 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@gmcculloug
Copy link
Member

@bzwei Please review/approve.

@gmcculloug gmcculloug merged commit 3d0c76e into ManageIQ:master Apr 26, 2018
@gmcculloug gmcculloug added this to the Sprint 85 Ending May 7, 2018 milestone Apr 26, 2018
@lfu lfu deleted the v2v_log_extraction branch April 27, 2018 19:58
@JPrause
Copy link
Member

JPrause commented May 22, 2018

@miq-bot add_label blocker

simaishi pushed a commit that referenced this pull request May 31, 2018
Add methods to extract v2v log from conversion host.
(cherry picked from commit 3d0c76e)

https://bugzilla.redhat.com/show_bug.cgi?id=1584695
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit ec5d5a040db8d92cc9b4b80d85542beb39575c73
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Thu Apr 26 12:23:45 2018 -0400

    Merge pull request #17333 from lfu/v2v_log_extraction
    
    Add methods to extract v2v log from conversion host.
    (cherry picked from commit 3d0c76e43bc22fe9d447625d79b0d58e98cf9e53)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1584695

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.

6 participants