Automation

 View Only
  • 1.  How to Add VMFS LUN with vSphere PowerCli

    Posted Jul 20, 2010 12:20 PM

    I have a DR SAN that has a few LUNs that are replicated with snapmirror from a prod SAN.

    The LUN contains VMs.

    The idea is to break the snapmirrors, mount the LUNs to the DR Virtual Center and inventory the VMs.

    Here's a few things I did.

    In the virtual center I manually added storage: select ESX host > choose Disk/LUN > Select the LUN > choose keep signature > and the LUN mounts as a VMFS datastore.

    Then when I try to do the same thing on the next ESX host (there are 30 in the cluster), I get "Cannot change host configuration".

    I found an article (http://communities.vmware.com/thread/221065) that says "use new signature". So I removed the data store and added it again and it added to all the hosts as soon as I added it to the first. In other words I did not have to go through all 30 hosts. Great! .. But it named the datastore snap123_mydatastore. That's some random numbers after the word 'snap'. I just renamed that to mydatasore and it renamed it on all hosts. This is also great!

    However I have a few luns and I want to do this with a powershell script because this has to be done frequently to test DR.

    So I see that I can add a data store in powercli with:

    New-Datastore -vmhost esx_hostname -Vmfs -Name STORE_NAME -path (canonical name)

    Looks like the canonical name can be found under identifier in the Storage Adapters view > iSCSI Software Adapter

    So I ran the command

    New-Datastore -vmhost esx10 -Vmfs -Name ESX_VMFS1A -path naa.60a9800050334b42636f57644e637965

    and yes! this mounted the LUN to all hosts!

    But it formated or deleted everything that was on it. Same for my second lun.

    is there a switch that I can add to this command that imitates the manual process where you choose "New signature and keep all data on the lun" ?

    thanks



  • 2.  RE: How to Add VMFS LUN with vSphere PowerCli

    Posted Jul 20, 2010 12:27 PM

    I'm afraid the New-Datastore cmdlet won't allow you to do what you want to do.

    You should go for the SDK method called ResignatureUnresolvedVmfsVolume_Task. This keeps the content intact.

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 3.  RE: How to Add VMFS LUN with vSphere PowerCli

    Posted Jul 20, 2010 01:09 PM

    Thanks very much. I had a look and searched for how to use this.

    Do you happen to have any examples? What do you mean by SDK method as opposed to powershell?

    It will take a bit of figuring out but thanks for leading me in the right direction.



  • 4.  RE: How to Add VMFS LUN with vSphere PowerCli

    Posted Jul 20, 2010 01:57 PM

    The vSphere SDK provides through APIs access to the vSphere objects.

    The PowerCLI cmdlets are build upon these APIs.

    What is not provided by a cmdlet can be done by using one of the APIs directly.

    That is quite easy from PowerCLI thanks to the Get-View cmdlet.

    To call this particular method you have to:

    *) get the HostDatastoreSystem object

    *) get the devicepath

    *) call the method

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 5.  RE: How to Add VMFS LUN with vSphere PowerCli

    Posted Jul 20, 2010 05:04 PM

    Have a look at Mike's script in

    ____________

    Blog: LucD notes

    Twitter: lucd22