Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtualization/LXC: use utsname instead of container name #993

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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,7 @@ sub _getVirtualMachines {

my $uuid = getVirtualUUID($machineid, $hostname);
$container->{UUID} = $uuid if $uuid;
$container->{NAME} = $container->{UTS_NAME} if $container->{UTS_NAME};
mayasd marked this conversation as resolved.
Show resolved Hide resolved

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