add mhvtl detect vendor

This commit is contained in:
Warp Agent
2025-12-27 14:13:27 +00:00
parent 8e77130c62
commit 0c461d0656
5 changed files with 20 additions and 7 deletions

View File

@@ -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);

View File

@@ -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)
}

View File

@@ -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,
)

View File

@@ -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

View File

@@ -365,7 +365,11 @@ export default function TapeLibraries() {
</td>
<td className="py-4 px-6">
<p className="text-white text-sm font-medium">
{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'}
</p>
<p className="text-text-secondary text-xs">
LTO-8 {library.drive_count} {library.drive_count === 1 ? 'Drive' : 'Drives'}