working on storage dashboard
This commit is contained in:
@@ -11,6 +11,7 @@ export interface PhysicalDisk {
|
||||
is_ssd: boolean
|
||||
health_status: string
|
||||
is_used: boolean
|
||||
attached_to_pool?: string // Pool name if disk is used in a ZFS pool
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
@@ -44,8 +45,8 @@ export interface Repository {
|
||||
|
||||
export const storageApi = {
|
||||
listDisks: async (): Promise<PhysicalDisk[]> => {
|
||||
const response = await apiClient.get<PhysicalDisk[]>('/storage/disks')
|
||||
return response.data
|
||||
const response = await apiClient.get<{ disks: PhysicalDisk[] | null }>('/storage/disks')
|
||||
return response.data.disks || []
|
||||
},
|
||||
|
||||
syncDisks: async (): Promise<{ task_id: string }> => {
|
||||
@@ -54,13 +55,13 @@ export const storageApi = {
|
||||
},
|
||||
|
||||
listVolumeGroups: async (): Promise<VolumeGroup[]> => {
|
||||
const response = await apiClient.get<VolumeGroup[]>('/storage/volume-groups')
|
||||
return response.data
|
||||
const response = await apiClient.get<{ volume_groups: VolumeGroup[] | null }>('/storage/volume-groups')
|
||||
return response.data.volume_groups || []
|
||||
},
|
||||
|
||||
listRepositories: async (): Promise<Repository[]> => {
|
||||
const response = await apiClient.get<Repository[]>('/storage/repositories')
|
||||
return response.data
|
||||
const response = await apiClient.get<{ repositories: Repository[] | null }>('/storage/repositories')
|
||||
return response.data.repositories || []
|
||||
},
|
||||
|
||||
getRepository: async (id: string): Promise<Repository> => {
|
||||
@@ -84,3 +85,92 @@ export const storageApi = {
|
||||
},
|
||||
}
|
||||
|
||||
export interface ZFSPool {
|
||||
id: string
|
||||
name: string
|
||||
description?: string
|
||||
raid_level: string // stripe, mirror, raidz, raidz2, raidz3
|
||||
disks: string[] // device paths
|
||||
spare_disks?: string[] // spare disk paths
|
||||
size_bytes: number
|
||||
used_bytes: number
|
||||
compression: string // off, lz4, zstd, gzip
|
||||
deduplication: boolean
|
||||
auto_expand: boolean
|
||||
scrub_interval: number // days
|
||||
is_active: boolean
|
||||
health_status: string // online, degraded, faulted, offline
|
||||
created_at: string
|
||||
updated_at: string
|
||||
created_by: string
|
||||
}
|
||||
|
||||
export const zfsApi = {
|
||||
listPools: async (): Promise<ZFSPool[]> => {
|
||||
const response = await apiClient.get<{ pools: ZFSPool[] | null }>('/storage/zfs/pools')
|
||||
return response.data.pools || []
|
||||
},
|
||||
|
||||
getPool: async (id: string): Promise<ZFSPool> => {
|
||||
const response = await apiClient.get<ZFSPool>(`/storage/zfs/pools/${id}`)
|
||||
return response.data
|
||||
},
|
||||
|
||||
createPool: async (data: {
|
||||
name: string
|
||||
description?: string
|
||||
raid_level: string
|
||||
disks: string[]
|
||||
compression?: string
|
||||
deduplication?: boolean
|
||||
auto_expand?: boolean
|
||||
}): Promise<ZFSPool> => {
|
||||
const response = await apiClient.post<ZFSPool>('/storage/zfs/pools', data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
deletePool: async (id: string): Promise<void> => {
|
||||
await apiClient.delete(`/storage/zfs/pools/${id}`)
|
||||
},
|
||||
|
||||
addSpareDisk: async (id: string, disks: string[]): Promise<void> => {
|
||||
await apiClient.post(`/storage/zfs/pools/${id}/spare`, { disks })
|
||||
},
|
||||
|
||||
listDatasets: async (poolId: string): Promise<ZFSDataset[]> => {
|
||||
const response = await apiClient.get<{ datasets: ZFSDataset[] | null }>(`/storage/zfs/pools/${poolId}/datasets`)
|
||||
return response.data.datasets || []
|
||||
},
|
||||
|
||||
createDataset: async (poolId: string, data: {
|
||||
name: string
|
||||
type: 'filesystem' | 'volume'
|
||||
compression?: string
|
||||
quota?: number
|
||||
reservation?: number
|
||||
mount_point?: string
|
||||
}): Promise<ZFSDataset> => {
|
||||
const response = await apiClient.post<ZFSDataset>(`/storage/zfs/pools/${poolId}/datasets`, data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
deleteDataset: async (poolId: string, datasetName: string): Promise<void> => {
|
||||
await apiClient.delete(`/storage/zfs/pools/${poolId}/datasets/${datasetName}`)
|
||||
},
|
||||
}
|
||||
|
||||
export interface ZFSDataset {
|
||||
name: string
|
||||
pool: string
|
||||
type: string // filesystem, volume, snapshot
|
||||
mount_point: string
|
||||
used_bytes: number
|
||||
available_bytes: number
|
||||
referenced_bytes: number
|
||||
compression: string
|
||||
deduplication: string
|
||||
quota: number // -1 for unlimited
|
||||
reservation: number
|
||||
created_at: string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user