Skip to content

Commit

Permalink
Merge pull request #395 from fdupont-redhat/v2v_fix_workers_balance
Browse files Browse the repository at this point in the history
Remove check on number of runners when converting VM
(cherry picked from commit 7a0d04d)

https://bugzilla.redhat.com/show_bug.cgi?id=1610550
  • Loading branch information
mkanoor authored and simaishi committed Aug 13, 2018
1 parent 1452ad8 commit 17ab5da
Showing 1 changed file with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ def initialize(handle = $evm)
@handle = handle
end

def set_retry(message = nil, interval = '1.minutes')
@handle.log(:info, message) if message.present?
@handle.root['ae_result'] = 'retry'
@handle.root['ae_retry_interval'] = interval
end

def main
require 'json'

Expand All @@ -31,31 +25,23 @@ def main

@handle.log(:info, "Transformation - Started On: #{start_timestamp}")

destination_ems = @handle.vmdb(:ext_management_system).find_by(:id => task.get_option(:destination_ems_id))
max_runners = Transformation::TransformationHosts::Common::Utils.ems_max_runners(destination_ems, factory_config)
if Transformation::TransformationHosts::Common::Utils.get_runners_count_by_ems(destination_ems, factory_config) >= max_runners
@handle.log(:info, "Too many transformations running [#{max_runners}]. Retrying.")
else
wrapper_options = ManageIQ::Automate::Transformation::TransformationHosts::Common::Utils.virtv2vwrapper_options(task)

# WARNING: Enable at your own risk, as it may lead to sensitive data leak
# @handle.log(:info, "JSON Input:\n#{JSON.pretty_generate(wrapper_options)}") if @debug
wrapper_options = ManageIQ::Automate::Transformation::TransformationHosts::Common::Utils.virtv2vwrapper_options(task)

@handle.log(:info, "Connecting to #{transformation_host.name} as #{transformation_host.authentication_userid}") if @debug
@handle.log(:info, "Executing '/usr/bin/virt-v2v-wrapper.py'")
result = Transformation::TransformationHosts::Common::Utils.remote_command(task, transformation_host, "/usr/bin/virt-v2v-wrapper.py", wrapper_options.to_json)
raise result[:stderr] unless result[:rc].zero?
# WARNING: Enable at your own risk, as it may lead to sensitive data leak
# @handle.log(:info, "JSON Input:\n#{JSON.pretty_generate(wrapper_options)}") if @debug

# Record the wrapper files path
@handle.log(:info, "Command stdout: #{result[:stdout]}") if @debug
task.set_option(:virtv2v_wrapper, JSON.parse(result[:stdout]))
@handle.log(:info, "Connecting to #{transformation_host.name} as #{transformation_host.authentication_userid}") if @debug
@handle.log(:info, "Executing '/usr/bin/virt-v2v-wrapper.py'")
result = Transformation::TransformationHosts::Common::Utils.remote_command(task, transformation_host, "/usr/bin/virt-v2v-wrapper.py", wrapper_options.to_json)
raise result[:stderr] unless result[:rc].zero?

# Record the status in the task object
task.set_option(:virtv2v_started_on, start_timestamp)
task.set_option(:virtv2v_status, 'active')
end
# Record the wrapper files path
@handle.log(:info, "Command stdout: #{result[:stdout]}") if @debug
task.set_option(:virtv2v_wrapper, JSON.parse(result[:stdout]))

set_retry if task.get_option(:virtv2v_started_on).nil?
# Record the status in the task object
task.set_option(:virtv2v_started_on, start_timestamp)
task.set_option(:virtv2v_status, 'active')
rescue => e
@handle.set_state_var(:ae_state_progress, 'message' => e.message)
raise
Expand Down

0 comments on commit 17ab5da

Please sign in to comment.