Module: MiqVimVdlVcConnectionMod

Included in:
MiqVimVm
Defined in:
lib/VMwareWebService/MiqVimVdlMod.rb

Overview

module MiqVimVdlConnectionMod

Instance Method Summary collapse

Instance Method Details

#vdlVcConnectionObject

Return a VixDiskLib connection object for the VC server that VIM is connected to. The connection is specific to this VM, and should be closed by the caller when it has finished accessing the VM’s disk files.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/VMwareWebService/MiqVimVdlMod.rb', line 31

def vdlVcConnection
  require 'VMwareWebService/VixDiskLib/VixDiskLib'

  VixDiskLib.init(->(s) { $vim_log.info  "VMware(VixDiskLib): #{s}" },
                  ->(s) { $vim_log.warn  "VMware(VixDiskLib): #{s}" },
                  ->(s) { $vim_log.error "VMware(VixDiskLib): #{s}" })

  $log.info "MiqVimVdlVcConnectionMod.vdlVcConnection: server - #{invObj.server}"
  thumb_print = if invObj.isVirtualCenter?
                  VcenterThumbPrint.new(invObj.server)
                else
                  ESXThumbPrint.new(invObj.server, invObj.username, invObj.password)
                end

  sha1 = thumb_print.to_sha1
  VixDiskLib.connect(:serverName => invObj.server,
                     :vmxSpec    => vixVmxSpec,
                     :thumbPrint => sha1,
                     :port       => 902,
                     :credType   => VixDiskLib_raw::VIXDISKLIB_CRED_UID,
                     :userName   => invObj.username,
                     :password   => invObj.password)
end