The toolbox library is a lightweight, extensible framework for implementing VMware guest tools functionality. The primary focus of the library is the implementation of VM guest RPC protocols, transport and dispatch. These protocols are undocumented for the most part, but open-vm-tools serves as a reference implementation. The toolbox provides default implementations of the supported RPCs, which can be overridden and/or extended by consumers.
Feature list from the perspective of vSphere public API interaction. The properties, objects and methods listed are relative to the VirtualMachine managed object type.
The toolbox reports version as guestToolsUnmanaged
.
The VMX determines these values based on the toolbox's response to the ping
RPC.
The VMX requests this value via the Set_Option broadcastIP
RPC.
The default value can be overridden by setting the Service.PrimaryIP
function.
See vim.vm.GuestInfo
This data is pushed to the VMX using the SendGuestInfo(INFO_IPADDRESS_V3)
RPC.
See GuestNicInfo.
The PowerCommandHandler provides power hooks for customized guest shutdown and reboot.
Not supported, but authentication can be customized.
Method | Supported | Client Examples |
---|---|---|
ChangeFileAttributesInGuest | Yes | chmod |
chown | ||
touch | ||
CreateTemporaryDirectoryInGuest | Yes | mktemp |
CreateTemporaryFileInGuest | Yes | mktemp |
DeleteDirectoryInGuest | Yes | rmdir |
DeleteFileInGuest | Yes | rm |
InitiateFileTransferFromGuest | Yes | download |
InitiateFileTransferToGuest | Yes | upload |
ListFilesInGuest | Yes | ls |
MakeDirectoryInGuest | Yes | mkdir |
MoveDirectoryInGuest | Yes | mv |
MoveFileInGuest | Yes | mv |
Currently, the ListProcessesInGuest
and TerminateProcessInGuest
methods only apply those processes and goroutines
started by StartProgramInGuest
.
Method | Supported | Client Examples |
---|---|---|
ListProcessesInGuest | Yes | ps |
ReadEnvironmentVariableInGuest | Yes | getenv |
StartProgramInGuest | Yes | start |
TerminateProcessInGuest | Yes | kill |
See vim.vm.guest.ProcessManager
Guest operations can be authenticated using the toolbox.CommandServer.Authenticate
hook.
The toolbox ProcessManager can manage both OS processes and Go functions running as go routines.
The hgfs.FileHandler
interface can be used to customize file transfer.
The toolbox provides support for I/O redirection without the use of disk files within the guest.
Access to stdin, stdout and stderr streams is implemented as an hgfs.FileHandler
within the ProcessManager
.
See toolbox.Client and govc guest.run
Building on top of the process I/O functionality, toolbox.NewProcessRoundTrip
can be used to start a Go function to
implement the http.RoundTripper interface over vmx guest RPC. This
makes it possible to use the Go http.Client without network access to the VM
or to a port that is bound to the guest's loopback address. It is intended for use with bootstrap configuration for
example.
The toolbox provides support for transferring directories to and from guests as gzip'd tar streams, without writing the
tar file itself to the guest file system. Archive supports is implemented as an hgfs.FileHandler
within the hgfs
package. See hgfs.NewArchiveHandler
With standard vmware-tools, the file size is reported as returned by stat()
and hence a Content-Length
header of
size 0
. The toolbox reports /proc file size as hgfs.LargePacketMax
to enable transfer of these files. Note that if
the file data fits within in hgfs.LargePacketMax
, the Content-Length
header will be correct as it is sent after the
first read by the vmx. However, if the file data exceeds hgfs.LargePacketMax
, the Content-Length
will be
hgfs.LargePacketMax
, and client side will truncate to that size.
The Go tests cover most of the toolbox code and can be run on any Linux or MacOSX machine, virtual or otherwise.
To test the toolbox with vSphere API interaction, it must be run inside a VM managed by vSphere without the standard vmtoolsd running.
The toolbox-test.sh can be used to run the full suite of toolbox tests with vSphere API interaction.
Use the -s
flag to start the standalone version of the toolbox and leave it running, to test vSphere interaction
without running the test suite.
The toolbox guest RPC implementations tend to be simple and portable thanks to the Go standard library, but are only supported on Linux currently. Support for other guests, such as Windows, has been kept in mind but not yet tested.
The toolbox is supported with vSphere 6.0 and 6.5, but may function with older versions.