Documentation
¶
Overview ¶
Package find implements inventory listing and searching.
The Finder is an alternative to the object.SearchIndex FindByInventoryPath() and FindChild() methods. SearchIndex.FindByInventoryPath requires an absolute path, whereas the Finder also supports relative paths and patterns via path.Match. SearchIndex.FindChild requires a parent to find the child, whereas the Finder also supports an ancestor via recursive object traversal.
The various Finder methods accept a "path" argument, which can absolute or relative to the Folder for the object type. The Finder supports two modes, "list" and "find". The "list" mode behaves like the "ls" command, only searching within the immediate path. The "find" mode behaves like the "find" command, with the search starting at the immediate path but also recursing into sub Folders relative to the Datacenter. The default mode is "list" if the given path contains a "/", otherwise "find" mode is used.
The exception is to use a "..." wildcard with a path to find all objects recursively underneath any root object. For example: VirtualMachineList("/DC1/...")
Finder methods can also convert a managed object reference (aka MOID) to an object instance. For example: VirtualMachine("VirtualMachine:vm-123") or VirtualMachine("vm-123")
See also: https://github.com/vmware/govmomi/blob/main/govc/README.md#usage
Index ¶
- func InventoryPath(ctx context.Context, client *vim25.Client, obj types.ManagedObjectReference) (string, error)
- type DefaultMultipleFoundError
- type DefaultNotFoundError
- type Finder
- func (f *Finder) ClusterComputeResource(ctx context.Context, path string) (*object.ClusterComputeResource, error)
- func (f *Finder) ClusterComputeResourceList(ctx context.Context, path string) ([]*object.ClusterComputeResource, error)
- func (f *Finder) ClusterComputeResourceOrDefault(ctx context.Context, path string) (*object.ClusterComputeResource, error)
- func (f *Finder) ComputeResource(ctx context.Context, path string) (*object.ComputeResource, error)
- func (f *Finder) ComputeResourceList(ctx context.Context, path string) ([]*object.ComputeResource, error)
- func (f *Finder) ComputeResourceOrDefault(ctx context.Context, path string) (*object.ComputeResource, error)
- func (f *Finder) Datacenter(ctx context.Context, path string) (*object.Datacenter, error)
- func (f *Finder) DatacenterList(ctx context.Context, path string) ([]*object.Datacenter, error)
- func (f *Finder) DatacenterOrDefault(ctx context.Context, path string) (*object.Datacenter, error)
- func (f *Finder) Datastore(ctx context.Context, path string) (*object.Datastore, error)
- func (f *Finder) DatastoreCluster(ctx context.Context, path string) (*object.StoragePod, error)
- func (f *Finder) DatastoreClusterList(ctx context.Context, path string) ([]*object.StoragePod, error)
- func (f *Finder) DatastoreClusterOrDefault(ctx context.Context, path string) (*object.StoragePod, error)
- func (f *Finder) DatastoreList(ctx context.Context, path string) ([]*object.Datastore, error)
- func (f *Finder) DatastoreOrDefault(ctx context.Context, path string) (*object.Datastore, error)
- func (f *Finder) DefaultClusterComputeResource(ctx context.Context) (*object.ClusterComputeResource, error)
- func (f *Finder) DefaultComputeResource(ctx context.Context) (*object.ComputeResource, error)
- func (f *Finder) DefaultDatacenter(ctx context.Context) (*object.Datacenter, error)
- func (f *Finder) DefaultDatastore(ctx context.Context) (*object.Datastore, error)
- func (f *Finder) DefaultDatastoreCluster(ctx context.Context) (*object.StoragePod, error)
- func (f *Finder) DefaultFolder(ctx context.Context) (*object.Folder, error)
- func (f *Finder) DefaultHostSystem(ctx context.Context) (*object.HostSystem, error)
- func (f *Finder) DefaultNetwork(ctx context.Context) (object.NetworkReference, error)
- func (f *Finder) DefaultResourcePool(ctx context.Context) (*object.ResourcePool, error)
- func (f *Finder) Element(ctx context.Context, ref types.ManagedObjectReference) (*list.Element, error)
- func (f *Finder) Folder(ctx context.Context, path string) (*object.Folder, error)
- func (f *Finder) FolderList(ctx context.Context, path string) ([]*object.Folder, error)
- func (f *Finder) FolderOrDefault(ctx context.Context, path string) (*object.Folder, error)
- func (f *Finder) HostSystem(ctx context.Context, path string) (*object.HostSystem, error)
- func (f *Finder) HostSystemList(ctx context.Context, path string) ([]*object.HostSystem, error)
- func (f *Finder) HostSystemOrDefault(ctx context.Context, path string) (*object.HostSystem, error)
- func (f *Finder) ManagedObjectList(ctx context.Context, path string, include ...string) ([]list.Element, error)
- func (f *Finder) ManagedObjectListChildren(ctx context.Context, path string, include ...string) ([]list.Element, error)
- func (f *Finder) Network(ctx context.Context, path string) (object.NetworkReference, error)
- func (f *Finder) NetworkList(ctx context.Context, path string) ([]object.NetworkReference, error)
- func (f *Finder) NetworkOrDefault(ctx context.Context, path string) (object.NetworkReference, error)
- func (f *Finder) ObjectReference(ctx context.Context, ref types.ManagedObjectReference) (object.Reference, error)
- func (f *Finder) ResourcePool(ctx context.Context, path string) (*object.ResourcePool, error)
- func (f *Finder) ResourcePoolList(ctx context.Context, path string) ([]*object.ResourcePool, error)
- func (f *Finder) ResourcePoolListAll(ctx context.Context, path string) ([]*object.ResourcePool, error)
- func (f *Finder) ResourcePoolOrDefault(ctx context.Context, path string) (*object.ResourcePool, error)
- func (f *Finder) SetDatacenter(dc *object.Datacenter) *Finder
- func (f *Finder) VirtualApp(ctx context.Context, path string) (*object.VirtualApp, error)
- func (f *Finder) VirtualAppList(ctx context.Context, path string) ([]*object.VirtualApp, error)
- func (f *Finder) VirtualMachine(ctx context.Context, path string) (*object.VirtualMachine, error)
- func (f *Finder) VirtualMachineList(ctx context.Context, path string) ([]*object.VirtualMachine, error)
- type MultipleFoundError
- type NotFoundError
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InventoryPath ¶ added in v0.24.0
func InventoryPath(ctx context.Context, client *vim25.Client, obj types.ManagedObjectReference) (string, error)
InventoryPath composes the given object's inventory path. There is no vSphere property or method that provides an inventory path directly. This method uses the ManagedEntity.Parent field to determine the ancestry tree of the object and the ManagedEntity.Name field for each ancestor to compose the path.
Types ¶
type DefaultMultipleFoundError ¶
type DefaultMultipleFoundError struct {
// contains filtered or unexported fields
}
func (DefaultMultipleFoundError) Error ¶
func (e DefaultMultipleFoundError) Error() string
type DefaultNotFoundError ¶
type DefaultNotFoundError struct {
// contains filtered or unexported fields
}
func (*DefaultNotFoundError) Error ¶
func (e *DefaultNotFoundError) Error() string
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}