@@ -102,6 +102,7 @@ func (c *Client) lister(ref types.ManagedObjectReference) *list.Lister {
102
102
// return the pointer for the same folder, and should also deal with
103
103
// the case where folderPath is nil or empty.
104
104
func (c * Client ) FindFolder (ctx context.Context , folderPath string ) (vmFolder * object.Folder , err error ) {
105
+ c .logger .Tracef ("FindFolder() path=%q" , folderPath )
105
106
if strings .Contains (folderPath , ".." ) {
106
107
// ".." not supported as per:
107
108
// https://github.com/vmware/govmomi/blob/master/find/finder.go#L114
@@ -155,6 +156,7 @@ func (c *Client) finder(ctx context.Context) (*find.Finder, *object.Datacenter,
155
156
// RemoveVirtualMachines removes VMs matching the given path from the
156
157
// system. The path may include wildcards, to match multiple VMs.
157
158
func (c * Client ) RemoveVirtualMachines (ctx context.Context , path string ) error {
159
+ c .logger .Tracef ("RemoveVirtualMachines() path=%q" , path )
158
160
finder , _ , err := c .finder (ctx )
159
161
if err != nil {
160
162
return errors .Trace (err )
@@ -215,6 +217,7 @@ func (c *Client) RemoveVirtualMachines(ctx context.Context, path string) error {
215
217
216
218
// VirtualMachines return list of all VMs in the system matching the given path.
217
219
func (c * Client ) VirtualMachines (ctx context.Context , path string ) ([]* mo.VirtualMachine , error ) {
220
+ c .logger .Tracef ("VirtualMachines() path=%q" , path )
218
221
finder , _ , err := c .finder (ctx )
219
222
if err != nil {
220
223
return nil , errors .Trace (err )
@@ -242,6 +245,7 @@ func (c *Client) VirtualMachines(ctx context.Context, path string) ([]*mo.Virtua
242
245
// ComputeResources returns a slice of all compute resources in the datacenter,
243
246
// along with a slice of each compute resource's full path.
244
247
func (c * Client ) ComputeResources (ctx context.Context ) ([]ComputeResource , error ) {
248
+ c .logger .Tracef ("ComputeResources()" )
245
249
_ , datacenter , err := c .finder (ctx )
246
250
if err != nil {
247
251
return nil , errors .Trace (err )
@@ -294,6 +298,7 @@ func (c *Client) computeResourcesFromRef(ctx context.Context, ref types.ManagedO
294
298
295
299
// Folders returns the datacenter's folders object.
296
300
func (c * Client ) Folders (ctx context.Context ) (* object.DatacenterFolders , error ) {
301
+ c .logger .Tracef ("Folders()" )
297
302
_ , datacenter , err := c .finder (ctx )
298
303
if err != nil {
299
304
return nil , errors .Trace (err )
@@ -307,6 +312,7 @@ func (c *Client) Folders(ctx context.Context) (*object.DatacenterFolders, error)
307
312
308
313
// Datastores returns list of all datastores in the system.
309
314
func (c * Client ) Datastores (ctx context.Context ) ([]mo.Datastore , error ) {
315
+ c .logger .Tracef ("Datastores()" )
310
316
finder , datacenter , err := c .finder (ctx )
311
317
if err != nil {
312
318
return nil , errors .Trace (err )
@@ -344,6 +350,7 @@ func (c *Client) Datastores(ctx context.Context) ([]mo.Datastore, error) {
344
350
// ResourcePools returns a list of all of the resource pools (possibly
345
351
// nested) under the given path.
346
352
func (c * Client ) ResourcePools (ctx context.Context , path string ) ([]* object.ResourcePool , error ) {
353
+ c .logger .Tracef ("ResourcePools() path=%q" , path )
347
354
finder , _ , err := c .finder (ctx )
348
355
if err != nil {
349
356
return nil , errors .Trace (err )
@@ -365,7 +372,7 @@ func (c *Client) ResourcePools(ctx context.Context, path string) ([]*object.Reso
365
372
// whereas parentFolderName is the subfolder in DC's root-folder.
366
373
// The parentFolderName will fallback to DC's root-folder if it's an empty string.
367
374
func (c * Client ) EnsureVMFolder (ctx context.Context , parentFolderName string , relativeFolderPath string ) (* object.Folder , error ) {
368
-
375
+ c . logger . Tracef ( "EnsureVMFolder() parent=%q, rel=%q" , parentFolderName , relativeFolderPath )
369
376
finder , _ , err := c .finder (ctx )
370
377
if err != nil {
371
378
return nil , errors .Trace (err )
@@ -409,6 +416,7 @@ func (c *Client) EnsureVMFolder(ctx context.Context, parentFolderName string, re
409
416
410
417
// DestroyVMFolder destroys a folder(folderPath could be either relative path of vmfolder of datacenter or full path).
411
418
func (c * Client ) DestroyVMFolder (ctx context.Context , folderPath string ) error {
419
+ c .logger .Tracef ("DestroyVMFolder() path=%q" , folderPath )
412
420
folder , err := c .FindFolder (ctx , folderPath )
413
421
if errors .IsNotFound (err ) {
414
422
return nil
@@ -430,6 +438,7 @@ func (c *Client) DestroyVMFolder(ctx context.Context, folderPath string) error {
430
438
431
439
// MoveVMFolderInto moves one VM folder into another.
432
440
func (c * Client ) MoveVMFolderInto (ctx context.Context , parentPath , childPath string ) error {
441
+ c .logger .Tracef ("MoveVMFolderInto() parent=%q, child=%q" , parentPath , childPath )
433
442
parent , err := c .FindFolder (ctx , parentPath )
434
443
if err != nil {
435
444
return errors .Trace (err )
@@ -455,6 +464,7 @@ func (c *Client) MoveVMsInto(
455
464
folderPath string ,
456
465
vms ... types.ManagedObjectReference ,
457
466
) error {
467
+ c .logger .Tracef ("MoveVMsInto() path=%q, vms=%v" , folderPath , vms )
458
468
folder , err := c .FindFolder (ctx , folderPath )
459
469
if err != nil {
460
470
return errors .Trace (err )
@@ -479,6 +489,8 @@ func (c *Client) UpdateVirtualMachineExtraConfig(
479
489
vmInfo * mo.VirtualMachine ,
480
490
metadata map [string ]string ,
481
491
) error {
492
+ c .logger .Tracef ("UpdateVirtualMachineExtraConfig() vmInfo.Name=%q, metadata=%v" ,
493
+ vmInfo .Name , metadata )
482
494
var spec types.VirtualMachineConfigSpec
483
495
for k , v := range metadata {
484
496
opt := & types.OptionValue {Key : k , Value : v }
@@ -497,6 +509,7 @@ func (c *Client) UpdateVirtualMachineExtraConfig(
497
509
498
510
// DeleteDatastoreFile deletes a file or directory in the datastore.
499
511
func (c * Client ) DeleteDatastoreFile (ctx context.Context , datastorePath string ) error {
512
+ c .logger .Tracef ("DeleteDatastoreFile() path=%q" , datastorePath )
500
513
_ , datacenter , err := c .finder (ctx )
501
514
if err != nil {
502
515
return errors .Trace (err )
@@ -724,6 +737,7 @@ func isManagedObjectNotFound(err error) bool {
724
737
// UserHasRootLevelPrivilege returns whether the connected user has the
725
738
// specified privilege on the root-level object.
726
739
func (c * Client ) UserHasRootLevelPrivilege (ctx context.Context , privilege string ) (bool , error ) {
740
+ c .logger .Tracef ("UserHasRootLevelPrivilege() privilege=%q" , privilege )
727
741
session , err := c .client .SessionManager .UserSession (ctx )
728
742
if err != nil {
729
743
return false , errors .Annotate (err , "getting user session" )
0 commit comments