fix: Robust TGT LUN mapping + debug info
This commit is contained in:
BIN
dist/adastra-vtl-installer-1.0.0.tar.gz
vendored
BIN
dist/adastra-vtl-installer-1.0.0.tar.gz
vendored
Binary file not shown.
2
dist/adastra-vtl-installer/VERSION
vendored
2
dist/adastra-vtl-installer/VERSION
vendored
@@ -1,4 +1,4 @@
|
|||||||
Adastra VTL Installer
|
Adastra VTL Installer
|
||||||
Version: 1.0.0
|
Version: 1.0.0
|
||||||
Build Date: 2025-12-10 12:13:48
|
Build Date: 2025-12-10 12:20:01
|
||||||
Build Host: vtl-dev
|
Build Host: vtl-dev
|
||||||
|
|||||||
29
dist/adastra-vtl-installer/web-ui/api.php
vendored
29
dist/adastra-vtl-installer/web-ui/api.php
vendored
@@ -325,36 +325,18 @@ function addLun($params) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine backing store type and device type
|
// Determine backing store type (simplify to just bstype)
|
||||||
$bstypeParam = '';
|
$bstypeParam = '';
|
||||||
$deviceTypeParam = '';
|
|
||||||
|
|
||||||
if (strpos($device, '/dev/sg') === 0) {
|
if (strpos($device, '/dev/sg') === 0) {
|
||||||
$bstypeParam = '--bstype sg'; // Use sg (passthrough) for generic scsi devices
|
$bstypeParam = '--bstype sg';
|
||||||
|
|
||||||
// Detect specific device type (tape or changer)
|
|
||||||
$lsscsiOutput = [];
|
|
||||||
exec("sudo /usr/bin/lsscsi -g | grep " . escapeshellarg($device), $lsscsiOutput);
|
|
||||||
|
|
||||||
if (!empty($lsscsiOutput)) {
|
|
||||||
$line = $lsscsiOutput[0];
|
|
||||||
if (strpos($line, 'mediumx') !== false) {
|
|
||||||
$deviceTypeParam = '--device-type changer';
|
|
||||||
} elseif (strpos($line, 'tape') !== false) {
|
|
||||||
$deviceTypeParam = '--device-type tape';
|
|
||||||
} else {
|
|
||||||
$deviceTypeParam = '--device-type pt'; // Default to passthrough if unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = sprintf(
|
$command = sprintf(
|
||||||
'sudo /usr/sbin/tgtadm --lld iscsi --mode logicalunit --op new --tid %d --lun %d --backing-store %s %s %s 2>&1',
|
'sudo /usr/sbin/tgtadm --lld iscsi --mode logicalunit --op new --tid %d --lun %d --backing-store %s %s 2>&1',
|
||||||
$tid,
|
$tid,
|
||||||
$lun,
|
$lun,
|
||||||
escapeshellarg($device),
|
escapeshellarg($device),
|
||||||
$bstypeParam,
|
$bstypeParam
|
||||||
$deviceTypeParam
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = [];
|
$output = [];
|
||||||
@@ -369,7 +351,8 @@ function addLun($params) {
|
|||||||
} else {
|
} else {
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'error' => 'Failed to add LUN: ' . implode(' ', $output)
|
'error' => 'Failed to add LUN: ' . implode(' ', $output),
|
||||||
|
'command' => $command // Debug info
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,36 +325,18 @@ function addLun($params) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine backing store type and device type
|
// Determine backing store type (simplify to just bstype)
|
||||||
$bstypeParam = '';
|
$bstypeParam = '';
|
||||||
$deviceTypeParam = '';
|
|
||||||
|
|
||||||
if (strpos($device, '/dev/sg') === 0) {
|
if (strpos($device, '/dev/sg') === 0) {
|
||||||
$bstypeParam = '--bstype sg'; // Use sg (passthrough) for generic scsi devices
|
$bstypeParam = '--bstype sg';
|
||||||
|
|
||||||
// Detect specific device type (tape or changer)
|
|
||||||
$lsscsiOutput = [];
|
|
||||||
exec("sudo /usr/bin/lsscsi -g | grep " . escapeshellarg($device), $lsscsiOutput);
|
|
||||||
|
|
||||||
if (!empty($lsscsiOutput)) {
|
|
||||||
$line = $lsscsiOutput[0];
|
|
||||||
if (strpos($line, 'mediumx') !== false) {
|
|
||||||
$deviceTypeParam = '--device-type changer';
|
|
||||||
} elseif (strpos($line, 'tape') !== false) {
|
|
||||||
$deviceTypeParam = '--device-type tape';
|
|
||||||
} else {
|
|
||||||
$deviceTypeParam = '--device-type pt'; // Default to passthrough if unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = sprintf(
|
$command = sprintf(
|
||||||
'sudo /usr/sbin/tgtadm --lld iscsi --mode logicalunit --op new --tid %d --lun %d --backing-store %s %s %s 2>&1',
|
'sudo /usr/sbin/tgtadm --lld iscsi --mode logicalunit --op new --tid %d --lun %d --backing-store %s %s 2>&1',
|
||||||
$tid,
|
$tid,
|
||||||
$lun,
|
$lun,
|
||||||
escapeshellarg($device),
|
escapeshellarg($device),
|
||||||
$bstypeParam,
|
$bstypeParam
|
||||||
$deviceTypeParam
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = [];
|
$output = [];
|
||||||
@@ -369,7 +351,8 @@ function addLun($params) {
|
|||||||
} else {
|
} else {
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'error' => 'Failed to add LUN: ' . implode(' ', $output)
|
'error' => 'Failed to add LUN: ' . implode(' ', $output),
|
||||||
|
'command' => $command // Debug info
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user