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) GetTask(ctx context.Context, taskRef string) (*mo.Task, error)
- func (s *Session) WithCachingTagsManager(ctx context.Context, f func(m *CachingTagsManager) error) error
- func (s *Session) WithRestClient(ctx context.Context, f func(c *rest.Client) error) 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. 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.WithCachingTagsManager 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 tag name and its id. In case ID was passed, the original method from tags.Manager would be used.
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) 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. In case ID was passed, the original method from tags.Manager would be used.
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 // contains filtered or unexported fields }
Session is a vSphere session with a configured Finder.
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.