Changes

Jump to: navigation, search

Working with VMware Tools Scripts and Power States

15 bytes added, 15:29, 6 November 2008
no edit summary
The power state of a VMware Server virtual machine can be changed either from within the guest operating system itself (for example by initiating the operating system's own shutdown command from within the VMware Remote Console) or by using the VI Web Access interface.
In the case of changing the power state from within the VI Web Access interface, a number of configuration options are available in terms of what actually happens when the power state is changed (for example when the VI Web Access ''power off'' button is clicked) and also which VMware Tools scripts are triggered within the guest operating system.
== Changing Virtual Machine Power State from VI Web Access ==
When a virtual machine is powered on or off, suspended, resumed or restarted it is said to have undergone a change in ''power state''. The VI Web Access interface provides no less than five locations where the power state of a virtual machine may be changed. The most prominent of these are located in the tool bar which runs along the top of the interface. Toolbar buttons are provided to power on, power off, suspend and restart the virtual machine currently selected from the ''Inventory'' panel.
In addition, power state options are listed in the ''Commands'' panel of the virtual machine workspace area when a virtual machine is selected from the inventory. Similarly, power state options are listed for the currently selected virtual machine within the ''Virtual Machines'' menu option in the menu bar at the top of the VI Web Access interface.
If the host system is selected from the inventory panel and the ''Virtual Machines'' tab of the workspace is selected, a list of virtual machines appears together with a ''Commands'' panel. As each virtual machine is selected from this list, the ''Commands '' panel updates with a list of suitable commands, including power state changes, for the selected machine.
Finally, power state change controls are available in the VMware Remote Console of a running virtual machine within the ''Remote Console->Troubleshoot'' menu option.
The ''Power Controls'' section of the configuration panel specifies the action performed when the VI Web Access power off, suspend and restart options are chosen for a virtual machine:
* '''Power Off''' - The ''Power Off'' command can be configured to immediately power down the virtual guest (an effect similar to simply removing the power from a physical computer system). The effect is immediate but also poses the risk that data will be lost given that the guest operating system running within the virtual machine is not provided the opportunity to perform a clean shutdown. If VMware Tools have been installed on the guest operating system, the ''Shut Down Guest'' option may be selected to ensure an orderly shutdown of the guest operating system prior to the removal of "virtual power" to the virtual machine.
* '''Suspend''' - As with the ''Power Off'' command, two options are available for suspending virtual machines from within the VI Web Access management interface. If ''Suspend'' is selected, the virtual machine will be suspended without triggering the suspend process of the guest operating system (assuming the guest includes such a feature). If VMware Tools have been installed on the guest, the ''Suspend Guest'' option will first trigger the guest operating system's suspend mechanism prior to suspending the virtual machine.
The previous section described how the guest operating system running within a VMware Server virtual machine may be cleanly shutdown, restarted or suspended through the installation on VMware Tools on the guest. When a user instructs VI Web Access to change the power state of a virtual machine, VMware Server communicates with a VMware Tools process running on the guest operating system and instructs it to execute a script. The script which is executed depends on the nature of the power state change, together with script configuration settings made within the VMware Tools control panel (covered in detail later in this chapter).
the The ''VMware Tools Scripts'' section of the power configuration panel allows VMware Tools script execution to be disabled for each of the power state changes. To prevent a script running at a particular point, simply deselect the check box next to the corresponding description.
=== BIOS Setup ===
== The Default VMware Tools Scripts ==
If a virtual machine is configured to use VMware Tools scripts then either the default scripts installed with Vmware VMware Tools, or custom scripts may be used. On Windows based guest operating systems, the default scripts take the form of Windows Batch files and are located in \Program Files\VMware\VMware Tools. On Linux guests the default scripts are shell scripts and reside in /etc/vmware-tools. On both guest types the files are descriptively named ''poweroff-vm-default'', ''poweron-vm-default'', ''resume-vm-default'' and ''suspend-vm-default''.
A review of the content of these scripts using a text or programmers programming editor will reveal that by default they actually do very little. For example, with the exception of suspend and resume, the Windows VMware Tools scripts contain nothing but a couple of comment lines. The real power of the Vmware VMware Tools scripts is the ability to configure custom scripts.
== Creating Custom VMware Tools Scripts ==
As described in the previous section, the default scripts provided may be overridden using custom scripts. Custom scripts may be created either by modifying the default scripts, or by creating new scripts and configuring VMware Tools to use the new script in place of the default script. Custom scripts may be edited using any suitable text or programming editor, or by using the ''Edit...'' button located on the ''Scripts'' tab of the Vmware VMware Tools control panel (for more details on the VMware control panel read [[The VMware Tools Control Panel]] chapter of this book). Note that the use of the control panel script editing feature on Linux will require knowledge of the ''vi'' editor. Those lacking the necessary skills with ''vi'' should consider directly creating and editing the custom scripts using their preferred editor outside the context of the control panel.
To create a custom script using the VMware Tools control panel, click on the ''Scripts'' tab and select from the menu the power change event for which the custom script is to be created from the menu. Ensure that the ''Use script'' option is selected and click on ''Custom Script'' at which point the text box containing the path to the script and the ''Browse'' and ''Edit'' buttons will be enabled. To edit the default script simply click on the ''Edit'' button and make the modification in the resulting edit window. To edit an existing custom script or create an entirely new script, enter the path and name of the script file into the the text field and press the ''Edit'' button. Once the script is complete, save the file and exit the editor to return to the control panel.
If custom scripts are being created outside of the VMware Tools control panel (and are new files rather than modifications to the existing default scripts) it will be necessary to configure VMware Tools to use these scripts. To achieve this, open the VMware Tools control panel, select the ''Scripts'' tab and choose the appropriate power state from the drop down menu. Ensure that ''Use scripts'' and ''Custom Script'' are both selected, use the ''Browse'' feature to navigate to and select the new custom script and click on ''OK'' to apply the change.
== Linux, Solaris and FreeBSD Reboot and Shutdown Commands ==
In addition to the scripts outlined above, an additional mechanism is provided on Linux, Solaris and FreeBSD guests for executing commands when a virtual machine is either shut down or rebooted. These are specified in the ''/etc'/vmware-tools.conf'' file using the '''halt-command =''' and '''reboot-command = ''' directives.
1,798
edits

Navigation menu