diff --git a/inventory.schema.json b/inventory.schema.json index 222cb4d..62236b2 100644 --- a/inventory.schema.json +++ b/inventory.schema.json @@ -2838,7 +2838,7 @@ }, "type": { "type": "string", - "pattern": "^(Unmanaged|Computer|Networking|Printer|Storage|Power|Phone|Video|KVM)$" + "pattern": "^(Unmanaged|Computer|Networking|Printer|Storage|Power|Phone|Video|KVM|Pdu)$" }, "uptime": { "type": "string", @@ -2855,6 +2855,42 @@ }, "credentials": { "type": "integer" + }, + "pdu": { + "type": "object", + "title": "Power Distribution Unit inventory", + "properties": { + "type": { + "type": "string", + "title": "PDU type" + }, + "plugs": { + "title": "List of plugs of pdu", + "type": "array", + "items": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "title": "Plug name" + }, + "number": { + "type": "integer", + "title": "Plug number" + }, + "type": { + "type": "string", + "title": "Plug type" + } + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } } }, @@ -2967,7 +3003,7 @@ "type": "string", "title": "Item type", "default": "Unmanaged", - "pattern": "^(Unmanaged|Computer|Phone|NetworkEquipment|Printer)$" + "pattern": "^(Unmanaged|Computer|Phone|NetworkEquipment|Printer|Pdu)$" }, "partial": { "type": "boolean", diff --git a/lib/php/Converter.php b/lib/php/Converter.php index 470b607..4f9d759 100644 --- a/lib/php/Converter.php +++ b/lib/php/Converter.php @@ -1303,6 +1303,7 @@ public function convertNetworkInventory(array $data): array case 'Phone': case 'Printer': case 'Unmanaged': + case 'Pdu': $itemtype = $device_info['type']; break; case 'Networking': @@ -1437,6 +1438,10 @@ public function convertNetworkInventory(array $data): array case "error": $data['content'][$key] = $device_data; break; + case "pdu": + // put pdu into network_device + $data['content']['network_device'][$key] = $device_data; + break; default: throw new RuntimeException('Key ' . $key . ' is not handled in network devices conversion'); } diff --git a/tests/Glpi/Inventory/tests/units/Schema.php b/tests/Glpi/Inventory/tests/units/Schema.php index bda21a5..103ee7d 100644 --- a/tests/Glpi/Inventory/tests/units/Schema.php +++ b/tests/Glpi/Inventory/tests/units/Schema.php @@ -51,7 +51,7 @@ public function testValidateUnknownItemtype(): void $json = json_decode(json_encode(['deviceid' => 'myid', 'itemtype' => $itemtype, 'content' => ['versionclient' => 'GLPI-Agent_v1.0', 'hardware' => ['name' => 'my inventory']]])); $instance = new \Glpi\Inventory\Schema(); $this->expectException(\RuntimeException::class); - $this->expectExceptionMessage('\\\\Glpi\\\\Custom\\\\Asset\\\\Mine" does not match to ^(Unmanaged|Computer|Phone|NetworkEquipment|Printer)$'); + $this->expectExceptionMessage('\\\\Glpi\\\\Custom\\\\Asset\\\\Mine" does not match to ^(Unmanaged|Computer|Phone|NetworkEquipment|Printer|Pdu)$'); $this->assertFalse($instance->validate($json)); }