From 67fcd2e71e639da4f6ba7ccecec53647f00cd12e 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 b72d0e856..a773e4767 100644 --- a/Changes +++ b/Changes @@ -14,6 +14,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];