Automation

 View Only
  • 1.  remove-HD physical RDM errors out, leaves RDMP files

    Posted Mar 06, 2009 03:59 PM

    I'm attempting to script the removal of Raw devices. I'm looking to reverse the method I had of creating new RDMs by mapping UUID to the vmhba number. I guess i'm in wonder why there is no remove-harddisk cmdlet... So I am working on the remove-HD code posted.

    I am running into an issue where the script partially works.

    My test environment has 4 RDMs. It removes two of them from the VMX and removes the .VMDK file, but doesn't remove the RDMP.VMDK file.

    The other two remain untouched but the tasks in powershell complete as if everything were fine. The tasks in VC error out with the below information.

    Here is the thread where i posted this question first, but really this is a new unanswered question and wanted to offer points to the correct answer.

    screen shot of datastore showing the RDMP files

    the two RDMP files were previously not visible since the .VMDK geometry file was there.

    If anyone has some knowledge on how i can tweak remove-HD to accomplish removing the RDMPs and any hints on why it might fail in a foreach after two loops.



  • 2.  RE: remove-HD physical RDM errors out, leaves RDMP files

    Posted Mar 06, 2009 08:03 PM

    Looks like the remove-HD script uses this method of the fileManager object to remove the VMDK... which doesn't remove the RDMP.VMDK

    DeleteDatastoreFile_Task

    I'm thinking this one of the VirtualDiskManager object might take care of that issue.... if i can stumble my way through the SDK and fix it i'll post it.

    DeleteVirtualDisk_Task

    Apparently the VirtualDiskManager is null on my system when i go to use it. VC 2.5u3, ESXi 14xxx. VIToolKit 1.5

    I have to say it... WHERE IS THE REMOVE-HARDDISK CMDLET?



  • 3.  RE: remove-HD physical RDM errors out, leaves RDMP files

    Posted Mar 09, 2009 08:33 PM

    I have been able to get the following script functioning, although I would not say consistently. I am having problems. It did delete the VMDK and RDMPVMDK for the first two RDMs in my test VM, then errored out.

    I will prob post this into the SDK forum... guessing it is more related to that area.

    I just took the previous persons "remove-hd.ps1" and modified it to use the new VirtualDiskManager and DeleteVirtualDisk_Task feature

    .............and where is the remove-harddisk cmd-let?

    ____ NOTE

    During test,... the script will go through the foreach twice. the $name variable, which houses $dev.backing.filename shows up null after two iterations.

    __Final Note

    I got it to work.

    From Remove-HD.ps1 i did the following.

    Changed the deletDatastorefile FileManager task to DeleteVirtualDisk_Task of the VirtualDiskManager.

    Then I took the Get-view command out of the function ( it would error out after two iterations.)

    If anyone cares for the code I will upload it.



  • 4.  RE: remove-HD physical RDM errors out, leaves RDMP files

    Posted Mar 10, 2009 07:41 PM

    Solved in previous post.



  • 5.  RE: remove-HD physical RDM errors out, leaves RDMP files

    Posted Jun 03, 2009 05:22 PM

    Hello,

    I am using the remove-HD function that you created in this post and have a few questions. I am trying to use it to remove all RDM's from a VM. I noticed that when you changed the filemgr task to vdiskmgr task, the script now authenticates directly to the ESX host to perform this task rather that the VC. So when it removes the RDM I no longer see the task in the VC console. When I tried to edit the script to run just from VC credentials, it fails to delete the RDM. Is there any way to have both? I would love to only authenticate to VC and not locally to the host. Any ideas? Also, since I am trying to remove all RDM's from a VM, is there an easy way to loop through all the disks and remove them, without having to enter all the harddisk names manually or hard coding? Thanks in advance for any help, and thanks for the great function.

    Sean



  • 6.  RE: remove-HD physical RDM errors out, leaves RDMP files

    Posted Jun 15, 2009 06:13 PM

    Hey -

    Sorry for the really delayed response. I have been out of comission lately for working on this utility. As for your questions.

    1. At the time of development, the function to remove virtual hard disk was not populated by the API off of VC. That Managed object was only available hitting the ESX Server directly. I haven't tried to see fi that object was available thru vc lately, but my guess is that it is not if you tried it and it failed.

    2. You could get it to remove all the RDMs from a virtual machine. I have it setup to be selective in case your VM has RDMs from multiple arrays,, and lets say you work for EMC and wanted to use this utility.... it could help you. You'd just need to populate the array with all the rdms rather than asking for them to be matched with teh WWPNs...

    I could prob get to it, but my lab is in shambles after neglect for a period....



  • 7.  RE: remove-HD physical RDM errors out, leaves RDMP files

    Posted Jun 16, 2009 06:00 AM

    Hello olan025,

    Thank you for the info. Yeah it would be really helpful to me if you any insight into how to remove all RDM's from a VM. The issue for me is I have the OS disk of all my VM's as vmdk's and all the data disks are RDM's. So i just need to delete all Hard disks that are Hard Disk 2 or greater. I have no idea how to get all hardisks of a VM and remove only those greater than equal to Hard Disk 2. Thank you again for all the help.

    • Sean



  • 8.  RE: remove-HD physical RDM errors out, leaves RDMP files

    Posted Jun 16, 2009 12:14 PM

    Yeah-

    The logic is in the type of disks you get... ie get-vm | get-harddisk | where ... thingy equals type raw device...

    the syntax i can work out if i get some time on my lab.