development #2

Merged
othman.suseno merged 10 commits from development into main 2025-12-28 20:31:32 +00:00
5 changed files with 20 additions and 7 deletions
Showing only changes of commit 0c461d0656 - Show all commits

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, ` _, err = m.service.db.ExecContext(ctx, `
INSERT INTO virtual_tape_libraries ( INSERT INTO virtual_tape_libraries (
name, description, mhvtl_library_id, backing_store_path, name, description, mhvtl_library_id, backing_store_path,
slot_count, drive_count, is_active vendor, slot_count, drive_count, is_active
) VALUES ($1, $2, $3, $4, $5, $6, $7) ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
`, libraryName, fmt.Sprintf("MHVTL Library %d (%s)", libInfo.LibraryID, libInfo.Product), `, 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 { if err != nil {
return fmt.Errorf("failed to insert library: %w", err) 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, ` _, err = m.service.db.ExecContext(ctx, `
UPDATE virtual_tape_libraries SET UPDATE virtual_tape_libraries SET
name = $1, description = $2, backing_store_path = $3, name = $1, description = $2, backing_store_path = $3,
is_active = $4, updated_at = NOW() vendor = $4, is_active = $5, updated_at = NOW()
WHERE id = $5 WHERE id = $6
`, libraryName, fmt.Sprintf("MHVTL Library %d (%s)", libInfo.LibraryID, libInfo.Product), `, libraryName, fmt.Sprintf("MHVTL Library %d (%s)", libInfo.LibraryID, libInfo.Product),
libInfo.HomeDirectory, true, existingID) libInfo.HomeDirectory, libInfo.Vendor, true, existingID)
if err != nil { if err != nil {
return fmt.Errorf("failed to update library: %w", err) return fmt.Errorf("failed to update library: %w", err)
} }

View File

@@ -33,6 +33,7 @@ type VirtualTapeLibrary struct {
Description string `json:"description"` Description string `json:"description"`
MHVTLibraryID int `json:"mhvtl_library_id"` MHVTLibraryID int `json:"mhvtl_library_id"`
BackingStorePath string `json:"backing_store_path"` BackingStorePath string `json:"backing_store_path"`
Vendor string `json:"vendor,omitempty"`
SlotCount int `json:"slot_count"` SlotCount int `json:"slot_count"`
DriveCount int `json:"drive_count"` DriveCount int `json:"drive_count"`
IsActive bool `json:"is_active"` 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) { func (s *Service) ListLibraries(ctx context.Context) ([]VirtualTapeLibrary, error) {
query := ` query := `
SELECT id, name, description, mhvtl_library_id, backing_store_path, 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 slot_count, drive_count, is_active, created_at, updated_at, created_by
FROM virtual_tape_libraries FROM virtual_tape_libraries
ORDER BY name ORDER BY name
@@ -247,6 +249,7 @@ func (s *Service) ListLibraries(ctx context.Context) ([]VirtualTapeLibrary, erro
var createdBy sql.NullString var createdBy sql.NullString
err := rows.Scan( err := rows.Scan(
&lib.ID, &lib.Name, &description, &lib.MHVTLibraryID, &lib.BackingStorePath, &lib.ID, &lib.Name, &description, &lib.MHVTLibraryID, &lib.BackingStorePath,
&lib.Vendor,
&lib.SlotCount, &lib.DriveCount, &lib.IsActive, &lib.SlotCount, &lib.DriveCount, &lib.IsActive,
&lib.CreatedAt, &lib.UpdatedAt, &createdBy, &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) { func (s *Service) GetLibrary(ctx context.Context, id string) (*VirtualTapeLibrary, error) {
query := ` query := `
SELECT id, name, description, mhvtl_library_id, backing_store_path, 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 slot_count, drive_count, is_active, created_at, updated_at, created_by
FROM virtual_tape_libraries FROM virtual_tape_libraries
WHERE id = $1 WHERE id = $1
@@ -294,6 +298,7 @@ func (s *Service) GetLibrary(ctx context.Context, id string) (*VirtualTapeLibrar
var createdBy sql.NullString var createdBy sql.NullString
err := s.db.QueryRowContext(ctx, query, id).Scan( err := s.db.QueryRowContext(ctx, query, id).Scan(
&lib.ID, &lib.Name, &description, &lib.MHVTLibraryID, &lib.BackingStorePath, &lib.ID, &lib.Name, &description, &lib.MHVTLibraryID, &lib.BackingStorePath,
&lib.Vendor,
&lib.SlotCount, &lib.DriveCount, &lib.IsActive, &lib.SlotCount, &lib.DriveCount, &lib.IsActive,
&lib.CreatedAt, &lib.UpdatedAt, &createdBy, &lib.CreatedAt, &lib.UpdatedAt, &createdBy,
) )

View File

@@ -26,6 +26,7 @@ export interface VirtualTapeLibrary {
name: string name: string
mhvtl_library_id: number mhvtl_library_id: number
storage_path: string storage_path: string
vendor?: string
slot_count: number slot_count: number
drive_count: number drive_count: number
is_active: boolean is_active: boolean

View File

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