working on storage dashboard

This commit is contained in:
Warp Agent
2025-12-25 09:01:49 +00:00
parent a08514b4f2
commit a5e6197bca
29 changed files with 4028 additions and 528 deletions

View File

@@ -2,6 +2,26 @@
-- Storage and Tape Component Schema
-- Version: 2.0
-- ZFS pools table
CREATE TABLE IF NOT EXISTS zfs_pools (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(255) NOT NULL UNIQUE,
description TEXT,
raid_level VARCHAR(50) NOT NULL, -- stripe, mirror, raidz, raidz2, raidz3
disks TEXT[] NOT NULL, -- array of device paths
size_bytes BIGINT NOT NULL,
used_bytes BIGINT NOT NULL DEFAULT 0,
compression VARCHAR(50) NOT NULL DEFAULT 'lz4', -- off, lz4, zstd, gzip
deduplication BOOLEAN NOT NULL DEFAULT false,
auto_expand BOOLEAN NOT NULL DEFAULT false,
scrub_interval INTEGER NOT NULL DEFAULT 30, -- days
is_active BOOLEAN NOT NULL DEFAULT true,
health_status VARCHAR(50) NOT NULL DEFAULT 'online', -- online, degraded, faulted, offline
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
created_by UUID REFERENCES users(id)
);
-- Disk repositories table
CREATE TABLE IF NOT EXISTS disk_repositories (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),

View File

@@ -0,0 +1,31 @@
-- AtlasOS - Calypso
-- Add ZFS Pools Table
-- Version: 4.0
-- Note: This migration adds the zfs_pools table that was added to migration 002
-- but may not have been applied if migration 002 was run before the table was added
-- ZFS pools table
CREATE TABLE IF NOT EXISTS zfs_pools (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(255) NOT NULL UNIQUE,
description TEXT,
raid_level VARCHAR(50) NOT NULL, -- stripe, mirror, raidz, raidz2, raidz3
disks TEXT[] NOT NULL, -- array of device paths
size_bytes BIGINT NOT NULL,
used_bytes BIGINT NOT NULL DEFAULT 0,
compression VARCHAR(50) NOT NULL DEFAULT 'lz4', -- off, lz4, zstd, gzip
deduplication BOOLEAN NOT NULL DEFAULT false,
auto_expand BOOLEAN NOT NULL DEFAULT false,
scrub_interval INTEGER NOT NULL DEFAULT 30, -- days
is_active BOOLEAN NOT NULL DEFAULT true,
health_status VARCHAR(50) NOT NULL DEFAULT 'online', -- online, degraded, faulted, offline
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
created_by UUID REFERENCES users(id)
);
-- Create index on name for faster lookups
CREATE INDEX IF NOT EXISTS idx_zfs_pools_name ON zfs_pools(name);
CREATE INDEX IF NOT EXISTS idx_zfs_pools_created_by ON zfs_pools(created_by);
CREATE INDEX IF NOT EXISTS idx_zfs_pools_health_status ON zfs_pools(health_status);

View File

@@ -168,8 +168,18 @@ func NewRouter(cfg *config.Config, db *database.DB, log *logger.Logger) *gin.Eng
storageGroup.GET("/volume-groups", storageHandler.ListVolumeGroups)
storageGroup.GET("/repositories", storageHandler.ListRepositories)
storageGroup.GET("/repositories/:id", storageHandler.GetRepository)
storageGroup.POST("/repositories", storageHandler.CreateRepository)
storageGroup.DELETE("/repositories/:id", storageHandler.DeleteRepository)
storageGroup.POST("/repositories", requirePermission("storage", "write"), storageHandler.CreateRepository)
storageGroup.DELETE("/repositories/:id", requirePermission("storage", "write"), storageHandler.DeleteRepository)
// ZFS Pools
storageGroup.GET("/zfs/pools", storageHandler.ListZFSPools)
storageGroup.GET("/zfs/pools/:id", storageHandler.GetZFSPool)
storageGroup.POST("/zfs/pools", requirePermission("storage", "write"), storageHandler.CreateZPool)
storageGroup.DELETE("/zfs/pools/:id", requirePermission("storage", "write"), storageHandler.DeleteZFSPool)
storageGroup.POST("/zfs/pools/:id/spare", requirePermission("storage", "write"), storageHandler.AddSpareDisk)
// ZFS Datasets
storageGroup.GET("/zfs/pools/:id/datasets", storageHandler.ListZFSDatasets)
storageGroup.POST("/zfs/pools/:id/datasets", requirePermission("storage", "write"), storageHandler.CreateZFSDataset)
storageGroup.DELETE("/zfs/pools/:id/datasets/:dataset", requirePermission("storage", "write"), storageHandler.DeleteZFSDataset)
}
// SCST