fusioninventory / fusioninventory-for-glpi

FusionInventory plugin for GLPI
http://www.FusionInventory.org/
GNU Affero General Public License v3.0
361 stars 148 forks source link

SNMP Inventory: sysLocation is not correctly parsed #2603

Open nbriche opened 6 years ago

nbriche commented 6 years ago

When setting a switch's sysLocation to a location's complete name (e. g. "First Site > Building 2 > Room 5"), I would expect the location to be parsed and the location to be set to the correct sublocation, the way users locations are parsed when set up in LDAP fields.

Instead, a new root location "First Site > Building 2 > Room 5" is created. This is, I think, because the inventory agent escapes the > char to an HTML entity ">", and the server-side import doesn't unescape. Or, alternately, because sysLocation should be set with the index of the GLPI location label, although that would make that field pretty much unusable by other tools?

I've tried to find where sysLocation is processed, and I've traced it down to more or less formatconvert.class.php:1955, although I'm not really sure.

cadegenn commented 5 years ago

+1 I got the exact same issue. Location path separator '>' is actually replace by its html entity in the XML data sent to server.

ddurieux commented 5 years ago

Not sure the " > " is managed. I will check it

ddurieux commented 5 years ago

It's not managed with the >

cadegenn commented 5 years ago

Yes I just checked it as well. I filled the sysLocation to a string like "BAT1 > FLOOR1 > ROOM1". I added a call to html_entity_decode() to the line provided by @nbriche but FusionInventory created a new location with name "BAT1 > FLOOR1 > ROOM1" instead of retrieving the "ROOM1" child of the "FLOOR1", child of "BAT1"

In the database, I checked that a new row in the glpi_locations table have been created

I'll try to dig further...

ddurieux commented 5 years ago

Yes that's it, the multilevel not managed in fusioninventory for the moment, that's why I tagged it in feature

nbriche commented 5 years ago

If this issue is used to discuss this feature:

It would be nice if there were an option to specify one (or more) separators: not every device allow the ">" character in the sysLocation field (I'm looking at you Avaya)

ddurieux commented 5 years ago

Yes it could be a good idea ;)

Benoit221 commented 4 years ago

I encountered the same fail with location indication in the tag and regex match :

# id, entities_id, is_recursive, name, locations_id, completename, comment, level, ancestors_cache, sons_cache, address, postcode, town, state, country, building, room, latitude, longitude, altitude, date_mod, date_creation
'43', '1', '0', 'INFORMATIQUE', '22', 'SERVICE > INFORMATIQUE', NULL, '2', '{\"22\":22}', '{\"43\":43}', NULL, NULL, 'SERVICE', NULL, 'France', NULL, NULL, '48.467', '-2.514', NULL, '2020-08-11 09:59:51', '2020-08-11 09:59:51'
'723', '1', '0', 'SERVICE > INFORMATIQUE', '0', 'SERVICE > INFORMATIQUE', '', '1', '[]', '{\"723\":723}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2020-08-27 12:20:58', '2020-08-27 12:20:58'