VMware Cloud Community
BarryCoombs
Contributor
Contributor
Jump to solution

iSCSI Configuration

Is it possible to configure iSCSI via the VI-Toolkit, i.e. enable iSCSI and add the send targets?

Cheers

VCP

www.virtualisedreality.com | www.twitter.com/virtualisedreal
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I'm not sure if I understood your question correctly.

Did you mean setting up iSCSI from scratch which starts with setting up a VMKernel portgroup ?

Or did you mean adding a datastore from an iSCSI LUN ?

The last option is described in example 2 of the New-Datastore cmdlet.

Execute

Get-Help New-Datastore -Examples

and in example 2 you will see a complete procedure for adding a datastore.

Extract from the New-Datastore help

--------------  Example 2 --------------

C:\PS>$iscsiHba = "vmhba32"
$iscsiServer = "10.23.113.94"
$iscsiPort = 3260
$h = Get-VMHost
$hostView = Get-View -VIObject $h
$storageSystem = Get-View
$hostView.configManager.storageSystem
# Enable software iSCSI controller
$storageSystem.UpdateSoftwareInternetScsiEnabled($true)
# Add iSCSI Server for dynamic discovery
$target = New-Object VMware.Vim.HostInternetScsiHBASendTarget
$target.address = $iscsiServer
$target.port = $iscsiPort
$storageSystem.AddInternetScsiSendTargets($iscsiHba, $target)
# Scan for iSCSI devices
$storageSystem.RescanHba($iscsiHba)
# Get lunPath and create new storage
$lunpath = Get-ScsiLun $h | where {$_.CanonicalName.StartsWith($iscsiHba)} | Get-ScsiLunPath

New-Datastore -Vmfs -VMHost $h -Path $lunpath.LunPath -Name iSCSI

#   Configures an iScsi storage adapter, gets the LUN path and creates an iScsi datastore named iScsi on the $h virtual machine host. Note that the
#   only difference between creating an iScsi datastore and a Vmfs datastore is in the argument passed to the Path parameter. When creating an iScsi
#   datastore the path must be taken from an iScsi Lun device.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

I'm not sure if I understood your question correctly.

Did you mean setting up iSCSI from scratch which starts with setting up a VMKernel portgroup ?

Or did you mean adding a datastore from an iSCSI LUN ?

The last option is described in example 2 of the New-Datastore cmdlet.

Execute

Get-Help New-Datastore -Examples

and in example 2 you will see a complete procedure for adding a datastore.

Extract from the New-Datastore help

--------------  Example 2 --------------

C:\PS>$iscsiHba = "vmhba32"
$iscsiServer = "10.23.113.94"
$iscsiPort = 3260
$h = Get-VMHost
$hostView = Get-View -VIObject $h
$storageSystem = Get-View
$hostView.configManager.storageSystem
# Enable software iSCSI controller
$storageSystem.UpdateSoftwareInternetScsiEnabled($true)
# Add iSCSI Server for dynamic discovery
$target = New-Object VMware.Vim.HostInternetScsiHBASendTarget
$target.address = $iscsiServer
$target.port = $iscsiPort
$storageSystem.AddInternetScsiSendTargets($iscsiHba, $target)
# Scan for iSCSI devices
$storageSystem.RescanHba($iscsiHba)
# Get lunPath and create new storage
$lunpath = Get-ScsiLun $h | where {$_.CanonicalName.StartsWith($iscsiHba)} | Get-ScsiLunPath

New-Datastore -Vmfs -VMHost $h -Path $lunpath.LunPath -Name iSCSI

#   Configures an iScsi storage adapter, gets the LUN path and creates an iScsi datastore named iScsi on the $h virtual machine host. Note that the
#   only difference between creating an iScsi datastore and a Vmfs datastore is in the argument passed to the Path parameter. When creating an iScsi
#   datastore the path must be taken from an iScsi Lun device.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
halr9000
Commander
Commander
Jump to solution

Yes! It is quite a bit of typing due to the breadth of iscsi settings, but you can definitely do it. I have documented how to do this in my book, which is due in stores around April 1st. I'm sitting here listening to a Steve Ballmer keynote or I would paste some code. Smiley Happy

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
BarryCoombs
Contributor
Contributor
Jump to solution

Nice plug Smiley Wink what's your book then and will it help a complete newb to PowerShell like me?

Cheers

VCP

www.virtualisedreality.com | www.twitter.com/virtualisedreal
0 Kudos
halr9000
Commander
Commander
Jump to solution

Oh sorry, I forgot that my forum signature doesn't show up from email-gateway replies. See the link for more info. Due out in April.






[vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos