"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Ocsinventory/Agent/Backend/Virtualization/Libvirt.pm" between
Ocsinventory-Unix-Agent-2.6.1.tar.gz and Ocsinventory-Unix-Agent-2.8.0.tar.gz

About: Ocsinventory-Agent is a Linux agent for OCS Inventory NG.

Libvirt.pm  (Ocsinventory-Unix-Agent-2.6.1):Libvirt.pm  (Ocsinventory-Unix-Agent-2.8.0)
skipping to change at line 17 skipping to change at line 17
sub check { sub check {
my $params = shift; my $params = shift;
my $common = $params->{common}; my $common = $params->{common};
$common->can_run('virsh') $common->can_run('virsh')
} }
sub run { sub run {
my $params = shift; my $params = shift;
my $common = $params->{common}; my $common = $params->{common};
foreach (`virsh list --all`) { foreach (`virsh --readonly list --all`) {
if (/^\s*(\d+|\s+\-)\s+(\S+)\s+(\S.+)/){ if (/^\s*(\d+|\s+\-)\s+(\S+)\s+(\S.+)/){
my $memory; my $memory;
my $vcpu; my $vcpu;
my $name = $2; my $name = $2;
my $status = $3; my $status = $3;
$status =~ s/^shut off/off/; $status =~ s/^shut off/off/;
my $xml = `virsh dumpxml $name`; my $xml = `virsh --readonly dumpxml $name`;
my $data = XMLin($xml); my $data = XMLin($xml);
my $vcpu = $data->{vcpu}; my $vcpu = $data->{vcpu};
my $uuid = $data->{uuid}; my $uuid = $data->{uuid};
my $vmtype = $data->{type}; my $vmtype = $data->{type};
if ($data->{currentMemory}->{unit}) { if ($data->{currentMemory}->{unit}) {
$memory = $1 if $data->{currentMemory}->{content} =~ /(\d+)\d{3} $/; $memory = $1 if $data->{currentMemory}->{content} =~ /(\d+)\d{3} $/;
$vcpu = $data->{vcpu}->{content}; $vcpu = $data->{vcpu}->{content};
} else { } else {
$memory = $1 if $data->{currentMemory} =~ /(\d+)\d{3}$/; $memory = $1 if $data->{currentMemory} =~ /(\d+)\d{3}$/;
$vcpu = $data->{vcpu}; $vcpu = $data->{vcpu};
} }
my $machine = { my %machine = (
MEMORY => $memory, MEMORY => $memory,
NAME => $name, NAME => $name,
UUID => $uuid, UUID => $uuid,
STATUS => $status, STATUS => $status,
SUBSYSTEM => "Libvirt", SUBSYSTEM => "Libvirt",
VMTYPE => $vmtype, VMTYPE => $vmtype,
VCPU => $vcpu, VCPU => $vcpu,
}; );
$common->addVirtualMachine($machine); $common->addVirtualMachine(\%machine);
} }
} }
} }
1; 1;
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)