Home > Blogs > VMware {code}

Talking Code: VMware Cloud on AWS – API Endpoint Overview

We’re back with another edition of Talking Code! This time we have a lightboard walkthrough of the API endpoints that are available as part of VMware Cloud on AWS!

VMware Cloud on AWS – API Endpoint Overview

For more information, check out the VMware Code Developer Center microsite for VMware Cloud on AWS.

For more videos in the Talking Code series, see the Talking Code Archive

As always, let us know in the comments what other videos you’d like to see in the future!

Talking Code: DCLI Interactive Mode

VMware Code is kicking off a brand new series of informational videos that are going to be called ‘Talking Code’. This series is going to take an in-depth look at some of the tools, documentation, example scripts, and more that is available for developers and automation specialists from VMware!

This first video is going to take a look at the interactive mode of Datacenter CLI (DCLI). This is especially important as DCLI recently received a huge update in the form of version 2.9.1!

Talking Code – DCLI Interactive Mode

For more information on DCLI, please see the following page: VMware Code – DCLI

Let us know in the comments what other videos you’d like to see in the future!

Improving Association of Samples and VMware Products

On Friday, we deployed an update to Sample Exchange on VMware {code} that allows you to select any VMware product or SDK when contributing a sample. As a result, developers looking for samples for VMware products and services will have an easier time finding relevant content. Continue reading

VMware Code Developer Center Microsite – VMware Cloud on AWS

VMware Code has a terrific set of Developer Center microsites already available for vRealize Automation, NSX, Workspace ONE, and Apteligent. Each of these Developer Centers give easy access to documentation, developer and automation tools, code samples, and more. As of today, we are happy to announce the brand-new microsite dedicated to VMware Cloud on AWS!

VMware Code Developer Center Microsite for VMware Cloud on AWS

The VMware Code Developer Center microsite for VMware Cloud on AWS gives direct access to those resources developers and automation specialists desire most! There’s an overview featuring what’s available through the VMware Cloud on AWS service as well as some videos that dive right into the available APIs and tooling available. This is followed up by a more detailed overview of the available core capabilities. Then, the key use cases are outlined along with the ability to find out more information about each of them and what kind of development efforts are estimated.

The Developer Resources section has a ton of great information available. This section gives direct links to the SDKs and CLIs that support VMware Cloud on AWS. There is also a detailed list of documentation and blog posts to help better understand each aspect of the service as well as how to quickly and easily get started using each of those SDKs and CLIs. Lastly, this section features code that’s been contributed by both VMware and the community to the VMware Code Sample Exchange in a variety of formats. From PowerCLI to Python, CloudFormation to Terraform, there’s some great resources already available and we more than welcome additional contributions!

The last section is dedicated to Community! Community involvement is an important aspect of the automation and developer resources and this section includes links to get involved directly. Joining VMware Code allows for access to an active Slack group with over 5,000 members, receive regular newsletters with the latest VMware information, and access to the developer forums!

Check out the VMware Code Developer Center microsite for VMware Cloud on AWS today!
Let us know in the comments what you think and/or if there’s anything missing that you may be looking for.

Datacenter CLI – Installation Walkthrough

Datacenter CLI (DCLI) 2.9.1 has been released and the new features are fantastic! One of the key new updates is how we install this new version of DCLI. In the past, DCLI was installed as part of vSphere CLI (vCLI). In this current version, DCLI is installed through the Python Package Index (PyPI) using pip. PyPI is the official, third-party, online repository for Python packages. Pip is a package management system which handles the installation process of Python packages from repositories like PyPI.

If you already have Python installed, version 2.7 or later, we can install DCLI with the following command:

DCLI Installation Process

Let’s cover a couple scenarios where the above might not work.

Command Not Found – MacOS

MacOS comes with Python installed by default. However, this version of Python is generally used for system related tasks, isn’t up to date, and doesn’t always include pip. That means that there is a chance you could be greeted with the following:
DCLI Install - pip command not found

Installing a new, updated, version of Python is quite simple and can be done in multiple ways. My preferred way of installing Python on MacOS is with Homebrew, a widely used command line driven package manager. It can be easily downloaded and installed with the following command:

Example: Installing Homebrew

Then, we can install Python with the following command:

Afterwards, pip will now be available and we can now easily install DCLI with the command above!

Command Not Found – Windows

Windows does not come natively with Python installed. The first step will be to download and install a supported version of Python (2.7 or better). This can be obtained from the Python Downloads page. When performing the installation, ensure the ‘Add Python x.x to PATH’ option is checked.

DCLI Installation - Python Install

Once the installation is complete, open up your favorite terminal window (I used PowerShell), and run the following command:

DCLI Installation - pip install dcli

Summary

Datacenter CLI 2.9.1 greatly expands the available features and changed the installation process. This blog took a detailed look at the installation process and how to the more well-known issues people have ran into.

For more information about the DCLI 2.9.1 release, see the following vSphere blog post: New Release: VMware Datacenter CLI 2.9.1 For more specific information about, see the VMware Datacenter CLI (DCLI) User’s Guide.

VMware Cloud on AWS Developer Center Updates

VMware Cloud on AWS does a tremendous job at enabling our automation experts, developers, and DevOps teams. With a robust set of RESTful APIs, open-sourced SDKs, then capping it all off with the Developer Center located directly in the Cloud Console, access has never been easier. One of the key features of VMware Cloud on AWS is the more frequent update cadence. This allows us to release enhancements on a more regular basis, of which the Developer Center is also included.

With that said, I am happy to announce some of the latest updates to the Developer Center!

API Explorer Redesign

The API Explorer is one of the easiest ways to start learning, modeling, and even using the VMware Cloud on AWS RESTful APIs. It has received several extremely nice updates! After clicking on the “API Explorer” tab, you’ll notice immediately how the layout has been changed. The new side bar allows us to easily switch between the API namespaces as well as auto-populate parameter fields. These may seem like minor updates, but they really help to streamline its usage.

Let’s take an example: we need to list out the logical networks within a particular SDDC, in this case the “CPBU-TMM” SDDC.

If you’re consuming the REST calls directly through an SDK, REST API client, or a programming language, you will need to perform the following calls to retrieve that information:

  1. Obtain the Org ID: GET /orgs
  2. Obtain the SDDC ID, using the Org ID: GET /orgs/{orgID}/sddcs
  3. Obtain the logical networks, using both the Org and SDDC IDs: GET /orgs/{orgID}/sddcs/{sddcID}/networks/4.0/sddc/networks

If you’re using the API Explorer, thanks to the new side menu, we can consolidate that down to a single call!

VMware Cloud on AWS Developer Center Updates - API Explorer

From the above example, you can also see the other new addition in the form of a yellow warning bar. This is just a friendly reminder that the API Explorer is running against your live environment. If you make an API call in the API Explorer, that call will actually run. If you delete something, it really will get deleted! Just keep that in mind as you’re exploring these APIs.

Code Sample Updates

The Code Samples section has also received some updates! This section has been updated to reference the VMware Code Sample Exchange. Therefore, as samples are added to the VMware Code Sample Exchange, those samples will start being populated within the Code Samples tab. We can see several examples which have been created in the example below.

VMware Cloud on AWS Developer Center Updates - Code Samples

SDK Updates

The last of the updates is to the SDKs section. The layout has been updated to match the look and feel of the other tabs. It’s the same great information, just with a consistent look and feel!

VMware Cloud on AWS Developer Center Updates - SDKs

Summary

The VMware Cloud on AWS Developer Center is a great resource which provides a central location to access all kinds of automation and developer based information. The Developer Center is also receiving updates on a regular basis to provide optimized access to all of those resources. The latest update adds a redesigned API Explorer, integrated Code Samples with the VMware Code Sample Exchange, and a consistent theme through all of the available sections.

Let us know in the comments what your favorite feature of the Developer Center is and what functionality you’re most looking forward to us adding!

New APIs and SDKs for vSphere 6.7

The time has come! vSphere 6.7 has been released, and with it comes a host of new APIs and SDKs for automating, extending, and integrating the vSphere platform. Continue reading

VMware Cloud on AWS Integrations with CloudFormation

The latest update to VMware Cloud on AWS has some real gems in it for developers and automation engineers. As well as the introduction of the Developer Center (which is amazing). It’s such a terrific resource, I’m finding myself using it all the time! The other big news was the addition of an Open Sourced Github repository to showcase VMware Cloud on AWS integrations written by both VMware and the community at large.

The first of these integrations is the support for CloudFormation and Terraform integrations.

In this blog post we’re going to walk through how easy it is to create a software defined data center (SDDC) using the CloudFormation template available in the VMware Cloud on AWS Integration Examples repository. Please note, this will require an AWS account and may incur AWS charges.

First things first, we need to get access to the template. We can clone the repository locally with the following command:

CloudFormation Stack Creation

In order to deploy our SDDC with CloudFormation, we’ll need to start by logging into the AWS Console and checking to make sure we’re in the Oregon region. If you’re not in that region, there is a drop-down box towards the top right-hand side with a site name that’s located between your user account and the “Support” drop-down. Click on the drop-down and select “US West (Oregon)”.

Example: Selecting the Oregon Region

We’ll now want to go to the CloudFormation service. We can find the service by clicking on the “Services” drop-down and locating it in the “Management Tools” section. Alternatively, just type “CloudFormation” in the AWS services search box on the main screen of the console.

Once in the CloudFormation service, we will want to create a new stack by clicking on the “Create New Stack” button. This stack will be used to deploy our SDDC that will be based on the template we’ll import on the next screen.

Example: Creating a new CloudFormation Stack

As part of the stack creation process, we’ll need to either create a new template or select an existing template. We can upload the template we retrieved from the GitHub repo by choosing “Upload a template to Amazon S3” then clicking on “Choose File”. Browse to the location the repo was cloned to, select the “vmc-aws-cloud-cf-template.txt”, and click “Next”.

Example: Choosing the repository sourced template

On the next screen we will need to specify a stack name. In this case, I used “VMWonAWS-CF” as the stack name.

Example: Assigning the new stack a name

For the “Options” screen, there is nothing to update, so we can click “Next”. On the last screen, review the details and check the box that you “acknowledge that AWS CloudFormation might create IAM resources”. We’re now ready to create our stack by clicking the “Create” button!

After few moments, we should see a screen like the following indicating that the stack creation has been successfully completed.

Example: stack creation process

SDDC Creation

We’ve now laid out the groundwork to deploy our new SDDC. One piece of which is the result of the stack creation, in the form of a new Lambda function. We’ll use this function to input our SDDC criteria and then ultimately deploy our new SDDC.

While we’re still in the CloudFormation service, we’ll want to click on our newly created stack to retrieve the details. Once on the “Stack Detail” page, expand the “Resources” section. There we see the IAM Role and Lambda function. Click on the physical ID of the Lambda function, which will take us to the function’s page.

Example: Examining the newly created stack resources

Once on the newly created Lamda function page, scroll down to the “Environmental variables” section. This section is where we need to input the criteria for the SDDC variables:

  • connected_account_id: Enter the AWS account this SDDC should be connected to.
    Note: This is the ID for the account which can be pulled from the API with the following:
    Method: GET /orgs/{org}/account-link/connected-accounts
    Property: ID
  • email: Enter an email address which you would like notified when the process has completed.
  • name: Enter the desired name of the SDDC
  • numOfHosts: Enter the number of desired hosts. (Minimum is 4)
  • orgId: Enter the Org ID for which the SDDC will be assigned. (This is available in the VMware Cloud Console in the “Support Info” tab)
  • region: Enter the desired region. (Case sensitive format: US_WEST_2)
  • customer_subnet_ids: Enter the desired subnet ID for VPC traffic.
    Note: This is the ID for the VPC subnet which can be pulled from the API with the following:

    Method: GET /orgs/{org}/account-link/compatible-subnets
    Property: subnet_id
  • user_refresh_token: Enter the creating user’s OAuth Refresh Token.
    Note: This is available in the VMware Cloud Console by clicking your username then “OAuth Refresh Token”.
  • vpc_cidr: Enter the desired subnet to use that corresponds with preferred management subnet. (Default is 10.2.0.0/16)

Example: Filling in the SDDC variables for the lambda resource

With all of our variables now input, we’re ready to save and run our function. First, click “Save” then click “Test”. On the “Configure test event” pop out, give the test event a name and click “Create”.

Example: Creating a lambda test event

Next to the “Test” button is a drop-down list of events. Make sure that list is set to our previously created test event and then click “Test” again. If everything was set properly, we should see a response like the following:

Example: lambda test event results

We can note from the above image that the response is a task. If we source out the ID, we can then follow along using the tasks API until the creation is complete. Alternatively, we can also watch the deployment process on the SDDCs tab of our Cloud Console.

Example: VMware Cloud on AWS Cloud Console results

Summary

The latest update to VMware Cloud on AWS introduced a couple great features for developers and automation specialists as well as a way for you to share your integrations. This blog covered the newly released integrations with CloudFormation. We showed how to access the CloudFormation template in the VMware Cloud on AWS Integration Examples repository. We then walked through how to easily get started deploying SDDCs in VMware Cloud on AWS using the CloudFormation template.

Get started with it today and let us know how you’re planning on integrating this into your existing workflows in the comments below!

Netherlands VMUG Hackathon 2018

On March 19th, 2018, at the Galloway in the 1931 Conference Centre in the Netherlands, VMware {code} and NLVMUG held their first Hackathon with the theme “Fun, Beers and Gyros.” Sixteen participants in three teams worked diligently from 1:30 in the afternoon for six hours until 8:30 at nightonly taking a break to eat some delicious gyros, reenergize with some sugar and caffeine, or grab stickers and souvenirs from the giveaway table.

A gyro learning, coding, and connecting

Hard at work coding before breaking into the soda

The giveaway table, moments before becoming completely empty

Each of the three teams had their own unique visions for their projects. At the end of the night, three judges, Boudewijn Aelbers, Joep Piscaer, and Wouter Kursten awarded the teams a retro gaming console for their hard work.

Vintage game console

Taking home the prize for Best in IOT, the team from PQR created a way to integrate vRealize Automation with the Homey home automation controller to initiate a deployment using voice commands. They used a Philips Hue lightbulb to indicate the status of the deployment based on its color and a moving Lego Mindstorms robot that would move an object to a different zone on the table to represent the stage of deployment. And, as an added bonus, if would throw the object off the table if the VM request was requested.

Lego Mindstorm robot built by the PQR team

The team from ITQ won Best in Cloud Native for their project that created a way to deploy a Minecraft server using BOSH through voice commands via an Amazon Echo. Taking it one step further, they then deployed a Kubernetes cluster using BOSH and initiated it using more voice commands. The Minecraft character Steve guides the user through the deployment process on a custom interface created by the team.

Steve from Minecraft guiding deployment

The third and final team came from DICTU and won the prize for Most Innovative. They created a way to fully automate deployment of a secure tenant and infrastructure (IaaS) in which everything was secured, error-free, and auditable. The deployed virtual machines were encrypted using VM Encryption with HyTrust as the key management and were micro-segmented using NSX. Intra-VM and vMotion traffic were encrypted using SSL to further increase security. Finally, the team used vRealize Network Insight and vRealize Operations to monitor the security on that infrastructure.

Every team impressed the judges with their projects, and with the help of food, drink, and innovation, the energy brought back the strong community feeling of the early days of the NLVMUG UserCon. Overall, the team behind the Hackathon thought it turned out to be a resounding success, and they are looking forward outdoing themselves next year.

The Hackathon was a huge success, we set out to create a fun and relaxed time and going back to the core of the VMUG community, which worked out exceptionally! Next year is going to be even more awesome.

Martijn Smit, NLVMUG Hackathon Organizer & NSX Specialist, VMware

 

 

The participants were very enthusiastic; the comradery was great to see. If it’s up to me there will be an even greater, bigger hackathon in 2019!

Erik Scholten, Cloud Management Specialist, VMware

 

Interested in running your own Hackathon in your region? Contact us at code@vmware.com or @vmwarecode for more information about our VMware {code} Experiences.

 

Photo credits: Alex Muetstege, TAM

 

Getting Started Using the vSphere Automation SDK for Python with VMware Cloud on AWS

The vSphere Automation SDK for Python has recently received some exciting updates. These updates add the ability to easily develop against and automate VMware Cloud on AWS! There are even samples to list organization information, manage SDDCs, and lots of networking functionality!

Let’s take a look at how to easily get started with this SDK on a MacOS system. Before diving in though, there are a couple prerequisites we’ll need to download and install.

Prerequisites

The first thing we’ll want to do before getting started with this SDK is to clone the repository to the local system. We can do that with the following command:

Example: Cloning the SDK Repository Locally

Next, we’ll need to install the package manager, Homebrew. Using Homebrew will allow us to easily download and update additional programs. It can be easily downloaded and installed with the following command:

Example: Installing Homebrew

Now, we’ll install Python in the recommended version of 3.6. It’s worth noting that MacOS comes with a version of Python already installed. However, it is generally an older version (normally, Python 2.7) and is used for some system related tasks. Due to that, it is best not to modify that version or the defaults.

Utilizing our package manager, we’ll install Python 3.6 with the following command:

Example: Installing Python 3.6 Using Homebrew

It’s also recommended to isolate your development environments from each other so, we’ll setup a virtual environment and jump into it. We can do that with the following commands:

Example: Create and Enter a Virtual Environment

Then, we’ll install the SDK requirements. They’re listed within the root of the SDK folder in the file labeled: requirements.txt. After checking out which requirements are necessary, we’ll install those requirements by way of the following command while in the root of the SDK folder:

Lastly, we need to update the PYTHONPATH variable. This allows Python to be able to use the SDK helper methods. We can do this with the following command:

One other item worth mentioning is an IDE. This will make editing, running and debugging the code a lot easier to deal with. I generally use Visual Studio Code, which is available here.

Let’s get started using some of the samples that have been included with this SDK.

Obtaining Refresh Token

The VMware Cloud on AWS APIs use an OAuth refresh token for authentication. These have to be created through the Cloud Console. Once logged into the Cloud Console, click the drop-down on the top right-hand corner that’s by your name. From there, click on the ‘OAuth Refresh Token’ button. If you don’t already have a refresh token available, there will be a blue link to create a new token. Afterwards, you’ll have a refresh token and be ready to authenticate into the VMware Cloud on AWS APIs.

Example: Obtaining the VMware Cloud on AWS OAuth Token

Obtaining Organization Information

The most important thing you can do when getting started is making your Organization (Org) ID easily accessible. This ID is referenced in almost every API method VMware Cloud on AWS has. If we browse through the SDK folder structure, we’ll see there’s an example we can use to retrieve information about the Orgs. There is a Python package named ‘organization_operations.py’ in the ‘samples/vmc/orgs’ directory.

Example:

Example: Obtaining Org listings and detailed information about an Org

We can see in the results above this example performs a couple tasks. First, we receive a list of all the Orgs this refresh token is associated with. Second, we get some additional information about the first Org that was returned.

Obtaining SDDC Information

The next most important thing we can obtain is information about the SDDC/s this Org has. However, at the time of this blog release, that functionality wasn’t explicitly available. Let’s see how to do this in the REPL, or Python’s interactive interpreter:

Example: Using the REPL to obtain SDDC Information

I think this ability is something that will be quite helpful as part of the example SDDC package. Adding it is as easy as adding the following to the ‘create_delete_sddc.py’ file:

Example: Obtaining a list of SDDCs in an Org

However, you won’t need to do that. This SDK is open-sourced and I was able to submit a pull request to get it added in already! As part of the PR, we updated the file name to be ‘sddc_crud.py’ and it is available in the ‘samples/vmc/sddc’ directory.

Logical Network Tasks

Last example, let’s run through some tasks for logical network administration. There’s a sample for this as well. The ‘logical_network_crud.py’ package will create a new logical network, list all of the logical networks, list only the newly created logical network, and then delete the newly created logical network. This file is available in the ‘samples/vmc/networks/’ directory.

Example:

Example: Logical Network Workflow to create, list, and delete an object

Summary

This post shows you how to easily get started with the vSphere Automation SDK for Python with VMware Cloud on AWS. It takes you through the setup of your local development environment, as well as running some of the individual samples. You can then take whichever is most relevant to you and apply to your environment or, pull parts of this code out and use it to automate or integrate as needed.

With our SDKs now being open sourced, we are intent on making sure these samples are of a high quality. If you notice areas of improvement, or come up with some new samples, please feel free to raise issues or pull requests on our GitHub repository.

If you’ve missed any of the prior posts, here are the others in this ‘Getting Started’ series with our open-sourced SDKs: