line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::Hpvm; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
59702967
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
81
|
|
4
|
1
|
|
|
1
|
|
15
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
105
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1393
|
use XML::TreePP; |
|
1
|
|
|
|
|
11080
|
|
|
1
|
|
|
|
|
25
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
810
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
548
|
|
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; |