Automated Consumption of the VMware Marketplace

Since I last blogged about the VMware Cloud Marketplace, a lot of has happened with this service: they’ve merged it with the VSX (VMware Solution Exchange) and renamed it to VMware Marketplace (see the announcement).

I hadn’t had many reasons and opportunities to use it but I’ve been thinking about the whole VM provisioning recently and I thought it would be great if we could access the Marketplace programmatically.

Why? Well, I’d love to automate the full deployment of a VMware platform – from infrastructure to networking to security to application.

As an example, I can use Terraform to create an entire VMware Cloud on AWS environment, Python or Terraform to create networks or security rules and PowerCLI for example to deploy VMs… But what if we want to deploy VMs from a public inventory?

Yes, we have the ability to use PowerCLI or Terraform for Content Libraries but these are private inventories.

I thought it would be nice to access the my.vmware.com and the VMware Marketplace inventories programmatically. Andrew and Antoine took care of the first one with vmw-cli (Node.js) and gomyvmware (Go) so I started to focus on the Marketplace APIs.


Before I start with the APIs, let’s look at the user interface. If you look at the Marketplace, there are thousands of solutions. If I select just the ones validated for VMware Cloud on AWS, I get roughly 140 OVAs. The browsing experience is pretty straight-forward:

Browsing the VMware Marketplace

Then you can select the item you want and either download it locally or subscribe to it.

For example, if I want to install the API Gateway software Kong on VMC, I would do the following:

Subscribing to a Product on the VMware Marketplace

As you can see above, once I select a solution, what happens is that I create a new Content Library (or select an existing one) in a vCenter of my choice and upload the solution OVA to that Content Library. Then, I can go back to my vCenter and deploy it.

While that’s fine, I’d like to access the Marketplace directly from vCenter (that’s for another blog) or access it from a terminal if I’m going to leverage it alongside, for example, OVFTool or Terraform.


With the Marketplace being still fairly new, its APIs are still not widely documented (would be nice to see them on the developer portal) so I had to do a bit of trial and error to get this working and I got the help of the Marketplace API developers themselves when I got stuck (thanks folks!).

I have now a simple Python-based tool to query the Marketplace and subscribe to a product.

I use the same structure as PyVMC and some of the code – like the authentication – is common.

I have built two main commands. First, the ‘search-product’. Just put the name of the product you’re looking for as an argument (here, I am searching for “Kong”).

$ python3 pymarket.py search-product Kong
+------------------------+--------------------------------------+---------------+----------------+
|      Product Name      |                  ID                  | Solution Type | Latest version |
+------------------------+--------------------------------------+---------------+----------------+
| Kong Virtual Appliance | b93a9a91-a05f-4262-a96e-ef21c8c6d387 |      OVA      |  2.1.0_8_r06   |
|  Kong Enterprise 2020  | 0a2f6f6e-8cef-400e-a19e-15454a531d2a |   CONTAINER   |      1.5       |
|    Kong Helm Chart     | 619dd92f-9732-4e09-b226-30c97748ec36 |   CONTAINER   |     2.1.3      |
+------------------------+--------------------------------------+---------------+----------------+

The search returns the solution type (my focus is on OVA at the moment so the tool just works for this format at the moment) and the product ID. Once you know the product you want to register, it’s easy enough, just use the subscribe command. Use the Product ID and the version as arguments.

$ python3 pymarket.py subscribe b93a9a91-a05f-4262-a96e-ef21c8c6d387 2.1.0_8_r06
Products Deployments Request Accepted: the product image has been added to the Content Library Kong Virtual Appliance---2.1.0_8_r06.

That’s it! Pretty simple, right?

What you can see in your vCenter is a new Content Library with the OVA waiting for you to leverage.


To run this script, go to my GitHub repo:

https://github.com/nvibert/pymarket

I’ve kept it simple for now. It will install it in the default datastore on VMC (WorkloadDatastore). Just add your VMC SDDC ID, OrgID and token to the config.ini and you will be good to go.


Now that you have your OVA in the Content Library, you can use Terraform to deploy it (Iike I explained in a previous post) or OVFTool (like I explained in this other post).

As mentioned earlier, these APIs are just a means to an end. The goal is to find a way to consume inventories easier and enable vSphere administrators to do their jobs faster.

Thanks for reading. I’d love to hear your feedback on Twitter if you have any thoughts!

Advertisement

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 )

Facebook photo

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

Connecting to %s