From fea8f5cccd7c05f3b76667c5ec1d357861e79d61 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 19 May 2026 12:07:00 +0200 Subject: [PATCH 1/4] feat: add storages support in virtual machines Add storages as an optional field in the virtualmachines schema definition, reusing the existing storages $ref from the computer level. This allows hypervisors such as Hyper-V to report virtual disk files (VHDs) with their path and size as part of the VM inventory. --- CHANGELOG.md | 4 ++++ examples/computer_2_partial_vms.json | 17 ++++++++++++----- inventory.schema.json | 3 +++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7261f20..b2dded9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ The present file will list all changes made to the project; according to the [Keep a Changelog](http://keepachangelog.com/) project. +## [Unreleased] + +Add storages support in virtual machines + ## [1.2.3] - 2026-01-22 Exclude CSV header from iftypes conversion diff --git a/examples/computer_2_partial_vms.json b/examples/computer_2_partial_vms.json index 833e2c6..1aa9627 100644 --- a/examples/computer_2_partial_vms.json +++ b/examples/computer_2_partial_vms.json @@ -63,11 +63,18 @@ "vmtype": "docker" }, { - "name": "'T", - "owner": "local", - "subsystem": "Oracle VM VirtualBox", - "vcpu": 1, - "vmtype": "virtualbox" + "name": "ServerVM01", + "subsystem": "microsoft", + "vcpu": 4, + "memory": 8192, + "status": "running", + "vmtype": "hyperv", + "storages": [ + { + "name": "C:\\VMs\\ServerVM01.vhdx", + "disksize": 102400 + } + ] } ] }, diff --git a/inventory.schema.json b/inventory.schema.json index 222cb4d..c95aa4b 100644 --- a/inventory.schema.json +++ b/inventory.schema.json @@ -2092,6 +2092,9 @@ }, "serial": { "type": "string" + }, + "storages": { + "$ref": "#/properties/content/properties/storages" } } } From 5939752734981b2ad1a91a70a080763cf647a285 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 19 May 2026 15:04:33 +0200 Subject: [PATCH 2/4] examples: add Hyper-V VMs with storages instead of editing existing example --- examples/computer_2_partial_vms.json | 17 +++---- examples/computer_3_partial_hyperv_vms.json | 50 +++++++++++++++++++++ 2 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 examples/computer_3_partial_hyperv_vms.json diff --git a/examples/computer_2_partial_vms.json b/examples/computer_2_partial_vms.json index 1aa9627..833e2c6 100644 --- a/examples/computer_2_partial_vms.json +++ b/examples/computer_2_partial_vms.json @@ -63,18 +63,11 @@ "vmtype": "docker" }, { - "name": "ServerVM01", - "subsystem": "microsoft", - "vcpu": 4, - "memory": 8192, - "status": "running", - "vmtype": "hyperv", - "storages": [ - { - "name": "C:\\VMs\\ServerVM01.vhdx", - "disksize": 102400 - } - ] + "name": "'T", + "owner": "local", + "subsystem": "Oracle VM VirtualBox", + "vcpu": 1, + "vmtype": "virtualbox" } ] }, diff --git a/examples/computer_3_partial_hyperv_vms.json b/examples/computer_3_partial_hyperv_vms.json new file mode 100644 index 0000000..d21432c --- /dev/null +++ b/examples/computer_3_partial_hyperv_vms.json @@ -0,0 +1,50 @@ +{ + "content": { + "hardware": { + "chassis_type": "Server", + "memory": 65536, + "name": "HYPERV-HOST01", + "uuid": "A1B2C3D4-1234-5678-ABCD-1234567890AB", + "vmsystem": "Physical" + }, + "versionclient": "GLPI-Agent_v1.12", + "virtualmachines": [ + { + "name": "ServerVM01", + "status": "running", + "uuid": "6A257FA0-FA76-4BF4-A3FB-67AEE79316BD", + "vcpu": 4, + "memory": 8192, + "vmtype": "hyperv", + "storages": [ + { + "name": "C:\\VMs\\ServerVM01.vhdx", + "disksize": 102400 + }, + { + "name": "\\\\nas01\\VMs\\ServerVM01-data.vhdx", + "disksize": 512000 + } + ] + }, + { + "name": "ServerVM02", + "status": "off", + "uuid": "7B368GB1-GB87-5CG5-B4GC-78BFF8A427CE", + "vcpu": 2, + "memory": 4096, + "vmtype": "hyperv", + "storages": [ + { + "name": "C:\\VMs\\ServerVM02.vhdx", + "disksize": 51200 + } + ] + } + ] + }, + "deviceid": "hyperv-host-2024-01-15-10-00-00", + "action": "inventory", + "itemtype": "Computer", + "partial": true +} From 104094b244d72d6fbb109e27408a68bbe0a97df9 Mon Sep 17 00:00:00 2001 From: javier lago Date: Wed, 27 May 2026 14:18:23 +0200 Subject: [PATCH 3/4] fix: use drives instead of storages for VM virtual disk inventory storages maps to the Drive asset class in GLPI (physical hardware component), while drives maps to Volume (logical volume, shown in Volumes tab). VHDs are logical volumes, so drives with volumn/total fields is the correct mapping. Update example to use volumn/total instead of name/disksize accordingly. --- examples/computer_3_partial_hyperv_vms.json | 16 ++++++++-------- inventory.schema.json | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/computer_3_partial_hyperv_vms.json b/examples/computer_3_partial_hyperv_vms.json index d21432c..f38d86f 100644 --- a/examples/computer_3_partial_hyperv_vms.json +++ b/examples/computer_3_partial_hyperv_vms.json @@ -16,14 +16,14 @@ "vcpu": 4, "memory": 8192, "vmtype": "hyperv", - "storages": [ + "drives": [ { - "name": "C:\\VMs\\ServerVM01.vhdx", - "disksize": 102400 + "volumn": "C:\\VMs\\ServerVM01.vhdx", + "total": 102400 }, { - "name": "\\\\nas01\\VMs\\ServerVM01-data.vhdx", - "disksize": 512000 + "volumn": "\\\\nas01\\VMs\\ServerVM01-data.vhdx", + "total": 512000 } ] }, @@ -34,10 +34,10 @@ "vcpu": 2, "memory": 4096, "vmtype": "hyperv", - "storages": [ + "drives": [ { - "name": "C:\\VMs\\ServerVM02.vhdx", - "disksize": 51200 + "volumn": "C:\\VMs\\ServerVM02.vhdx", + "total": 51200 } ] } diff --git a/inventory.schema.json b/inventory.schema.json index c95aa4b..ba111db 100644 --- a/inventory.schema.json +++ b/inventory.schema.json @@ -2093,8 +2093,8 @@ "serial": { "type": "string" }, - "storages": { - "$ref": "#/properties/content/properties/storages" + "drives": { + "$ref": "#/properties/content/properties/drives" } } } From 89c8707328652e2052d0f32316832b5b711e576c Mon Sep 17 00:00:00 2001 From: javier lago Date: Wed, 27 May 2026 14:19:29 +0200 Subject: [PATCH 4/4] fix: update changelog to reflect drives support in virtual machines --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2dded9..f4a7922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The present file will list all changes made to the project; according to the ## [Unreleased] -Add storages support in virtual machines +Add drives support in virtual machines ## [1.2.3] - 2026-01-22