line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::Hpvm; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
44317797
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
95
|
|
4
|
1
|
|
|
1
|
|
14
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
745
|
use XML::TreePP; |
|
1
|
|
|
|
|
10930
|
|
|
1
|
|
|
|
|
23
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
615
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
351
|
|
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
|
0
|
|
|
|
|
|
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
|
|
|
|
|
|
|
VMID => $info->{local_id} |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
push @machines, $machine; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return @machines; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |