From 5c15ac712e56dd5c4245d335d77828f56958fae6 Mon Sep 17 00:00:00 2001 From: Guillaume Bougard Date: Thu, 23 Nov 2023 11:46:59 +0100 Subject: [PATCH] feat: assetname-support option also apply during agent deviceid creation --- Changes | 2 ++ lib/GLPI/Agent.pm | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index d6efa0071..2b1d7e46c 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/lib/GLPI/Agent.pm b/lib/GLPI/Agent.pm index 114554af7..96fcfcca4 100644 --- a/lib/GLPI/Agent.pm +++ b/lib/GLPI/Agent.pm @@ -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];