Getting the list of the tapes in the Offline Shelf

StarWind VTL, VTL Free, VTL Appliance

Moderators: anton (staff), art (staff), Anatoly (staff), Max (staff)

Post Reply
cforest
Posts: 15
Joined: Fri Dec 14, 2018 10:48 am

Wed Oct 23, 2019 5:10 pm

Hi there,

Just wanted to ask if there is any way to get the lists of the tapes in the Offline Shelf for a given VTL device via StarWindX with PowerShell? We need it to automate inserting a tape back to the drive/slot when we don't know the names of the such tapes in advance. To automate it, we already have two piece of codes:

1. InsertVirtualTape.ps1 in your Samples - it is a good example of how to insert a tape when you know its name

2. A code to get a free slot:

Code: Select all

foreach ($slot in $device.Slots) {
        if (($slot.Barcode -eq '') -and (($slot.SlotName -match 'TapeDrive') -or ($slot.SlotName -match 'Storage'))) {
            $freeSlot = $slot.slotAddress;
            "Slot: " + $slot.SlotName
            break;
        }
    }
The only thing we don't know is how to get the list of the tapes in the Offline Shelf. Is there any way to get it with PowerShell?

Version 8.0.0.13182
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Wed Oct 23, 2019 6:42 pm

You might want to check:

Code: Select all

$server.Devices[0].Tapes
for the property called SlotType.
For a tape in any slot it would return "Storage", while for offline tapes it is "Unknown".
Sample output:

Code: Select all

PS C:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell> $server.Devices[0].Tapes


Barcode   : SWCJJ003
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ006
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ007
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ008
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ009
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00A
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00B
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00C
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00D
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00E
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00F
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00G
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ00H
SlotType  : Storage
TapeType  : U-832 
Size      : 12288000
UsedSpace : 0

Barcode   : SWCJJ004
SlotType  : Unknown
TapeType  : 
Size      : 0
UsedSpace : 0

Barcode   : SWCJJ005
SlotType  : Unknown
TapeType  : 
Size      : 0
UsedSpace : 0
Attachments
Screen Shot 2019-10-23 at 21.41.30.png
Screen Shot 2019-10-23 at 21.41.30.png (42.06 KiB) Viewed 12388 times
cforest
Posts: 15
Joined: Fri Dec 14, 2018 10:48 am

Thu Oct 24, 2019 4:56 pm

Thank you!

It seems to work. The only thing I changed was using both SlotType and TapeType, because I observed "Unknown" for tapes in the Offline Shelf and the tapes in Drives.

Code: Select all

if (($tape.SlotType -match 'Unknown') -and ($tape.TapeType -eq '')) {
Offline Tape: SWPKU001
Offline Tape: SWPKU004
Offline Tape: SWPKU00A

Drive1: SWPKU003
Drive2: SWPKU009

====


Barcode : SWPKU003
SlotType : Unknown
TapeType : U-832
Size : 5120
UsedSpace : 0

====
Barcode : SWPKU009
SlotType : Unknown
TapeType : U-832
Size : 5120
UsedSpace : 0

====
Barcode : SWPKU008
SlotType : Storage
TapeType : U-832
Size : 5120
UsedSpace : 0

====
Barcode : SWPKU005
SlotType : Storage
TapeType : U-832
Size : 5120
UsedSpace : 0

====
Barcode : SWPKU007
SlotType : Storage
TapeType : U-832
Size : 5120
UsedSpace : 0

====
Barcode : SWPKU006
SlotType : Storage
TapeType : U-832
Size : 5120
UsedSpace : 0

====
Barcode : SWPKU002
SlotType : Storage
TapeType : U-832
Size : 5120
UsedSpace : 0

====
Barcode : SWPKU001
SlotType : Unknown
TapeType :
Size : 0
UsedSpace : 0

====
Barcode : SWPKU004
SlotType : Unknown
TapeType :
Size : 0
UsedSpace : 0

====
Barcode : SWPKU00A
SlotType : Unknown
TapeType :
Size : 0
UsedSpace : 0
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Fri Oct 25, 2019 9:26 am

Totally makes sense. I missed it, so thanks for pointing it out.
Glad it worked for you.
Post Reply