diff --git a/rust/share/device.storage.schema.json b/rust/share/device.storage.schema.json new file mode 100644 index 0000000000..39ebbfcee6 --- /dev/null +++ b/rust/share/device.storage.schema.json @@ -0,0 +1,206 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://github.com/openSUSE/agama/blob/master/rust/share/device.storage.schema.json", + "title": "Storage device", + "description": "Schema to describe a device both in 'system' and 'proposal'.", + "type": "object", + "additionalProperties": false, + "required": ["sid", "name"], + "properties": { + "sid": { "type": "integer" }, + "name": { "type": "string" }, + "description": { "type": "string" }, + "block": { "$ref": "#/$defs/block" }, + "drive": { "$ref": "#/$defs/drive" }, + "filesystem": { "$ref": "#/$defs/filesystem" }, + "md": { "$ref": "#/$defs/md" }, + "multipath": { "$ref": "#/$defs/multipath" }, + "partitionTable": { "$ref": "#/$defs/partitionTable" }, + "partition": { "$ref": "#/$defs/partition" }, + "partitions": { + "type": "array", + "items": { "$ref": "#" } + }, + "volumeGroup": { "$ref": "#/$defs/volumeGroup" }, + "logicalVolumes": { + "type": "array", + "items": { "$ref": "#" } + } + }, + "$defs": { + "block": { + "type": "object", + "additionalProperties": false, + "required": ["start", "size", "shrinking"], + "properties": { + "start": { "type": "integer" }, + "size": { "type": "integer" }, + "active": { "type": "boolean" }, + "encrypted": { "type": "boolean" }, + "udevIds": { + "type": "array", + "items": { "type": "string" } + }, + "udevPaths": { + "type": "array", + "items": { "type": "string" } + }, + "systems": { + "type": "array", + "items": { "type": "string" } + }, + "shrinking": { + "anyOf": [ + { "$ref": "#/$defs/shrinkingSupported" }, + { "$ref": "#/$defs/shrinkingUnsupported" } + ] + } + } + }, + "shrinkingSupported": { + "type": "object", + "additionalProperties": false, + "properties": { + "supported": { "type": "integer" } + } + }, + "shrinkingUnsupported": { + "type": "object", + "additionalProperties": false, + "properties": { + "unsupported": { + "type": "array", + "items": { "type": "string" } + } + } + }, + "drive": { + "type": "object", + "additionalProperties": false, + "properties": { + "type": { "enum": ["disk", "raid", "multipath", "dasd"] }, + "vendor": { "type": "string" }, + "model": { "type": "string" }, + "transport": { "type": "string" }, + "bus": { "type": "string" }, + "busId": { "type": "string" }, + "driver": { + "type": "array", + "items": { "type": "string" } + }, + "info": { "$ref": "#/$defs/driveInfo" } + } + }, + "driveInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "sdCard": { "type": "boolean" }, + "dellBoss": { "type": "boolean" } + } + }, + "filesystem": { + "type": "object", + "additionalProperties": false, + "required": ["sid", "type"], + "properties": { + "sid": { "type": "integer" }, + "type": { "$ref": "#/$defs/filesystemType" }, + "mountPath": { "type": "string" }, + "label": { "type": "string" } + } + }, + "filesystemType": { + "enum": [ + "bcachefs", + "btrfs", + "exfat", + "ext2", + "ext3", + "ext4", + "f2fs", + "jfs", + "nfs", + "nilfs2", + "ntfs", + "reiserfs", + "swap", + "tmpfs", + "vfat", + "xfs" + ] + }, + "md": { + "type": "object", + "additionalProperties": false, + "required": ["level", "devices"], + "properties": { + "level": { "$ref": "#/$defs/mdRaidLevel" }, + "devices": { + "type": "array", + "items": { "type": "integer" } + }, + "uuid": { "type": "string" } + } + }, + "mdRaidLevel": { + "title": "MD level", + "enum": [ + "raid0", + "raid1", + "raid5", + "raid6", + "raid10" + ] + }, + "multipath": { + "type": "object", + "additionalProperties": false, + "required": ["wireNames"], + "properties": { + "wireNames": { + "type": "array", + "items": { "type": "string" } + } + } + }, + "partitionTable": { + "type": "object", + "additionalProperties": false, + "required": ["type", "unusedSlots"], + "properties": { + "type": { "$ref": "#/$defs/ptableType" }, + "unusedSlots": { + "type": "array", + "items": { + "type": "array", + "items": { "type": "integer" } + } + } + } + }, + "ptableType": { + "enum": ["gpt", "msdos", "dasd"] + }, + "partition": { + "type": "object", + "additionalProperties": false, + "required": ["efi"], + "properties": { + "efi": { "type": "boolean" } + } + }, + "volumeGroup": { + "type": "object", + "additionalProperties": false, + "required": ["size", "physicalVolumes"], + "properties": { + "size": { "type": "integer" }, + "physicalVolumes": { + "type": "array", + "items": { "type": "integer" } + } + } + } + } +} diff --git a/rust/share/proposal.storage.schema.json b/rust/share/proposal.storage.schema.json new file mode 100644 index 0000000000..876c9c0ea6 --- /dev/null +++ b/rust/share/proposal.storage.schema.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://github.com/openSUSE/agama/blob/master/rust/share/proposal.storage.schema.json", + "title": "Proposal", + "description": "API description of the storage proposal.", + "type": "object", + "additionalProperties": false, + "properties": { + "devices": { + "description": "Expected layout of the system after the commit phase.", + "type": "array", + "items": { "$ref": "device.storage.schema.json" } + }, + "actions": { + "description": "Sorted list of actions to execute during the commit phase.", + "type": "array", + "items": { "$ref": "#/$defs/action" } + } + }, + "$defs": { + "action": { + "type": "object", + "additionalProperties": false, + "required": ["device", "text"], + "properties": { + "device": { "type": "integer" }, + "text": { "type": "string" }, + "subvol": { "type": "boolean" }, + "delete": { "type": "boolean" }, + "resize": { "type": "boolean" } + } + } + } +} diff --git a/rust/share/system.storage.schema.json b/rust/share/system.storage.schema.json new file mode 100644 index 0000000000..96020738f2 --- /dev/null +++ b/rust/share/system.storage.schema.json @@ -0,0 +1,107 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://github.com/openSUSE/agama/blob/master/rust/share/system.storage.schema.json", + "title": "System", + "description": "API description of the system", + "type": "object", + "additionalProperties": false, + "properties": { + "devices": { + "description": "All relevant devices on the system", + "type": "array", + "items": { "$ref": "device.storage.schema.json" } + }, + "availableDrives": { + "description": "SIDs of the available drives", + "type": "array", + "items": { "type": "integer" } + }, + "availableMdRaids": { + "description": "SIDs of the available MD RAIDs", + "type": "array", + "items": { "type": "integer" } + }, + "candidateDrives": { + "description": "SIDs of the drives that are candidate for installation", + "type": "array", + "items": { "type": "integer" } + }, + "candidateMdRaids": { + "description": "SIDs of the MD RAIDs that are candidate for installation", + "type": "array", + "items": { "type": "integer" } + }, + "productMountPoints": { + "description": "Meaningful mount points for the current product", + "type": "array", + "items": { "type": "string" } + }, + "encryptionMethods": { + "description": "Possible encryption methods for the current system and product", + "type": "array", + "items": { "type": "string" } + }, + "volumeTemplates": { + "description": "Volumes defined by the product as templates", + "type": "array", + "items": { "$ref": "#/$defs/volume" } + }, + "issues": { + "type": "array", + "items": { "$ref": "#/$defs/issue" } + } + }, + "$defs": { + "volume": { + "type": "object", + "additionalProperties": false, + "required": ["mountPath", "minSize", "autoSize"], + "properties": { + "mountPath": { "type": "string" }, + "mountOptions": { + "type": "array", + "items": { "type": "string" } + }, + "fsType": { "$ref": "device.storage.schema.json#/$defs/filesystemType" }, + "autoSize": { "type": "boolean" }, + "minSize": { "type": "integer" }, + "maxSize": { "type": "integer" }, + "snapshots": { "type": "boolean" }, + "transactional": { "type": "boolean" }, + "outline": { "$ref": "#/$defs/volumeOutline" } + } + }, + "volumeOutline": { + "type": "object", + "additionalProperties": false, + "required": ["required", "supportAutoSize"], + "properties": { + "required": { "type": "boolean" }, + "supportAutoSize": { "type": "boolean" }, + "fsTypes": { + "type": "array", + "items": { "$ref": "device.storage.schema.json#/$defs/filesystemType" } + }, + "adjustByRam": { "type": "boolean" }, + "snapshotsConfigurable": { "type": "boolean" }, + "snapshotsAffectSizes": { "type": "boolean" }, + "sizeRelevantVolumes": { + "type": "array", + "items": { "type": "string" } + } + } + }, + "issue": { + "type": "object", + "additionalProperties": false, + "required": ["description"], + "properties": { + "description": { "type": "string" }, + "class": { "type": "string" }, + "details": { "type": "string" }, + "source": { "enum": ["config", "system"] }, + "severity": { "enum": ["warn", "error"] } + } + } + } +} diff --git a/web/src/api/storage/proposal.ts b/web/src/api/storage/proposal.ts new file mode 100644 index 0000000000..0973d1931d --- /dev/null +++ b/web/src/api/storage/proposal.ts @@ -0,0 +1,118 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type MDLevel = "raid0" | "raid1" | "raid5" | "raid6" | "raid10"; + +/** + * API description of the storage proposal. + */ +export interface Proposal { + /** + * Expected layout of the system after the commit phase. + */ + devices?: StorageDevice[]; + /** + * Sorted list of actions to execute during the commit phase. + */ + actions?: Action[]; +} +/** + * Schema to describe a device both in 'system' and 'proposal'. + */ +export interface StorageDevice { + sid: number; + name: string; + description?: string; + block?: Block; + drive?: Drive; + filesystem?: Filesystem; + md?: Md; + multipath?: Multipath; + partitionTable?: PartitionTable; + partition?: Partition; + partitions?: StorageDevice[]; + volumeGroup?: VolumeGroup; + logicalVolumes?: StorageDevice[]; +} +export interface Block { + start: number; + size: number; + active?: boolean; + encrypted?: boolean; + udevIds?: string[]; + udevPaths?: string[]; + systems?: string[]; + shrinking: ShrinkingSupported | ShrinkingUnsupported; +} +export interface ShrinkingSupported { + supported?: number; +} +export interface ShrinkingUnsupported { + unsupported?: string[]; +} +export interface Drive { + type?: "disk" | "raid" | "multipath" | "dasd"; + vendor?: string; + model?: string; + transport?: string; + bus?: string; + busId?: string; + driver?: string[]; + info?: DriveInfo; +} +export interface DriveInfo { + sdCard?: boolean; + dellBoss?: boolean; +} +export interface Filesystem { + sid: number; + type: + | "bcachefs" + | "btrfs" + | "exfat" + | "ext2" + | "ext3" + | "ext4" + | "f2fs" + | "jfs" + | "nfs" + | "nilfs2" + | "ntfs" + | "reiserfs" + | "swap" + | "tmpfs" + | "vfat" + | "xfs"; + mountPath?: string; + label?: string; +} +export interface Md { + level: MDLevel; + devices: number[]; + uuid?: string; +} +export interface Multipath { + wireNames: string[]; +} +export interface PartitionTable { + type: "gpt" | "msdos" | "dasd"; + unusedSlots: number[][]; +} +export interface Partition { + efi: boolean; +} +export interface VolumeGroup { + size: number; + physicalVolumes: number[]; +} +export interface Action { + device: number; + text: string; + subvol?: boolean; + delete?: boolean; + resize?: boolean; +} diff --git a/web/src/api/storage/system.ts b/web/src/api/storage/system.ts new file mode 100644 index 0000000000..f219eac34c --- /dev/null +++ b/web/src/api/storage/system.ts @@ -0,0 +1,196 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type MDLevel = "raid0" | "raid1" | "raid5" | "raid6" | "raid10"; + +/** + * API description of the system + */ +export interface System { + /** + * All relevant devices on the system + */ + devices?: StorageDevice[]; + /** + * SIDs of the available drives + */ + availableDrives?: number[]; + /** + * SIDs of the available MD RAIDs + */ + availableMdRaids?: number[]; + /** + * SIDs of the drives that are candidate for installation + */ + candidateDrives?: number[]; + /** + * SIDs of the MD RAIDs that are candidate for installation + */ + candidateMdRaids?: number[]; + /** + * Meaningful mount points for the current product + */ + productMountPoints?: string[]; + /** + * Possible encryption methods for the current system and product + */ + encryptionMethods?: string[]; + /** + * Volumes defined by the product as templates + */ + volumeTemplates?: Volume[]; + issues?: Issue[]; +} +/** + * Schema to describe a device both in 'system' and 'proposal'. + */ +export interface StorageDevice { + sid: number; + name: string; + description?: string; + block?: Block; + drive?: Drive; + filesystem?: Filesystem; + md?: Md; + multipath?: Multipath; + partitionTable?: PartitionTable; + partition?: Partition; + partitions?: StorageDevice[]; + volumeGroup?: VolumeGroup; + logicalVolumes?: StorageDevice[]; +} +export interface Block { + start: number; + size: number; + active?: boolean; + encrypted?: boolean; + udevIds?: string[]; + udevPaths?: string[]; + systems?: string[]; + shrinking: ShrinkingSupported | ShrinkingUnsupported; +} +export interface ShrinkingSupported { + supported?: number; +} +export interface ShrinkingUnsupported { + unsupported?: string[]; +} +export interface Drive { + type?: "disk" | "raid" | "multipath" | "dasd"; + vendor?: string; + model?: string; + transport?: string; + bus?: string; + busId?: string; + driver?: string[]; + info?: DriveInfo; +} +export interface DriveInfo { + sdCard?: boolean; + dellBoss?: boolean; +} +export interface Filesystem { + sid: number; + type: + | "bcachefs" + | "btrfs" + | "exfat" + | "ext2" + | "ext3" + | "ext4" + | "f2fs" + | "jfs" + | "nfs" + | "nilfs2" + | "ntfs" + | "reiserfs" + | "swap" + | "tmpfs" + | "vfat" + | "xfs"; + mountPath?: string; + label?: string; +} +export interface Md { + level: MDLevel; + devices: number[]; + uuid?: string; +} +export interface Multipath { + wireNames: string[]; +} +export interface PartitionTable { + type: "gpt" | "msdos" | "dasd"; + unusedSlots: number[][]; +} +export interface Partition { + efi: boolean; +} +export interface VolumeGroup { + size: number; + physicalVolumes: number[]; +} +export interface Volume { + mountPath: string; + mountOptions?: string[]; + fsType?: + | "bcachefs" + | "btrfs" + | "exfat" + | "ext2" + | "ext3" + | "ext4" + | "f2fs" + | "jfs" + | "nfs" + | "nilfs2" + | "ntfs" + | "reiserfs" + | "swap" + | "tmpfs" + | "vfat" + | "xfs"; + autoSize: boolean; + minSize: number; + maxSize?: number; + snapshots?: boolean; + transactional?: boolean; + outline?: VolumeOutline; +} +export interface VolumeOutline { + required: boolean; + supportAutoSize: boolean; + fsTypes?: ( + | "bcachefs" + | "btrfs" + | "exfat" + | "ext2" + | "ext3" + | "ext4" + | "f2fs" + | "jfs" + | "nfs" + | "nilfs2" + | "ntfs" + | "reiserfs" + | "swap" + | "tmpfs" + | "vfat" + | "xfs" + )[]; + adjustByRam?: boolean; + snapshotsConfigurable?: boolean; + snapshotsAffectSizes?: boolean; + sizeRelevantVolumes?: string[]; +} +export interface Issue { + description: string; + class?: string; + details?: string; + source?: "config" | "system"; + severity?: "warn" | "error"; +}