Pages: [1]
Print
Author Topic: add iscsi target to a cluster  (Read 1224 times)
X505
Newbie
*
Posts: 3



View Profile WWW
« on: March 19, 2009, 02:31:34 PM »

It also work on a datacenter  Grin

Code:
Param ($cluster = "")
#$cluster = "vmcluster"
$iscsiHba = "vmhba32" #might be vmhba33
$iscsiServer = "iscsi_ip"
$iscsiPort = 3260

$target = New-Object VMware.Vim.HostInternetScsiHBASendTarget
$target.address = $iscsiServer
$target.port = $iscsiPort
$iscsiauthprop = New-Object VMware.Vim.HostInternetScsiHbaAuthenticationProperties
#$iscsiauthprop.ChapAuthEnabled = "true"
#$iscsiauthprop.ChapName = "user"
#$iscsiauthprop.ChapSecret = "password"
$h = Get-VMHost -Location $cluster
Foreach ($hostView in ( Get-View -VIObject $h)) {
    $storageSystem = Get-View $hostView.configManager.storageSystem
    # Enable software iSCSI controller
    $storageSystem.UpdateSoftwareInternetScsiEnabled($true)
    # Add iSCSI Server for dynamic discovery
    $storageSystem.AddInternetScsiSendTargets($iscsiHba, $target)
    $storageSystem.UpdateInternetScsiAuthenticationProperties($iscsiHba,$iscsiauthprop)
    # Scan for iSCSI devices
    $storageSystem.RescanHba($iscsiHba)
}

Thanks to http://doitsmarter.blogspot.com/2009/02/esx-iscsi-enable-script-using-vi.html
I just add the "-location" for the cluster/datacenter way
Logged

esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: March 20, 2009, 07:25:31 AM »

very nice!
Logged
Pages: [1]
Print
Jump to: