C# Sample Programs
The C# (.NET) sample programs are located in the SDK\vsphere-ws\dotnet\cs\samples\ directory. Details listed in C# (.Net) Sample Programs. Each of the examples listed in the table is actually a directory that contains a .cs file, a .csproj file, a filename2008.csproj file, and a filename2010.csproj file.
The samples include a GeneratingStubs.txt file and a readme_dotnet.html file at top level.
The readme file explains how to build the examples using Visual Studio 2005 or Visual C# 2005 Express.
Adds a virtual NIC to the ESX/ESXi system. First specifies a HostVirtualNicSpec, and then adds the NIC to the host.
AppUtil – Utility application that drives the user input mechanism for other samples and includes some other utility functions.
ArgumentHandlingException – Handles command-line exceptions. Used by AppUtil.
CertPolicy – Handles certification problems by displaying informational messages.
ClientUtil – Client utilities related to prompting the user and logging. Used by AppUtil.
Log – Logger to file or console.
OptionSpec – Option parsing utility.
ServiceUtils, ServiceUtilsV25 – Utilities for connecting to the server.
VersionUtil – Utility that determines the name space and supported versions.
VMUtils – Utility that sets values for a basic virtual machine. Some of the setup, such as adding a floppy disk drive, might not always be needed.
Uses the PerformanceManager for basic monitoring.
Retrieves the contents of the ServiceInstance starting at the root folder, and prints a listing of ManagedEntity objects. Optionally, obtains properties for a specific type, or by default, for ManagedEntity itself.
CIMInfo versioning sample that retrieves the details of CIM_Fan like Activecooling, Caption, CommunicationStatus and so on.
Creates a Folder, Cluster, Datacenter or standalone host. Prompts the user for the item to create and where to put the item, for example, in a folder.
Extracts a task from scheduledTaskManager and deletes it. This sample is well commented and illustrates using the PropertyCollector. You can create the task using the OneTimeScheduledTask example.
Retrieves the specified set of properties for the given managed object reference into an array of result objects (returned in the same order as the property list)
Creates an EventHistoryCollector and monitors the corresponding events.
Downloads the files in the virtual machine configuration directory as well as the files in the virtual machine snapshot, suspend, and log directories. Writes progress to the console.
Displays the performance measurements of a specified counter of a specified ESX/ESXi for a specified duration, or 20 minutes (default) at the console.
Creates a ScheduledTask that powers off a virtual machine and schedules the task using a OnceTaskScheduler. You can delete the task using the DeleteOneTimeScheduledTask commandlet.
Defines a printEntityCounters function that prints counters for a virtual machine, host, or resource pool.
Illustrates use of the PropertyCollector.
Illustrates use of the QueryMemoryOverhead method. The folder includes two examples, QueryMemoryOverheadV25 uses the currently valid QueryMemoryOverheadEx method, QueryMemoryOverhead uses the deprecated QueryMemoryOverhead method.
Removes a host from a cluster or a virtual machine from a host. Handles errors, for example, if the host is not in a cluster, by printing that information to the command line.
Creates an alarm that monitors virtual machine state and sends email if the virtual machine power is off. Includes error handling, for example, when the command is attempted with an ESX/ESXi host as a target.
Axis 4.1
SDK\samples\Axis\java\com\vmware – Top-level directory for Java samples
SDK\samples\Axis\java\com\vmware\security – Credential store utility
SDK\samples\Axis\java\com\vmware\vim and SDK\samples\Axis\java\com\vmware\vim25 – Stub directories. The vim directory contains stubs for servers that precede VirtualCenter 2.5, the vim25 directory contains stubs for VirtualCenter 2.5 and later, including vSphere 4.0 and later.
Includes functions for information retrieval, such as functions that create an association traversal filter, retrieve an instance of a specified CIM class, get a single instance of the class provided, and run the specified operation for that instance of the class.
CIM utility functions, including a wrapper that provides an enumerator over all the instances of the specified class and some simpler wrappers.
Retrieves and formats the last event from the host daemon or vpxd. Includes a function that formats the event message.
Demonstrates how to create and monitor an EventHistoryCollector. Uses the latestPage property of EventHistoryCollector to filter the events.
Creating EventHistoryCollector filtered for a single virtual machine.
Monitoring events using the latestPage property of the EventHistoryCollector.
Prints all managed entities and for each entity its type, reference value, property name, property value, inner object type, inner reference value and inner property value.
Deletes a managed entity from the inventory tree. The managed entity can be a virtual machine, a ClusterComputeResource, or a folder.
Demonstrates how to use the PropertyCollector to monitor one or more properties of one or more managed objects. In particular this sample monitors one or all virtual machines and all hosts or one host for changes to some basic properties.
Demonstrates uses of the licensing API using License managed object reference.
Illustrates the use of the PropertyCollector API.
Destroys or unregisters a managed inventory object like a Host, VirtualMachine, Folder, and so on.
Connects to the server, logs in, lists the inventory contents (managed entities) at the console, and logs out.
Puts virtual machine files into a specified datacenter and datastore and registers and reconfigures the corresponding virtual machine.
Retrieves configuration files, snapshots files, log files, and virtual disk files of a virtual machine and places them on the system on which the program is run.
Reads performance measurements from the current time, or from a specified start time, for a specified duration.
Writes the available counters of a managed entity into the specified file at the specified location. The managed entity can be a host system, a virtual machine, or a resource pool.
An esxtop-like sample application that lets administrators specify the CPU and memory counters by name to obtain metrics for a specified host.
Demonstrates creating a ScheduledTask using the ScheduledTaskManager.
Displays the CanonicalName,Vendor, Model, Data, Namespace and NamespaceId of the host’s SCSI LUN.
Locates an existing virtual machine on the vCenter Server system, makes a template from this virtual machine, and deploys instances of the template onto a datacenter.
Creates a delta disk on top of an existing virtual disk in a virtual machine, and simultaneously removes the original disk using the reconfigure API.
Checks whether migration with VMotion is feasible between two hosts. Performs the migration if the hosts are compatible.
Consolidates a linked virtual machine by using the VirtualMachine.PromoteDisks method.
Samples in the version directory illustrate running against hosts that have different versions of vSphere or VMware Infrastructure installed.
The HostPowerOps sample includes running against Virtual Infrastructure 2.0. The other samples apply to Virtual Infrastructure 2.5 and later versions including vSphere 4.0.
Displays properties of a virtual machine based on the API version supported by the host to which you connect.
Searches the virtual disk files in all the datastores available in a specified host using the properties ControllerType and ThinProperty.
This samples illustrates how to run a sample against hosts of multiple versions, including Virtual Infrastructure 2.0.
Uses the HostPatchManager managed object to upgrade the components in an ESXi system.
Determines the amount of memory overhead necessary to power on a virtual machine with the specified characteristics.