Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'tag' support for NetDiscovery/NetInventory tasks #828

Closed
wants to merge 13 commits into from

Conversation

eduardomozart
Copy link
Contributor

@eduardomozart eduardomozart commented Jan 20, 2025

Hello,
This commit adds the same Computer tag to NetDiscovery/NetInventory and ESX inventory tasks. This fix glpi-project/glpi-inventory-plugin#504

A little background: I have a small IT company and I act more like a MSP for other small business. These clients doesn't have condition to keep a GLPI server on their own. I use an Entity for each client have access to their own assets and I was able to create a Entity rule (Administration > Rules > Rules for assigning an item to an entity) based on GLPI-Agent tag, but it was working only for Computer inventory, other devices (like SNMP switches and printers) was being assigned to the default Entity and I had to move them manually to the respective Entity. I couldn't find any attribute that I could use to differ the clients based only on the available Entity rules fields - I couldn't use the subnet/IP address because most clients have a 192.168.0.0/24 network so it wouldn't be reliable. As those tasks doesn't provide the TAG field, I decided to create this PR to be able to use the Computer tag to assign those devices to the correct Entity.

Here's the Entity rule I've created:

image

Here's a screenshot to prove it's working:

image

Here's sample inventory files I've used to test the rule (a SNMP printer):

esx_esxi01.xml.txt
netdiscovery_brother.xml.txt
netinventory_brother.xml.txt

Note: For some reason, it works only when importing a non-existing device, if it already exists, it updates it's information but it doesn't change it's Entity. It seems that the Entity rules is applied only when the device is created on GLPI, but I'm not sure if it's a bug or an intended feature.

@g-bougard
Copy link
Member

Hi @eduardomozart

I think you missed few points.

First using the tag means you add the agent tag to all scanned devices. This is not the same logic than for computers where each computer can have its own tag. This is probably not a problem in your context as you probably have dedicated agent to each customer, but this could become one for other people: if they scan all their network, they will have problem if the scanning agent has a tag for the computer inventory and a rule starts to relocate their devices in the wrong entity because of this.

Than there's still a way to import network devices and have them into the expected entity:

  • in glpi-inventory-plugin, create the iprange into the expected entity
  • if ipranges use same start and/or end ip, you can just create another one, just use the right iprange in dedicated tasks

Most people use this entity allocation rules, if I merged you PR, I'm sure we will start to have unexpected side-effect with a lot of users.

@g-bougard g-bougard closed this Jan 21, 2025
@eduardomozart
Copy link
Contributor Author

Yes, I saw that there's an <ENTITY> tag which seems to be reported on server-side tasks, I believe it exists for this purpose. Thank you for your clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tag isn't added to NetInventory tasks
2 participants