You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2022-09-26 10:20:45

barcelosj
Member
Registered: 2019-02-13
Posts: 13

Location rules not working as expected

Hi,

We are experiencing a problem with the latest version of GLPI ( 10.0.3 ).

I have created a "Location Rule" that assigns a location to a computer based on its IP Address.

When a new computer matches its criteria, instead of assign the location specified, GLPI creates a new location, naming it as the database id of the correct location and assign it to the computer, instead of using the existing one.

For example;

If I check the table glpi_location I have:

id   name
--   -----------
7    Barcelona

When I import a computer that matches the criteria, a new row is created on the table glpi_location:

id   name
--   -----------
7    Barcelona
8    7

And the new computer is assigned to the new location named "7", instead of the expected "Barcelona".

I tried to delete all locations and start over again, but the behaviour persists.

How can i make it work properly?

Thanks!

Offline

#2 2022-10-04 15:36:20

barcelosj
Member
Registered: 2019-02-13
Posts: 13

Re: Location rules not working as expected

anyone? roll

Offline

#3 2022-10-05 09:08:49

Gorthaur
Member
Registered: 2022-10-05
Posts: 2

Re: Location rules not working as expected

I also have the same issue, exactly the same.

Anyone help ?

thanks for your help smile

Offline

#4 2022-10-05 22:15:29

barcelosj
Member
Registered: 2019-02-13
Posts: 13

Re: Location rules not working as expected

I don't know how to solve it, but I have found a workaround.

I have created a Stored Procedure in MariaDB that updates the location_id at glpi_computers and glpi_monitors tables:

DELIMITER $$
CREATE DEFINER=`username`@`localhost` PROCEDURE `correct_locations`( IN bad_loc INT, IN right_loc INT)
BEGIN
	UPDATE `glpi_computers`
	set
	`locations_id` = right_loc where `locations_id` = bad_loc;
	UPDATE `glpi_monitors`
	set
	`locations_id` = right_loc where `locations_id` = bad_loc;
	END$$

DELIMITER ;

Then,  I have set an event that is launched every minute passing as parameteres the location_id that must be corrected. For example:

DELIMITER $$

ALTER DEFINER=`username`@`localhost` EVENT `keep_locations` ON SCHEDULE EVERY 1 MINUTE STARTS '2022-10-05 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
	CALL correct_locations(9,7);
	CALL correct_locations(25,13);
	CALL correct_locations(26,12);
	CALL correct_locations(27,10);
	CALL correct_locations(28,18);
	CALL correct_locations(29,22);
	END$$

DELIMITER ;

Hope it helps.

Offline

#5 2022-10-14 19:47:27

barcelosj
Member
Registered: 2019-02-13
Posts: 13

Re: Location rules not working as expected

I have reported as an issue on github

https://github.com/glpi-project/glpi/issues/12988

Offline

Board footer

Powered by FluxBB