Comprehensive data protection for all workloads
Post Reply
ivan_cecoel
Novice
Posts: 8
Liked: never
Joined: Jun 28, 2010 9:05 am
Full Name: Ivan Hidalgo
Contact:

Pseudo StoragevMotion script

Post by ivan_cecoel »

Hi, I have an ESX 4.1 and recentlly we have the need to move ours machines to another LUN, we don't have the VSphere Enterprise version so, we don't have the Storage vMotion funcionality and If I want to move the machines we have to stop machine, move to the other LUN and then power on, and depends the size of the VM it can cost much time.
But Veeam and the PowerCLI help to down the time that I spend to move this machines to 5 minutes logoff.

Well, first I do a replica job to replica the VM to the new LUN and when finish I run a job that run this PowerCli script

Code: Select all

$initialVM=$args[0]
$replica=$args[0]+"_replica"
$user="root"
$pass="12345678"
Connect-VIServer -Server 192.168.30.3 -User $user -Password $pass
Shutdown-VMGuest -VM $initialVM -Confirm:$false -Verbose
$vms = Get-VM -Name $initialVM

do {$vms = Get-VM -Name $initialVM} while ($vms.PowerState -ne "PoweredOff") 

Start-VM -VM $initialVM
Start-Sleep -Seconds 60
$vms = get-vm -Name $replica
$qMsgUuidMoved = "msg.uuid.altered:"
$choiceMove = 2
$vmview = $vms | Get-View 
 
      if($vmview.Runtime.Question -ne $null -and $vmview.Runtime.Question.Text.StartsWith($qMsgUuidMoved))
      {
         $vmview.AnswerVM($vmview.Runtime.Question.Id, $choiceMove)
      }


Well, this script shutdown the VM in the old LUN, wait until this shutdown is complete, and then start the machine replicated in the new LUN, and answer the question that if I moved or copy the machine. With that the downtime are maximum 5 minutes.

I test this with little servers, I don't know if work with a Domain Controller or a Exchange, or something could be wrong doing this?
I want to add the script the option to put the same MAC address to the Network Card, because there are server with program licensed by this MAC.

I hope it can help someone.

Thanks!
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Pseudo StoragevMotion script

Post by Vitaliy S. »

Hello Ivan,

Thank you for sharing this script with the community, much appreciated!
Post Reply

Who is online

Users browsing this forum: Kazz, Semrush [Bot] and 88 guests