Skip to content

Commit

Permalink
compute a compound identifier for Virtuozzo
Browse files Browse the repository at this point in the history
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 <Matthieu.Marc@ensam.eu>
  • Loading branch information
guillomovitch committed Jul 10, 2015
1 parent ab41a42 commit 43b373e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Expand Up @@ -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,
});
Expand Down

0 comments on commit 43b373e

Please sign in to comment.