github.com/vmware/govmomi@v0.37.2/vapi/library/finder/README.md (about)

     1  # The content library finder
     2  The govmomi package now includes a finder for the content library, [`github.com/vmware/govmomi/vapi/library.Finder`](https://github.com/akutz/govmomi/blob/feature/content-library/vapi/library/finder/finder.go). This finder supports searching for objects in the content library using an inventory path design similar to the [standard govmomi finder](https://github.com/vmware/govmomi/blob/main/find/finder.go) and includes support for wildcard matching courtesy of golang's [`path.Match`](https://golang.org/pkg/path/#Match). For example:
     3  
     4  | Pattern | Result |
     5  |---------|--------|
     6  | `*` | Gets all of the content libraries |
     7  | `*/` | Gets all of the content library items for all of the content libraries. |
     8  | `/Public/` | Gets all of the content library items for the content library named `Public` |
     9  | `/*/*/` | Gets all of the content library files for all of the content library items for all of the content libraries. |
    10  | `Public/*/photon2*` | Gets all of the files that begin with `photon2` in all of the content library items for the content library named `Public` |
    11  
    12  The use of a wildcard character in the search string results in a full listing of content library objects for that part of the path's server-side analogue. If `Public/Photon2*` is searched, then all of the content library items for the `Public` library are listed in order to perform the wildcard matching. However, if `Public/PhotonOS-2-GA` then the server-side API call [`library:item:find`](https://vdc-repo.vmware.com/vmwb-repository/dcr-public/1cd28284-3b72-4885-9e31-d1c6d9e26686/71ef7304-a6c9-43b3-a3cd-868b2c236c81/doc/operations/com/vmware/content/library/item.find-operation.html) is used to find an item with the name `PhotonOS-2-GA`.
    13  
    14  ## Performance
    15  Search strings that do not use wildcard characters **should** be **more** efficient as these searches rely on server-side find calls and do not require dumping all of the objects. However, this is only true for systems with a large number of objects in the content libraries. This is due to the number of round-trips required to lookup an object with a direct path. For example:
    16  
    17  | Search path | Roundtrips |
    18  |------|------------|
    19  | `Public/Photon2` | 4 |
    20  | `Public*/Photon2*` | 2 |
    21  
    22  The *absolute* search path takes twice as many roundtrips compared to the search path with wildcards:
    23  
    24  ### Absolute path search logic
    25  1. Find library ID for library with name using server-side find API
    26  2. Get library with library ID
    27  3. Find item ID for item with name using server-side find API
    28  4. Get item with item ID
    29  
    30  ### Wildcard search logic
    31  1. Get all of the libraries and filter the pattern on the client-side
    32  2. Get all of the items for the library and filter the pattern on the client-=side
    33  
    34  ### Searches at scale
    35  While a system that has few content library objects benefits from wildcard search logic, the fact is that the above approach regarding absolute paths proves out to be **much** more efficient for systems with large numbers of content library objects.
    36  
    37  
    38  ## `govc library.ls`
    39  
    40  ### Listing all the objects in the content library
    41  
    42  ```console
    43  $ govc library.ls '*/*/'
    44  /ISOs/CentOS-7-x86_64-Minimal-1804/CentOS-7-x86_64-Minimal-1804.iso
    45  /ISOs/CoreOS Production/coreos_production_iso_image.iso
    46  /ISOs/VMware-VCSA-all-6.7.0-8217866.iso/VMware-VCSA-all-6.7.0-8217866.iso
    47  /ISOs/VMware-VIM-all-6.7.0-8217866.iso/VMware-VIM-all-6.7.0-8217866.iso
    48  /ISOs/ubuntu-16.04.5-server-amd64/ubuntu-16.04.5-server-amd64.iso
    49  /ISOs/photon-2.0-304b817/photon-2.0-304b817.iso
    50  /OVAs/VMware-vCenter-Server-Appliance-6.7.0.10000-8217866_OVF10.ova/VMware-vCenter-Server-Appliance-6.7.0.10000-8217866_OVF10.ova
    51  /OVAs/coreos_production_vmware_ova/coreos_production_vmware_ova.ovf
    52  /OVAs/coreos_production_vmware_ova/coreos_production_vmware_ova-1.vmdk
    53  /OVAs/centos_cloud_template/centos_cloud_template-2.iso
    54  /OVAs/centos_cloud_template/centos_cloud_template.ovf
    55  /OVAs/centos_cloud_template/centos_cloud_template-1.vmdk
    56  /OVAs/centos_cloud_template/centos_cloud_template-3.nvram
    57  /OVAs/photon-custom-hw13-2.0-304b817/photon-ova-disk1.vmdk
    58  /OVAs/photon-custom-hw13-2.0-304b817/photon-ova.ovf
    59  /OVAs/yakity-centos/yakity-centos-2.nvram
    60  /OVAs/yakity-centos/yakity-centos-1.vmdk
    61  /OVAs/yakity-centos/yakity-centos.ovf
    62  /OVAs/yakity-photon/yakity-photon-1.vmdk
    63  /OVAs/yakity-photon/yakity-photon.ovf
    64  /OVAs/yakity-photon/yakity-photon-2.nvram
    65  /OVAs/ubuntu-16.04-server-cloudimg-amd64/ubuntu-16.04-server-cloudimg-amd64.ovf
    66  /OVAs/ubuntu-16.04-server-cloudimg-amd64/ubuntu-16.04-server-cloudimg-amd64-1.vmdk
    67  /sk8-TestUploadOVA/photon2-cloud-init/photon2-cloud-init.ovf
    68  /sk8-TestUploadOVA/photon2-cloud-init/photon2-cloud-init-1.vmdk
    69  /Public/photon2-cloud-init/photon2-cloud-init.ovf
    70  /Public/photon2-cloud-init/photon2-cloud-init-1.vmdk
    71  ```
    72  
    73  ## `govc library.info`
    74  
    75  ### Getting the info for all the objects in the content library
    76  
    77  ```console
    78  $ govc library.info '*/*/'
    79  Name:       CentOS-7-x86_64-Minimal-1804.iso
    80    Path:     /ISOs/CentOS-7-x86_64-Minimal-1804/CentOS-7-x86_64-Minimal-1804.iso
    81    Size:     824637106200
    82    Version:  1
    83  Name:       coreos_production_iso_image.iso
    84    Path:     /ISOs/CoreOS Production/coreos_production_iso_image.iso
    85    Size:     824637441624
    86    Version:  1
    87  Name:       VMware-VCSA-all-6.7.0-8217866.iso
    88    Path:     /ISOs/VMware-VCSA-all-6.7.0-8217866.iso/VMware-VCSA-all-6.7.0-8217866.iso
    89    Size:     824637106368
    90    Version:  1
    91  Name:       VMware-VIM-all-6.7.0-8217866.iso
    92    Path:     /ISOs/VMware-VIM-all-6.7.0-8217866.iso/VMware-VIM-all-6.7.0-8217866.iso
    93    Size:     824637106504
    94    Version:  1
    95  Name:       ubuntu-16.04.5-server-amd64.iso
    96    Path:     /ISOs/ubuntu-16.04.5-server-amd64/ubuntu-16.04.5-server-amd64.iso
    97    Size:     824637441944
    98    Version:  1
    99  Name:       photon-2.0-304b817.iso
   100    Path:     /ISOs/photon-2.0-304b817/photon-2.0-304b817.iso
   101    Size:     824637106672
   102    Version:  1
   103  Name:       VMware-vCenter-Server-Appliance-6.7.0.10000-8217866_OVF10.ova
   104    Path:     /OVAs/VMware-vCenter-Server-Appliance-6.7.0.10000-8217866_OVF10.ova/VMware-vCenter-Server-Appliance-6.7.0.10000-8217866_OVF10.ova
   105    Size:     824637106880
   106    Version:  1
   107  Name:       coreos_production_vmware_ova.ovf
   108    Path:     /OVAs/coreos_production_vmware_ova/coreos_production_vmware_ova.ovf
   109    Size:     824637107032
   110    Version:  1
   111  Name:       coreos_production_vmware_ova-1.vmdk
   112    Path:     /OVAs/coreos_production_vmware_ova/coreos_production_vmware_ova-1.vmdk
   113    Size:     824637107072
   114    Version:  1
   115  Name:       centos_cloud_template-2.iso
   116    Path:     /OVAs/centos_cloud_template/centos_cloud_template-2.iso
   117    Size:     824636997760
   118    Version:  1
   119  Name:       centos_cloud_template.ovf
   120    Path:     /OVAs/centos_cloud_template/centos_cloud_template.ovf
   121    Size:     824636997792
   122    Version:  1
   123  Name:       centos_cloud_template-1.vmdk
   124    Path:     /OVAs/centos_cloud_template/centos_cloud_template-1.vmdk
   125    Size:     824636997832
   126    Version:  1
   127  Name:       centos_cloud_template-3.nvram
   128    Path:     /OVAs/centos_cloud_template/centos_cloud_template-3.nvram
   129    Size:     824636997856
   130    Version:  1
   131  Name:       photon-ova-disk1.vmdk
   132    Path:     /OVAs/photon-custom-hw13-2.0-304b817/photon-ova-disk1.vmdk
   133    Size:     824637107280
   134    Version:  1
   135  Name:       photon-ova.ovf
   136    Path:     /OVAs/photon-custom-hw13-2.0-304b817/photon-ova.ovf
   137    Size:     824637107328
   138    Version:  1
   139  Name:       yakity-centos-2.nvram
   140    Path:     /OVAs/yakity-centos/yakity-centos-2.nvram
   141    Size:     824637253000
   142    Version:  2
   143  Name:       yakity-centos-1.vmdk
   144    Path:     /OVAs/yakity-centos/yakity-centos-1.vmdk
   145    Size:     824637253024
   146    Version:  2
   147  Name:       yakity-centos.ovf
   148    Path:     /OVAs/yakity-centos/yakity-centos.ovf
   149    Size:     824637253056
   150    Version:  2
   151  Name:       yakity-photon-1.vmdk
   152    Path:     /OVAs/yakity-photon/yakity-photon-1.vmdk
   153    Size:     824637107504
   154    Version:  5
   155  Name:       yakity-photon.ovf
   156    Path:     /OVAs/yakity-photon/yakity-photon.ovf
   157    Size:     824637107536
   158    Version:  5
   159  Name:       yakity-photon-2.nvram
   160    Path:     /OVAs/yakity-photon/yakity-photon-2.nvram
   161    Size:     824637107560
   162    Version:  5
   163  Name:       ubuntu-16.04-server-cloudimg-amd64.ovf
   164    Path:     /OVAs/ubuntu-16.04-server-cloudimg-amd64/ubuntu-16.04-server-cloudimg-amd64.ovf
   165    Size:     824637442112
   166    Version:  1
   167  Name:       ubuntu-16.04-server-cloudimg-amd64-1.vmdk
   168    Path:     /OVAs/ubuntu-16.04-server-cloudimg-amd64/ubuntu-16.04-server-cloudimg-amd64-1.vmdk
   169    Size:     824637442136
   170    Version:  1
   171  Name:       photon2-cloud-init.ovf
   172    Path:     /sk8-TestUploadOVA/photon2-cloud-init/photon2-cloud-init.ovf
   173    Size:     824636903184
   174    Version:  1
   175  Name:       photon2-cloud-init-1.vmdk
   176    Path:     /sk8-TestUploadOVA/photon2-cloud-init/photon2-cloud-init-1.vmdk
   177    Size:     824636903208
   178    Version:  1
   179  Name:       photon2-cloud-init.ovf
   180    Path:     /Public/photon2-cloud-init/photon2-cloud-init.ovf
   181    Size:     824637442304
   182    Version:  3
   183  Name:       photon2-cloud-init-1.vmdk
   184    Path:     /Public/photon2-cloud-init/photon2-cloud-init-1.vmdk
   185    Size:     824637442328
   186    Version:  3
   187  ```