Files
vtl-appliance/dist/adastra-vtl-installer/docs/WEB_UI_CONFIG_LOADER_FIX.md
Othman H. Suseno 01080498af feat: Major VTL System Upgrade (Auth, Monitoring, CLI, Installer)
- Web UI:
  - Added secure Authentication system (Login, 2 Roles: Admin/Viewer)
  - Added System Monitoring Dashboard (Health, Services, Power Mgmt)
  - Added User Management Interface (Create, Delete, Enable/Disable)
  - Added Device Mapping view in iSCSI tab (lsscsi output)
- Backend:
  - Implemented secure session management (auth.php)
  - Added power management APIs (restart/shutdown appliance)
  - Added device mapping API
- CLI:
  - Created global 'vtl' management tool
  - Added scripts for reliable startup (vtllibrary fix)
- Installer:
  - Updated install.sh with new dependencies (tgt, sudoers, permissions)
  - Included all new components in build-installer.sh
- Docs:
  - Consolidated documentation into docs/ folder
2025-12-09 18:15:36 +00:00

7.8 KiB

🔄 Web UI Config Loader Fix

📋 Issue

Web UI was not loading existing configuration from /etc/mhvtl/device.conf on page load. Instead, it always showed hardcoded default values (STK L700, XYZZY_A, etc.), forcing users to manually reconfigure everything even when a valid config already existed.

Previous Behavior

On Page Load:

  • Always showed default values:
    • Vendor: STK
    • Product: L700
    • Serial: XYZZY_A
    • 4 default drives with IBM ULT3580-TD5/TD6

User Experience:

  • Had to manually re-enter all existing configuration
  • No way to see current server configuration
  • Risk of overwriting working config with defaults

Fix Applied

New Behavior

On Page Load:

  1. Fetches existing device.conf from server via API
  2. Parses the configuration file
  3. Populates all form fields with actual values
  4. Loads all existing drives with correct settings
  5. Falls back to defaults only if no config exists

Implementation

1. Updated Page Load Sequence

Before:

document.addEventListener('DOMContentLoaded', function () {
    initNavigation();
    addDefaultDrives();      // ❌ Always use defaults
    generateConfig();
});

After:

document.addEventListener('DOMContentLoaded', function () {
    initNavigation();
    loadExistingConfig();    // ✅ Load from server first
});

2. Added loadExistingConfig() Function

Fetches configuration from server:

function loadExistingConfig() {
    fetch('api.php', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ action: 'load_config' })
    })
    .then(response => response.json())
    .then(data => {
        if (data.success && data.config) {
            parseAndLoadConfig(data.config);  // Parse and populate
        } else {
            addDefaultDrives();  // Fallback to defaults
            generateConfig();
        }
    })
    .catch(error => {
        console.error('Error loading config:', error);
        addDefaultDrives();  // Fallback on error
        generateConfig();
    });
}

3. Added parseAndLoadConfig() Function

Comprehensive parser that extracts:

Library Configuration:

  • Library ID, Channel, Target, LUN
  • Vendor, Product, Serial Number
  • NAA, Home Directory, Backoff

Drive Configuration:

  • Drive Number, Channel, Target, LUN
  • Library ID, Slot Number
  • Vendor, Product, Serial Number
  • NAA, Compression settings, Backoff

Parsing Logic:

function parseAndLoadConfig(configText) {
    const lines = configText.split('\n');
    let libraryData = {};
    let drivesData = [];
    
    // Parse line by line
    for (let line of lines) {
        if (line.startsWith('Library:')) {
            // Extract: Library: 10 CHANNEL: 00 TARGET: 00 LUN: 00
            const match = line.match(/Library:\s+(\d+)\s+CHANNEL:\s+(\d+)...
        }
        else if (line.startsWith('Drive:')) {
            // Extract: Drive: 11 CHANNEL: 00 TARGET: 01 LUN: 00
            const match = line.match(/Drive:\s+(\d+)\s+CHANNEL:\s+(\d+)...
        }
        else if (line.includes('Vendor identification:')) {
            // Extract vendor name
        }
        // ... more parsing logic
    }
    
    // Populate UI fields
    document.getElementById('lib-vendor').value = libraryData.vendor;
    // ... populate all fields
    
    // Recreate drives
    drivesData.forEach(driveData => {
        const drive = { /* mapped data */ };
        drives.push(drive);
        renderDrive(drive);
    });
}

4. Added findDriveType() Helper

Maps vendor/product to drive type dropdown:

function findDriveType(vendor, product) {
    for (const [key, value] of Object.entries(driveTypes)) {
        if (value.vendor === vendor && value.product === product) {
            return key;  // e.g., 'IBM ULT3580-TD8'
        }
    }
    return 'IBM ULT3580-TD8';  // Default fallback
}

🎯 Features

1. Smart Loading

  • Loads existing config if available
  • Falls back to defaults if no config exists
  • Handles errors gracefully

2. Complete Parsing

  • Parses all library settings
  • Parses all drive configurations
  • Maintains MHVTL drive ID convention (11, 12, 13, 14)

3. Accurate Mapping

  • Maps vendor/product to correct drive types
  • Preserves all compression settings
  • Maintains NAA and serial numbers

4. User-Friendly

  • Shows actual current configuration
  • No need to re-enter existing settings
  • Can modify and save changes easily

📊 Example

Current Configuration on Server

VERSION: 5

Library: 10 CHANNEL: 00 TARGET: 00 LUN: 00
 Vendor identification: ADASTRA
 Product identification: HEPHAESTUS-V
 Unit serial number: HPV00001
 NAA: 10:22:33:44:ab:cd:ef:00
 Home directory: /opt/mhvtl
 Backoff: 400

Drive: 11 CHANNEL: 00 TARGET: 01 LUN: 00
 Library ID: 10 Slot: 01
 Vendor identification: IBM
 Product identification: ULT3580-TD8
 Unit serial number: XYZZY_A1
 NAA: 10:22:33:44:ab:cd:ef:01
 Compression: factor 3 enabled 1
 Compression type: lzo
 Backoff: 400

Drive: 12 CHANNEL: 00 TARGET: 02 LUN: 00
 Library ID: 10 Slot: 02
 Vendor identification: HP
 Product identification: Ultrium 6-SCSI
 Unit serial number: XYZZY_A2
 ...

Web UI Now Shows

Library Tab:

  • Library ID: 10
  • Vendor: ADASTRA
  • Product: HEPHAESTUS-V
  • Serial: HPV00001
  • NAA: 10:22:33:44:ab:cd:ef:00
  • Home Directory: /opt/mhvtl
  • Backoff: 400

Drives Tab:

  • Drive 11 (IBM ULT3580-TD8)

    • Channel: 0, Target: 1, LUN: 0
    • Library ID: 10, Slot: 1
    • Serial: XYZZY_A1
  • Drive 12 (HP Ultrium 6-SCSI)

    • Channel: 0, Target: 2, LUN: 0
    • Library ID: 10, Slot: 2
    • Serial: XYZZY_A2

🔄 Workflow

Before Fix:

  1. User opens web UI
  2. Sees default values (STK L700)
  3. Has to manually configure everything
  4. Risk of losing existing config

After Fix:

  1. User opens web UI
  2. Sees actual current configuration
  3. Can modify if needed
  4. Or just review current settings

📁 Files Modified

  1. /builder/adastra-vtl/web-ui/script.js

    • Updated DOMContentLoaded event handler
    • Added loadExistingConfig() function
    • Added parseAndLoadConfig() function
    • Added findDriveType() helper function
  2. /var/www/html/mhvtl-config/script.js

    • Deployed updated version to web server

🧪 Testing

Test Case 1: Existing Configuration

Setup: Valid device.conf exists at /etc/mhvtl/device.conf

Expected:

  • Web UI loads all values from config
  • Library settings match file
  • All drives displayed correctly
  • Drive IDs follow MHVTL convention (11, 12, 13, 14)

Test Case 2: No Configuration

Setup: No device.conf file exists

Expected:

  • Web UI falls back to defaults
  • Shows 4 default drives
  • User can configure from scratch

Test Case 3: API Error

Setup: API endpoint fails or returns error

Expected:

  • Web UI catches error gracefully
  • Falls back to defaults
  • Error logged to console
  • User can still use the UI

🎉 Benefits

  1. Time Saving - No need to re-enter existing configuration
  2. Accuracy - Shows actual current state of the system
  3. Safety - Less risk of accidentally overwriting working config
  4. Convenience - Can review settings without SSH access
  5. Professional - Behaves like a proper configuration manager

This fix complements the previous fixes:

  1. Drive ID Convention Fix - Ensures correct drive numbering (11, 12, 13, 14)
  2. Library Detection Fix - Fixed vtllibrary startup issues
  3. Web UI Drive ID Fix - Fixed config generation

All three fixes work together to provide a complete, working solution.


Status: FIXED
Date: December 9, 2025
Tested On: Ubuntu 24.04.3 LTS
Web Server: Apache 2.4
Access URL: http://localhost/mhvtl-config/