Hi All,

As I only have 1 storage server at the moment (1 to be added later). For the 1 I have now, can I know how to set up its LUNs, I have the below working script for 2 Nodes but not for 1, I’m unsure how to tweak the script for setting up a Single Node..

Can any one help with this, thanks..

param($addr="192.168.30.225", $port=3261, $user="root", $password="starwind",
      $addr2="192.168.30.226", $port2=$port, $user2=$user, $password2=$password,
#common
	$initMethod="NotSynchronize",
	$size=1024,
	$sectorSize=512,
	$failover=0,
	$bmpType=1,
	$bmpStrategy=0,
#primary node
	$imagePath="/mnt/md0/vSANStrg",
	$imageName="vsn",
	$createImage=$true,
	$storageName="",
	$targetAlias="vsn",
	$poolName="pool1",
	$syncSessionCount=1,
	$aluaOptimized=$true,
	$cacheMode="none",
	$cacheSize=0,
	$syncInterface="#p2=192.168.35.226:3260,192.168.40.226:3260",
	$hbInterface="#p2=192.168.45.226:3260,192.168.30.226:3260",
	$createTarget=$true,
	$bmpFolderPath="",
#secondary node
	$imagePath2="/mnt/md0/vSANStrg",
	$imageName2="vsn",
	$createImage2=$true,
	$storageName2="",
	$targetAlias2="vsn",
	$poolName2="pool1",
	$syncSessionCount2=1,
	$aluaOptimized2=$false,
	$cacheMode2=$cacheMode,
	$cacheSize2=$cacheSize,
	$syncInterface2="#p1=192.168.35.225:3260,192.168.40.225:3260",
	$hbInterface2="#p1=192.168.45.225:3260,192.168.30.225:3260",
	$createTarget2=$true,
	$bmpFolderPath2=""
 )
	
Import-Module StarWindX

try
{
	Enable-SWXLog -level SW_LOG_LEVEL_DEBUG

	$server = New-SWServer -host $addr -port $port -user $user -password $password

	$server.Connect()

	$firstNode = new-Object Node

	$firstNode.HostName = $addr
	$firstNode.HostPort = $port
	$firstNode.Login = $user
	$firstNode.Password = $password
	$firstNode.ImagePath = $imagePath
	$firstNode.ImageName = $imageName
	$firstNode.Size = $size
	$firstNode.CreateImage = $createImage
	$firstNode.StorageName = $storageName
	$firstNode.TargetAlias = $targetAlias
	$firstNode.AutoSynch = $autoSynch
	$firstNode.SyncInterface = $syncInterface
	$firstNode.HBInterface = $hbInterface
	$firstNode.PoolName = $poolName
	$firstNode.SyncSessionCount = $syncSessionCount
	$firstNode.ALUAOptimized = $aluaOptimized
	$firstNode.CacheMode = $cacheMode
	$firstNode.CacheSize = $cacheSize
	$firstNode.FailoverStrategy = $failover
	$firstNode.CreateTarget = $createTarget
	$firstNode.BitmapStoreType = $bmpType
	$firstNode.BitmapStrategy = $bmpStrategy
	$firstNode.BitmapFolderPath = $bmpFolderPath
    
	#
	# device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
	#
	$firstNode.SectorSize = $sectorSize
    
	$secondNode = new-Object Node

	$secondNode.HostName = $addr2
	$secondNode.HostPort = $port2
	$secondNode.Login = $user2
	$secondNode.Password = $password2
	$secondNode.ImagePath = $imagePath2
	$secondNode.ImageName = $imageName2
	$secondNode.CreateImage = $createImage2
	$secondNode.StorageName = $storageName2
	$secondNode.TargetAlias = $targetAlias2
	$secondNode.AutoSynch = $autoSynch2
	$secondNode.SyncInterface = $syncInterface2
	$secondNode.HBInterface = $hbInterface2
	$secondNode.SyncSessionCount = $syncSessionCount2
	$secondNode.ALUAOptimized = $aluaOptimized2
	$secondNode.CacheMode = $cacheMode2
	$secondNode.CacheSize = $cacheSize2
	$secondNode.FailoverStrategy = $failover
	$secondNode.CreateTarget = $createTarget2
	$secondNode.BitmapFolderPath = $bmpFolderPath2
        
	$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod $initMethod
    
	while ($device.SyncStatus -ne [SwHaSyncStatus]::SW_HA_SYNC_STATUS_SYNC)
	{
		$syncPercent = $device.GetPropertyValue("ha_synch_percent")
	        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow

		Start-Sleep -m 2000

		$device.Refresh()
	}
}
catch
{
	Write-Host $_ -foreground red 
}
finally
{
	$server.Disconnect()
}
4 Spice ups

Remove all references to $secondNode and its parameters.
Use Add-Device instead of Add-HADevice, since HA is not needed.
Simplify the parameters to only those relevant to the single node.

I don’t want to give you a direct answer or amendments to your code, so see if the above helps. Obviously it’s better to teach you than give you the answer.

2 Spice ups

Thanks @Rod-IT

Wasn’t looking for a code in reply, Add-Device was what I wanted to know..

Would you know where I can find the PowerShell commands list for the module, can’t seem to find it, the Sample Code in the Web UI links to StarWind’s Management platform installer..

2 Spice ups

You could try

Get-Command -Module StarWindX

C:\Program Files\StarWind Software\StarWind\StarWindX\Help

3 Spice ups

Great, thanks again @Rod-IT

2 Spice ups

I found the below commands list..

PS C:\Users\Administrator\Desktop> Get-Command -Module StarWindX

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Add-HADevice                                       1.0.0.0    StarWindX
Function        Add-HAPartner                                      1.0.0.0    StarWindX
Function        Add-ImageDevice                                    1.0.0.0    StarWindX
Function        Add-RamDevice                                      1.0.0.0    StarWindX
Function        Add-VirtualTape                                    1.0.0.0    StarWindX
Function        Add-VirtualTapeLibrary                             1.0.0.0    StarWindX
Function        BruteForce                                         1.0.0.0    StarWindX
Function        Disable-SWXLog                                     1.0.0.0    StarWindX
Function        Enable-SWXLog                                      1.0.0.0    StarWindX
Function        Get-Device                                         1.0.0.0    StarWindX
Function        Get-DeviceID                                       1.0.0.0    StarWindX
Function        Get-DevicePerf                                     1.0.0.0    StarWindX
Function        Get-ServerPerf                                     1.0.0.0    StarWindX
Function        Get-SWLicense                                      1.0.0.0    StarWindX
Function        Get-SWXInstance                                    1.0.0.0    StarWindX
Function        Get-TargetPerf                                     1.0.0.0    StarWindX
Function        New-HAImageFile                                    1.0.0.0    StarWindX
Function        New-ImageFile                                      1.0.0.0    StarWindX
Function        New-Snapshot                                       1.0.0.0    StarWindX
Function        New-SWServer                                       1.0.0.0    StarWindX
Function        New-Target                                         1.0.0.0    StarWindX
Function        Remove-Device                                      1.0.0.0    StarWindX
Function        Remove-HAPartner                                   1.0.0.0    StarWindX
Function        Remove-Snapshot                                    1.0.0.0    StarWindX
Function        Remove-SWLicense                                   1.0.0.0    StarWindX
Function        Remove-Target                                      1.0.0.0    StarWindX
Function        Set-SWLicense                                      1.0.0.0    StarWindX
Function        Set-SWXLogLevel                                    1.0.0.0    StarWindX
Function        Write-StdErr                                       1.0.0.0    StarWindX

There is no command that looks like it will allow for a Single Node, I tried the below but it did not work, and asks for a the Second Node..

param($addr="192.168.30.151", $port=3261, $user="root", $password="starwind",
#common
	$initMethod="NotSynchronize",
	$size=1024,
	$sectorSize=512,
	$failover=0,
	$bmpType=1,
	$bmpStrategy=0,
#primary node
	$imagePath="/mnt/md0/vol1",
	$imageName="vlab",
	$createImage=$true,
	$storageName="",
	$targetAlias="vlab",
	$poolName="pool1",
	$syncSessionCount=1,
	$aluaOptimized=$true,
	$cacheMode="none",
	$cacheSize=0,
	$syncInterface="#p2=192.168.35.151:3260,192.168.40.151:3260",
	$hbInterface="#p2=192.168.45.151:3260,192.168.30.151:3260",
	$createTarget=$true,
	$bmpFolderPath=""
 )
	
Import-Module StarWindX

try
{
	Enable-SWXLog -level SW_LOG_LEVEL_DEBUG

	$server = New-SWServer -host $addr -port $port -user $user -password $password

	$server.Connect()

	$firstNode = new-Object Node

	$firstNode.HostName = $addr
	$firstNode.HostPort = $port
	$firstNode.Login = $user
	$firstNode.Password = $password
	$firstNode.ImagePath = $imagePath
	$firstNode.ImageName = $imageName
	$firstNode.Size = $size
	$firstNode.CreateImage = $createImage
	$firstNode.StorageName = $storageName
	$firstNode.TargetAlias = $targetAlias
	$firstNode.AutoSynch = $autoSynch
	$firstNode.SyncInterface = $syncInterface
	$firstNode.HBInterface = $hbInterface
	$firstNode.PoolName = $poolName
	$firstNode.SyncSessionCount = $syncSessionCount
	$firstNode.ALUAOptimized = $aluaOptimized
	$firstNode.CacheMode = $cacheMode
	$firstNode.CacheSize = $cacheSize
	$firstNode.FailoverStrategy = $failover
	$firstNode.CreateTarget = $createTarget
	$firstNode.BitmapStoreType = $bmpType
	$firstNode.BitmapStrategy = $bmpStrategy
	$firstNode.BitmapFolderPath = $bmpFolderPath
    
	#
	# device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
	#
	$firstNode.SectorSize = $sectorSize

	$device = Add-HADevice -server $server -firstNode $firstNode -initMethod $initMethod
    
	while ($device.SyncStatus -ne [SwHaSyncStatus]::SW_HA_SYNC_STATUS_SYNC)
	{
		$syncPercent = $device.GetPropertyValue("ha_synch_percent")
	        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow

		Start-Sleep -m 2000

		$device.Refresh()
	}
}
catch
{
	Write-Host $_ -foreground red 
}
finally
{
	$server.Disconnect()
}

Don’t think I missed anything..

2 Spice ups

Below is the script to be used for a Single Node, its jut not named as one would expect..

StarWind VSAN Help : Creating a New Image File Device

Tested, and works for a Single Node..

1 Spice up