Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Mar 6, 2024
1 parent e35d470 commit a002bee
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions web/src/client/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,35 @@ 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
* @property {string[]} [udevIds]
* @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
Expand Down Expand Up @@ -173,20 +187,30 @@ 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;
device.udevIds = blockProperties.UdevIds.v;
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)
};
};

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -378,6 +405,8 @@ class ProposalManager {

const systemDevices = await this.system.getDevices();

console.log("system: ", systemDevices);

const buildResult = (proxy) => {
const buildSpaceAction = dbusSpaceAction => {
return {
Expand Down

0 comments on commit a002bee

Please sign in to comment.