"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Ocsinventory/Agent/Backend/OS/MacOS/Storages.pm" between
Ocsinventory-Unix-Agent-2.6.1.tar.gz and Ocsinventory-Unix-Agent-2.8.0.tar.gz

About: Ocsinventory-Agent is a Linux agent for OCS Inventory NG.

Storages.pm  (Ocsinventory-Unix-Agent-2.6.1):Storages.pm  (Ocsinventory-Unix-Agent-2.8.0)
package Ocsinventory::Agent::Backend::OS::MacOS::Storages; package Ocsinventory::Agent::Backend::OS::MacOS::Storages;
use strict; use strict;
sub check { sub check {
my $params = shift; my $params = shift;
my $common = $params->{common}; my $common = $params->{common};
return $common->can_load('Mac::SysProfile'); return $common->can_load('Mac::SysProfile');
return $common->can_run('system_profiler');
} }
sub getManufacturer { sub getManufacturer {
my $model = shift;
if($model =~ /(maxtor|western|sony|compaq|hewlett packard|ibm|seagate|toshiba| my $model = shift;
fujitsu|lg|samsung|nec|transcend|matshita|pioneer|hitachi)/i) { $model =~ s/APPLE HDD //;
return ucfirst(lc($1)); if ($model =~ /(maxtor|western|sony|compaq|hewlett packard|ibm|seagate|toshi
} ba|fujitsu|lg|samsung|nec|transcend|matshita|pioneer|hitachi)/i) {
elsif ($model =~ /^HP/) { return ucfirst(lc($1));
return "Hewlett Packard"; } elsif ($model =~ /^APPLE SSD/) {
} return "Apple";
elsif ($model =~ /^WDC/) { } elsif ($model =~ /^HP/) {
return "Western Digital"; return "Hewlett Packard";
} } elsif ($model =~ /^WDC/) {
elsif ($model =~ /^ST/) { return "Western Digital";
return "Seagate"; } elsif ($model =~ /^ST/) {
} return "Seagate";
elsif ($model =~ /^HD/ or $model =~ /^IC/ or $model =~ /^HU/) { } elsif ($model =~ /^HDi|^HT/ or $model =~ /^IC/ or $model =~ /^HU/) {
return "Hitachi"; return "Hitachi";
} }
} }
sub run { sub run {
my $params = shift; my $params = shift;
my $common = $params->{common}; my $common = $params->{common};
my $logger = $params->{logger}; my $logger = $params->{logger};
my $devices = {}; my $devices = {};
my $profile = Mac::SysProfile->new(); my $profile = Mac::SysProfile->new();
# Get SATA Drives # Get SATA Drives
my $sata = $profile->gettype('SPSerialATADataType'); my $sata = $profile->gettype('SPSerialATADataType');
if ( ref($sata) eq 'ARRAY') { if ( ref($sata) eq 'ARRAY') {
foreach my $storage ( @$sata ) { foreach my $storage ( @$sata ) {
next unless ( ref($storage) eq 'HASH' ); next unless ( ref($storage) eq 'HASH' );
my $description; my $type;
if ( $storage->{'_name'} =~ /DVD/i || $storage->{'_name'} =~ /CD/i ) { if ( $storage->{'_name'} =~ /DVD/i || $storage->{'_name'} =~ /CD/i ) {
$description = 'CD-ROM Drive'; $type = 'CD-ROM Drive';
} } elsif ($storage->{'_name'} =~ /SSD/i || $storage->{'spsata_medium_type
else { '} =~ /Solid State/i) {
$description = 'Disk drive'; $type = 'Disk SSD drive';
} }else {
$type = 'Disk drive';
my $size = $storage->{'size'}; }
if ($size =~ /GB/) {
$size =~ s/ GB//; my $size = $storage->{'size'};
$size *= 1024; if ($size =~ /GB/) {
} $size =~ s/ GB//;
if ($size =~ /TB/) { $size *= 1024;
$size =~ s/ TB//; }
$size *= 1048576; if ($size =~ /TB/) {
$size =~ s/ TB//;
$size *= 1048576;
}
my $manufacturer = getManufacturer($storage->{'_name'});
my $model = $storage->{'device_model'};
$model =~ s/\s*$manufacturer\s*//i;
my $description = "Status: $storage->{'smart_status'}";
if ($storage->{'spsata_trim_support'} =~ /Yes/ ) { $description .= " - T
rim: $storage->{'spsata_trim_support'}";}
$devices->{$storage->{'_name'}} = {
NAME => $storage->{'bsd_name'},
SERIALNUMBER => $storage->{'device_serial'},
DISKSIZE => $size,
FIRMWARE => $storage->{'device_revision'},
MANUFACTURER => $manufacturer,
DESCRIPTION => $description,
TYPE => $type,
MODEL => $model
};
} }
}
my $manufacturer = getManufacturer($storage->{'_name'}); # Get PATA Drives
my $scsi = $profile->gettype('SPParallelSCSIDataType');
my $model = $storage->{'device_model'}; if ( ref($scsi) eq 'ARRAY') {
$model =~ s/\s*$manufacturer\s*//i; foreach my $storage ( @$scsi ) {
next unless ( ref($storage) eq 'HASH' );
my $type;
if ( $storage->{'_name'} =~ /DVD/i || $storage->{'_name'} =~ /CD/i ) {
$type = 'CD-ROM Drive';
}
else {
$type = 'Disk drive';
}
my $size = $storage->{'size'};
if ($size =~ /GB/) {
$size =~ s/ GB//;
$size *= 1024;
}
if ($size =~ /TB/) {
$size =~ s/ TB//;
$size *= 1048576;
}
my $manufacturer = getManufacturer($storage->{'_name'});
my $model = $storage->{'device_model'};
$model =~ s/\s*$manufacturer\s*//i;
my $description = "Status: $storage->{'smart_status'}";
if ($storage->{'spsata_trim_support'} =~ /Yes/ ) { $description .= " - T
rim: $storage->{'spsata_trim_support'}";}
$devices->{$storage->{'_name'}} = {
NAME => $storage->{'_name'},
SERIAL => $storage->{'device_serial'},
DISKSIZE => $size,
FIRMWARE => $storage->{'device_revision'},
MANUFACTURER => $manufacturer,
DESCRIPTION => $description,
MODEL => $model
};
$devices->{$storage->{'_name'}} = {
NAME => $storage->{'name'},
SERIALNUMBER => $storage->{'device_serial'},
DISKSIZE => $size,
FIRMWARE => $storage->{'device_revision'},
MANUFACTURER => $manufacturer,
DESCRIPTION => $description,
MODEL => $model
};
}
}
# Get PATA Drives
my $pata = $profile->gettype('SPParallelATADataType');
if ( ref($sata) eq 'ARRAY') {
foreach my $storage ( @$pata ) {
next unless ( ref($storage) eq 'HASH' );
my $description;
if ( $storage->{'_name'} =~ /DVD/i || $storage->{'_name'} =~ /CD/i ) {
$description = 'CD-ROM Drive';
}
else {
$description = 'Disk drive';
} }
}
my $manufacturer = getManufacturer($storage->{'_name'}); # Get PATA drives
my $pata = $profile->gettype('SPParallelATADataType');
my $model = $storage->{'device_model'};
my $size; if ( ref($pata) eq 'ARRAY') {
foreach my $storage ( @$pata ) {
next unless ( ref($storage) eq 'HASH' );
my $type;
if ( $storage->{'_name'} =~ /DVD/i || $storage->{'_name'} =~ /CD/i
) {
$type = 'CD-ROM Drive';
} else {
$type = 'Disk drive';
}
my $manufacturer = getManufacturer($storage->{'_name'});
my $model = $storage->{'device_model'};
my $size = $storage->{'size'};
if ($size =~ /GB/) {
$size =~ s/ GB//;
$size *= 1024;
}
if ($size =~ /TB/) {
$size =~ s/ TB//;
$size *= 1048576;
}
my $description = "";
$devices->{$storage->{'_name'}} = {
NAME => $storage->{'bsd_name'},
SERIALNUMBER=> $storage->{'device_serial'},
DISKSIZE => $size,
FIRMWARE => $storage->{'device_revision'},
MANUFACTURER => $manufacturer,
DESCRIPTION => $description,
TYPE => $type,
MODEL => $model
};
}
}
$devices->{$storage->{'_name'}} = { # Get NVMe Drives
NAME => $storage->{'_name'}, my $nve = $profile->gettype('SPNVMeDataType');
SERIAL => $storage->{'device_serial'},
DISKSIZE => $size,
FIRMWARE => $storage->{'device_revision'},
MANUFACTURER => $manufacturer,
DESCRIPTION => $description,
MODEL => $model
};
if ( ref($nve) eq 'ARRAY') {
foreach my $storage ( @$nve ) {
next unless ( ref($storage) eq 'HASH' );
my $type = 'Disk NVMe Drive';
my $size = $storage->{'size'};
if ($size =~ /GB/) {
$size =~ s/ GB//;
$size *= 1024;
}
if ($size =~ /TB/) {
$size =~ s/ TB//;
$size *= 1048576;
}
my $manufacturer = getManufacturer($storage->{'_name'});
my $model = $storage->{'device_model'};
$model =~ s/\s*$manufacturer\s*//i;
my $description = "";
$devices->{$storage->{'_name'}} = {
NAME => $storage->{'bsd_name'},
SERIALNUMBER=> $storage->{'device_serial'},
DISKSIZE => $size,
FIRMWARE => $storage->{'device_revision'},
MANUFACTURER => $manufacturer,
DESCRIPTION => $description,
TYPE => $type,
MODEL => $model
};
}
} }
}
foreach my $device ( keys %$devices ) { foreach my $device ( keys %$devices ) {
$common->addStorages($devices->{$device}); $common->addStorages($devices->{$device});
} }
} }
1; 1;
 End of changes. 14 change blocks. 
97 lines changed or deleted 201 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)