From 43b373ed3db163d6439a65d4945f87755686b550 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Fri, 10 Jul 2015 22:45:59 +0200 Subject: [PATCH] compute a compound identifier for Virtuozzo Virtuozzo uses the same UUID for host and guest, so we have to compute our own compound indentifier for the guest, using local container ID. Reported-by: Matthieu Marc --- .../Agent/Task/Inventory/Virtualization/Virtuozzo.pm | 8 +++++++- .../Agent/Task/Inventory/Virtualization/Vmsystem.pm | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Virtuozzo.pm b/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Virtuozzo.pm index 1dd102bba1..088a462b44 100644 --- a/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Virtuozzo.pm +++ b/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Virtuozzo.pm @@ -29,6 +29,8 @@ sub doInventory { # no service containers in glpi my $line = <$handle>; + my $hostID = $inventory->{h}{CONTENT}{HARDWARE}{UUID} || ''; + while (my $line = <$handle>) { chomp $line; @@ -70,12 +72,16 @@ sub doInventory { } } + # compute specific identifier for the guest, as CTID is + # unique only for the local hosts + my $uuid = $hostID . '-' . $ctid; + $inventory->addEntry( section => 'VIRTUALMACHINES', entry => { NAME => $name, VCPU => $cpus, - UUID => $ctid, + UUID => $uuid, MEMORY => $memory, STATUS => $status, SUBSYSTEM => $subsys, diff --git a/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Vmsystem.pm b/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Vmsystem.pm index 851c86d72a..02c5952d3a 100644 --- a/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Vmsystem.pm +++ b/lib/FusionInventory/Agent/Task/Inventory/Virtualization/Vmsystem.pm @@ -76,6 +76,17 @@ sub doInventory { }); } + # compute a compound identifier, as Virtuozzo uses the same identifier + # for the host and for the guests + if ($type eq 'Virtuozzo') { + my $hostID = $inventory->{h}{CONTENT}{HARDWARE}{UUID} || ''; + my $guestID = getFirstMatch( + file => '/proc/self/status', + pattern => qr/^envID:\s*(\d+)/ + ) || ''; + $inventory->setHardware({ UUID => $hostID . '-' . $guestID }); + } + $inventory->setHardware({ VMSYSTEM => $type, });