fixing iscsi mapping for library
This commit is contained in:
@@ -285,3 +285,42 @@ func (a *App) handleEjectTape(w http.ResponseWriter, r *http.Request) {
|
||||
"drive_id": fmt.Sprintf("%d", req.DriveID),
|
||||
})
|
||||
}
|
||||
|
||||
// handleListVTLDevicesForISCSI returns all tape devices (drives and medium changers) for iSCSI passthrough
|
||||
func (a *App) handleListVTLDevicesForISCSI(w http.ResponseWriter, r *http.Request) {
|
||||
devices := []map[string]interface{}{}
|
||||
|
||||
// Get drives
|
||||
drives, err := a.vtlService.ListDrives()
|
||||
if err == nil {
|
||||
for _, drive := range drives {
|
||||
devices = append(devices, map[string]interface{}{
|
||||
"type": "drive",
|
||||
"device": drive.Device,
|
||||
"id": drive.ID,
|
||||
"library_id": drive.LibraryID,
|
||||
"vendor": drive.Vendor,
|
||||
"product": drive.Product,
|
||||
"description": fmt.Sprintf("Tape Drive %d (Library %d) - %s %s", drive.ID, drive.LibraryID, drive.Vendor, drive.Product),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Get medium changers
|
||||
changers, err := a.vtlService.ListMediaChangers()
|
||||
if err == nil {
|
||||
for _, changer := range changers {
|
||||
devices = append(devices, map[string]interface{}{
|
||||
"type": "changer",
|
||||
"device": changer.Device,
|
||||
"id": changer.ID,
|
||||
"library_id": changer.LibraryID,
|
||||
"slots": changer.Slots,
|
||||
"drives": changer.Drives,
|
||||
"description": fmt.Sprintf("Media Changer (Library %d) - %d slots, %d drives", changer.LibraryID, changer.Slots, changer.Drives),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, devices)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user