Skip to content

Commit

Permalink
Conversion Host - Handle CA bundle from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiendupont committed May 14, 2019
1 parent aef906a commit a30879b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/conversion_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def check_conversion_host_role(miq_task_id = nil)
tag_resource_as('disabled')
end

def enable_conversion_host_role(vmware_vddk_package_url = nil, vmware_ssh_private_key = nil, miq_task_id = nil)
def enable_conversion_host_role(vmware_vddk_package_url = nil, vmware_ssh_private_key = nil, osp_ca_bundle = nil, miq_task_id = nil)
raise "vmware_vddk_package_url is mandatory if transformation method is vddk" if vddk_transport_supported && vmware_vddk_package_url.nil?
raise "vmware_ssh_private_key is mandatory if transformation_method is ssh" if ssh_transport_supported && vmware_ssh_private_key.nil?
playbook = "/usr/share/v2v-conversion-host-ansible/playbooks/conversion_host_enable.yml"
Expand All @@ -211,7 +211,7 @@ def enable_conversion_host_role(vmware_vddk_package_url = nil, vmware_ssh_privat
:v2v_transport_method => source_transport_method,
:v2v_vddk_package_url => vmware_vddk_package_url,
:v2v_ssh_private_key => vmware_ssh_private_key,
:v2v_ca_bundle => resource.ext_management_system.connection_configurations['default'].certificate_authority
:v2v_ca_bundle => osp_ca_bundle || resource.ext_management_system.connection_configurations['default'].certificate_authority
}.compact
ansible_playbook(playbook, extra_vars, miq_task_id)
ensure
Expand Down
4 changes: 3 additions & 1 deletion app/models/conversion_host/configurations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def enable(params, auth_user = nil)

ssh_key = params.delete(:conversion_host_ssh_private_key)

osp_ca_bundle = params.delete(:osp_ca_bundle)

new(params).tap do |conversion_host|
if ssh_key
conversion_host.authentications << AuthPrivateKey.create!(
Expand All @@ -78,7 +80,7 @@ def enable(params, auth_user = nil)
)
end

conversion_host.enable_conversion_host_role(vmware_vddk_package_url, vmware_ssh_private_key, miq_task_id)
conversion_host.enable_conversion_host_role(vmware_vddk_package_url, vmware_ssh_private_key, osp_ca_bundle, miq_task_id)
conversion_host.save!

if miq_task_id
Expand Down
5 changes: 3 additions & 2 deletions spec/models/conversion_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,16 @@
enable_extra_vars = {
:v2v_host_type => 'openstack',
:v2v_transport_method => 'ssh',
:v2v_ssh_private_key => 'fake ssh private key'
:v2v_ssh_private_key => 'fake ssh private key',
:v2v_ca_bundle => 'fake CA bundle'
}
check_extra_vars = {
:v2v_host_type => 'openstack',
:v2v_transport_method => 'ssh'
}
expect(conversion_host).to receive(:ansible_playbook).once.ordered.with(enable_playbook, enable_extra_vars, nil)
expect(conversion_host).to receive(:ansible_playbook).once.ordered.with(check_playbook, check_extra_vars, nil)
conversion_host.enable_conversion_host_role(nil, 'fake ssh private key')
conversion_host.enable_conversion_host_role(nil, 'fake ssh private key', 'fake CA bundle')
end
end
end
Expand Down

0 comments on commit a30879b

Please sign in to comment.