Skip to content

Commit 7430218

Browse files
authored
Fix Proxmox/LXC memory conversion Lxc.pm (#869)
Fix memory conversion for LXC containers on Proxmox by converting plain byte values to MB
1 parent 636e8e1 commit 7430218

File tree

2 files changed

+3
-3
lines changed
  • lib/GLPI/Agent/Task/Inventory/Virtualization
  • t/tasks/inventory/virtualization

2 files changed

+3
-3
lines changed

lib/GLPI/Agent/Task/Inventory/Virtualization/Lxc.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ sub _getVirtualMachine {
103103
}
104104

105105
if ($key eq 'lxc.cgroup.memory.limit_in_bytes' || $key eq 'lxc.cgroup2.memory.max') {
106-
$val .= "b" if $val =~ /[KMGTP]$/i;
106+
$val .= $val =~ /[KMGTP]$/i ? "b" : $val =~ /^\d+$/ ? "bytes" : "";
107107
$container->{MEMORY} = getCanonicalSize($val, 1024);
108108
}
109109

t/tasks/inventory/virtualization/lxc.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ my %container_tests = (
2323
NAME => 'config',
2424
VMTYPE => 'lxc',
2525
STATUS => STATUS_OFF,
26-
MEMORY => '2048000',
26+
MEMORY => '1',
2727
MAC => '01:23:45:67:89:0a',
2828
VCPU => 4
2929
}
@@ -55,7 +55,7 @@ my %container_tests = (
5555
VMTYPE => 'lxc',
5656
STATUS => STATUS_RUNNING,
5757
MAC => 'fa:ee:26:ef:6b:1c',
58-
MEMORY => 2147483648,
58+
MEMORY => 2048,
5959
VCPU => 2
6060
}
6161
},

0 commit comments

Comments
 (0)