glpi icon indicating copy to clipboard operation
glpi copied to clipboard

Rules for import and link equipments for VMware inventory not working properly

Open acdmail opened this issue 1 year ago • 8 comments

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • [X] I have searched the existing issues

Version

10.0.16 + GLPI inventory plugin 1.4.0

Bug description

I am using GLPI 10.0.16 and GLPI Inventory plugin 1.4.0 together with default "Rules for import and link equipments" provided by GLPI. I am performing the inventory of IT infrastructure using installation of GLPI Agents directly on the hosts and also performing the inventory of ESX hosts using GLPI Inventory plugin. To have as full view of hosts as possible before the GLPI Agents will be installed on host I have activated the options "Import virtual machines" and "Create computer for virtual machines" in Administration->Inventory". If I perform the Inventory of ESX and as result have Computers created in Computers, on installation of GLPI Agent on corresponding hosts(VM) I am expecting the earlier created Computers to be updated however new Computers are created. In the example on the screenshot it can be seen that as result of inventory of ESX 2 Computers are created, ubuntu22-esx and redhat8-esx, once the GLPI Agent is installed on these instead of ubuntu22-esx and redhat8-esx to be updated new Computers are created ubuntu22-agent and rh8-agent. Results after ESX inventory: Screenshot 2024-10-01 192812 Results after GLPI Agent installed Screenshot 2024-10-01 192916

Relevant log output

No response

Page URL

No response

Steps To reproduce

1.Install test ESX host and deploy 2 VM's on it 2.Install GLPI 10.0.16 with GLPI Inventory plugin 1.4.0 3. On GLPI host install GLPI Agent to be used as Actor for ESX inventory Task 4. In GLPI Web in "Administration->Inventory" tick options "Import virtual machines" and "Create computer for virtual machines" 5. In GLPI Web in Administratation->GLPI Inventory->Tasks, create task to inventory VMWare (VMWare host remote inventory) 6. Run VMWare inventory task 7. Install GLPI Agent on each VM from p 1. and perform Inventory

Your GLPI setup information

Information about system installation & configuration
GLPI 10.0.16 (/glpi => /usr/share/glpi)
Installation mode: TARBALL
Current language:en_US

Server
 
Operating system: Linux isos_glpi 4.18.0-513.5.1.el8_9.x86_64 #​1 SMP Fri Sep 29 05:21:10 EDT 2023 x86_64
PHP 8.1.29 apache2handler (Core, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, apcu, bz2, ctype, curl,
date, dom, exif, fileinfo, filter, ftp, gd, hash, iconv, intl, json, ldap, libxml, mbstring, mysqli, mysqlnd, openssl, pcre,
pdo_sqlite, pdo_sqlsrv, posix, session, snmp, sodium, sqlite3, sqlsrv, standard, tokenizer, xml, xmlreader, xmlwriter, zip,
zlib)
Setup: max_execution_time="120" memory_limit="1280M" post_max_size="100M" safe_mode="" session.save_handler="files"
upload_max_filesize="100M" disable_functions=""
Software: Apache ()
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0
Server Software: mariadb.org binary distribution
Server Version: 10.5.26-MariaDB-ubu2004
Server SQL Mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Parameters: [email protected]/glpi
Host info: 192.168.1.122 via TCP/IP

PHP version (8.1.29) is supported. Sessions configuration is OK. Allocated memory is sufficient. mysqli extension is installed. Following extensions are installed: dom, fileinfo, filter, libxml, json, simplexml, xmlreader, xmlwriter. curl extension is installed. gd extension is installed. intl extension is installed. zlib extension is installed. The constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present. Database engine version (10.5.26) is supported. No files from previous GLPI version detected. The log file has been created successfully. Write access to /var/lib/glpi/files/_cache has been validated. Write access to /var/lib/glpi/files/_cron has been validated. Write access to /var/lib/glpi/files has been validated. Write access to /var/lib/glpi/files/_dumps has been validated. Write access to /var/lib/glpi/files/_graphs has been validated. Write access to /var/lib/glpi/files/_lock has been validated. Write access to /var/lib/glpi/files/_pictures has been validated. Write access to /var/lib/glpi/files/_plugins has been validated. Write access to /var/lib/glpi/files/_rss has been validated. Write access to /var/lib/glpi/files/_sessions has been validated. Write access to /var/lib/glpi/files/_tmp has been validated. Write access to /var/lib/glpi/files/_uploads has been validated.

Web server root directory configuration seems safe. Sessions configuration is secured. OS and PHP are relying on 64 bits integers. exif extension is installed. ldap extension is installed. openssl extension is installed. Following extensions are installed: bz2, Phar, zip. Zend OPcache extension is installed. Following extensions are installed: ctype, iconv, mbstring, sodium. Write access to /usr/share/glpi/marketplace has been validated. Timezones seems loaded in database.

GLPI constants
 
GLPI_ROOT: "/usr/share/glpi"
GLPI_CONFIG_DIR: "/etc/glpi"
GLPI_VAR_DIR: "/var/lib/glpi/files"
GLPI_DOC_DIR: "/var/lib/glpi/files"
GLPI_CRON_DIR: "/var/lib/glpi/files/_cron"
GLPI_DUMP_DIR: "/var/lib/glpi/files/_dumps"
GLPI_GRAPH_DIR: "/var/lib/glpi/files/_graphs"
GLPI_LOCK_DIR: "/var/lib/glpi/files/_lock"
GLPI_PICTURE_DIR: "/var/lib/glpi/files/_pictures"
GLPI_PLUGIN_DOC_DIR: "/var/lib/glpi/files/_plugins"
GLPI_RSS_DIR: "/var/lib/glpi/files/_rss"
GLPI_SESSION_DIR: "/var/lib/glpi/files/_sessions"
GLPI_TMP_DIR: "/var/lib/glpi/files/_tmp"
GLPI_UPLOAD_DIR: "/var/lib/glpi/files/_uploads"
GLPI_CACHE_DIR: "/var/lib/glpi/files/_cache"
GLPI_LOG_DIR: "/var/log/glpi"
GLPI_SYSTEM_CRON: true
GLPI_MARKETPLACE_DIR: "/usr/share/glpi/marketplace"
GLPI_USE_CSRF_CHECK: "1"
GLPI_CSRF_EXPIRES: "7200"
GLPI_CSRF_MAX_TOKENS: "100"
GLPI_USE_IDOR_CHECK: "1"
GLPI_IDOR_EXPIRES: "7200"
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: false
GLPI_SERVERSIDE_URL_ALLOWLIST: ["/^(https?|feed):\/\/[^@:]+(\/.*)?$/"]
GLPI_TELEMETRY_URI: "https://telemetry.glpi-project.org"
GLPI_INSTALL_MODE: "TARBALL"
GLPI_NETWORK_MAIL: "[email protected]"
GLPI_NETWORK_SERVICES: "https://services.glpi-network.com"
GLPI_MARKETPLACE_ALLOW_OVERRIDE: true
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: true
GLPI_USER_AGENT_EXTRA_COMMENTS: ""
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: "1"
GLPI_AJAX_DASHBOARD: "1"
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: "0"
GLPI_CENTRAL_WARNINGS: "1"
GLPI_TEXT_MAXSIZE: "4000"
GLPI_LOCAL_I18N_DIR: "/var/lib/glpi/files/_locales"
GLPI_INVENTORY_DIR: "/var/lib/glpi/files/_inventories"
GLPI_NETWORK_REGISTRATION_API_URL: "https://services.glpi-network.com/api/registration/"
GLPI_MARKETPLACE_PLUGINS_API_URI: "https://services.glpi-network.com/api/marketplace/"
GLPI_I18N_DIR: "/usr/share/glpi/locales"
GLPI_VERSION: "10.0.16"
GLPI_SCHEMA_VERSION: "10.0.16@b13256c443dd4fdb27b4a0d3b8fea8caba4dfaa9"
GLPI_MARKETPLACE_PRERELEASES: false
GLPI_MIN_PHP: "7.4.0"
GLPI_MAX_PHP: "8.4.0"
GLPI_YEAR: "2024"

Libraries
 
htmlawed/htmlawed version 1.2.14 in (/usr/share/glpi/vendor/htmlawed/htmlawed)
phpmailer/phpmailer version 6.8.0 in (/usr/share/glpi/vendor/phpmailer/phpmailer/src)
simplepie/simplepie version 1.5.8 in (/usr/share/glpi/vendor/simplepie/simplepie/library)
tecnickcom/tcpdf version 6.4.4 in (/usr/share/glpi/plugins/pdf/vendor/tecnickcom/tcpdf)
michelf/php-markdown in (/usr/share/glpi/vendor/michelf/php-markdown/Michelf)
true/punycode in (/usr/share/glpi/vendor/true/punycode/src)
iamcal/lib_autolink in (/usr/share/glpi/vendor/iamcal/lib_autolink)
sabre/dav in (/usr/share/glpi/vendor/sabre/dav/lib/DAV)
sabre/http in (/usr/share/glpi/vendor/sabre/http/lib)
sabre/uri in (/usr/share/glpi/vendor/sabre/uri/lib)
sabre/vobject in (/usr/share/glpi/vendor/sabre/vobject/lib)
laminas/laminas-i18n in (/usr/share/glpi/vendor/laminas/laminas-i18n/src)
laminas/laminas-servicemanager in (/usr/share/glpi/vendor/laminas/laminas-servicemanager/src)
monolog/monolog in (/usr/share/glpi/vendor/monolog/monolog/src/Monolog)
sebastian/diff in (/usr/share/glpi/vendor/sebastian/diff/src)
donatj/phpuseragentparser in (/usr/share/glpi/vendor/donatj/phpuseragentparser/src/UserAgent)
elvanto/litemoji in (/usr/share/glpi/vendor/elvanto/litemoji/src)
symfony/console in (/usr/share/glpi/vendor/symfony/console)
scssphp/scssphp in (/usr/share/glpi/vendor/scssphp/scssphp/src)
laminas/laminas-mail in (/usr/share/glpi/vendor/laminas/laminas-mail/src/Protocol)
laminas/laminas-mime in (/usr/share/glpi/vendor/laminas/laminas-mime/src)
rlanvin/php-rrule in (/usr/share/glpi/vendor/rlanvin/php-rrule/src)
ramsey/uuid in (/usr/share/glpi/vendor/ramsey/uuid/src)
psr/log in (/usr/share/glpi/vendor/psr/log/Psr/Log)
psr/simple-cache in (/usr/share/glpi/vendor/psr/simple-cache/src)
psr/cache in (/usr/share/glpi/vendor/psr/cache/src)
league/csv in (/usr/share/glpi/vendor/league/csv/src)
mexitek/phpcolors in (/usr/share/glpi/vendor/mexitek/phpcolors/src/Mexitek/PHPColors)
guzzlehttp/guzzle in (/usr/share/glpi/vendor/guzzlehttp/guzzle/src)
guzzlehttp/psr7 in (/usr/share/glpi/vendor/guzzlehttp/psr7/src)
glpi-project/inventory_format in (/usr/share/glpi/vendor/glpi-project/inventory_format/lib/php)
wapmorgan/unified-archive in (/usr/share/glpi/vendor/wapmorgan/unified-archive/src)
paragonie/sodium_compat in (/usr/share/glpi/vendor/paragonie/sodium_compat/src)
symfony/cache in (/usr/share/glpi/vendor/symfony/cache)
html2text/html2text in (/usr/share/glpi/vendor/html2text/html2text/src)
symfony/css-selector in (/usr/share/glpi/vendor/symfony/css-selector)
symfony/dom-crawler in (/usr/share/glpi/vendor/symfony/dom-crawler)
twig/twig in (/usr/share/glpi/vendor/twig/twig/src)
twig/string-extra in (/usr/share/glpi/vendor/twig/string-extra)
symfony/polyfill-ctype not found
symfony/polyfill-iconv not found
symfony/polyfill-mbstring not found
symfony/polyfill-php80 not found
symfony/polyfill-php81 not found
symfony/polyfill-php82 in (/usr/share/glpi/vendor/symfony/polyfill-php82)
league/oauth2-client in (/usr/share/glpi/vendor/league/oauth2-client/src/Provider)
league/oauth2-google in (/usr/share/glpi/vendor/league/oauth2-google/src/Provider)
thenetworg/oauth2-azure in (/usr/share/glpi/vendor/thenetworg/oauth2-azure/src/Provider)

LDAP directories
 
Server: '192.168.1.211', Port: '389', BaseDN: 'dc=mydomain,dc=local', Connection filter: none, RootDN: 'glpi_binduser', Use TLS:
'1'

SQL replicas
 
Not active

Notifications
 
Way of sending emails: PHP

Plugins list
 
fields               Name: Additional Fields              Version: 1.21.11    State: Enabled
Install Method: Manual appliances Name: Appliances Version: 3.2.0 State: Enabled
Install Method: Manual behaviors Name: Behaviours Version: 2.7.3 State: Enabled
Install Method: Manual datainjection Name: Data injection Version: 2.13.5 State: Enabled
Install Method: Manual glpiinventory Name: GLPI Inventory Version: 1.4.0 State: Enabled
Install Method: Manual sccm Name: Interface - SCCM Version: 2.4.3 State: Enabled
Install Method: Manual addressing Name: IP Adressing Version: 3.0.2 State: Enabled
Install Method: Manual uninstall Name: Item's Lifecycle (uninstall) Version: 2.9.2 State: Enabled
Install Method: Manual mydashboard Name: My Dashboard Version: 2.1.5 State: Enabled
Install Method: Manual genericobject Name: Objects management Version: 2.14.9 State: Enabled
Install Method: Manual pdf Name: Print to pdf Version: 3.0.0 State: Enabled
Install Method: Manual printercounters Name: Printer counters Version: 2.0.1 State: Enabled
Install Method: Manual reports Name: Reports Version: 1.16.0 State: Enabled
Install Method: Manual

Anything else?

No response

acdmail avatar Oct 01 '24 18:10 acdmail

Hello,

Exactly the same thing happens to me.

Pay attention to the warning indicated in the inventory settings.

image

alexmicontini avatar Oct 02 '24 10:10 alexmicontini

alexmicontini

Hello, Thanks for your comment, however for me this option is not activated. I am interested in some basic information to be available in inventory based on VMWare inventory for tracking purpose until the GLPI Agent is installed, performs the inventory and full information including components is available through it. Normally, as Serial number and/or UUID are properly extracted from VM through VMWare inventory and are matching the one collected using GLPI Agent, the process should be flawless, however it is not the case...

acdmail avatar Oct 02 '24 12:10 acdmail

As far as I understand, that can be achieved from Rules configuration. Default ones are working out of the box, but it's not possible all cases are correctly handled.

trasher avatar Oct 02 '24 13:10 trasher

I think we should report the problem to the agent developer and tell him that both the ESX task and the Inventory task obtain the same machine identifier value so that it does not create a new one but rather updates it.

alexmicontini avatar Oct 02 '24 13:10 alexmicontini

As far as I understand, that can be achieved from Rules configuration. Default ones are working out of the box, but it's not possible all cases are correctly handled.

Hello, I have put below the extract from default rules set, normally this kind of situation should be handled by "Computer update (by serial + uuid)" or "Computer update (by serial)" rules , however for this particular case inventory through VMWARE than using agent, the rules are bypassed

image

Normally once the agent is performing the inventory of host it is sending the results back to GLPI directly and these are passing through Import rules. For VMWare case in fact, the inventory is performed for ESX host and most probably the results including both ESX host and related VM hosts are send back to GLPI together. I suppose normally this should pass through rules one by one, ESX one, then each related host, so same set of rules should apply, am I wrong?

acdmail avatar Oct 02 '24 13:10 acdmail

I think we should report the problem to the agent developer and tell him that both the ESX task and the Inventory task obtain the same machine identifier value so that it does not create a new one but rather updates it.

Honestly I think it is not the Agent issue, the Agent is just sending back to GLPI the collected info, once the info is reaching GLPI it is passing through rules defined in "Rules for import and link equipments" in order to decide on what to do on received info, import it, update existing item or deny the import.

acdmail avatar Oct 02 '24 14:10 acdmail

Hi @acdmail,

If the uuid obtained by the ESX task matched the UUID (they are similar but not identical) obtained by the GLPI agent, a new machine would not be created, but rather it would be updated. So I think it's more of an agent's problem than GLPI's.

Do the test,

  1. manually update the UUID of the machine created by the ESX task, putting the UUID of the machine created by the agent.
  2. Delete the machine created by the agent.
  3. Run the inventory on the machine where the agent is installed glpi-agent --debug --debug
  4. The machine created by the ESX agent is updated with the data obtained by the GLPI agent, a new machine is not created.

alexmicontini avatar Oct 03 '24 08:10 alexmicontini

hi @alexmicontini, Thanks for your reply. You are right the UUID's are not the same, however I do not think this is the GLPI Agent issue, one UUID is from VMWare point of view(collected by VMWare inventory task) another is from Operating system point of view(collected by Agent installed on the host), absolutely ok from my point of view.

However as we can see serial numbers are same which is again normal, this means that normally "Computer update (by serial)" rule should be in effect in order to update the host collected by VMWare Inventory with inventory info from GLPI Agent running directly on the host. Looking on this I realized that in fact @trasher is right, the only thing which is needed for at least this to work is to move the "Computer update (by serial)" rule to be in front of "Computer import (by serial + uuid).

image

if I do it like this I have the good results, the hosts collected by VMWare inventory task are properly created in GLPI, once GLPI agent is installed on the hosts the hosts are properly updated.

image

Next I would like to make sure that once I will run the VMWare inventory again my vm's collected through GLPI Agent are not updated back anymore by the same "Computer update (by serial)"

In order to do it I observe that VMWare inventory is not collecting any Port/IP information

image

As result I put additional criteria in my "Computer update (by serial)" rule so rules are looking like below image

now if I run the VMWare inventory task I expect the ubuntu22-agent and rh8-agent to stay as is because normally information coming from VMWare inventory is not containing the IP however the results are not as expected, hosts are updated back to ubuntu22-esx and rh8-esx

image

and we can see that update was done through "Computer update (by serial)" rule which normally should not happen

image

acdmail avatar Oct 03 '24 14:10 acdmail

This issue has been closed as we only track bugs here.

You can get community support on forums or you can consider taking a subscription to get professional support. You can also contact GLPI editor team directly.

github-actions[bot] avatar Oct 29 '24 07:10 github-actions[bot]