VMware Cloud Community
wdavern
Contributor
Contributor

Automating building new hosts with iSCSI storage

I have written a powercli script for building new hosts using powercli.   I loop though all hosts in a build cluster and attempt to add the storage after adding a software initiator.   This is the code i use for adding the send targets:

 if ($environment -eq 'PROD') {

            #### Start adding iSCSI targets Prod environment:

            $ESXhost | Get-VMHostHba -Type iScsi | Where-Object {$_.Model -eq "iSCSI Software Adapter"} | New-IScsiHbaTarget -Address 172.16.53.141

            $ESXhost | Get-VMHostHba -Type iScsi | Where-Object {$_.Model -eq "iSCSI Software Adapter"} | New-IScsiHbaTarget -Address 172.16.53.142

            $ESXhost | Get-VMHostHba -Type iScsi | Where-Object {$_.Model -eq "iSCSI Software Adapter"} | New-IScsiHbaTarget -Address 172.16.53.143

 

At some point i do a rescan and all datastores and paths show up.  However, after doing a reboot, my storage guy is telling me that the powermax storage is showing On Fabric = Yes but Logged In = No.   Has anyone else seen this ?   Is there a better way to add the iscsi targets ?

 

 

Thanks,

 

Bill

 

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

Hard to tell, but you might want to have a look at the flowchart in KB1003952


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

Reply
0 Kudos
wdavern
Contributor
Contributor

Thank you for the suggestion LucD, i will take a look at the KB.
Reply
0 Kudos
wdavern
Contributor
Contributor

Hi LucD, i took a look at the KB and nothing seemed to help.   Then i found this old post that you were on :

https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-add-multiple-iSCSI-targets-with...

I tried adding the 16 iqn's using from the command line using :

esxcli iscsi adapter discovery statictarget add -A vmhba66 -a 172.16.5x.xxx:3260 -n iqn1992-04--SomelongString

Which worked and they now show up correctly on the array as Logged In and On Fabric.   So i want to do this via the Powercli script that I wrote.  Is the best way to do it like this :

build the $args like $args.name=xxx and then using

$esxcli.iscsi.adapter.discovery.statictarget.add.invoke($args)

Or is there a better way to do it now?

Thanks again.

Reply
0 Kudos
LucD
Leadership
Leadership

No, using Get-EsxCli is the best method afaik.


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

Reply
0 Kudos