cconard96 / jamf

JAMF Plugin for GLPI
GNU General Public License v2.0
6 stars 5 forks source link

Import not Working #122

Closed FlorentDerangere closed 1 year ago

FlorentDerangere commented 1 year ago

When i try to import computer i have this error

SQL Error "1406": Data too long for column 'description' at row 1 in query "INSERT INTO glpi_plugin_jamf_extensionattributes (jamf_id, jamf_type, name, description, data_type) VALUES ('5', 'Computer', 'Apple Software Update - Pending Updates', 'Lists all pending updates waiting to be installed by Apple Software Updates for macOS 10.13 or above. This EA assumes software updates are on and are checking for available updates frequently. One can supplement this EA by creating a JAMF Pro policy on a desired frequency with \"softwareupdate -list\" without quotes in the Files and Processes section, in the Execute Command box. ', 'String')" Unable to create new element or update existing one - Erreur durant l'éxecution de la requête : INSERT INTO glpi_plugin_jamf_extensionattributes (jamf_id, jamf_type, name, description, data_type) VALUES ('5', 'Computer', 'Apple Software Update - Pending Updates', 'Lists all pending updates waiting to be installed by Apple Software Updates for macOS 10.13 or above. This EA assumes software updates are on and are checking for available updates frequently. One can supplement this EA by creating a JAMF Pro policy on a desired frequency with \"softwareupdate -list\" without quotes in the Files and Processes section, in the Execute Command box. ', 'String') - L'erreur est Data too long for column 'description' at row 1

System Specifications (please complete the following information):

Can you Help Me ?

FlorentDerangere commented 1 year ago

When i do a discover i see all mac computer correctly, but i cannot import them

cconard96 commented 1 year ago

The description for extension attributes is a VARCHAR(255) type so it is limited to 255 characters. Changing the column to TEXT will resolve this issue and will not break compatibility with the current version of the plugin so you don't need to wait for a plugin update.

As you may have seen, I am looking for plugin contributors due to me not having much time to work on this plugin since I started working on the GLPI core full time. If you would like to try submitting a patch for this plugin to make this change, I would be happy to review and merge it. All DB/migrations stuff is done in the inc/migrations script. Otherwise, I will try to make a patch myself at some point soon.

FlorentDerangere commented 1 year ago

can you explain me what i have to do ?

cconard96 commented 1 year ago

A fix for just you (if you have access to the database):

ALTER TABLE `glpi_plugin_jamf_extensionattributes` MODIFY `description` TEXT NOT NULL;

A patch for the plugin:

  1. Bump the plugin version in setup.php to 3.0.2.
  2. Add an apply_3_0_2_migration function in the inc/migration.class.php file which will be run when the plugin is updated to 3.0.2.
  3. Add the logic to run the ALTER TABLE query. You can look at the migration for the previous version to see how to do this.
FlorentDerangere commented 1 year ago

now i have that

[2023-07-03 13:54:56] glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "default_manufacturer" in /var/www/glpi/plugins/jamf/inc/computersync.class.php at line 74 Backtrace : plugins/jamf/inc/devicesync.class.php:243 PluginJamfComputerSync->syncGeneral() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require()

[2023-07-03 13:54:56] glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "default_status" in /var/www/glpi/plugins/jamf/inc/computersync.class.php at line 80 Backtrace : plugins/jamf/inc/devicesync.class.php:243 PluginJamfComputerSync->syncGeneral() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require()

[2023-07-03 13:55:45] glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "default_manufacturer" in /var/www/glpi/plugins/jamf/inc/computersync.class.php at line 475 Backtrace : plugins/jamf/inc/devicesync.class.php:251 PluginJamfComputerSync->syncComponents() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require()

FlorentDerangere commented 1 year ago

I have another bug because i cannot saved the config for Default Settings, it's maybe the problem

image

FlorentDerangere commented 1 year ago

I have applied this fix (Fix default config values #117)

but not working

FlorentDerangere commented 1 year ago

Can you help me ?

FlorentDerangere commented 1 year ago

I have this error now when i try to import...

[2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 * MySQL query error: SQL: SELECT FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '8' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 MySQL query error: SQL: SELECT * FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '4' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 MySQL query error: SQL: SELECT FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '5' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 * MySQL query error: SQL: SELECT FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '9' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 MySQL query error: SQL: SELECT * FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '14' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 * MySQL query error: SQL: SELECT FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '11' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 MySQL query error: SQL: SELECT * FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '2' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 * MySQL query error: SQL: SELECT FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '17' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 MySQL query error: SQL: SELECT * FROM glpi_plugin_jamf_extensionattributes WHERE jamf_id = '3' AND itemtype = 'PluginJamfComputer' AND jamf_type = 'Computer' LIMIT 1 Error: Unknown column 'itemtype' in 'where clause' Backtrace : src/DBmysqlIterator.php:112 src/DBmysql.php:1056 DBmysqlIterator->execute() src/CommonDBTM.php:578 DBmysql->request() plugins/jamf/inc/computersync.class.php:292 CommonDBTM->find() plugins/jamf/inc/devicesync.class.php:248 PluginJamfComputerSync->syncExtensionAttributes() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.000\", 3.37Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 ** MySQL query error: SQL: INSERT INTO glpi_devicefirmwares (designation, manufacturers_id, entities_id, is_recursive, date_creation, date_mod) VALUES ('447.80.3.0.0', NULL, '0', '1', '2023-07-03 19:17:45', '2023-07-03 19:17:45') Error: Column 'manufacturers_id' cannot be null Backtrace : src/DBmysql.php:1320 src/CommonDBTM.php:722 DBmysql->insert() src/CommonDBTM.php:1317 CommonDBTM->addToDB() plugins/jamf/inc/sync.class.php:216 CommonDBTM->add() plugins/jamf/inc/computersync.class.php:477 PluginJamfSync->applyDesiredState() plugins/jamf/inc/devicesync.class.php:251 PluginJamfComputerSync->syncComponents() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.023\", 3.48Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 MySQL query error: SQL: INSERT INTO glpi_items_devicefirmwares (itemtype, items_id, devicefirmwares_id, is_deleted, is_dynamic, entities_id, is_recursive, locations_id) VALUES ('Computer', '1526', '-1', '0', '1', '0', '1', '0') Error: Out of range value for column 'devicefirmwares_id' at row 1 Backtrace : src/DBmysql.php:1320 src/CommonDBTM.php:722 DBmysql->insert() src/CommonDBTM.php:1317 CommonDBTM->addToDB() plugins/jamf/inc/sync.class.php:216 CommonDBTM->add() plugins/jamf/inc/computersync.class.php:490 PluginJamfSync->applyDesiredState() plugins/jamf/inc/devicesync.class.php:251 PluginJamfComputerSync->syncComponents() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.002\", 3.50Mio)"} [2023-07-03 19:18:54] glpisqllog.ERROR: DBmysql::query() in /var/www/glpi/src/DBmysql.php line 370 *** MySQL query error: SQL: UPDATE glpi_plugin_jamf_devices SET itemtype = 'Computer', items_id = '1526', activation_lock_enabled = '0', entry_date = '2021-06-14T14:25:39.082+0000', jamf_items_id = '27', udid = 'BC977FA5-DF3B-52ED-B18F-FF6828A8C6A0', managed = '1', supervised = '1', sync_date = '2023-07-03 19:17:45' WHERE itemtype = 'Computer' AND items_id = '1526' Error: Incorrect datetime value: '2021-06-14T14:25:39.082+0000' for column db_glpi.glpi_plugin_jamf_devices.entry_date at row 1 Backtrace : src/DBmysql.php:1461 src/DBmysql.php:1499 DBmysql->updateOrDie() plugins/jamf/inc/devicesync.class.php:301 DBmysql->updateOrInsert() plugins/jamf/inc/devicesync.class.php:254 PluginJamfDeviceSync->finalizeSync() plugins/jamf/inc/computersync.class.php:663 PluginJamfDeviceSync::sync() plugins/jamf/ajax/import.php:65 PluginJamfComputerSync::import() public/index.php:73 require() {"user":"2@CSI-GLPI","mem_usage":"0.018\", 3.66Mio)"}