C# Sample ProgramsThe 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 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. Creates a user. Specifies permissions for the user using the AuthorizationManager. 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) Displays properties of an ESX/ESXi host. The properties displayed depend on the version of the host. Displays a set of properties for a virtual machine. The properties displayed depend on the version of the software on the host. Retrieves and formats the last event on the ESX/ESXi or vCenter Server system. Demonstrates event formatting. 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. Displays the current performance measurements of selected CPU counters of any specified virtual machine at the console. Records a session and allows you to retrieve a specified set of properties for a specified managed object reference into an array of result objects. 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. Illustrates the use of the SearchIndex API. Demonstrates connecting to a service, logging on to service, obtaining service content, and logging out from the service. Returns all events on the latest page on the EventHistoryCollector. Validates that migration with VMotion is feasible between two hosts, and performs the migration if the hosts are compatible. Retrieves a reference to a virtual machine and invokes power operations specified on the command line on that virtual machine. 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. Monitors updates on a virtual machine using the PropertyCollector.
■ SDK\samples\Axis\java\com\vmware – Top-level directory for Java samples
■ SDK\samples\Axis\java\com\vmware\apputils – Helper applications.
■ SDK\samples\Axis\java\com\vmware\samples – Samples. Details listed in Java Sample Programs.
■ 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.
■ 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. Moves a managed entity from its current location in the inventory to a new location in a specified folder Illustrates the use of the PropertyCollector API. Illustrates the use of the SearchIndex API. Connects to the server, logs in, lists the inventory contents (managed entities) at the console, and logs out. Adds a virtual NIC to a port group on a virtual switch an removes a virtual NIC from a port group. 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 deleting a ScheduledTask. Accesses the local credential store to obtain a single user account to log in to the specified server. Creates a user account and password and stores them in the local credential store. 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 virtual machine. Different command-line input creates the virtual machine in different ways. 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. Reconfigures a virtual machine. Includes reconfiguring the disk size, disk mode and so on. 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 the host based on the API version supported by ESX/ESXi or vCenter Server. 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.