Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #405 from fdupont-redhat/v2v_change_vmware_uri
Change VMware URI to connect directly to ESXi
(cherry picked from commit 154c82f)

https://bugzilla.redhat.com/show_bug.cgi?id=1621441
  • Loading branch information
gmcculloug authored and simaishi committed Sep 17, 2018
1 parent f552351 commit 25f3a0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Expand Up @@ -26,12 +26,10 @@ def vm_get_ref(vim, vm)
vim.serviceInstance.content.searchIndex.FindByUuid(:datacenter => dc, :uuid => vm.uid_ems, :vmSearch => true, :instanceUuid => false)
end

def self.get_vcenter_fingerprint(ems, handle = $evm)
command = "openssl s_client -connect #{ems.hostname}:443 2>\/dev\/null | openssl x509 -noout -fingerprint -sha1"
def self.host_fingerprint(host)
command = "openssl s_client -connect #{host.ipaddress}:443 2>\/dev\/null | openssl x509 -noout -fingerprint -sha1"
ssl_fingerprint = `#{command}`
fingerprint = ssl_fingerprint[17..ssl_fingerprint.size - 2]
handle.log(:info, "vCenter fingerprint: #{fingerprint}")
fingerprint
ssl_fingerprint[17..ssl_fingerprint.size - 2]
end

def self.vm_rename(vm, new_name, handle = $evm)
Expand Down
Expand Up @@ -79,24 +79,22 @@ def self.remote_command(task, transformation_host, command, stdin = nil, run_as

def self.virtv2vwrapper_options_vmwarews2rhevm_vddk(task)
source_vm = task.source
source_ems = source_vm.ext_management_system
source_cluster = source_vm.ems_cluster

destination_cluster = task.transformation_destination(source_cluster)
destination_ems = destination_cluster.ext_management_system
destination_storage = task.transformation_destination(source_vm.hardware.disks.select { |d| d.device_type == 'disk' }.first.storage)

vmware_uri = "vpx://"
vmware_uri += "#{source_ems.authentication_userid.gsub('@', '%40')}@#{source_ems.hostname}/"
vmware_uri += "#{source_cluster.v_parent_datacenter.gsub(' ', '%20')}/#{source_cluster.name.gsub(' ', '%20')}/#{source_vm.host.uid_ems}"
vmware_uri = "esx://"
vmware_uri += "root@#{source_vm.host.ipaddress}/"
vmware_uri += "?no_verify=1"

{
:vm_name => source_vm.name,
:transport_method => 'vddk',
:vmware_fingerprint => ManageIQ::Automate::Transformation::Infrastructure::VM::VMware::Utils.get_vcenter_fingerprint(source_ems),
:vmware_fingerprint => ManageIQ::Automate::Transformation::Infrastructure::VM::VMware::Utils.host_fingerprint(source_vm.host),
:vmware_uri => vmware_uri,
:vmware_password => source_ems.authentication_password,
:vmware_password => source_vm.host.authentication_password,
:rhv_url => "https://#{destination_ems.hostname}/ovirt-engine/api",
:rhv_cluster => destination_cluster.name,
:rhv_storage => destination_storage.name,
Expand Down

0 comments on commit 25f3a0a

Please sign in to comment.