From a002bee3e5ecfb7434aba2d612031df1553579c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 6 Mar 2024 16:03:46 +0000 Subject: [PATCH] WIP --- web/src/client/storage.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/web/src/client/storage.js b/web/src/client/storage.js index 66a92956bf..b10870c7bd 100644 --- a/web/src/client/storage.js +++ b/web/src/client/storage.js @@ -122,8 +122,10 @@ class DevicesManager { * @property {string[]} [wires] - Multipath wires (only for "multipath" type) * @property {string} [level] - MD RAID level (only for "md" type) * @property {string} [uuid] + * @property {number} [start] - First block of the region (only for block devices) * @property {boolean} [active] - * @property {string} [name] - Block device name + * @property {boolean} [encrypted] - Whether the device is encrypted (only for block devices) + * @property {string} [name] - Device name * @property {number} [size] * @property {number} [recoverableSize] * @property {string[]} [systems] - Name of the installed systems @@ -131,12 +133,24 @@ class DevicesManager { * @property {string[]} [udevPaths] * @property {PartitionTable} [partitionTable] * @property {Filesystem} [filesystem] + * @property {Component} [component] - When it is used as component of other devices + * @property {StorageDevice[]} [physicalVolumes] - Only for LVM VGs + * @property {StorageDevice[]} [logicalVolumes] - Only for LVM VGs * * @typedef {object} PartitionTable * @property {string} type * @property {StorageDevice[]} partitions + * @property {PartitionSlot[]} unusedSlots * @property {number} unpartitionedSize - Total size not assigned to any partition * + * @typedef {object} PartitionSlot + * @property {number} start + * @property {number} size + * + * @typedef {object} Component + * @property {string} type + * @property {string[]} deviceNames + * * @typedef {object} Filesystem * @property {string} type * @property {boolean} isEFI @@ -173,7 +187,9 @@ class DevicesManager { const addBlockProperties = (device, blockProperties) => { device.active = blockProperties.Active.v; + device.encrypted = blockProperties.Encrypted.v; device.name = blockProperties.Name.v; + device.start = blockProperties.Start.v; device.size = blockProperties.Size.v; device.recoverableSize = blockProperties.RecoverableSize.v; device.systems = blockProperties.Systems.v; @@ -181,12 +197,20 @@ class DevicesManager { device.udevPaths = blockProperties.UdevPaths.v; }; + const addLvmVgProperties = (device, lvmVgProperties) => { + device.type = "LvmVg"; + device.physicalVolumes = lvmVgProperties.PhysicalVolumes.v.map(d => buildDevice(d, dbusDevices)); + device.logicalVolumes = lvmVgProperties.LogicalVolumes.v.map(d => buildDevice(d, dbusDevices)); + }; + const addPtableProperties = (device, ptableProperties) => { + const buildPartitionSlot = ([start, size]) => ({ start, size }); const partitions = ptableProperties.Partitions.v.map(p => buildDevice(p, dbusDevices)); device.partitionTable = { type: ptableProperties.Type.v, partitions, - unpartitionedSize: device.size - partitions.reduce((s, p) => s + p.size, 0) + unpartitionedSize: device.size - partitions.reduce((s, p) => s + p.size, 0), + unusedSlots: ptableProperties.UnusedSlots.v.map(buildPartitionSlot) }; }; @@ -228,6 +252,9 @@ class DevicesManager { const blockProperties = dbusDevice["org.opensuse.Agama.Storage1.Block"]; if (blockProperties !== undefined) addBlockProperties(device, blockProperties); + const lvmVgProperties = dbusDevice["org.opensuse.Agama.Storage1.LVM.VolumeGroup"]; + if (lvmVgProperties !== undefined) addLvmVgProperties(device, lvmVgProperties); + const ptableProperties = dbusDevice["org.opensuse.Agama.Storage1.PartitionTable"]; if (ptableProperties !== undefined) addPtableProperties(device, ptableProperties); @@ -378,6 +405,8 @@ class ProposalManager { const systemDevices = await this.system.getDevices(); + console.log("system: ", systemDevices); + const buildResult = (proxy) => { const buildSpaceAction = dbusSpaceAction => { return {