Trying out Application Transformer for VMware Tanzu (ATVT) CLI

VMware released ATVT version 2.0 few days back with lots of new features in it (You can find release note here). One of the feature that came out with ATVT 2.0 is a CLI to interact with ATVT and I think it’s really the needed one. In this post, I will demonstrate the steps to configure ATVT CLI and how to run few commands.

Pre-requirements

  • ATVT v2.0 is up and running
  • You have downloaded the CLI binary. If not, you can go to the link here and download the binary based on your operating system. It supports mac, linux and windows platforms.

Steps to setup an ATVT CLI

In this demonstration, I am using mac OS. But overall instructions and commands are going to be the same.

  • Change permission of the atvt cli binary and make it executable.
$ chmod +x <name of the binary>
  • Now, there are two ways to pass the credentials while running the atvt cli. One is to pass the username, password and fqdn/ip along with command itself or create a config.yaml file with the required parameters in the same directory from where you are running the command.
  • Let’s go with the first option first. e.g. you want to list the VM’s from a vCenter inventory, you can run the below command –
$ atvt-cli discovery inventory vcenter list-vm -u admin -p "your atvt admin user pwd here" -f <fqdn or ip address of atvt instance>

And you will see a sample output like below.

[DEBUG] url=https://10.220.22.23/auth-manager/session||timeout=10m0s||retry=3||vals=||headers=Content-Type:[application/json;charset=UTF-8]||proc_time=2.820848||code=200
[DEBUG] url=https://10.220.22.23/discovery/virtualmachines?observe=response&sort=modified%2CDESC||timeout=10m0s||retry=3||vals=||headers=Content-Type:[application/json;charset=UTF-8];Authorization:[Bearer --removing token due to a security reason]||proc_time=1.814091||code=200
{
  "_embedded": {
    "virtualmachines": [
      {
        "id": "6abb80f4-755d-4a95-b72a-c6f8b42e25d5",
        "name": "web_db_vm",
        "network": "user-workload",
        "hostname": "localhost.localdomain",
        "datastore": "vsanDatastore",
        "ip": "",
        "numCPU": 2,
        "memoryMB": "4.00 GB",
        "cli": null,
        "vcenterFqdn": "vc.testdemo.com",
        "dataCenter": "vc01",
        "cluster": "vc01cl01",
        "ResourcePool": "Resources",
        "folder": "vm",
        "numOfDisks": 2,
        "sizeOfDisks": "36.08 GB"
      },
----output trimmed 

For more commands, you can refer the official CLI guide here

Now, Let’s talk about the second method where you do not want to pass the details in every command. So, we will create a config.yaml file and key in the required details. e.g.

cat config.yaml
atvt:
    fqdn: 10.220.22.23 - replace with your atvt ip or fqdn
#    port: 4200 - you do not need this
    username: admin
    password: "your atvt admin password"

just save the file and run the sample command like below.

$ atvt-cli discovery inventory vcenter list-vm

Great, so now we know the different methods to run the atvt-cli. Let’s explore few more helpful options.

You might be interested in exporting some of these results e.g. list of VM’s returned by above command. Use the following option in a command line.

$ atvt-cli discovery inventory vcenter list-vm -e vmlist.json

[DEBUG] url=https://10.220.22.23/auth-manager/session||timeout=10m0s||retry=3||vals=||headers=Content-Type:[application/json;charset=UTF-8]||proc_time=2.600782||code=200
[DEBUG] url=https://10.220.22.23/discovery/virtualmachines?observe=response&sort=modified%2CDESC||timeout=10m0s||retry=3||vals=||headers=Content-Type:[application/json;charset=UTF-8];Authorization:[Bearer removed token]||proc_time=1.938654||code=200

Just cat the vmlist.json file and you will see the same output that was displayed as a standard output.

Explore more options by running the help option.


$ atvt-cli --help
ATVT-CLI is a CLI Client library for Application Transformer for VMware Tanzu.This application is a tool to interact with ATVT.

Usage:
  atvt-cli [flags]
  atvt-cli [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  discovery   Set of discovery commands
  help        Help about any command

Flags:
  -c, --config string     Import ATVT Client info from default yml
  -f, --fqdn string       Application Transformer FQDN / IP, ex: appliance.example.com
  -h, --help              help for atvt-cli
  -p, --password string   Application Transformer admin password
  -u, --username string   Application Transformer admin username

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

If you want to look help option for specific commands, you can include them and then try to see the help. e.g. below one prints the help output for discovery command.

$ atvt-cli discovery --help
Set of ATVT discovery command to scan and introspect the ATVT cluster.

Usage:
  atvt-cli discovery [flags]
  atvt-cli discovery [command]

Available Commands:
  activity    Command to list the ATVT transactions
  inventory   ATVT inventory(VC, VMs, Componenets, etc) related commands
  settings    ATVT configuration and policy settings

Flags:
  -h, --help   help for discovery

Global Flags:
  -c, --config string     Import ATVT Client info from default yml
  -f, --fqdn string       Application Transformer FQDN / IP, ex: appliance.example.com
  -p, --password string   Application Transformer admin password
  -u, --username string   Application Transformer admin username

Use "atvt-cli discovery [command] --help" for more information about a command.

To know more, visit VMware official doc here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s