line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::XenCitrixServer; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
56347558
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
675
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1005
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $runMeIfTheseChecksFailed = ["FusionInventory::Agent::Task::Inventory::Virtualization::Libvirt"]; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub isEnabled { |
11
|
0
|
|
|
0
|
0
|
|
return canRun('xe'); |
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
|
|
|
|
|
|
my $command = 'xe vm-list'; |
21
|
0
|
|
|
|
|
|
foreach my $machine (_getUUID(command => $command, logger => $logger)) { |
22
|
0
|
|
|
|
|
|
my $machineextend = _getVirtualMachines( |
23
|
|
|
|
|
|
|
command => "xe vm-param-list uuid=$machine->{UUID}", |
24
|
|
|
|
|
|
|
logger => $logger, |
25
|
|
|
|
|
|
|
); |
26
|
0
|
|
|
|
|
|
foreach my $key ($machineextend) { |
27
|
0
|
|
|
|
|
|
$machine->{$key} = $machineextend->{$key}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$inventory->addEntry( |
31
|
0
|
|
|
|
|
|
section => 'VIRTUALMACHINES', entry => $machine |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _getUUID { |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
return unless $handle; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my @machines; |
43
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
44
|
0
|
|
|
|
|
|
chomp $line; |
45
|
0
|
0
|
|
|
|
|
next unless $line =~ /uuid ( RO)/; |
46
|
0
|
|
|
|
|
|
my (undef, $uuid) = split(':', $line); |
47
|
0
|
|
|
|
|
|
chomp $uuid; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $machine = { |
50
|
|
|
|
|
|
|
UUID => $uuid, |
51
|
|
|
|
|
|
|
SUBSYSTEM => 'xe', |
52
|
|
|
|
|
|
|
VMTYPE => 'xen', |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
push @machines, $machine; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
close $handle; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return @machines; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _getVirtualMachines { |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
return unless $handle; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# xe status |
70
|
0
|
|
|
|
|
|
my %status_list = ( |
71
|
|
|
|
|
|
|
'running' => 'running', |
72
|
|
|
|
|
|
|
'halted' => 'shutdown', |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $machine; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
78
|
0
|
|
|
|
|
|
chomp $line; |
79
|
0
|
|
|
|
|
|
my ($extendedlabel, $value) = split('\): ', $line); |
80
|
0
|
|
|
|
|
|
chomp $value; |
81
|
0
|
0
|
|
|
|
|
if ($extendedlabel =~ /name-label/) { |
82
|
0
|
|
|
|
|
|
$machine->{NAME} = $value; |
83
|
0
|
|
|
|
|
|
next; |
84
|
|
|
|
|
|
|
} |
85
|
0
|
0
|
|
|
|
|
if ($extendedlabel =~ /memory-actual/) { |
86
|
0
|
|
|
|
|
|
$machine->{MEMORY} = ($value / 1048576); |
87
|
0
|
|
|
|
|
|
next; |
88
|
|
|
|
|
|
|
} |
89
|
0
|
0
|
|
|
|
|
if ($extendedlabel =~ /power-state/) { |
90
|
0
|
0
|
|
|
|
|
$machine->{STATUS} = $value ? $status_list{$value} : 'off'; |
91
|
0
|
|
|
|
|
|
next; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
0
|
|
|
|
|
if ($extendedlabel =~ /VCPUs-number/) { |
94
|
0
|
|
|
|
|
|
$machine->{VCPU} = $value; |
95
|
0
|
|
|
|
|
|
next; |
96
|
|
|
|
|
|
|
} |
97
|
0
|
0
|
|
|
|
|
if ($extendedlabel =~ /name-description/) { |
98
|
0
|
0
|
|
|
|
|
next if $value eq ''; |
99
|
0
|
|
|
|
|
|
$machine->{COMMENT} = $value; |
100
|
0
|
|
|
|
|
|
next; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return $machine; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |