| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FusionInventory::Agent::SOAP::VMware::Host; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
20699669
|
use strict; |
|
|
3
|
|
|
|
|
12
|
|
|
|
3
|
|
|
|
|
134
|
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
108
|
|
|
|
3
|
|
|
|
|
105
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
438
|
use FusionInventory::Agent::Tools; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
5300
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
0
|
|
|
0
|
1
|
|
my ($class, %params) = @_; |
|
10
|
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $self = { |
|
12
|
|
|
|
|
|
|
hash => $params{hash}, |
|
13
|
|
|
|
|
|
|
vms => $params{vms} |
|
14
|
|
|
|
|
|
|
}; |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
bless $self, $class; |
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
return $self; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _asArray { |
|
22
|
0
|
|
|
0
|
|
|
my $h = shift; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return |
|
25
|
0
|
0
|
|
|
|
|
ref $h eq 'ARRAY' ? @$h : |
|
|
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$h ? ($h) : |
|
27
|
|
|
|
|
|
|
() ; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub getBootTime { |
|
31
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self->{hash}[0]{summary}{runtime}{bootTime}; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getHostname { |
|
37
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return $self->{hash}[0]{name} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub getBiosInfo { |
|
44
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $hardware = $self->{hash}[0]{hardware}; |
|
47
|
0
|
|
|
|
|
|
my $biosInfo = $hardware->{biosInfo}; |
|
48
|
0
|
|
|
|
|
|
my $systemInfo = $hardware->{systemInfo}; |
|
49
|
0
|
|
|
|
|
|
my $ssn; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
return unless ref($biosInfo) eq 'HASH'; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $identifierValue; |
|
54
|
0
|
0
|
|
|
|
|
if (ref($systemInfo->{otherIdentifyingInfo}) eq 'HASH') { |
|
|
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$identifierValue = $systemInfo->{otherIdentifyingInfo}->{identifierValue}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
elsif (ref($systemInfo->{otherIdentifyingInfo}) eq 'ARRAY') { |
|
58
|
0
|
|
|
|
|
|
foreach (@{$systemInfo->{otherIdentifyingInfo}}) { |
|
|
0
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ($_->{identifierType}->{key} eq 'ServiceTag') { |
|
60
|
0
|
|
|
|
|
|
$ssn = $_->{identifierValue}; |
|
61
|
0
|
|
|
|
|
|
last; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return { |
|
67
|
0
|
|
|
|
|
|
BDATE => $biosInfo->{releaseDate}, |
|
68
|
|
|
|
|
|
|
BVERSION => $biosInfo->{biosVersion}, |
|
69
|
|
|
|
|
|
|
SMODEL => $systemInfo->{model}, |
|
70
|
|
|
|
|
|
|
SMANUFACTURER => $systemInfo->{vendor}, |
|
71
|
|
|
|
|
|
|
ASSETTAG => $identifierValue, |
|
72
|
|
|
|
|
|
|
SSN => $ssn |
|
73
|
|
|
|
|
|
|
}; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub getHardwareInfo { |
|
77
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $dnsConfig = $self->{hash}[0]{config}{network}{dnsConfig}; |
|
80
|
0
|
|
|
|
|
|
my $hardware = $self->{hash}[0]{hardware}; |
|
81
|
0
|
|
|
|
|
|
my $summary = $self->{hash}[0]{summary}; |
|
82
|
0
|
|
|
|
|
|
my $product = $summary->{config}->{product}; |
|
83
|
0
|
|
|
|
|
|
my $systemInfo = $hardware->{systemInfo}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return { |
|
86
|
0
|
|
0
|
|
|
|
NAME => $dnsConfig->{hostName}, |
|
87
|
|
|
|
|
|
|
DNS => join('/', _asArray($dnsConfig->{address})), |
|
88
|
|
|
|
|
|
|
WORKGROUP => $dnsConfig->{domainName}, |
|
89
|
|
|
|
|
|
|
MEMORY => int($hardware->{memorySize} / (1024 * 1024)), |
|
90
|
|
|
|
|
|
|
UUID => $summary->{hardware}->{uuid} || $systemInfo->{uuid}, |
|
91
|
|
|
|
|
|
|
OSVERSION => $product->{version}, |
|
92
|
|
|
|
|
|
|
OSNAME => $product->{name}, |
|
93
|
|
|
|
|
|
|
OSCOMMENTS => $product->{fullName} |
|
94
|
|
|
|
|
|
|
}; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub getCPUs { |
|
98
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my %cpuManufacturor = ( |
|
101
|
|
|
|
|
|
|
amd => 'AMD', |
|
102
|
|
|
|
|
|
|
intel => 'Intel', |
|
103
|
|
|
|
|
|
|
); |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $hardware = $self->{hash}[0]{hardware}; |
|
106
|
0
|
|
|
|
|
|
my $totalCore = $hardware->{cpuInfo}{numCpuCores}; |
|
107
|
0
|
|
|
|
|
|
my $totalThread = $hardware->{cpuInfo}{numCpuThreads}; |
|
108
|
0
|
|
|
|
|
|
my $cpuEntries = $hardware->{cpuPkg}; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my @cpus; |
|
111
|
0
|
|
|
|
|
|
foreach (_asArray($cpuEntries)) { |
|
112
|
|
|
|
|
|
|
push @cpus, |
|
113
|
|
|
|
|
|
|
{ |
|
114
|
|
|
|
|
|
|
CORE => $totalCore / _asArray($cpuEntries), |
|
115
|
|
|
|
|
|
|
MANUFACTURER => $cpuManufacturor{ $_->{vendor} } || $_->{vendor}, |
|
116
|
|
|
|
|
|
|
NAME => $_->{description}, |
|
117
|
|
|
|
|
|
|
SPEED => int( $_->{hz} / ( 1000 * 1000 ) ), |
|
118
|
0
|
|
0
|
|
|
|
THREAD => eval { $totalThread / $totalCore } |
|
|
0
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
}; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return @cpus; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub getControllers { |
|
126
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my @controllers; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
foreach ( @{ $self->{hash}[0]{hardware}{pciDevice} } ) { |
|
|
0
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $pciid = sprintf( "%x:%x", $_->{vendorId}, $_->{deviceId} ); |
|
133
|
0
|
|
|
|
|
|
my $pcisubsystemid = |
|
134
|
|
|
|
|
|
|
sprintf( "%x:%x", $_->{subVendorId}, $_->{subDeviceId} ); |
|
135
|
0
|
|
|
|
|
|
my $pciclass = sprintf( "%x", $_->{classId} ); |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
$pcisubsystemid = '' if $pcisubsystemid =~ /^[0:]+$/; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# Workaround: sometime the pciid are odd negative number. |
|
140
|
|
|
|
|
|
|
# e.g: 111d:ffff8018, ffff8086:244e, ffff8086:ffffa02c |
|
141
|
0
|
|
|
|
|
|
foreach ( $pciid, $pcisubsystemid, $pciclass ) { |
|
142
|
0
|
|
|
|
|
|
s/(\w+:)/000$1:/; |
|
143
|
0
|
|
|
|
|
|
s/:(\w+)/:000$1/; |
|
144
|
0
|
|
|
|
|
|
s/.*(\w{4}:).*(\w{4}).*/$1$2/g; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
|
|
|
|
|
push @controllers, |
|
147
|
|
|
|
|
|
|
{ |
|
148
|
|
|
|
|
|
|
NAME => $_->{deviceName}, |
|
149
|
|
|
|
|
|
|
MANUFACTURER => $_->{vendorName}, |
|
150
|
|
|
|
|
|
|
PCICLASS => $pciclass, |
|
151
|
|
|
|
|
|
|
PCIID => $pciid, |
|
152
|
|
|
|
|
|
|
PCISUBSYSTEMID => $pcisubsystemid, |
|
153
|
|
|
|
|
|
|
PCISLOT => $_->{id}, |
|
154
|
|
|
|
|
|
|
}; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
return @controllers; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _getNic { |
|
162
|
0
|
|
|
0
|
|
|
my ($ref, $isVirtual) = @_; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
return { |
|
165
|
0
|
0
|
0
|
|
|
|
DESCRIPTION => $ref->{device}, |
|
166
|
|
|
|
|
|
|
DRIVER => $ref->{driver}, |
|
167
|
|
|
|
|
|
|
IPADDRESS => $ref->{spec}{ip}{ipAddress}, |
|
168
|
|
|
|
|
|
|
IPMASK => $ref->{spec}{ip}{subnetMask}, |
|
169
|
|
|
|
|
|
|
MACADDR => $ref->{mac} || $ref->{spec}{mac}, |
|
170
|
|
|
|
|
|
|
MTU => $ref->{spec}{mtu}, |
|
171
|
|
|
|
|
|
|
PCISLOT => $ref->{pci}, |
|
172
|
|
|
|
|
|
|
STATUS => $ref->{spec}{ip}{ipAddress} ? 'Up' : 'Down', |
|
173
|
|
|
|
|
|
|
VIRTUALDEV => $isVirtual, |
|
174
|
|
|
|
|
|
|
SPEED => $ref->{spec}{linkSpeed}{speedMb}, |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub getNetworks { |
|
179
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
180
|
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my @networks; |
|
182
|
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
my $seen = {}; |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
foreach my $nicType (qw/vnic pnic consoleVnic/) { |
|
186
|
0
|
|
|
|
|
|
foreach (_asArray($self->{hash}[0]{config}{network}{$nicType})) |
|
187
|
|
|
|
|
|
|
{ |
|
188
|
|
|
|
|
|
|
|
|
189
|
0
|
0
|
|
|
|
|
next if $seen->{$_->{device}}++; |
|
190
|
0
|
0
|
|
|
|
|
my $isVirtual = $nicType eq 'vnic'?1:0; |
|
191
|
0
|
|
|
|
|
|
push @networks, _getNic($_, $isVirtual); |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
my @vnic; |
|
196
|
0
|
0
|
|
|
|
|
push @vnic, $self->{hash}[0]{config}{network}{consoleVnic} |
|
197
|
|
|
|
|
|
|
if $self->{hash}[0]{config}{network}{consoleVnic}; |
|
198
|
0
|
0
|
|
|
|
|
push @vnic, $self->{hash}[0]{config}{vmotion}{netConfig}{candidateVnic} |
|
199
|
|
|
|
|
|
|
if $self->{hash}[0]{config}{vmotion}{netConfig}{candidateVnic}; |
|
200
|
0
|
|
|
|
|
|
foreach my $entry (@vnic) { |
|
201
|
0
|
|
|
|
|
|
foreach (_asArray($entry)) { |
|
202
|
0
|
0
|
|
|
|
|
next if $seen->{$_->{device}}++; |
|
203
|
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
push @networks, _getNic($_, 1); |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
return @networks; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub getStorages { |
|
212
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
my @storages; |
|
215
|
0
|
|
|
|
|
|
foreach my $entry ( |
|
216
|
|
|
|
|
|
|
_asArray($self->{hash}[0]{config}{storageDevice}{scsiLun})) |
|
217
|
|
|
|
|
|
|
{ |
|
218
|
0
|
|
|
|
|
|
my $serialnumber; |
|
219
|
|
|
|
|
|
|
my $size; |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# TODO |
|
222
|
|
|
|
|
|
|
#$volumnMapping{$entry->{canonicalName}} = $entry->{deviceName}; |
|
223
|
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
foreach my $altName (_asArray($entry->{alternateName})) { |
|
225
|
0
|
0
|
|
|
|
|
next unless ref($altName) eq 'HASH'; |
|
226
|
0
|
0
|
|
|
|
|
next unless $altName->{namespace}; |
|
227
|
0
|
0
|
|
|
|
|
next unless $altName->{data}; |
|
228
|
0
|
0
|
|
|
|
|
if ( $altName->{namespace} eq 'SERIALNUM' ) { |
|
229
|
0
|
|
|
|
|
|
$serialnumber .= $_ foreach ( @{ $altName->{data} } ); |
|
|
0
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
} |
|
232
|
0
|
0
|
0
|
|
|
|
if ( $entry->{capacity}{blockSize} && $entry->{capacity}{block} ) { |
|
233
|
0
|
|
|
|
|
|
$size = int(($entry->{capacity}{blockSize} *$entry->{capacity}{block})/1024/1024); |
|
234
|
|
|
|
|
|
|
} |
|
235
|
0
|
|
|
|
|
|
my $manufacturer; |
|
236
|
0
|
0
|
0
|
|
|
|
if ( $entry->{vendor} && ( $entry->{vendor} !~ /^\s*ATA\s*$/ ) ) { |
|
237
|
0
|
|
|
|
|
|
$manufacturer = $entry->{vendor}; |
|
238
|
|
|
|
|
|
|
} else { |
|
239
|
0
|
|
|
|
|
|
$manufacturer = getCanonicalManufacturer( $entry->{model} ); |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
$manufacturer =~ s/\s*(\S.*\S)\s*/$1/; |
|
243
|
|
|
|
|
|
|
|
|
244
|
0
|
|
|
|
|
|
my $model = $entry->{model}; |
|
245
|
0
|
|
|
|
|
|
$model =~ s/\s*(\S.*\S)\s*/$1/; |
|
246
|
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
push @storages, { |
|
248
|
|
|
|
|
|
|
DESCRIPTION => $entry->{displayName}, |
|
249
|
|
|
|
|
|
|
DISKSIZE => $size, |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# INTERFACE |
|
252
|
|
|
|
|
|
|
MANUFACTURER => $manufacturer, |
|
253
|
|
|
|
|
|
|
MODEL => $model, |
|
254
|
|
|
|
|
|
|
NAME => $entry->{deviceName}, |
|
255
|
|
|
|
|
|
|
TYPE => $entry->{deviceType}, |
|
256
|
|
|
|
|
|
|
SERIAL => $serialnumber, |
|
257
|
|
|
|
|
|
|
FIRMWARE => $entry->{revision}, |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# SCSI_COID |
|
260
|
|
|
|
|
|
|
# SCSI_CHID |
|
261
|
|
|
|
|
|
|
# SCSI_UNID |
|
262
|
|
|
|
|
|
|
# SCSI_LUN |
|
263
|
|
|
|
|
|
|
}; |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
|
return @storages; |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub getDrives { |
|
272
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
273
|
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
my @drives; |
|
275
|
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
foreach ( |
|
277
|
|
|
|
|
|
|
_asArray($self->{hash}[0]{config}{fileSystemVolume}{mountInfo})) |
|
278
|
|
|
|
|
|
|
{ |
|
279
|
0
|
|
|
|
|
|
my $volumn; |
|
280
|
0
|
0
|
0
|
|
|
|
if ( $_->{volume}{type} && ( $_->{volume}{type} =~ /NFS/i ) ) { |
|
281
|
0
|
|
|
|
|
|
$volumn = $_->{volume}{remoteHost} . ':' . $_->{volume}{remotePath}; |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
# TODO |
|
284
|
|
|
|
|
|
|
# } else { |
|
285
|
|
|
|
|
|
|
# $volumn = $volumnMapping{$_->{volume}{extent}{diskName}}." ".$_->{volume}{extent}{partition}; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
0
|
|
0
|
|
|
|
push @drives, |
|
288
|
|
|
|
|
|
|
{ |
|
289
|
|
|
|
|
|
|
SERIAL => $_->{volume}{uuid}, |
|
290
|
|
|
|
|
|
|
TOTAL => int( ( $_->{volume}{capacity} || 0 ) / ( 1000 * 1000 ) ), |
|
291
|
|
|
|
|
|
|
TYPE => $_->{mountInfo}{path}, |
|
292
|
|
|
|
|
|
|
VOLUMN => $volumn, |
|
293
|
|
|
|
|
|
|
NAME => $_->{volume}{name}, |
|
294
|
|
|
|
|
|
|
FILESYSTEM => lc( $_->{volume}{type} ) |
|
295
|
|
|
|
|
|
|
}; |
|
296
|
|
|
|
|
|
|
} |
|
297
|
|
|
|
|
|
|
|
|
298
|
0
|
|
|
|
|
|
return @drives; |
|
299
|
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub getVirtualMachines { |
|
302
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
303
|
|
|
|
|
|
|
|
|
304
|
0
|
|
|
|
|
|
my @virtualMachines; |
|
305
|
|
|
|
|
|
|
|
|
306
|
0
|
|
|
|
|
|
foreach my $vm (@{$self->{vms}}) { |
|
|
0
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
my $machine = $vm->[0]; |
|
308
|
0
|
0
|
|
|
|
|
my $status = |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
$machine->{summary}{runtime}{powerState} eq 'poweredOn' ? 'running' : |
|
310
|
|
|
|
|
|
|
$machine->{summary}{runtime}{powerState} eq 'poweredOff' ? 'off' : |
|
311
|
|
|
|
|
|
|
$machine->{summary}{runtime}{powerState} eq 'suspended' ? 'pause' : |
|
312
|
|
|
|
|
|
|
undef ; |
|
313
|
0
|
0
|
|
|
|
|
print "Unknown status (".$machine->{summary}{runtime}{powerState}.")\n" if !$status; |
|
314
|
|
|
|
|
|
|
|
|
315
|
0
|
|
|
|
|
|
my @mac; |
|
316
|
0
|
|
|
|
|
|
foreach my $device (_asArray($machine->{config}{hardware}{device})) { |
|
317
|
0
|
0
|
|
|
|
|
push @mac, $device->{macAddress} if $device->{macAddress}; |
|
318
|
|
|
|
|
|
|
} |
|
319
|
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
my $comment = $machine->{config}{annotation}; |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
# hack to preserve annotation / comment formating |
|
323
|
0
|
0
|
|
|
|
|
$comment =~ s/\n/
/gm if $comment; |
|
324
|
|
|
|
|
|
|
|
|
325
|
0
|
0
|
0
|
|
|
|
if ( |
|
326
|
|
|
|
|
|
|
defined($_->[0]{summary}{config}{template}) |
|
327
|
|
|
|
|
|
|
&& |
|
328
|
|
|
|
|
|
|
$_->[0]{summary}{config}{template} eq 'true' |
|
329
|
|
|
|
|
|
|
) { |
|
330
|
0
|
|
|
|
|
|
next; |
|
331
|
|
|
|
|
|
|
} |
|
332
|
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
|
push @virtualMachines, |
|
334
|
|
|
|
|
|
|
{ |
|
335
|
|
|
|
|
|
|
VMID => $machine->{summary}{vm}, |
|
336
|
|
|
|
|
|
|
NAME => $machine->{name}, |
|
337
|
|
|
|
|
|
|
STATUS => $status, |
|
338
|
|
|
|
|
|
|
UUID => $machine->{summary}{config}{uuid}, |
|
339
|
|
|
|
|
|
|
MEMORY => $machine->{summary}{config}{memorySizeMB}, |
|
340
|
|
|
|
|
|
|
VMTYPE => 'VMware', |
|
341
|
|
|
|
|
|
|
VCPU => $machine->{summary}{config}{numCpu}, |
|
342
|
|
|
|
|
|
|
MAC => join( '/', @mac ), |
|
343
|
|
|
|
|
|
|
COMMENT => $comment |
|
344
|
|
|
|
|
|
|
}; |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
|
|
347
|
0
|
|
|
|
|
|
return @virtualMachines; |
|
348
|
|
|
|
|
|
|
} |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
1; |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
__END__ |