glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.13k stars 1.28k forks source link

Migration to 10.0.1 with Glpi-agent - computers are all moved to Root entity #11853

Closed VanAxl closed 2 years ago

VanAxl commented 2 years ago

Code of Conduct

Is there an existing issue for this?

Version

10.0.1

Bug description

Hi, I've testing the migration from glpi 9.x to the version 10.0.1. Everything is working fine so far. So I did create a group policy to run the vbs script to install the GLPI agent 1.2 (with the option to uninstall the Fusion Inventory agent first). That works too.

But my computers are put in sub entity when they are created, I mean manually by the technician when he setup the computer for the first time, before providing it to the final user.. There is no rules for auto assignment.

And with this new GLPI agent, it moves automatically the computer to the root entity (we have such entity change in the history of the computer). That is very annoying cause we do have several hundred of computers in GLPI. So I would like to avoid to move again manually all my computer.

Is it a bug, or is there any settings to keep computer on their current entity ?

Thanks Nicolas

Relevant log output

No response

Page URL

No response

Steps To reproduce

Migrate GPI 9.5 to GLPI 10.0.1 update the GLPI agent on a test computer from FusionInventory to glpi agent 1.2 Run the agent on the computer, so it sends the inventory to the GLPI 10.0.1.

Then computer is changed to root entity.

Your GLPI setup information

Information about system installation and configuration
GLPI 10.0.1 ( => /usr/share/glpi)
Installation mode: TARBALL
Current language:en_GB

Server
 
Operating system: Linux Intranet 5.10.0-14-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64
PHP 8.0.19 apache2handler (Core, FFI, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, apcu, bz2, calendar,
    ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, intl, json, ldap, libxml, mbstring, mysqli,
    mysqlnd, oci8, openssl, pcre, pdo_mysql, posix, readline, session, shmop, soap, sockets, sodium, standard, sysvmsg, sysvsem,
    sysvshm, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib)
Setup: max_execution_time="30" memory_limit="64M" post_max_size="8M" safe_mode="" session.save_handler="files"
    upload_max_filesize="2M" 
Software: Apache/2.4.53 (Debian) (Apache/2.4.53 (Debian) Server at glpi.valve-precision.com Port 443
)
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15
Server Software: Debian 11
    Server Version: 10.5.12-MariaDB-0+deb11u1
    Server SQL Mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    Parameters: glpi@euvpfsql.euvpf.valve-precision.fr/glpiTmp
    Host info: euvpfsql.euvpf.valve-precision.fr via TCP/IP

PHP version (8.0.19) is supported.
Sessions configuration is OK.
Allocated memory is sufficient.
mysqli extension is installed.
Following extensions are installed: dom, fileinfo, json, simplexml.
curl extension is installed.
gd extension is installed.
intl extension is installed.
libxml extension is installed.
zlib extension is installed.
The constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present.
Database engine version (10.5.12) is supported.
The log file has been created successfully.
Write access to /usr/share/glpi/files/_cache has been validated.
Write access to /usr/share/glpi/config has been validated.
Write access to /usr/share/glpi/files/_cron has been validated.
Write access to /usr/share/glpi/files has been validated.
Write access to /usr/share/glpi/files/_dumps has been validated.
Write access to /usr/share/glpi/files/_graphs has been validated.
Write access to /usr/share/glpi/files/_lock has been validated.
Write access to /usr/share/glpi/files/_pictures has been validated.
Write access to /usr/share/glpi/files/_plugins has been validated.
Write access to /usr/share/glpi/files/_rss has been validated.
Write access to /usr/share/glpi/files/_sessions has been validated.
Write access to /usr/share/glpi/files/_tmp has been validated.
Write access to /usr/share/glpi/files/_uploads has been validated.
Web access to the files directory should not be allowed but this cannot be checked automatically on this instance.
Make sure access to error log file (/files/_log/php-errors.log) is forbidden; otherwise review .htaccess file and web server configuration.
exif extension is installed.
ldap extension is installed.
openssl extension is installed.
zip extension is installed.
bz2 extension is installed.
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: /usr/share/glpi/config
GLPI_VAR_DIR: /usr/share/glpi/files
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: 
GLPI_TELEMETRY_URI: https://telemetry.glpi-project.org
GLPI_INSTALL_MODE: TARBALL
GLPI_NETWORK_MAIL: glpi@teclib.com
GLPI_NETWORK_SERVICES: https://services.glpi-network.com
GLPI_MARKETPLACE_ALLOW_OVERRIDE: 1
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: 1
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_DOC_DIR: /usr/share/glpi/files
GLPI_CACHE_DIR: /usr/share/glpi/files/_cache
GLPI_CRON_DIR: /usr/share/glpi/files/_cron
GLPI_DUMP_DIR: /usr/share/glpi/files/_dumps
GLPI_GRAPH_DIR: /usr/share/glpi/files/_graphs
GLPI_LOCAL_I18N_DIR: /usr/share/glpi/files/_locales
GLPI_LOCK_DIR: /usr/share/glpi/files/_lock
GLPI_LOG_DIR: /usr/share/glpi/files/_log
GLPI_PICTURE_DIR: /usr/share/glpi/files/_pictures
GLPI_PLUGIN_DOC_DIR: /usr/share/glpi/files/_plugins
GLPI_RSS_DIR: /usr/share/glpi/files/_rss
GLPI_SESSION_DIR: /usr/share/glpi/files/_sessions
GLPI_TMP_DIR: /usr/share/glpi/files/_tmp
GLPI_UPLOAD_DIR: /usr/share/glpi/files/_uploads
GLPI_INVENTORY_DIR: /usr/share/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/glpi-plugins/
GLPI_I18N_DIR: /usr/share/glpi/locales
GLPI_VERSION: 10.0.1
GLPI_SCHEMA_VERSION: 10.0.1@a130db99c7d9b131c2e2ea59fe0d6260fe93d831
GLPI_MARKETPLACE_PRERELEASES: 
GLPI_MIN_PHP: 7.4.0
GLPI_MAX_PHP: 8.2.0
GLPI_YEAR: 2022

Libraries
 
htmlawed/htmlawed version 1.2.6 in (/usr/share/glpi/vendor/htmlawed/htmlawed)
phpmailer/phpmailer version 6.6.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/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)
blueimp/jquery-file-upload in (/usr/share/glpi/vendor/blueimp/jquery-file-upload/server/php)
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 in (/usr/share/glpi/vendor/symfony/polyfill-php81)

LDAP directories
 

SQL replicas
 
Not active

Notifications
 
Way of sending emails: SMTP+TLS (anonymous@precisionglobal-com.mail.protection.outlook.com)

Plugins list
 
    fields               Name: Additionnal fields             Version: 1.8.2      State: Not installed
    archires             Name: Architectures réseau           Version: 2.6.0      State: Not installed
    datainjection        Name: Data injection                 Version: 2.11.1     State: Enabled
    consumables          Name: Demande de consommables        Version: 1.6.0      State: Not installed
    formcreator          Name: Form Creator                   Version: 2.12.2     State: Installed / not activated
    fusioninventory      Name: FusionInventory                Version: 9.5+3.0    State: Installed / not activated
    resources            Name: Human Resources                Version: 3.0.0      State: Enabled
    mreporting           Name: More Reporting                 Version: 1.8.0      State: Enabled
    oauthimap            Name: Oauth IMAP                     Version: 1.4.0      State: Enabled
    genericobject        Name: Objects management             Version: 2.11.0     State: Not installed
    order                Name: Orders management              Version: 2.9.0      State: Enabled
    reports              Name: Rapports                       Version: 1.14.1     State: Installed / not activated
    manufacturersimports Name: Suppliers imports              Version: 3.0.1      State: Enabled
    dashboard            Name: Tableau de bord                Version: 0.9.8      State: Not installed

Anything else?

No response

cconard96 commented 2 years ago

I believe you are looking for Administration > Rules > Rules for assigning an item to an entity to control which entity an asset is added to when imported.

VanAxl commented 2 years ago

Thanks for your reply. Well in fact there is no rules that can match this manual filing. My computers have just been put in some sub-entity "by hand". I just want them to stay where they are with that new GLPI-Agent . Here is the log in History tab of the asset, showing that the glpi-agent inventory has moved my computer :

image
Mika64 commented 2 years ago

Same here for many hosts

2022-06-09_09-47

trasher commented 2 years ago

Does issue occurs on migration, or when a new inventory occurs?

Mika64 commented 2 years ago

That's happens on a new inventory. Old items (with no recent inventory) are not impacted.

trasher commented 2 years ago

Ok, then the issue title is wrong. The entities_id field should have been locked, since it's been edited by user.

2 solutions: an issue on plugin migration, or an issue on locking fields.

If you change by hand the entity on a computer; and run a new inventory on it, do you have the same behavior?

VanAxl commented 2 years ago

"If you change by hand the entity on a computer; and run a new inventory on it, do you have the same behavior?" => I've tried that, and it stays on the correct entity. I confirm that the migration has no impact for old devices : It will only move back the asset to the root entity when a new inventory (from the new glpi agent) is received for this asset.

Mika64 commented 2 years ago

Here, we still use fusioninventory-agent

VanAxl commented 2 years ago

Maybe a workaround would be to force the entity_id to be locked for all assets (placed manually in a entity) before doing the migration, or at least before receiving any new GLpi-Agent inventory ? I'm not sure how to do this.

trasher commented 2 years ago

Agent is not relevant. This is an issue migrating from fi plugin. Have you installed and migrated to glpi-inventory-plugin? If so, there is something wrong in its migration. If you did not activate the new plugin, nothing gets migrated; but you can add a global lock on entities_id field.

trasher commented 2 years ago

BTW, adding a global lock is certainly the way to go in your case; this will ensure inventory will never try to update the field. This feature is available since 10.0.1

VanAxl commented 2 years ago

Agent is not relevant. This is an issue migrating from fi plugin. Have you installed and migrated to glpi-inventory-plugin? If so, there is something wrong in its migration. If you did not activate the new plugin, nothing gets migrated; but you can add a global lock on entities_id field.

Yes for my tests, I used a computer that was linked to the production GLPI environnement (in 9.5). on that computer I've used the vbs script (glpi-agent-deployment.vbs) to uninstall and install the new glpi-agent , and point this agent to my test environment where I have the Migrated GLPI server (10.0.1) by the server= command argument.

I will try to test now with keeping the FI agent , and only change the server to report the inventory. I will see if it keeps my asset to the good entity. I'll keep you posted.

trasher commented 2 years ago

As I've already said, agent is not relevant

VanAxl commented 2 years ago

Ok you are right. Same result even when keeping the fusion inventory agent. Do know what I missed in the GLPI migration process. The glpi plugin has not really be "installed" in glpi, as it seems to be part of the system now, from my understanding. I just delete the old fusion inventory plugin from the Setup>plugins page.

Can you point me to the right direction to set that global Lock of the entity of my assets ? I can't find where to set this on, on my own.

trasher commented 2 years ago

There is a button in the inventory configuration page

VanAxl commented 2 years ago

There is a button in the inventory configuration page

ok thanks for that. I've found that page. But I didn't find the computer entity on the dropdown list, when trying to add a global lock

image

I 'm thinking about doing that in a different way. All my computers/assets have a user reported from the inventory (User field of the asset). Is it possible to create some kind of rule that will put the computer in the same entity as where the user is ? Cause my users are still in good entities.

trasher commented 2 years ago

Indeed, entity field is not available for global locks. As a workaround, you can try to insert directly in database:

INSERT INTO `glpi_lockedfields` (`itemtype`, `items_id`, `field`, `value`, `is_global`) VALUES
('Computer', 0, 'entities_id', NULL, 1);
trasher commented 2 years ago

11853 makesentities_id fields available on global locks. Initial issue can only be fixed with a migration of locked fields from fusioninventory plugin with glpiinventory plugin.

trasher commented 2 years ago

In facts, glpi-inventory plugin already takes care of migrating locked fields; but was not taking care of old global locks. This will be fixed as of https://github.com/glpi-project/glpi-inventory-plugin/pull/128

cablop commented 2 months ago

We still see this issue in 10.0.12 with GLPI Inventory 1.3.5. We didn't have Fusion Inventory before. We locked the Entity field individualy for a test computer, and then globaly with the SQL mentioned above. And the inventory update just doesn't respect the locked field and just updates it.

In fact, it does not only change the entity field, but also changes the values in the soundcard and harddrives fields. Changing 7 to 0, and those are the ids of the entities too.

image

cedric-anne commented 2 months ago

@cablop Please open a new issue and give all requested information.