Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions inventory.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
}
},
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions lib/php/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Glpi/Inventory/tests/units/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down