Skip to content

Commit

Permalink
Enabling conversion_host and disabling it
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswnl committed Nov 14, 2018
1 parent 0582476 commit 931fc57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
5 changes: 3 additions & 2 deletions app/models/conversion_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ def check_conversion_host_role
tag_resource_as('disabled')
end

def enable_conversion_host_role
def enable_conversion_host_role(v2v_vddk_package_url = nil)
install_conversion_host_module
v2v_vddk_package_url |= "http://#{resource.ext_management_system.hostname}/vddk/VMware-vix-disklib-stable.tar.gz"
playbook = "/usr/share/ovirt-ansible-v2v-conversion-host/playbooks/conversion_host_enable.yml"
extra_vars = {
:v2v_vddk_package_name => "VMware-vix-disklib-stable.tar.gz",
:v2v_vddk_package_url => "http://#{resource.ext_management_system.hostname}/vddk/VMware-vix-disklib-stable.tar.gz"
:v2v_vddk_package_url => v2v_vddk_package_url
}
ansible_playbook(playbook, extra_vars)
ensure
Expand Down
20 changes: 8 additions & 12 deletions app/models/conversion_host/configurations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,18 @@ def enable_queue(params, auth_user = nil)
end

def enable(params)
op_arg = params.each_with_object([]) { |(k, v), l| l.push("#{k}=#{v}") }.join(', ')
_log.info("Enabling a conversion_host with parameters: #{op_arg}")

success = false
resource_info = 'not found/invalid'
_log.info("Enabling a conversion_host with parameters: #{params}")

vddk_url = params.delete("param_v2v_vddk_package_url")
resource_id = params[:resource_id]
resource_type = params[:resource_type]
resource = resource_type.constantize.find(resource_id)

success = create!(params)
resource_info = "type=#{params[:resource_type]} id=#{params[:resource_id]}"
conversion_host = new(params.merge(:resource => resource))
conversion_host.enable_conversion_host_role
success = conversion_host.save!
ensure
resource_info = "type=#{params[:resource_type]} id=#{params[:resource_id]}"
notify_configuration_result('enable', success, resource_info)
end

Expand All @@ -61,13 +59,11 @@ def self.disable_queue(params, auth_user = nil)
end

def disable(params)
success = false
resource_info = "type=#{resource.class.name} id=#{resource.id}"
_log.info("Disabling a conversion_host #{resource_info} with parameters: #{params}")

op_arg = params.each_with_object([]) { |(k, v), l| l.push("#{k}=#{v}") }.join(', ')
_log.info("Disabling a conversion_host with parameters: #{op_arg}")

success = destroy
disable_conversion_host_role
success = destroy!
ensure
self.class.notify_configuration_result('disable', success, resource_info)
end
Expand Down

0 comments on commit 931fc57

Please sign in to comment.