From 0c461d0656e3034ae90e17fedeccb233f1f006ef Mon Sep 17 00:00:00 2001 From: Warp Agent Date: Sat, 27 Dec 2025 14:13:27 +0000 Subject: [PATCH] add mhvtl detect vendor --- .../migrations/007_add_vendor_to_vtl_libraries.sql | 3 +++ backend/internal/tape_vtl/mhvtl_monitor.go | 12 ++++++------ backend/internal/tape_vtl/service.go | 5 +++++ frontend/src/api/tape.ts | 1 + frontend/src/pages/TapeLibraries.tsx | 6 +++++- 5 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 backend/internal/common/database/migrations/007_add_vendor_to_vtl_libraries.sql diff --git a/backend/internal/common/database/migrations/007_add_vendor_to_vtl_libraries.sql b/backend/internal/common/database/migrations/007_add_vendor_to_vtl_libraries.sql new file mode 100644 index 0000000..a23ebce --- /dev/null +++ b/backend/internal/common/database/migrations/007_add_vendor_to_vtl_libraries.sql @@ -0,0 +1,3 @@ +-- Add vendor column to virtual_tape_libraries table +ALTER TABLE virtual_tape_libraries ADD COLUMN IF NOT EXISTS vendor VARCHAR(255); + diff --git a/backend/internal/tape_vtl/mhvtl_monitor.go b/backend/internal/tape_vtl/mhvtl_monitor.go index f5e73ab..117ac41 100644 --- a/backend/internal/tape_vtl/mhvtl_monitor.go +++ b/backend/internal/tape_vtl/mhvtl_monitor.go @@ -275,10 +275,10 @@ func (m *MHVTLMonitor) syncLibrary(ctx context.Context, libInfo LibraryInfo) err _, err = m.service.db.ExecContext(ctx, ` INSERT INTO virtual_tape_libraries ( name, description, mhvtl_library_id, backing_store_path, - slot_count, drive_count, is_active - ) VALUES ($1, $2, $3, $4, $5, $6, $7) + vendor, slot_count, drive_count, is_active + ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) `, libraryName, fmt.Sprintf("MHVTL Library %d (%s)", libInfo.LibraryID, libInfo.Product), - libInfo.LibraryID, backingStorePath, slotCount, driveCount, true) + libInfo.LibraryID, backingStorePath, libInfo.Vendor, slotCount, driveCount, true) if err != nil { return fmt.Errorf("failed to insert library: %w", err) } @@ -288,10 +288,10 @@ func (m *MHVTLMonitor) syncLibrary(ctx context.Context, libInfo LibraryInfo) err _, err = m.service.db.ExecContext(ctx, ` UPDATE virtual_tape_libraries SET name = $1, description = $2, backing_store_path = $3, - is_active = $4, updated_at = NOW() - WHERE id = $5 + vendor = $4, is_active = $5, updated_at = NOW() + WHERE id = $6 `, libraryName, fmt.Sprintf("MHVTL Library %d (%s)", libInfo.LibraryID, libInfo.Product), - libInfo.HomeDirectory, true, existingID) + libInfo.HomeDirectory, libInfo.Vendor, true, existingID) if err != nil { return fmt.Errorf("failed to update library: %w", err) } diff --git a/backend/internal/tape_vtl/service.go b/backend/internal/tape_vtl/service.go index 0507912..1f7f458 100644 --- a/backend/internal/tape_vtl/service.go +++ b/backend/internal/tape_vtl/service.go @@ -33,6 +33,7 @@ type VirtualTapeLibrary struct { Description string `json:"description"` MHVTLibraryID int `json:"mhvtl_library_id"` BackingStorePath string `json:"backing_store_path"` + Vendor string `json:"vendor,omitempty"` SlotCount int `json:"slot_count"` DriveCount int `json:"drive_count"` IsActive bool `json:"is_active"` @@ -223,6 +224,7 @@ func (s *Service) createTape(ctx context.Context, tape *VirtualTape) error { func (s *Service) ListLibraries(ctx context.Context) ([]VirtualTapeLibrary, error) { query := ` SELECT id, name, description, mhvtl_library_id, backing_store_path, + COALESCE(vendor, '') as vendor, slot_count, drive_count, is_active, created_at, updated_at, created_by FROM virtual_tape_libraries ORDER BY name @@ -247,6 +249,7 @@ func (s *Service) ListLibraries(ctx context.Context) ([]VirtualTapeLibrary, erro var createdBy sql.NullString err := rows.Scan( &lib.ID, &lib.Name, &description, &lib.MHVTLibraryID, &lib.BackingStorePath, + &lib.Vendor, &lib.SlotCount, &lib.DriveCount, &lib.IsActive, &lib.CreatedAt, &lib.UpdatedAt, &createdBy, ) @@ -284,6 +287,7 @@ func (s *Service) ListLibraries(ctx context.Context) ([]VirtualTapeLibrary, erro func (s *Service) GetLibrary(ctx context.Context, id string) (*VirtualTapeLibrary, error) { query := ` SELECT id, name, description, mhvtl_library_id, backing_store_path, + COALESCE(vendor, '') as vendor, slot_count, drive_count, is_active, created_at, updated_at, created_by FROM virtual_tape_libraries WHERE id = $1 @@ -294,6 +298,7 @@ func (s *Service) GetLibrary(ctx context.Context, id string) (*VirtualTapeLibrar var createdBy sql.NullString err := s.db.QueryRowContext(ctx, query, id).Scan( &lib.ID, &lib.Name, &description, &lib.MHVTLibraryID, &lib.BackingStorePath, + &lib.Vendor, &lib.SlotCount, &lib.DriveCount, &lib.IsActive, &lib.CreatedAt, &lib.UpdatedAt, &createdBy, ) diff --git a/frontend/src/api/tape.ts b/frontend/src/api/tape.ts index df8d2d1..48c68eb 100644 --- a/frontend/src/api/tape.ts +++ b/frontend/src/api/tape.ts @@ -26,6 +26,7 @@ export interface VirtualTapeLibrary { name: string mhvtl_library_id: number storage_path: string + vendor?: string slot_count: number drive_count: number is_active: boolean diff --git a/frontend/src/pages/TapeLibraries.tsx b/frontend/src/pages/TapeLibraries.tsx index 91ccfb7..4e74bb1 100644 --- a/frontend/src/pages/TapeLibraries.tsx +++ b/frontend/src/pages/TapeLibraries.tsx @@ -365,7 +365,11 @@ export default function TapeLibraries() {

- {isVTL ? 'MHVTL' : 'physical' in library ? (library as PhysicalTapeLibrary).vendor : 'N/A'} + {isVTL + ? (library as VirtualTapeLibrary).vendor || 'MHVTL' + : 'physical' in library + ? (library as PhysicalTapeLibrary).vendor + : 'N/A'}

LTO-8 • {library.drive_count} {library.drive_count === 1 ? 'Drive' : 'Drives'}