Skip to content

Commit dbf3bd3

Browse files
committed
feat: Make full-inventory-postpone feature really works on MacOSX for few categories
1 parent e2971a3 commit dbf3bd3

File tree

8 files changed

+20
-14
lines changed

8 files changed

+20
-14
lines changed

lib/GLPI/Agent/Task/Inventory/MacOS/Drives.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ sub doInventory {
7777
}
7878

7979
# add filesystems to the inventory
80-
foreach my $key (keys %filesystems) {
80+
foreach my $key (sort keys %filesystems) {
8181
$inventory->addEntry(
8282
section => 'DRIVES',
8383
entry => $filesystems{$key}

lib/GLPI/Agent/Task/Inventory/MacOS/License.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ sub doInventory {
4343
);
4444
}
4545

46-
foreach my $transmitFile (@transmitFiles) {
46+
foreach my $transmitFile (sort @transmitFiles) {
4747
my $info = _getTransmitLicenses(
4848
command => "plutil -convert xml1 -o - '$transmitFile'"
4949
);
@@ -54,7 +54,7 @@ sub doInventory {
5454

5555
# VMware
5656
my @vmwareFiles = Glob('"/Library/Application Support/VMware Fusion/license-*"');
57-
foreach my $vmwareFile (@vmwareFiles) {
57+
foreach my $vmwareFile (sort @vmwareFiles) {
5858
my %info;
5959
# e.g:
6060
# LicenseType = "Site"

lib/GLPI/Agent/Task/Inventory/MacOS/Printers.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sub doInventory {
2424
my $infos = getSystemProfilerInfos(type => 'SPPrintersDataType', logger => $logger);
2525
my $info = $infos->{Printers};
2626

27-
foreach my $printer (keys %$info) {
27+
foreach my $printer (sort keys %$info) {
2828
next unless ref($info->{printer}) eq 'HASH';
2929

3030
$inventory->addEntry(

lib/GLPI/Agent/Task/Inventory/MacOS/Softwares.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ sub _getSoftwaresList {
4646
my $info = $infos->{Applications};
4747

4848
my @softwares;
49-
for my $name (keys %$info) {
49+
for my $name (sort keys %$info) {
5050
my $app = $info->{$name};
5151

5252
# Windows application found by Parallels (issue #716)

lib/GLPI/Agent/Task/Inventory/MacOS/Sound.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sub doInventory {
2323
my $infos = getSystemProfilerInfos(type => 'SPAudioDataType', logger => $logger);
2424
my $info = $infos->{'Audio (Built In)'};
2525

26-
foreach my $sound (keys %$info){
26+
foreach my $sound (sort keys %$info){
2727
$inventory->addEntry(
2828
section => 'SOUNDS',
2929
entry => {

lib/GLPI/Agent/Task/Inventory/MacOS/Storages.pm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ sub _getSerialATAStorages {
4444
);
4545
return unless $infos->{storages};
4646
my @storages = ();
47-
foreach my $hash (values %{$infos->{storages}}) {
47+
foreach my $name (sort keys %{$infos->{storages}}) {
48+
my $hash = $infos->{storages}->{$name};
4849
next unless $hash->{partition_map_type} || $hash->{detachable_drive};
4950
next if $hash->{_name} =~ /controller/i;
5051
my $storage = {
@@ -81,7 +82,8 @@ sub _getDiscBurningStorages {
8182
);
8283
return @storages unless $infos->{storages};
8384

84-
foreach my $hash (values %{$infos->{storages}}) {
85+
foreach my $name (sort keys %{$infos->{storages}}) {
86+
my $hash = $infos->{storages}->{$name};
8587
my $storage = {
8688
NAME => $hash->{bsd_name} || $hash->{_name},
8789
MANUFACTURER => getCanonicalManufacturer($hash->{manufacturer} || $hash->{_name}),
@@ -114,7 +116,8 @@ sub _getCardReaderStorages {
114116
return unless $infos->{storages};
115117

116118
my @storages = ();
117-
foreach my $hash (values %{$infos->{storages}}) {
119+
foreach my $name (sort keys %{$infos->{storages}}) {
120+
my $hash = $infos->{storages}->{$name};
118121
next if ($hash->{iocontent} || $hash->{file_system} || $hash->{mount_point}) && !$hash->{partition_map_type};
119122
my $storage;
120123
if ($hash->{_name} eq 'spcardreader') {
@@ -152,7 +155,8 @@ sub _getUSBStorages {
152155
return unless $infos->{storages};
153156

154157
my @storages = ();
155-
foreach my $hash (values %{$infos->{storages}}) {
158+
foreach my $name (sort keys %{$infos->{storages}}) {
159+
my $hash = $infos->{storages}->{$name};
156160
unless ($hash->{bsn_name} && $hash->{bsd_name} =~ /^disk/) {
157161
next if $hash->{_name} eq 'Mass Storage Device';
158162
next if $hash->{_name} =~ /keyboard|controller|IR Receiver|built-in|hub|mouse|tablet|usb(?:\d+)?bus/i;
@@ -215,7 +219,8 @@ sub _getFireWireStorages {
215219
return unless $infos->{storages};
216220

217221
my @storages = ();
218-
foreach my $hash (values %{$infos->{storages}}) {
222+
foreach my $name (sort keys %{$infos->{storages}}) {
223+
my $hash = $infos->{storages}->{$name};
219224
next unless $hash->{partition_map_type};
220225
my $storage = {
221226
NAME => $hash->{bsd_name} || $hash->{_name},

lib/GLPI/Agent/Task/Inventory/MacOS/Videos.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ sub _getVideoCards {
3939

4040
my @videos;
4141

42-
foreach my $videoName (keys %{$infos->{'Graphics/Displays'}}) {
42+
foreach my $videoName (sort keys %{$infos->{'Graphics/Displays'}}) {
4343
my $videoCardInfo = $infos->{'Graphics/Displays'}->{$videoName};
4444

4545
my $memory = getCanonicalSize($videoCardInfo->{'VRAM (Total)'} ||

lib/GLPI/Agent/Tools/License.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ sub getAdobeLicenses {
6767
}
6868
}
6969

70-
foreach my $key (keys %data) {
70+
foreach my $key (sort keys %data) {
7171
next unless $data{$key}{SN} || $data{$key}{with};
7272

7373
push @licenses, {
@@ -98,7 +98,8 @@ sub getAdobeLicensesWithoutSqlite {
9898
}
9999
}
100100

101-
while (my ($product, $component) = each %products) {
101+
foreach my $product (sort keys %products) {
102+
my $component = $products{$product};
102103
$copyContent = $contentFileAdobe;
103104
my $regex = $product.'\{\|\}[a-zA-Z0-9\-_]+SN([0-9]{24})';
104105
$copyContent =~ /$regex/;

0 commit comments

Comments
 (0)