How to download artifacts from the VMware Customer Connect website using laidbackware/vmd CLI?

If you are a VMware customer you most likely have an account on VMware Customer Connect (VCC). Sure, you can visit the site in your favorite browser, log in with your account credentials, navigate to the desired artifact, and download it.

But what if you want to automate the retrieval and installation of multiple artifacts from VCC?

Turns out there's a command-line interface available from Github, here: https://github.com/laidbackware/vmd.

You can download a pre-built Go binary release for a select set of operating systems (Linux, MacOS, and Windows).

On Linux, you could download and install with:

export VMD_VERSION=v0.3.0
❯ curl -LO https://github.com/laidbackware/vmd/releases/download/${VMD_VERSION}/vmd-linux-${VMD_VERSION}
❯ chmod +x vmd-linux-${VMD_VERSION}
❯ sudo mv vmd-linux-${VMD_VERSION} /usr/local/bin/vmd

Now, how do we use it? What does anyone uninitiated do?

❯ vmd --help
vmd downloads binaries from customerconnect.vmware.com

Usage:
  vmd [command]

Examples:
  # Download the latest version of release 11 with a file matching the pattern
  # If using a * in the filename value, make sure to wrap the text in single quotes on linux/macos
  vmd download -p vmware_tools -s vmtools -v 11.* -f 'VMware-Tools-darwin-*.zip' --accepteula

  # Download files using a manifest file
  # Show an example manifest using 'vmd get manifestexample'
  vmd download -m manifest.yml --accepteula

  # List of available products
  vmd get products

  # List of available sub-products of product vmware_tools
  vmd get subproducts -p vmware_tools

  # List of available versions of sub-products vmtools of vmware_tools
  vmd get versions -p vmware_tools -s vmtools

  # List of available files of version 11.3.0 of vmware_tools
  vmd get files -p vmware_tools -s vmtools -v 11.3.0

  # Display example manifest file
  vmd get manifestexample

Available Commands:
  completion  generate the autocompletion script for the specified shell
  download    Download file from VMware
  get         Display responses
  help        Help about any command
  logout      Remove all session cookies

Flags:
  -h, --help          help for vmd
      --pass string   Password used to authenticate [$VMD_PASS]
      --user string   Username used to authenticate [$VMD_USER]
  -v, --version       version for vmd

Use "vmd [command] --help" for more information about a command.

Ok. Good.

Well, I'm interested in downloading the latest available version of the Tanzu Kubernetes Grid CLI. What is the sequence of commands we could issue to fetch it?

First, we need to learn what products are available.

❯ vmd get products

There are quite a few, so I'm not going to bore you with the output. You'll come to find out that the product is named vmware_tanzu_kubernetes_grid.

A product is typically composed of a collection of artifacts (also known as sub-products). We can list them with:

❯ vmd get subproducts -p vmware_tanzu_kubernetes_grid
SUB-PRODUCT CODE        DESCRIPTION                       
nsx-alb                 VMware NSX Advanced Load Balancer
tkg                     VMware Tanzu Kubernetes Grid

Let's narrow down our search. We are looking for the latest version of a file. Let's ask for available versions and a file list.

❯ vmd get versions -p vmware_tanzu_kubernetes_grid -s tkg
'1.6.1' '1.6.0' '1.5.4' '1.5.3' '1.5.2' '1.5.1' '1.5.0' '1.4.3' '1.4.2' '1.4.1' '1.4.0' '1.3.1' '1.3.0' '1.2.1' '1.2.0' '1.1.3' '1.1.2' '1.1' '1.0'

❯ vmd get files -p vmware_tanzu_kubernetes_grid -s tkg -v 1.6.1
Logging in...
Getting DLG Details

Eula Accepted:         true
Eligable to Download:  true

FILENAME                                                                        SIZE            BUILD NUMBER    DESCRIPTION                                                              
tanzu-cli-bundle-linux-amd64.tar.gz                                             292.34 MB       21015577        VMware Tanzu CLI for Linux                                              
tanzu-cli-bundle-darwin-amd64.tar.gz                                            303.73 MB       21015577        VMware Tanzu CLI for Mac                                                
tanzu-cli-bundle-windows-amd64.zip                                              299.38 MB       21015577        VMware Tanzu CLI for Windows                                            
photon-3-kube-v1.23.10+vmware.1-tkg.1-efe12079f22627aa1246398eba077476.ova      1012 MB         21015577        Photon v3 Kubernetes v1.23.10 OVA                                       
photon-3-kube-v1.22.13+vmware.1-tkg.1-a10ef8e088cc2c89418bca79a2fcc594.ova      995.04 MB       21015577        Photon v3 Kubernetes v1.22.13 OVA                                       
photon-3-kube-v1.21.14+vmware.2-tkg.4-fd7fe2d5325ebcf3175338f2d50aa063.ova      977.62 MB       21015577        Photon v3 Kubernetes v1.21.14 OVA                                       
ubuntu-2004-kube-v1.23.10+vmware.1-tkg.2-b53d41690f8742e7388f2c553fd9a181.ova   1.66 GB         21015577        Ubuntu 2004 Kubernetes v1.23.10 OVA                                     
ubuntu-2004-kube-v1.22.13+vmware.1-tkg.2-ea08b304658a6cf17f5e74dc0ab7544f.ova   1.73 GB         21015577        Ubuntu 2004 Kubernetes v1.22.13 OVA                                     
ubuntu-2004-kube-v1.21.14+vmware.2-tkg.5-d793afae5aa18e50bd9175e339904496.ova   1.59 GB         21015577        Ubuntu 2004 Kubernetes v1.21.14 OVA                                     
kubectl-linux-v1.23.10+vmware.1.gz                                              12.75 MB        21015577        Kubectl cluster cli v1.23.10 for Linux                                  
kubectl-mac-v1.23.10+vmware.1.gz                                                14.02 MB        21015577        Kubectl cluster cli v1.23.10 for Mac                                    
kubectl-windows-v1.23.10+vmware.1.exe.gz                                        12.96 MB        21015577        Kubectl cluster cli v1.23.10 for Windows                                
crashd-linux-amd64-v0.3.7+vmware.5.tar.gz                                       8.26 MB         21015577        Crash Recovery and Diagnostics 0.3.7 for Linux for Tanzu Kubernetes Grid
crashd-darwin-amd64-v0.3.7+vmware.5.tar.gz                                      9.08 MB         21015577        Crash Recovery and Diagnostics 0.3.7 for Mac for Tanzu Kubernetes Grid  
velero-linux-v1.9.2+vmware.1.gz                                                 26.53 MB        21015577        Velero 1.9.2 for Linux                                                  
velero-mac-v1.9.2+vmware.1.gz                                                   27.11 MB        21015577        Velero 1.9.2 for Mac                                                    
velero-windows64-v1.9.2+vmware.1.gz                                             26.69 MB        21015577        Velero 1.9.2 for Windows

These two outputs allow us to ask for the specific versioned file we want.

Before we can download though, we will need to authenticate to VMware Customer Connect with a valid set of credentials. Thankfully we can set some environment variables:

export VMD_USER=you@domain.com
❯ export VMD_PASS=yourP@ssw0rd

Finally:

❯ vmd download -p vmware_tanzu_kubernetes_grid -s tkg -v 1.6.1 -o /tmp -f 'tanzu-cli-bundle-linux.*'
Logging in...
Collecting download payload

Download started to /tmp/tanzu-cli-bundle-linux-amd64.tar.gz
Downloading... 306 MB complete     
Download finished

That was helpful, wasn't it?

I hope you see how you can script downloading artifacts. I'll leave automating the installation of a collection of artifacts as an exercise for you.