Quantcast
Channel: VMware Communities: Message List - Trying to write AppleScript to power down VMs, then back them up; VMs not reporting suspended state correctly
Viewing all articles
Browse latest Browse all 8

Re: Trying to write AppleScript to power down VMs, then back them up; VMs not reporting suspended state correctly

$
0
0

Problem: VMware Fusion incorrectly reports to AppleScript that a virtual machine is powered down when the virtual machine is in fact suspended

 

Consequences: Virtual machines that need to be resumed so that they can be powered off so that they can be backed up correctly are instead backed up as suspended virtual machines

 

Potentially unique factors / variables: At least two of our virtual machines are imported (one from Parallels, and the other from an actual PC). However, I believe that this also occurs with the Win 7x64 virtual machine that we created from scratch. I'm travelling and can't verify that, though.

 

 

Steps to reproduce:
1. Suspend a virtual machine
2. Close all of the windows for that virtual machine (so that it is only available in the Virtual Machine Library)
3. Quit VMware Fusion (the problem only happens if it is AppleScript that opened / activated VMware Fusion)
4. Use AppleScript to open VMware Fusion & to query the state of the virtual machine
Note: When VMware Fusion is opened by AppleScript, sometimes if you click (or select) any of the windows, then the error does not occur

 

Results: AppleScript reports that the virtual machine is "powered off" (or safe to back up) when it is in fact suspended (and thus NOT actually safe to back up)

 

----- Sample AppleScript: -----

 

property resumeDelay : 45 -- how long to wait for VM to resume
tell application "VMware Fusion"
activate -- can't test to see if a VM is suspended unless VMware is running
delay 10 -- give the application time to open
repeat with currVM in documents
--display dialog "Name: " & (name of currVM)
--display dialog "Name: " & (OS name of currVM)
set powerState to power state of currVM
-- power off doesn't work on suspended VMs
if powerState is suspended then -- VM reports powered off even when actually suspended, reports correctly if VM's own window open (VM Library, right-click on VM, then select "Show Windows")
display dialog "VM " & (name of currVM) & " is suspended"
resume currVM -- only want to resume if actually suspended, otherwise it starts powered off VMs
delay resumeDelay -- give VM time to resume
end if
-- test section that normally is unnecessary and should be commented out
if powerState is powered off then
display dialog "VM " & (name of currVM) & " is powered off"
end if
if powerState is powered on then
-- XP unsaved docs prevent power off unless with force, Win7 works without force
try
(*if (OS name of currVM) contains "7" then
--display dialog "Win 7: would power off withOUT force"
power off currVM
delay powerOffDelay
else*)
--display dialog "Not Win 7 (XP, etc.): would power off with force"
power off currVM with force
--end if
on error errMsg number errNum
tell application "Finder"
display dialog ("errMsg: " & errMsg & ", errNum: " & errNum)
end tell
end try
end if
end repeat
quit
delay 5
end tell
------ end sample AppleScript ------

Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images