Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ sub _getVirtualMachine {
if ($params{version} < 2.1) {
# Before 2.1, we need to find MAC as lxc.network.hwaddr in config
$command .= "; grep lxc.network.hwaddr $params{config}";
$command .= "; grep lxc.utsname $params{config}";
} else {
$command .= " -c lxc.net.0.hwaddr";
$command .= " -c lxc.uts.name";
}

my $handle = getFileHandle(
Expand All @@ -87,6 +89,10 @@ sub _getVirtualMachine {

my $key = $1;
my $val = $2;
if ($key eq 'lxc.uts.name' || $key eq 'lxc.utsname') {
$container->{UTS_NAME} = $val;
}

if ($key eq 'lxc.network.hwaddr' || $key eq 'lxc.net.0.hwaddr') {
$container->{MAC} = lc($val)
if $val =~ $mac_address_pattern;
Expand Down Expand Up @@ -190,6 +196,8 @@ sub _getVirtualMachines {

my $uuid = getVirtualUUID($machineid, $hostname);
$container->{UUID} = $uuid if $uuid;
my $utsname = delete $container->{UTS_NAME};
$container->{NAME} = $utsname if $utsname && $container->{NAME} =~ /^\d+$/;

push @machines, $container;
}
Expand Down
1 change: 1 addition & 0 deletions t/tasks/inventory/virtualization/lxc.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ my %container_tests = (
version => 2.0,
result => {
NAME => 'config',
UTS_NAME => 'name1',
VMTYPE => 'lxc',
STATUS => STATUS_OFF,
MEMORY => '2048000',
Expand Down