bon, je commence à avancer, je réussi a mettre en pause, à lancer la sauvegarde quand la machine virutelle s’est enfin mis en pause, puis le remettre en lecture. le truc maintenant est d’arriver à ne pas relancer la machine virtual tant que le processus ubkernel.exe n’est pas terminé.
voila le code, une fois que j’aurais trouvé comment verifier que le processus est terminer, il faudra que je trouve comment mettre en pause une seule machine virtuelle
'======================================
’
’ Description: VMware VmCOM 1.0 Type Library
’
’ Name: VMCOMLib
’ Version: 1.0 [of Type Library]
’ GUID: {0407CAC2-41D7-4EB4-898B-4EC06C57BB81}
’
’ File: VmCOM.dll
’ Version: 1.0.0.1 [of file]
’
’ Extracted on: 2002.08.28 00:53:08
’
'=====================================
’ VmErr
'=====================================
Const vmErr_ALREADYCONNECTED = -2147220980
Const vmErr_BADRESPONSE = -2147220978
Const vmErr_BADSTATE = -2147220984
Const vmErr_BADVERSION = -2147220986
Const vmErr_DISCONNECT = -2147220979
Const vmErr_GARBAGE = -2147220977
Const vmErr_INSUFFICIENT_RESOURCES = -2147220970
Const vmErr_INVALIDARGS = -2147220989
Const vmErr_INVALIDVM = -2147220974
Const vmErr_NEEDINPUT = -2147220976
Const vmErr_NETFAIL = -2147220990
Const vmErr_NOACCESS = -2147220988
Const vmErr_NOEXECVMAUTHD = -2147220983
Const vmErr_NOMEM = -2147220991
Const vmErr_NOPROPERTY = -2147220982
Const vmErr_NOSUCHVM = -2147220981
Const vmErr_NOTCONNECTED = -2147220987
Const vmErr_NOTSUPPORTED = -2147220975
Const vmErr_PROXYFAIL = -2147220969
Const vmErr_TIMEOUT = -2147220985
Const vmErr_UNSPECIFIED = -2147219993
Const vmErr_VMBUSY = -2147220971
Const vmErr_VMEXISTS = -2147220972
Const vmErr_VMINITFAILED = -2147220973
'=====================================
’ VmExecutionState
'=====================================
Const vmExecutionState_Off = 2
Const vmExecutionState_On = 1
Const vmExecutionState_Stuck = 4
Const vmExecutionState_Suspended = 3
Const vmExecutionState_Unknown = 5
'=====================================
’ VmPlatform
'=====================================
Const vmPlatform_LINUX = 2
Const vmPlatform_UNKNOWN = 4
Const vmPlatform_VMNIX = 3
Const vmPlatform_WINDOWS = 1
'=====================================
’ VmPowerOpMode
'=====================================
Const vmPowerOpMode_Hard = 1
Const vmPowerOpMode_Soft = 2
Const vmPowerOpMode_TrySoft = 3
'=====================================
’ VmProdInfoType
'=====================================
Const vmProdInfo_Build = 3
Const vmProdInfo_Platform = 2
Const vmProdInfo_Product = 1
Const vmProdInfo_Version_Major = 4
Const vmProdInfo_Version_Minor = 5
Const vmProdInfo_Version_Revision = 6
'=====================================
’ VmProduct
'=====================================
Const vmProduct_ESX = 3
Const vmProduct_GSX = 2
Const vmProduct_UNKNOWN = 4
Const vmProduct_WS = 1
'=====================================
’ VmTimeoutId
'=====================================
Const vmTimeoutId_Default = 1
’
’ VmCOM VBScript Sample Program 3
’ Copyright 1998 VMware, Inc. All rights reserved. – VMware Confidential
’
’ Permission is hereby granted, free of charge, to any person obtaining a
’ copy of the software in this file (the “Software”), to deal in the
’ Software without restriction, including without limitation the rights to
’ use, copy, modify, merge, publish, distribute, sublicense, and/or sell
’ copies of the Software, and to permit persons to whom the Software is
’ furnished to do so, subject to the following conditions:
’
’ The above copyright notice and this permission notice shall be included in
’ all copies or substantial portions of the Software.
’
’ The names “VMware” and “VMware, Inc.” must not be used to endorse or
’ promote products derived from the Software without the prior written
’ permission of VMware, Inc.
’
’ Products derived from the Software may not be called “VMware”, nor may
’ “VMware” appear in their name, without the prior written permission of
’ VMware, Inc.
’
’ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
’ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
’ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
’ VMWARE,INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
’ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
’ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
’
’ ------
’
’ This program is for educational purposes only.
’ It is not to be used in production environments.
’
’ Description:
’
’ This script gets a list of virtual machines registered on
’ the local server. It attempts to power-on each VM that
’ is not already running and has a line in the config file:
’
’ autostart=true
’
’
’ Instructions for Windows 2000 and Windows XP host:
’
’ - save the contents of this file to a file named ‘sample3.vbs’
’
’ - there should be an accompanying file named ‘sample3.wsf’
’ It is placed in the same directory as this file during
’ product installation. This file is responsible for setting
’ up the Windows Script Host environment and loading the
’ VmCOM type library, thereby enabling this script to
’ reference symbolic constants such as vmExecutionState_On
’
’ - in a command line window, type:
’ cscript //nologo sample3.wsf
’
Set connect_params = CreateObject(“VmCOM.VmConnectParams”)
’ By default, connects to the local server.
’ To connect to a remote server, uncomment these lines and set
’ the values appropriately.
’
’ connect_params.hostname = “”
’ connect_params.username = “”
’ connect_params.password = “”
’
’ And use this if your port number is different
’ connect_params.port = 902
Set vm_server = CreateObject(“VmCOM.VmServerCtl”)
’ Handle errors non-fatally from here on
On Error Resume Next
’
’ Try connecting to server a few times. It’s possible the VMware services
’ are still in the process of starting up. We’ll wait a maximum of
’ 12 * 10 = 120 seconds = 2 minutes
’
connected = false
for tries = 1 to 12
vm_server.Connect connect_params
if Err.number = 0 then
connected = true
exit for
end if
WScript.Echo "Could not connect to server: " & Err.Description
WScript.Echo “Retrying in 10 seconds …”
WScript.Sleep 10000
Err.clear
next
if not connected then
WScript.Echo “Failed to connect to server. Giving up.”
WScript.Quit
end if
’ Get a list of all VMs from the server.
Set vmlist = vm_server.RegisteredVmNames
for each config in vmlist
’ Connect to the VM
Set vm = CreateObject(“VmCOM.VmCtl”)
vm.Connect connect_params, config
if Err.Number <> 0 then
WScript.Echo "Could not connect to VM " & config & ": " & Err.Description
Err.Clear
else
’ Check that the VM should be started automatically
auto_start = vm.Config(“autostart”)
auto_start =“true”
if Err.Number <> 0 then
if Err.Number <> vmErr_NOPROPERTY then
WScript.Echo "Could not read autostart variable: " & Err.Number & ": " & Err.Description
else
WScript.Echo "This VM is not configured for autostart: " & config
end if
Err.Clear
else
if auto_start = “true” or auto_start = “TRUE” or auto_start = “poweron” then
’ Check that the VM is powered off
power_state = vm.ExecutionState
if Err.Number <> 0 then
WScript.Echo "Error getting execution state: " & Err.Number & ": " & Err.Description
Err.Clear
Else
if power_state = vmExecutionState_Off or power_state = vmExecutionState_On then
vm.Suspend(vmPowerOpMode_Hard)
if Err.Number <> 0 then
WScript.Echo "Error powering on " & config & ": " & Err.Description
Err.Clear
else
' Wait between starting up VMs to smooth out the load on the server
WScript.Sleep 5000
end if
end if
end if
end if
end if
end if
Next
Do While vm.ExecutionState<> vmExecutionState_Suspended
Sleep(100)
Loop
Dim oShell
Set oShell = WScript.CreateObject (“WSCript.shell”)
oShell.run “test.ub4”
’
’ VmCOM VBScript Sample Program 3
’ Copyright 1998 VMware, Inc. All rights reserved. – VMware Confidential
’
’ Permission is hereby granted, free of charge, to any person obtaining a
’ copy of the software in this file (the “Software”), to deal in the
’ Software without restriction, including without limitation the rights to
’ use, copy, modify, merge, publish, distribute, sublicense, and/or sell
’ copies of the Software, and to permit persons to whom the Software is
’ furnished to do so, subject to the following conditions:
’
’ The above copyright notice and this permission notice shall be included in
’ all copies or substantial portions of the Software.
’
’ The names “VMware” and “VMware, Inc.” must not be used to endorse or
’ promote products derived from the Software without the prior written
’ permission of VMware, Inc.
’
’ Products derived from the Software may not be called “VMware”, nor may
’ “VMware” appear in their name, without the prior written permission of
’ VMware, Inc.
’
’ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
’ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
’ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
’ VMWARE,INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
’ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
’ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
’
’ ------
’
’ This program is for educational purposes only.
’ It is not to be used in production environments.
’
’ Description:
’
’ This script gets a list of virtual machines registered on
’ the local server. It attempts to power-on each VM that
’ is not already running and has a line in the config file:
’
’ autostart=true
’
’
’ Instructions for Windows 2000 and Windows XP host:
’
’ - save the contents of this file to a file named ‘sample3.vbs’
’
’ - there should be an accompanying file named ‘sample3.wsf’
’ It is placed in the same directory as this file during
’ product installation. This file is responsible for setting
’ up the Windows Script Host environment and loading the
’ VmCOM type library, thereby enabling this script to
’ reference symbolic constants such as vmExecutionState_On
’
’ - in a command line window, type:
’ cscript //nologo sample3.wsf
’
Set connect_params = CreateObject(“VmCOM.VmConnectParams”)
’ By default, connects to the local server.
’ To connect to a remote server, uncomment these lines and set
’ the values appropriately.
’
’ connect_params.hostname = “”
’ connect_params.username = “”
’ connect_params.password = “”
’
’ And use this if your port number is different
’ connect_params.port = 902
Set vm_server = CreateObject(“VmCOM.VmServerCtl”)
’ Handle errors non-fatally from here on
On Error Resume Next
’
’ Try connecting to server a few times. It’s possible the VMware services
’ are still in the process of starting up. We’ll wait a maximum of
’ 12 * 10 = 120 seconds = 2 minutes
’
connected = false
for tries = 1 to 12
vm_server.Connect connect_params
if Err.number = 0 then
connected = true
exit for
end if
WScript.Echo "Could not connect to server: " & Err.Description
WScript.Echo “Retrying in 10 seconds …”
WScript.Sleep 10000
Err.clear
next
if not connected then
WScript.Echo “Failed to connect to server. Giving up.”
WScript.Quit
end if
’ Get a list of all VMs from the server.
Set vmlist = vm_server.RegisteredVmNames
for each config in vmlist
’ Connect to the VM
Set vm = CreateObject(“VmCOM.VmCtl”)
vm.Connect connect_params, config
if Err.Number <> 0 then
WScript.Echo "Could not connect to VM " & config & ": " & Err.Description
Err.Clear
else
’ Check that the VM should be started automatically
auto_start = vm.Config(“autostart”)
auto_start =“true”
if Err.Number <> 0 then
if Err.Number <> vmErr_NOPROPERTY then
WScript.Echo "Could not read autostart variable: " & Err.Number & ": " & Err.Description
else
WScript.Echo "This VM is not configured for autostart: " & config
end if
Err.Clear
else
if auto_start = “true” or auto_start = “TRUE” or auto_start = “poweron” then
’ Check that the VM is powered off
power_state = vm.ExecutionState
if Err.Number <> 0 then
WScript.Echo "Error getting execution state: " & Err.Number & ": " & Err.Description
Err.Clear
Else
if power_state = vmExecutionState_Off or power_state = vmExecutionState_Suspended then
vm.Start(vmPowerOpMode_Soft)
if Err.Number <> 0 then
WScript.Echo "Error powering on " & config & ": " & Err.Description
Err.Clear
else
' Wait between starting up VMs to smooth out the load on the server
WScript.Sleep 5000
end if
end if
end if
end if
end if
end if
next
Edité le 18/07/2007 à 09:39