line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::Hpvm; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
60269098
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
58
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
578
|
use XML::TreePP; |
|
1
|
|
|
|
|
5482
|
|
|
1
|
|
|
|
|
20
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
482
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
312
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub isEnabled { |
11
|
0
|
|
|
0
|
0
|
|
return canRun('hpvmstatus'); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub doInventory { |
15
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
18
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
foreach my $machine (_getMachines( |
21
|
|
|
|
|
|
|
command => 'hpvmstatus -X', logger => $logger |
22
|
|
|
|
|
|
|
)) { |
23
|
0
|
|
|
|
|
|
$inventory->addEntry( |
24
|
|
|
|
|
|
|
section => 'VIRTUALMACHINES', entry => $machine |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _getMachines { |
30
|
0
|
|
|
0
|
|
|
my $xml = getAllLines(@_); |
31
|
0
|
0
|
|
|
|
|
return unless $xml; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $tpp = XML::TreePP->new(); |
34
|
0
|
|
|
|
|
|
my $data = $tpp->parse($xml); |
35
|
0
|
|
|
|
|
|
my $mvs = $data->{pman}->{virtual_machine}; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my %units = ( |
38
|
|
|
|
|
|
|
'MB' => 1, |
39
|
|
|
|
|
|
|
'GB' => 1024, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my %status = ( |
43
|
|
|
|
|
|
|
'On' => 'running', |
44
|
|
|
|
|
|
|
'Off' => 'off', |
45
|
|
|
|
|
|
|
'Invalid' => 'crashed', |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my @machines; |
49
|
0
|
|
|
|
|
|
foreach my $name (keys %$mvs) { |
50
|
0
|
|
|
|
|
|
my $info = $mvs->{$name}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $machine = { |
53
|
|
|
|
|
|
|
MEMORY => $info->{memory}->{total}->{content} * |
54
|
|
|
|
|
|
|
$units{$info->{memory}->{total}->{unit}}, |
55
|
|
|
|
|
|
|
NAME => $name, |
56
|
|
|
|
|
|
|
UUID => $info->{uuid}, |
57
|
|
|
|
|
|
|
STATUS => $status{$info->{vm_state}}, |
58
|
|
|
|
|
|
|
SUBSYSTEM => "HPVM", |
59
|
|
|
|
|
|
|
VMTYPE => "HPVM", |
60
|
|
|
|
|
|
|
VCPU => $info->{vcpu_number}, |
61
|
0
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
push @machines, $machine; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return @machines; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |