Skip to content

Commit

Permalink
feat: assetname-support option also apply during agent deviceid creation
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Nov 23, 2023
1 parent 818f949 commit 5c15ac7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ inventory:
this feature does not apply on MacOS or Windows
this feature now works for remote ssh and for option 3, it requires perl installed
on targeted computer and perl mode enabled on defined remote.
* Feature: Make assetname-support option also works to compute agent deviceid when
unknown

netdiscovery/netinventory:
* Enhanced Toshiba printers support
Expand Down
10 changes: 9 additions & 1 deletion lib/GLPI/Agent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,15 @@ sub _handlePersistentState {

if (!$self->{deviceid} && !$data->{deviceid}) {
# compute an unique agent identifier, based on host name and current time
my $hostname = getHostname();
my %config = ();
if ($self->{config}->{'assetname-support'}) {
if ($self->{config}->{'assetname-support'} == 1) {
$config{short} = 1;
} elsif ($self->{config}->{'assetname-support'} == 3) {
$config{fqdn} = 1;
}
}
my $hostname = getHostname(%config);

my ($year, $month , $day, $hour, $min, $sec) =
(localtime (time))[5, 4, 3, 2, 1, 0];
Expand Down

0 comments on commit 5c15ac7

Please sign in to comment.