Skip to content

Commit

Permalink
Add inventoriable capacity (#17807)
Browse files Browse the repository at this point in the history
* Add inventoriable capacity

Update DB schema with missing fields
Add configuration types for environment and process, use them in inventory
Add checks for Monitor and Peripherals
Add missing devices types in configuration
Add new tests
Fix Monitor and Printer inventory
Prevent numerous Undefined array key "glpi_currenttime"  loading bootstrap data

* Fix CS
  • Loading branch information
trasher authored Sep 17, 2024
1 parent d4fc0c0 commit 50a87ef
Show file tree
Hide file tree
Showing 55 changed files with 2,575 additions and 182 deletions.
60 changes: 0 additions & 60 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,12 +907,6 @@
'count' => 1,
'path' => __DIR__ . '/src/CommonItilObject_Item.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Computer.php',
];
$ignoreErrors[] = [
// identifier: instanceof.alwaysFalse
'message' => '#^Instanceof between static\\(Computer\\) and PDU will always evaluate to false\\.$#',
Expand Down Expand Up @@ -1231,12 +1225,6 @@
'count' => 1,
'path' => __DIR__ . '/src/DCRoom.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/DatabaseInstance.php',
];
$ignoreErrors[] = [
// identifier: identical.alwaysFalse
'message' => '#^Strict comparison using \\=\\=\\= between array and false will always evaluate to false\\.$#',
Expand Down Expand Up @@ -1963,12 +1951,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/AssetType.php',
];
$ignoreErrors[] = [
// identifier: classConstant.nonObject
'message' => '#^Cannot access constant class on CommonDBTM\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/Asset_PeripheralAsset.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$source_itemtype$#',
Expand Down Expand Up @@ -3649,12 +3631,6 @@
'count' => 8,
'path' => __DIR__ . '/src/Migration.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Monitor.php',
];
$ignoreErrors[] = [
// identifier: instanceof.alwaysFalse
'message' => '#^Instanceof between static\\(Monitor\\) and PDU will always evaluate to false\\.$#',
Expand Down Expand Up @@ -3685,12 +3661,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Monitor.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/NetworkEquipment.php',
];
$ignoreErrors[] = [
// identifier: if.alwaysTrue
'message' => '#^If condition is always true\\.$#',
Expand Down Expand Up @@ -3919,12 +3889,6 @@
'count' => 1,
'path' => __DIR__ . '/src/PendingReason_Item.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Peripheral.php',
];
$ignoreErrors[] = [
// identifier: instanceof.alwaysFalse
'message' => '#^Instanceof between static\\(Peripheral\\) and PDU will always evaluate to false\\.$#',
Expand Down Expand Up @@ -3955,12 +3919,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Peripheral.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Phone.php',
];
$ignoreErrors[] = [
// identifier: identical.alwaysFalse
'message' => '#^Strict comparison using \\=\\=\\= between array and false will always evaluate to false\\.$#',
Expand Down Expand Up @@ -4069,12 +4027,6 @@
'count' => 2,
'path' => __DIR__ . '/src/Plugin.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Printer.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$printer$#',
Expand Down Expand Up @@ -4225,12 +4177,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Rack.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/RefusedEquipment.php',
];
$ignoreErrors[] = [
// identifier: method.notFound
'message' => '#^Call to an undefined method Sabre\\\\VObject\\\\Document\\:\\:getBaseComponent\\(\\)\\.$#',
Expand Down Expand Up @@ -4783,12 +4729,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Toolbox.php',
];
$ignoreErrors[] = [
// identifier: greater.alwaysTrue
'message' => '#^Comparison operation "\\>" between int\\<1, max\\> and 0 is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Unmanaged.php',
];
$ignoreErrors[] = [
// identifier: identical.alwaysFalse
'message' => '#^Strict comparison using \\=\\=\\= between array and false will always evaluate to false\\.$#',
Expand Down
62 changes: 31 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions inc/relation.constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
'glpi_printers' => 'autoupdatesystems_id',
'glpi_refusedequipments' => 'autoupdatesystems_id',
'glpi_unmanageds' => 'autoupdatesystems_id',
'glpi_assets_assets' => 'autoupdatesystems_id',
],

'glpi_budgets' => [
Expand Down
14 changes: 14 additions & 0 deletions install/migrations/update_10.0.x_to_11.0.0/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
`assets_assetmodels_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`assets_assettypes_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`name` varchar(255) DEFAULT NULL,
`uuid` varchar(255) DEFAULT NULL,
`comment` text,
`serial` varchar(255) DEFAULT NULL,
`otherserial` varchar(255) DEFAULT NULL,
Expand All @@ -94,14 +95,18 @@
`is_recursive` tinyint NOT NULL DEFAULT '0',
`is_deleted` tinyint NOT NULL DEFAULT '0',
`is_template` tinyint NOT NULL DEFAULT '0',
`is_dynamic` tinyint NOT NULL DEFAULT '0',
`template_name` varchar(255) DEFAULT NULL,
`autoupdatesystems_id` int unsigned NOT NULL DEFAULT '0',
`date_creation` timestamp NULL DEFAULT NULL,
`date_mod` timestamp NULL DEFAULT NULL,
`last_inventory_update` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `assets_assetdefinitions_id` (`assets_assetdefinitions_id`),
KEY `assets_assetmodels_id` (`assets_assetmodels_id`),
KEY `assets_assettypes_id` (`assets_assettypes_id`),
KEY `name` (`name`),
KEY `uuid` (`uuid`),
KEY `users_id` (`users_id`),
KEY `users_id_tech` (`users_id_tech`),
KEY `locations_id` (`locations_id`),
Expand All @@ -111,6 +116,8 @@
KEY `is_recursive` (`is_recursive`),
KEY `is_deleted` (`is_deleted`),
KEY `is_template` (`is_template`),
KEY `is_dynamic` (`is_dynamic`),
KEY `autoupdatesystems_id` (`autoupdatesystems_id`),
KEY `date_creation` (`date_creation`),
KEY `date_mod` (`date_mod`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;
Expand All @@ -123,11 +130,18 @@
$migration->addKey('glpi_assets_assets', 'assets_assettypes_id');
$migration->addField('glpi_assets_assets', 'is_template', 'bool');
$migration->addKey('glpi_assets_assets', 'is_template');
$migration->addField('glpi_assets_assets', 'is_dynamic', 'bool');
$migration->addKey('glpi_assets_assets', 'is_dynamic');
$migration->addField('glpi_assets_assets', 'template_name', 'string');
$migration->dropKey('glpi_assets_assets', 'groups_id');
$migration->dropField('glpi_assets_assets', 'groups_id');
$migration->dropKey('glpi_assets_assets', 'groups_id_tech');
$migration->dropField('glpi_assets_assets', 'groups_id_tech');
$migration->addField('glpi_assets_assets', 'uuid', 'string');
$migration->addKey('glpi_assets_assets', 'uuid');
$migration->addField('glpi_assets_assets', 'autoupdatesystems_id', 'fkey');
$migration->addKey('glpi_assets_assets', 'autoupdatesystems_id');
$migration->addField('glpi_assets_assets', 'last_inventory_update', 'timestamp');
}

if (!$DB->tableExists('glpi_assets_assetmodels')) {
Expand Down
Loading

0 comments on commit 50a87ef

Please sign in to comment.