VMware Cloud Community
babukuttan
Contributor
Contributor

Need a script for unlimited storage vmotion of a vm between two data stores located on SAN luns


Hi,

    I have a VM which I need to do Storga evmotion between two datastores continously. Say; I need to run that for two days for a testing purpose. Is there any script available for that.Please guide me on this.

Thanks,

Babu

0 Kudos
4 Replies
vThinkBeyondVM
VMware Employee
VMware Employee

Hi Babu,

  Yes, this is possible by using Power CLI or VC SDK which available publicly. (Refer : VIJAVA open source SDK support site). You will have to write one script as per requirement.

Let me know if you need any help. Also let me know if you are completely new to PowerCLI or SDK. I will help you.

Thanks

-VIkas


----------------------------------------------------------------
Thanks & Regards
Vikas, VCP70, MCTS on AD, SCJP6.0, VCF, vSphere with Tanzu specialist.
https://vThinkBeyondVM.com/about
-----------------------------------------------------------------
Disclaimer: Any views or opinions expressed here are strictly my own. I am solely responsible for all content published here. Content published here is not read, reviewed or approved in advance by VMware and does not necessarily represent or reflect the views or opinions of VMware.

0 Kudos
babukuttan
Contributor
Contributor

Hi Vikas,

Thanks for coming up with this suggestion. I need to know more about writing that script. I have Power CLI installed on one of my hosts from which I can connect to VCenter server and ESXs.

Could you please help me.

Thanks,

Babu

0 Kudos
admin
Immortal
Immortal

Babu, Welcome to the communities.!!

As vikas mentioned her, it can be achieved through PowerCLI. Alan Renouf has written a one liner to do this which is mentioned here..http://www.virtu-al.net/2011/09/14/quick-and-simple-storage-vmotion-scripts/

If you would like to continue this multiple times include conditions and place it in a for / while loop. Thats it.

~dGeorgey

0 Kudos
vThinkBeyondVM
VMware Employee
VMware Employee

Hi Babu,

See if this works for you

1, First you install latest powerCLI in a Windows VM where PowerShell is there (PowerCLI is snap-in on the top on windows Powershell).

2. Connect to VC .

Use below command before running below script:

#Below command will connect PowerCLI snapin internally.

Add-PSSnapin Vmware* -ErrorAction SilentlyContinue

#First command, Enter VC/VCVA IP (linux VC)

  i)Set-PowerCLIConfiguration –ProxyPolicy ‘NoProxy’ -Confirm:$false

  ii)$VCVAIP = Read-Host " `n `n Please enter the VCVA IP Address::"

#Second command

Set-ExecutionPolicy unrestricted

#Third command

Connect-VIServer -Server $VCVAIP -User "USERNAME" -Password "PASSWORD"

Save below script in file say, "SVM.ps1" and then run the same as you run shell scripts.

$Source_Datastore = get-vm "VM-Name" | Get-Datastore

$i=1

while($i -eq 1){

if ($Source_Datastore.Name -eq "DS1"){

get-vm "VM-Name" | move-vm -Datastore DS2

Start-Sleep -s 20

$Source_Datastore = get-vm "VM-Name" | Get-Datastore

}

elseif ($Source_Datastore.Name -eq "DS2")

{

get-vm "VM-Name" | move-vm -Datastore DS1

Start-Sleep -s 20

$Source_Datastore = get-vm "VM-Name" | Get-Datastore

get-vm

}

}

Note: PLz give proper VM-Name and Datastore name as per your setup

Regards

Vikas, VCP 5.0, MSTS.

If the answer is useful,please award the points as appropriate.

Message was edited by: vickyvision2020


----------------------------------------------------------------
Thanks & Regards
Vikas, VCP70, MCTS on AD, SCJP6.0, VCF, vSphere with Tanzu specialist.
https://vThinkBeyondVM.com/about
-----------------------------------------------------------------
Disclaimer: Any views or opinions expressed here are strictly my own. I am solely responsible for all content published here. Content published here is not read, reviewed or approved in advance by VMware and does not necessarily represent or reflect the views or opinions of VMware.

0 Kudos