Example: Simple PropertyCollector Example (Java) uses a
ContainerView to specify the objects that start the collection process. This is the simplest way to set up a filter, using a single reference to a view to provide the
PropertyCollector with access to a set of objects. To select objects from the inventory, a filter includes
TraversalSpec and possibly
SelectionSpec objects. Use these objects to make object selections based on the references in a view, and to extend inventory traversal beyond those objects (or beyond the object specified in
ObjectSpec.obj).
Use a TraversalSpec object to identify a managed object type and a traversal property in that type.
TraversalSpec contains the following properties:
During inventory traversal, the PropertyCollector applies the
PropertySpec object or objects (
PropertyFilterSpec.propSet) to objects. Inventory traversal begins with the object identified by
ObjectSpec.obj and continues by following
TraversalSpec paths. If
PropertySpec.type matches the current object type, and the
skip property is
false, the
PropertyCollector sends the
PropertySpec.pathSet properties to your client.
Inventory Navigation is a representation of a
PropertyFilterSpec that defines traversal of
VirtualMachine objects. The filter uses a
ContainerView as a starting point. The
TraversalSpec for the
ContainerView specifies the
view property for access to the view’s virtual machines. The figure shows
TraversalSpec objects that extend navigation from a
VirtualMachine object to the associated
Network and
ResourcePool objects. The
PropertyCollector applies these
TraversalSpec objects to each of the
VirtualMachine objects in the view list. The figure also shows the
PropertySpec objects for collecting data from
VirtualMachine,
Network, and
ResourcePool objects.
The SelectSet list for the container view
TraversalSpec has two
TraversalSpec objects. Both specify a
VirtualMachine object context. One object uses the
network property to extend traversal to the
Network managed object. The other uses the
resourcePool property to extend traversal to the
ResourcePool managed object.
To retrieve properties that are embedded in data objects, the PropertySpec.PathSet property uses dot notation to specify the property paths.
The selectSet array in
ObjectSpec and
TraversalSpec objects can include
TraversalSpec objects and
SelectionSpec objects.
SelectionSpec is the base class for
TraversalSpec objects.
SelectionSpec defines the
name property. You can use a
SelectionSpec object in a
selectSet array as a reference to a named
TraversalSpec object. By using
SelectionSpec references, you can reuse a
TraversalSpec and you can define recursive traversal.
Use SelectionSpec references to avoid writing duplicate
TraversalSpec declarations. The
TraversalSpec identified in a
SelectionSpec reference must be within the same
PropertyFilterSpec.
SelectionSpec Reference shows the use of
SelectionSpec references to a virtual machine
TraversalSpec. The
SelectionSpec references are associated with
Network and
Datastore traversals.
If the ObjectSpec.selectSet array contains a
SelectionSpec, the referenced
TraversalSpec must identify the same object type.
TraversalSpec.type must match the type of the object specified in
ObjectSpec.obj. The
PropertyCollector applies the
TraversalSpec to the object and use the
TraversalSpec.path property to extend its traversal.
Use a SelectionSpec to apply a
TraversalSpec to the results of its own traversal. To use a recursive filter construction, create a
SelectionSpec that specifies the name of a
TraversalSpec and add it to the named
TraversalSpec selection set. The recursive construction extends inventory traversal beyond the paths directly represented by
TraversalSpec objects.
You can use recursive traversal on any inventory objects that can be nested. See Inventory Hierarchies and ServiceInstance for a general representation of the structure of an inventory. For example, on a vCenter Server, folders can nest to arbitrary depths. To describe a traversal path through a succession of folders, you can add a
SelectionSpec to the
Folder TraversalSpec. The
SelectionSpec must reference the
TraversalSpec.
Recursive TraversalSpec and SelectionSpec shows a representation of a
TraversalSpec and its associated
SelectionSpec for nested folder traversal.
Example: Nested Folder Traversal shows a Java code fragment that creates a recursive filter for nested folder traversal.
The TraversalSpec.path property identifies the
Folder.childEntity property for traversal to any child objects.