Documentation
¶
Index ¶
- func IsName(id string) bool
- type CachingTagsManager
- type Session
- func (s *Session) FindRefByInstanceUUID(ctx context.Context, UUID string) (object.Reference, error)
- func (s *Session) FindVM(ctx context.Context, UUID, name string) (*object.VirtualMachine, error)
- func (s *Session) GetCachingTagsManager() *CachingTagsManager
- func (s *Session) GetTask(ctx context.Context, taskRef string) (*mo.Task, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsName ¶
IsName returns true if the id is not an urn. this method came from vSphere sdk, see https://github.com/vmware/govmomi/blob/a2fb82dc55a8eb00932233aa8028ce97140df784/vapi/tags/tags.go#L121 for more context.
Types ¶
type CachingTagsManager ¶
CachingTagsManager wraps tags.Manager from vSphere SDK for cache mapping between tags or categories name and their ids, and for caching the full tag/category objects themselves. Reasoning behind this is the implementation details of tags/categories lookup by name, to find a tag/category by name vSphere SDK gets a list of ids and then makes an additional request for every object till it will not find matched names. Such peculiarity causes a huge performance degradation within environments with a large number of tags/categories, because in the worst case number of rest requests for object lookup might be equal to the number of objects.
See tags.Manager methods for more details: https://github.com/vmware/govmomi/blob/a2fb82dc55a8eb00932233aa8028ce97140df784/vapi/tags/tags.go#L172
This structure is intended to be used from a Session instance (Session.GetCachingTagsManager method specifically) presented in this module.
func (*CachingTagsManager) GetCategory ¶
GetCategory fetches the category information for the given identifier. The id parameter can be a Category ID or Category Name. This method shadows original tags.Manager method and caches mapping between category name and its id as well as the full category object, so any hit path (object cache or name->id cache) returns without REST calls.
In case if a category was not found in vCenter, this would be cached for 12 hours and lookup won't happen till cache expiration.
func (*CachingTagsManager) GetTag ¶
GetTag fetches the tag information for the given identifier. The id parameter can be a Tag ID or Tag Name. This method shadows original tags.Manager method and caches mapping between tag name and its id as well as the full tag object, so any hit path (object cache or name->id cache) returns without REST calls.
In case if a tag was not found in vCenter, this would be cached for 12 hours and lookup won't happen till cache expiration.
func (*CachingTagsManager) ListTagsForCategory ¶
ListTagsForCategory tag ids for the given category. The id parameter can be a Category ID or Category Name. Uses caching GetCategory method.
type Session ¶
type Session struct {
*govmomi.Client
Finder *find.Finder
Datacenter *object.Datacenter
TagManager *tags.Manager
// contains filtered or unexported fields
}
Session is a vSphere session with a configured Finder. This implementation is inspired by cluster-api-provider-vsphere's session caching pattern to avoid excessive vCenter login/logout cycles for REST API operations. Reference: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/main/pkg/session/session.go
func GetOrCreate ¶
func GetOrCreate( ctx context.Context, server, datacenter, username, password string, insecure bool) (*Session, error)
GetOrCreate gets a cached session or creates a new one if one does not already exist.
func (*Session) FindRefByInstanceUUID ¶
FindByInstanceUUID finds an object by its instance UUID.
func (*Session) GetCachingTagsManager ¶
func (s *Session) GetCachingTagsManager() *CachingTagsManager
GetCachingTagsManager returns the per-session CachingTagsManager that wraps the cached TagManager. It is created once when the session is created, so no new vCenter login/logout happens on access.