Skip to content

Commit

Permalink
feat: Make full-inventory-postpone feature really works on MacOSX for…
Browse files Browse the repository at this point in the history
… few categories
  • Loading branch information
g-bougard committed Apr 25, 2024
1 parent e2971a3 commit dbf3bd3
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/GLPI/Agent/Task/Inventory/MacOS/Drives.pm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ sub doInventory {
}

# add filesystems to the inventory
foreach my $key (keys %filesystems) {
foreach my $key (sort keys %filesystems) {
$inventory->addEntry(
section => 'DRIVES',
entry => $filesystems{$key}
Expand Down
4 changes: 2 additions & 2 deletions lib/GLPI/Agent/Task/Inventory/MacOS/License.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sub doInventory {
);
}

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

# VMware
my @vmwareFiles = Glob('"/Library/Application Support/VMware Fusion/license-*"');
foreach my $vmwareFile (@vmwareFiles) {
foreach my $vmwareFile (sort @vmwareFiles) {
my %info;
# e.g:
# LicenseType = "Site"
Expand Down
2 changes: 1 addition & 1 deletion lib/GLPI/Agent/Task/Inventory/MacOS/Printers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sub doInventory {
my $infos = getSystemProfilerInfos(type => 'SPPrintersDataType', logger => $logger);
my $info = $infos->{Printers};

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

$inventory->addEntry(
Expand Down
2 changes: 1 addition & 1 deletion lib/GLPI/Agent/Task/Inventory/MacOS/Softwares.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sub _getSoftwaresList {
my $info = $infos->{Applications};

my @softwares;
for my $name (keys %$info) {
for my $name (sort keys %$info) {
my $app = $info->{$name};

# Windows application found by Parallels (issue #716)
Expand Down
2 changes: 1 addition & 1 deletion lib/GLPI/Agent/Task/Inventory/MacOS/Sound.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sub doInventory {
my $infos = getSystemProfilerInfos(type => 'SPAudioDataType', logger => $logger);
my $info = $infos->{'Audio (Built In)'};

foreach my $sound (keys %$info){
foreach my $sound (sort keys %$info){
$inventory->addEntry(
section => 'SOUNDS',
entry => {
Expand Down
15 changes: 10 additions & 5 deletions lib/GLPI/Agent/Task/Inventory/MacOS/Storages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ sub _getSerialATAStorages {
);
return unless $infos->{storages};
my @storages = ();
foreach my $hash (values %{$infos->{storages}}) {
foreach my $name (sort keys %{$infos->{storages}}) {
my $hash = $infos->{storages}->{$name};
next unless $hash->{partition_map_type} || $hash->{detachable_drive};
next if $hash->{_name} =~ /controller/i;
my $storage = {
Expand Down Expand Up @@ -81,7 +82,8 @@ sub _getDiscBurningStorages {
);
return @storages unless $infos->{storages};

foreach my $hash (values %{$infos->{storages}}) {
foreach my $name (sort keys %{$infos->{storages}}) {
my $hash = $infos->{storages}->{$name};
my $storage = {
NAME => $hash->{bsd_name} || $hash->{_name},
MANUFACTURER => getCanonicalManufacturer($hash->{manufacturer} || $hash->{_name}),
Expand Down Expand Up @@ -114,7 +116,8 @@ sub _getCardReaderStorages {
return unless $infos->{storages};

my @storages = ();
foreach my $hash (values %{$infos->{storages}}) {
foreach my $name (sort keys %{$infos->{storages}}) {
my $hash = $infos->{storages}->{$name};
next if ($hash->{iocontent} || $hash->{file_system} || $hash->{mount_point}) && !$hash->{partition_map_type};
my $storage;
if ($hash->{_name} eq 'spcardreader') {
Expand Down Expand Up @@ -152,7 +155,8 @@ sub _getUSBStorages {
return unless $infos->{storages};

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

my @storages = ();
foreach my $hash (values %{$infos->{storages}}) {
foreach my $name (sort keys %{$infos->{storages}}) {
my $hash = $infos->{storages}->{$name};
next unless $hash->{partition_map_type};
my $storage = {
NAME => $hash->{bsd_name} || $hash->{_name},
Expand Down
2 changes: 1 addition & 1 deletion lib/GLPI/Agent/Task/Inventory/MacOS/Videos.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sub _getVideoCards {

my @videos;

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

my $memory = getCanonicalSize($videoCardInfo->{'VRAM (Total)'} ||
Expand Down
5 changes: 3 additions & 2 deletions lib/GLPI/Agent/Tools/License.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sub getAdobeLicenses {
}
}

foreach my $key (keys %data) {
foreach my $key (sort keys %data) {
next unless $data{$key}{SN} || $data{$key}{with};

push @licenses, {
Expand Down Expand Up @@ -98,7 +98,8 @@ sub getAdobeLicensesWithoutSqlite {
}
}

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

0 comments on commit dbf3bd3

Please sign in to comment.