20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/manageiq/network_discovery/modules/VMwareEsxVcProbe.rb', line 20
def self.probe(ost)
if !ost.discover_types.include?(:virtualcenter) && !ost.discover_types.include?(:esx)
$log.debug "Skipping VMwareEsxVcProbe" if $log
return
end
$log.debug "VMwareEsxVcProbe: probing ip = #{ost.ipaddr}" if $log
begin
require 'VMwareWebService/MiqVimClientBase'
MiqVimClientBase.new(ost.ipaddr, "test", "test")
rescue => err
$log.debug "VMwareEsxVcProbe: Failed to connect to VMware webservice: #{err}. ip = #{ost.ipaddr}" if $log
return
end
$log.debug "VMwareEsxVcProbe: ip = #{ost.ipaddr}, Connected to VMware webservice. Machine is either ESX or VirtualCenter." if $log
checked_vc = false
found_vc = false
if ost.discover_types.include?(:virtualcenter)
checked_vc = true
if PortScanner.portAndOrScan?(ost, VC_PORTS)
ost.os << :mswin
ost.hypervisor << :virtualcenter
found_vc = true
$log.debug "VMwareEsxVcProbe: ip = #{ost.ipaddr}, Machine is VirtualCenter." if $log
end
end
if !found_vc && ost.discover_types.include?(:esx) && PortScanner.portOrScan?(ost, ESX_PORTS)
if checked_vc || !PortScanner.portAndOrScan?(ost, VC_PORTS)
ost.os << :linux
ost.hypervisor << :esx
$log.debug "VMwareEsxVcProbe: ip = #{ost.ipaddr}, Machine is an ESX server." if $log
end
end
$log.debug "VMwareEsxVcProbe: probe of ip = #{ost.ipaddr} complete" if $log
end
|