Powershell cmdlets: how to get a list of free slots?

Software-based VM-centric and flash-friendly VM storage + free version

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

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

Fri Dec 14, 2018 10:58 am

Morning,

I am trying to leverage the InsertVirtualTape.ps1 script available in the StarWindX folder. Generally, it works, but I fail to understand if there is any method/property for a given slot to get to know if it is empty or not. Is it possible?

Just to make it more clear - here is the code:

Code: Select all

foreach($slot in $device.Slots) 	{
		write-host "Slot:"
		$slot
}
		
$tapeBarcode = "SW88V001";
$slotName = "Slot_1096";

$device.InsertTape($tapeBarcode, $slotName);
write-host "Completed!" -foreground yellow
In this code, is it possible to get free slots for $device, or verify if a given $slot is free or not?

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

Fri Dec 14, 2018 3:31 pm

In the sample script there is a comment as follows:

Code: Select all

#
# print all slots. if barcode is empty it means that slot is empty.
#
It makes me think this it is exactly what you are looking for. So, in your script you simply need to check whether the Barcode property is empty or not, and based on this you will be able to define whether some certain slot is free.
Last edited by Boris (staff) on Fri Dec 14, 2018 6:02 pm, edited 1 time in total.
cforest
Posts: 15
Joined: Fri Dec 14, 2018 10:48 am

Fri Dec 14, 2018 5:25 pm

Boris (staff) wrote:In the sample script there is a comment as follows:

Code: Select all

#
# print all slots. if barcode is empty it means that slot is empty.
#
It makes me this it is exactly what you are looking for. So, in your script you simply need to check whether the Barcode property is empty or not, and based on this you will be able to define whether some certain slot is free.
Thank you! I missed it. You are right. Actually, it is a bit strange for me. In my VTL device, I seem to have the following configuration:

Transport Slots 1
Drive Slots 4
import/Export Slots 3
Storage Slots 96

Tapes 9
Offline Shelf 1

So I am trying to insert a tape from Offline Shelf, but all Slots have their Barcodes not empty. How is it possible taking into account the number of slots and tapes? Is it possible to somehow free some slots with a cmdlet? What is interesting is that I am able to insert this tape in UI (StarWind Management Console) despite the fact that there are not slots with empty Barcode. What do I miss? Thank you!
cforest
Posts: 15
Joined: Fri Dec 14, 2018 10:48 am

Sun Dec 16, 2018 2:52 pm

Hi there,

Just in case, here is the StarWind version: 8.0.0.11818

To be more specific, attached are some details:

1. Screenshot.png - here is my VTL configuration (10 tapes, one of them being offline)
2. getTapesAndSlots.ps1 - a script to get a list of all tapes and slots for my VTL
3. TapesAndSlots.txt - the output of the script above (getTapesAndSlots.ps1) - a list of all tapes and slots
4. insertTape.ps1 - a script to insert a tape.

When running insertTape.ps1 with $slotName equal Slot_1, Slot_1001 or Slot_1011, I am getting the following error:

Inserting tape...Error:
Specified slot doesn't empty.


Why am I getting this error? Is there anything I am doing wrong here?

Thank you!
Attachments
TapesAndSlots.zip
(25.93 KiB) Downloaded 549 times
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Sun Dec 16, 2018 7:37 pm

As you use an outdated build, I would suggest you updating to the latest one in the first row, and check whether you encounter any similar issues. There have been improvements and you will most likely be able to achieve what you aim at.
cforest
Posts: 15
Joined: Fri Dec 14, 2018 10:48 am

Mon Dec 17, 2018 9:11 am

Hi Boris,

Thanks for the answer!

If this issue is to be resolved with the latest build, is it possible to get StarWindX.dll from the latest build for x64 platform just to verify if it works in our environment? The reason we ask for it is to be sure it is a panacea. At the moment, we are quite satisfied with the current version. To go through the upgrade procedure just to see if the issue is resolved and possibly get some new issues in the new version doesn't look encouraging. As we can see in the current build, the tape inserting functionality does work in UI, so it looks like it is a StarWindX issue, not core functionality, so this issue might be just resolved with a newer StarWindX.dll. Does it make sense? Hopefully so. If it does not, could you please at least confirm that you really had this issue in 8.0.0.11818, and it was really fixed?

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

Mon Dec 17, 2018 1:26 pm

Update: I tried to use StarWindX.dll from v.12658 with v. 11818 and got an error:

Inserting tape...Cannot convert argument "1", with value: "Slot_1", for "InsertTape" to type "System.Int32": "Cannot convert value "Slot_1" to type "System.Int32". Error: "Input string was not in a correct format.""


That's a bit strange since the dll is x64, and StarWind is installed on win 2016. Looks like old core and new StarWindX.dll are not compatible. Okay, no problem with that. We will try to install v.12658 to see if the issue with tape inserting is resolved.

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

Mon Dec 17, 2018 3:30 pm

Slot address is an integer (explicitly shown in the sample script), while you are passing it a string instead. Use 1 instead of "Slot_1".
Just be sure to update not only StarWindX to this newest build, but also the StarWind VSAN service.
cforest
Posts: 15
Joined: Fri Dec 14, 2018 10:48 am

Mon Dec 17, 2018 3:59 pm

Actually, in a sample for 11818, it looks like that:

$slotName = "Slot_4096";

But thank you so much for pointing out, anyway! It seems to have been changed in the latest version. I could miss it after an upgrade. So I will try with integer.

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

Mon Dec 17, 2018 5:00 pm

Let me know whether this solves your issue.
cforest
Posts: 15
Joined: Fri Dec 14, 2018 10:48 am

Mon Dec 17, 2018 5:17 pm

Update: installed 12658 from scratch with no upgrade. Inserting a tape seems to work. Thanks for your help!

Yuri
Oleg(staff)
Staff
Posts: 568
Joined: Fri Nov 24, 2017 7:52 am

Tue Dec 18, 2018 9:58 am

You are welcome!
Post Reply