VMware {code} Community
kadursandy
Contributor
Contributor

I want to add a FC LUN to vm and share the same FC LUN to other vm's under the same ESX host. How to achieve this through perl SDK

There are 4 vms under the same ESXi (vm1, vm2, vm3 and vm4). All 4 vm's are created with one "SCSI Controller 0" by default with LsiLogicController Parallel.

I want to add a FC(Fiber Channel) LUN to vm1 and share the same FC LUN to other vm's(share with vm2, vm3 and vm4) under the same ESX host. I need to do this for around 800 ESX hosts which has 4 vm's as explained.

Steps:

1. Add FC LUN to vm1.

2. Share the same FC LUN to vm2, vm3 and vm4

3. Repeat 1 and 2 for around 800 ESXi hosts.

Can you please share  the approach using vsphere Perl SDK. I am stuck as many forums give different approaches with different errors explained(I am confused and did not understand the approach)

Reply
0 Kudos
3 Replies
stumpr
Virtuoso
Virtuoso

You'll probably have to create an RDM mapping in this case.  You could share a VMDK out to multiple VMs with some VMX setting flags, but you mentioned direct FC LUN sharing.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=100278...

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=103416...

So, assuming you have the right application, you basically need to create the RDM mapping on VM1, then attach that as shared disks to VM2-VM4.

Will you have the LUN discovered on all hosts?  Or do you need to run discovery?

You can probably get a leg-up with rdmManagement.pl written by William Lam.  You'd then just modify the extraConfig to add the shared writer flag (look at the first KB).

Basically, the first VM gets a RDM mapping created (through ReconfigVM_Task() with proper disk backing), then each additional VM will point at the RDM mapping file created by the VM1 RDM mapping. 

If you work up some basic script logic, swing back and I'll be happy to iron it out into a working state.  You'll find the device creation and backing information to be a bit frustrating, it's where most of the errors will occur in the script.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos
kadursandy
Contributor
Contributor

Thanks for your response. Yes all LUNs are discovered on all the hosts already.

Step1: I have created the RDM mapping to VM1 and share_rdm.vmdk file is created in virtual compatability mode(William Lam script used below) - Successful

perl rdmManagement.pl --server 10.123.12.10 --username root --password vmpass --vmname VM1 --operation add --device /vmfs/devices/disks/naa.60002ac00000000028004ab500008f69 --compatmode virtual --filename share_rdm.vmdk

controllerKey=1000 unitNumber=1 backing=VirtualDiskRawDiskMappingVer1BackingInfo=HASH(0x2e15298) capacityInKB=1048576

Creating and adding "virtualMode" RDM: "share_rdm.vmdk" to VM1 ...

        Successfully added RDM to VM!

Step2: Now I am trying to share "share_rdm.vmdk" file to other VM2--VM4.-  FAILED

perl vmdkManagement.pl --server 10.123.12.10 --username root --password vmpass --operation add --vmdkname share_rdm.vmdk --vmname VM2 --datastore "datastore1 (2)"

Reconfiguring "VM2" to add VMDK: "[datastore1 (2)] VM1/share_rdm.vmdk" ...

Error:

SOAP Fault:

-----------

Fault string: The device or operation specified at index '0' is not supported for the existing virtual machine platform.

Fault detail: DeviceUnsupportedForVmPlatform

Can you please help me with this error ..What is missing to overcome this error.

Reply
0 Kudos
kadursandy
Contributor
Contributor

For Step1:


I am using rdmManagement.pl written by William Lam.  What are the values for extraConfig ?( to add the shared writer flag as per your guidance)

Line:

my $vmspec = VirtualMachineConfigSpec->new(deviceChange => [$devspec], extraConfig => ???? ); I went through vmware documentation could not get what values to be passed for extraConfig.


With the above change I will retry the Step2  ...

Step2:  I will try to share "share_rdm.vmdk" file to other VM2--VM4.-  FAILED

perl vmdkManagement.pl --server 10.123.12.10 --username root --password vmpass --operation add --vmdkname share_rdm.vmdk --vmname VM2 --datastore "datastore1 (2)"

Reconfiguring "VM2" to add VMDK: "[datastore1 (2)] VM1/share_rdm.vmdk"

Reply
0 Kudos