Home > Blogs > VMware {code} > Tag Archives: SDK

Tag Archives: SDK

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

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:

Enabling Developers in VMware Cloud on AWS

The latest release of VMware Cloud on AWS is here and it has something quite exciting built in for the automation experts, developers and DevOps teams. As part of this release, we are introducing a brand-new Developer Center. This area is a great resource allowing developers to get up and running quickly with VMware Cloud on AWS.

Developers can gain access to this information front and center as a new tab in the VMware Cloud on AWS console!

VMware Cloud on AWS Developer Center

The VMware Cloud on AWS Developer Center consists of several sections, each with the goal of helping to make the development and automation experience and learning easier.

API Explorer

The API Explorer section brings easy access to interact directly with the RESTful APIs available from the Cloud Services API and the VMware Cloud on AWS (VMC) API. These APIs are presented by way of an interactive API browser with some very nice integrations making it easy to work with VMC. The API Explorer being internal to the Cloud console allows us to use the existing refresh token to authenticate. We can also automatically populate certain fields, such as the Organization ID, to help improve the experience of learning and using these APIs. Learning the API and seeing the responses from within the API Explorer could not be easier with the ability to “Execute” these APIs and see the live responses.

Developer Center - API Explorer

Code Samples

The next section is focused on code samples. These are curated directly from the samples written by both VMware and the community in a variety of formats. These samples could be written in Python, PowerShell, be a Postman collection or other integration code samples provided on the VMware Code Samples Exchange.

Developer Center - Code Samples

SDKs

There is a wide variety of software development kits (SDKs) available to interact with the VMware Cloud on AWS APIs and the deployed SDDC products. The SDK section provides easy access to each of these open-sourced SDKs that are available on GitHub. There are also links to the documentation, samples, and even the ‘Getting Started’ blog post for each SDK!

Developer Center - SDKs

Downloads

The last section is called Downloads. This section is where there will be a wide variety of resources available. There will be command line resources like Datacenter CLI (DCLI) and PowerCLI. Also, there will be links to provisioning tool resources from Terraform and CloudFormation.

Developer Center - Downloads

Summary

The VMware Cloud on AWS Developer Center is a fantastic new resource that’s presented front and center in the Cloud console! Whether you’re an automation expert, developer, on a DevOps team, or a mix of all the above, this is going to be the best place to get up and running with the VMware Cloud on AWS APIs. You will be able to use the integrated API Explorer for discovery, access the open-sourced SDKs that can be used against this endpoint, have links to VMware and community contributed code samples, and direct links to download other related resources like PowerCLI and CloudFormation templates.

Getting Started with the vSphere Automation SDK for Perl

We are going to keep the ‘Getting Started’ series going on using the vSphere Automation SDKs. This time, we will be taking a look at the SDK for Perl.

If you’ve missed any of the prior posts, here are the others in the series:

Let’s take a look at how to easily get started with this SDK on a Windows 10 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: Clone vSphere Automation SDK for Perl Repo Locally

We also want to make sure Perl is available on the local system. The supported versions are Active Perl 5.14+ or Stawberry Perl 5.24.1.1+. For these examples, I’ll be using Active Perl which can be downloaded directly from their site: Active Perl

Example: Installing Active Perl

We will then need to make sure a couple Perl packages are installed and available. These can be installed with the following commands:

Example: Installing Additional Packages as Prerequisites

Next, this SDK also depends on some capabilities from the vSphere Perl SDK. We will need to login to the My VMware portal, download the executable, then install it from the following link: vSphere Perl SDK

We have one more step concerning the vSphere Perl SDK install. We also need to make sure the ‘python27.dll’ file is available in the vSphere Perl SDK’s folder as follows: ..\Perl\lib\VMware

The following code can be used to easily copy that file to the proper location:

Example: Copy Python27.dll to Appropriate Place for Perl Usage

Last part of the prerequisites is to configure the environmental variable PERL5LIB to look for modules in the newly cloned SDK directory. The following directories need to be specified:

  • ..\lib\runtime
  • ..\lib\sdk
  • ..\samples

The following code was used to configure the PERL5LIB environmental variable for my lab:

Example: Configuring the PERL5LIB Variable

We are now all setup to start using the vSphere Automation SDK for Perl!

Running Samples

There are a handful of samples that are already included with this SDK. The samples are separated by the API namespaces into different directories and then presented as scripts. We’ll be looking at running some of the samples from the vCenter directory.

The first example we’ll run is the List VMs sample. This sample can be found in the ‘..\samples\Vcenter\Vm’ directory. There are a couple sample scripts here, which also include deleting a VM and performing some power actions.

Example: Displaying Example Perl Scripts

If we run the ‘list_vms.pl’ sample as is, we will receive back the appropriate parameters to successfully complete the call. Those parameters would be username, password, and server name.

Performing the List VMs sample in my environment, with all of the required parameters, looks like the following:

Example: Running the ListVMs Sample Script

There’s another example in the VM folder which allows us to modify the power state for a given VM. However, this sample will take a given VM through all of the available power states. Again, running the sample without any parameters will give us the required parameters. We can see that we’ll need to also add parameters for the VM name and cleanup. The cleanup parameter is used to return the VM to the last state it was in.

Performing the List VMs sample in my environment, with all of the required parameters, looks like the following:

Example: Running the VM Power Lifecycle Script

The last example we’ll take a look at is the creation of a new VM. We’ll take advantage of one of this new API’s features and create a new VM using defaults. This means the API fills in any parameters we do not specify with values based on what Guest OS has been specified. It’s also import to note that the Guest OS has been hardcoded in the sample to be ‘Windows_9_64’. This can be found on line 71 of the ‘default_vm.pl’ script. Additional Guest OS types can be found in the API documentation: Guest_OS Types

We’ll start by moving to the following directory: ..\samples\Vcenter\Vm\Create\DefaultVM Running the ‘default_vm.pl’ script will show us a number of parameters we’ll need to specify. These parameters include names for the following: VM, Datacenter, Cluster, VM folder, datastore. There’s also the authentication and cleanup parameters. In this case, giving the cleanup parameter a ‘True’ value will remove the newly created VM.

Performing the Create New Default VM sample in my environment, with all of the required parameters, looks like the following:

Example: Usage of the CreateDefaultVm Sample

Summary

This post shows you how to easily get started with the vSphere Automation SDK for Perl. 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.

Getting Started with the vSphere Automation SDK for .NET

We are going to keep the ‘Getting Started’ series going on using the vSphere Automation SDKs. This time, we will be taking a look at this SDK for .NET.

If you’ve missed any of the prior posts, here are the others in the series:

Let’s take a look at how to easily get started with this SDK on a Windows 10 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: Clone vSphere Automation SDK for .NET Repo Locally

The other things we’ll need is .NET Framework 4.5 and Visual Studio 2015 or newer. I’ll be using Visual Studio 2017. On Windows 10, .NET Framework 4.5 should already be available. If it’s not, you can download it directly from Microsoft at the following link: Microsoft .NET Framework 4.5. If you don’t already have Visual Studio, it can be downloaded through the following link: Visual Studio

The next thing we need to do is build out the samples in Visual Studio. We start this process by opening Visual Studio. Now we can click on “File”, “Open”, then click “Project/Solution”. From the new Explorer window, browse to the root directory of where the SDK repo was cloned, then select and open the ‘vSphere-Samples.sln’ file.

Example: Adding SDK Samples to Visual Studio

Note: This process may take some time and if there are any missing dependencies found in the Visual Studio install, it will prompt to install those items.

We will be ready to finish building out the samples once the vSphere-Samples solution has been presented in the Solution Explorer. We’ll then right click on “Solution ‘vSphere-Samples’ (17 projects)” and select “Build Solution”. After a few moments there should be a message on the bottom information bar indicating “Build succeeded”.

Example: Build Solution for the included samples

We are now all setup to start using the vSphere Automation SDK for .NET!

Running Samples

There are a handful of samples already included with this SDK. The samples are separated by the API namespace into different directories and presented as projects. We’ll be looking at running some of the samples from the vCenter directory.

The first example we’ll take a look at is the ‘ListVMs’ sample. We start in the Solution Explorer, expanding ‘vcenter’, ‘vm’, and finally the ‘list’ directory. We can now see a ‘ListVMs’ project. We will want to right click the project and click ‘Set as StartUp Project’.

Example: Configuring the 'Set as Startup Project' Option

Prior to running the sample, we need to populate the sample with some properties such as which vCenter Server to connect to and with what credentials. We can find what the available properties are by clicking on the ‘Debug’ menu and then selecting ‘Start Without Debugging’.

Example: Retrieving Parameter Options through Start command

We should receive a command prompt window that gives us the available properties.

Example: Output from ListVMs Sample

In order to pass those parameters, we’ll need to open up the properties of the project. Once open, select the ‘Debug’ tab and look for the ‘Start options’ section. The ‘Command line arguments’ text box is where we’ll be specifying the parameter values. The parameters for my environment end up looking like the following:

Example: Populating Sample with Parameters for Start command

With the parameters now laid out, we’re ready to actually run the sample!

Example results after hitting the ‘Start’ button:
Example: Output from the ListVMs Sample

Alternatively, we can also run the built executable for the ListVMs sample. It is located in the following directory: ..\vmware\samples\vcenter\vm\list\ListVMs\bin\Debug

Example code:

We can also make modifications to an existing VM’s configuration. One example would be to update a VM’s CPU configuration, so let’s take a look at the CpuConfiguration sample. This project is under ‘vm’ then ‘hardware’. This sample is already configured to increase the CPU count to 2 and to enable CPU Hot Add. These options can be modified in the source code (CpuConfiguration.cs) at line 71 and 81, respectively.

This time we’ll run the sample directly from the executable. The first time we run it, without adding any parameters, we can see that we need our standard authentication parameters but we also need to specify the VM name. Running this sample in my environment looks like the following:

Example: Modify CPU Configuration of a VM with the CpuConfiguration Sample

The last example we’ll take a look at is the creation of a new VM. We’ll take advantage of one of this new API’s features and create a new VM using defaults by using the CreateDefaultVM project. This means the API fills in any parameters we do not specify with values based on what Guest OS has been specified. It’s also import to note that the Guest OS has been hardcoded in the sample to be ‘Windows_9_64’ on line 38 of the source code (CreateDefaultVm.cs). Additional Guest OS types can be found in the API documentation: Guest_OS Types

The project for this sample is located under ‘vm’ then ‘create’. However, we will again be running this sample directly from the executable. Running the executable without any parameters shows that we will need some additional parameters specified. These parameters include names for the following items: datacenter, cluster, vmfolder, and datastore.

Performing the Create Default VM sample in my environment, with all of the required parameters, looks like the following:

Example: Usage of the CreateDefaultVm Sample

Summary

This post shows you how to easily get started with the vSphere Automation SDK for .NET. 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.

Getting Started with the vSphere Automation SDK for Java

There has been another exciting open-sourced release in the vSphere Automation SDK lineup. This time, it is the vSphere Automation SDK for Java!

That means it’s time for another blog post in our series on ‘Getting Started with the vSphere Automation SDKs’. The posts available in the series so far are as follows:

We’ll be taking a look at how to easily get started with this SDK on a Mac. Before diving in, 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 repo local

Next, we’ll want to make sure we have the appropriate Java Development Kit (JDK) installed and available. The vSphere Automation SDK for Java has been developed to work with JDK 1.8. We can verify which version of Java is available by the following command:

Example: java version output

In this situation, my system doesn’t have Java installed at all. I’ll need to head out to the JDK8 download page to download and install the appropriate version. Once complete, repeat the last command to ensure JDK 1.8 is installed. Verifying and/or updating the JAVA_HOME and PATH variables is the last step to the install process. We’ll start by finding the current value for the JAVA_HOME variable, then updating it, if necessary, to the Home directory of the newly installed JDK. We’ll then repeat that process for the PATH variable as well. This can be done with the following commands:

Example of updating system variables

We will also need to ensure Maven, a build automation tool, is installed. We will use Maven to build out the SDK and the samples from source so we can start using it. My system doesn’t have Maven installed yet, so we’ll go to the download page and install it according to the instructions on Maven’s site. Alternatively, we can do it with the following commands:

Example of installing Maven

The last prerequisite, before starting to user the SDK, is instructing Maven to build out all the samples with Maven. We’ll first use the initialize command, within the cloned repository directory, to pre-stage any dependencies that are not available publicly. We’ll then follow that with install command. This can be done with the following commands:

Example of downloading SDK prereqs and building out SDK from source

We are now all setup to start using the vSphere Automation SDK for Java!

Running Samples

There are quite a few samples which are included with the SDK. Each sample can be run by using its fully qualified class name.

The first example we’ll take a look at is the ListVMs sample. In terminal, from the root of the SDK directory, we’ll call java, enabling assertions with the ‘ea’ parameter, using the ‘cp’ parameter to call the class path of ‘target/vsphere-samples-6.5.0.jar’, then the fully qualified class name. An example of this command is as follows:

Example parameters available for use with the ListVMs sample in the vSphere Automation SDK for Java

Based on the output, we see quite a few parameters that still need to be referenced in order to authenticate and run the sample. The required parameters are server, username, and password. However, there are also some considerations needed around the handling of the vCenter’s certificate. I’m using a lab environment that still has the vCenter’s self-signed certificate in use, so I’ll be using the ‘skip-server-verification’ parameter. Lastly, there are the optional paramaters, most of which are straight forward, but the config-file parameter is a convenient one. For now, we’ll keep it simple and call each parameter as part of the command. I’ll discuss using a configuration file later in this post.

Performing the ListVMs sample in my environment, with all of the required parameters, looks like the following:

Example output when listing VMs

There’s another sample which takes a VM through the lifecycle of power states. This sample can be discovered in the ‘../vmware/samples/vcenter/vm/power’ directory. The public class we’ll be using is ‘PowerLifeCyle’. If we run that without any parameters, we can see that we’ll need to add the ‘vmname’ parameter and call a specific VM by name. Running this sample can be done with the following command:

Example of taking a VM through the lifecycle of power states

The last example we’ll look at is the modifying the memory configured for a VM. This sample can be found in the ‘../vmware/samples/vcenter/vm/hardware/memory’ directory. The public class we’ll be using is ‘MemoryConfiguration’. If we run that without any parameters, we can see that we will again need to add the ‘vmname’ parameter and call a specific VM by name.

This sample will set the RAM to 8GB then enables hot-add. We can go execute this sample with the following command:

Example of memory configuration options

One last thing before wrapping this up, let’s walk through using the configuration file. The configuration file can be any text-based file which contains lines that begin with the parameter names. In the following example, we create a new file and modify the file to include the following lines:

We can now reference this config file in any of the examples to authenticate against a vCenter server. Reusing the ‘ListVMs’ sample, the command to run that again but instead using a configuration file will look like the following:

Example of using the configuration file

Summary

This post shows you how to easily get started with the vSphere Automation SDK for Java. 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.

vSphere Automation SDKs Updated for VMware Cloud on AWS

The vSphere Automation SDKs have recently received an exciting update! These open-sourced SDKs can now also interact with the VMware Cloud on AWS service. The first two SDK languages updated to include this feature set is Python and Java. The remaining SDK languages will follow soon.

The VMware Cloud on AWS service offers a couple different RESTful APIs to interact with. The updated SDKs will focus on the VMware Cloud on AWS (VMC) API, as well as provide the authentication method through the Cloud Services Platform (CSP) API. To find out more about the APIs available as part of the VMware Cloud on AWS service, see this blog post: An Overview of VMware Cloud on AWS APIs

On this initial release, both the Python and Java SDKs include a handful of sample frameworks. These include the following functions:

  • Listing all Organizations associated with a user
  • Creation and removal of an SDDC
  • Managing the host count for a deployed SDDC

Let’s take a look at a couple of these in action.

vSphere Automation SDK for Python

One of the vSphere Automation SDK for Python samples has the functionality to perform two methods. The first will list all of the organizations the user’s refresh token is associated with. These orgs will be displayed by ID and display name. The second will list more detailed information for the first organization, such as ID, display name, name, create and updated dates, and SLA. This sample can be executed with the following command:

Python SDK Sample to list Org information

This SDK also has a new way to interact with the API and that is through the interactive interpreter! This can be done by creating the service object using the ‘create_vmc_client’ function while passing our refresh token. At this point, we can start accessing the available collections. The collections can by discovered in two main ways. First, by referring to the documentation that’s located in the ‘vmc.zip’ file that’s located in the ‘doc’ folder. Second, by using tab-complete. Some example code to obtain similar output to our prior example while in the interactive shell:

Interactive Shell Python Example Usage

vSphere Automation SDK for Java

The vSphere Automation SDK for Java offers a similar sample to the first Python example from above. However, this particular sample operates a little differently. The output from this sample will be the complete details of each org the user is associated with. This sample can be executed with the following command:

Java SDK Sample to list Org information

Summary

The open-sourced vSphere Automation SDKs have recently received an update. This update allows these SDKs to work with the RESTful API service of VMware Cloud on AWS. There are also a number of samples available within each SDK to list information about organizations, add and/or remove SDDCs, and manage the host count within an SDDC. These samples are easy to have operational within a few minutes of updating your local repo and are quite simple to integrate into your existing code!

Stay tuned for a more detailed look at getting started with each of these SDKs with the VMware Cloud on AWS service in the future.

For more information about the VMware Cloud on AWS service, see the following blog post: VMware Cloud on AWS Technical Overview
For more information about the VMware Cloud on AWS APIs, see the following blog post: An Overview of VMware Cloud on AWS APIs

Introducing the New Workspace ONE Swift SDK

The VMware Workspace ONE product teams have been hard at work this year with the goal to make developing with VMware and Workspace ONE easier and better than ever. First we launched the brand new Workspace ONE Dev Center and then the completely revamped Workspace ONE Swift Software Development Kit (SDK).

You may already be familiar with the AirWatch Software Development Kit (SDK), a set of tools that let you easily add advanced security and management capabilities to enterprise mobile apps. The new Workspace ONE Swift SDK is the completely revamped version of the AirWatch SDK for the iOS platform. The Swift SDK takes the old SDK, written in Objective-C, and is updated with the Swift 3.1 (Swift 3.2 and 4.0 support is right around the corner) programming language from Apple (https://developer.apple.com/swift/) along with many other modern technologies.

By leveraging the latest and greatest Apple technology, the Swift SDK offers all of the benefits of the AirWatch SDK with a few more bells and whistles when it comes to user experience and performance.

You’ll love the Swift SDK, here is why:

  • Greatly reduced app-to-app flipping: The Swift SDK leverages a new protocol for app data sharing, significantly reducing the amount of app-to-app flipping required
  • Reduced integration time:  With the Swift SDK, you no longer need to include as many dependent frameworks
  • Refactored code: Much of the AirWatch SDK code has been refactored, resulting in less operations on the main thread, a smoother feel when interacting with UI elements and more
  • Support for Workspace ONE devices:  The Swift SDK apps will now also be compatible on devices enrolled through Workspace ONE

Architecture for the Future

In addition to the tangible user experience and performance improvements, there are several major underlying architecture changes made in the new Swift SDK which set the groundwork for future improvements. Future improvements will include things such as bitcode support and adoption of modern package management technologies like Cocoa Pods.

So, want to try it out?

The Workspace ONE Swift SDK is available today. Contact your account representative or AirWatch customer support for more information.

Using the Objective-C SDK? Here are some things you should know.

What behavior has changed between Objective-C and. Swift?

The Swift SDK will introduce a new mechanism using the shared keychain for SDK apps to communicate with other SDK apps on the device. This approach provides benefits from both a security and a user experience perspective.

SDK applications built by the same developer account and are also in the same keychain group or “cluster” will now be able to share an app passcode & SSO session with each other without requiring a flip to the Agent or Container application every time authentication is required. However, applications on the same device built by different keychain groups will not be able to take advantage of this passcode sharing capability. There will still be some scenarios where a flip to the Agent, Container, or Workspace ONE app is required for obtaining the server URL and other setup information but this particular flip should only occur once per cluster of apps.

The diagram below illustrates this new “clustering” behavior. The dotted cluster represents a unique developer account and keychain group. Applications with the same color code represents SDK apps which will share information with each other.

How will Swift SDK and Objective-C SDK applications interact and behave when both are present on a device?

Upon upgrading one app to use the Swift SDK (see State 2 in diagram below), the Objective-C SDK applications will automatically switch to the clustering behavior for passcode and other app data sharing mentioned in the behavior changes section above. Thus, the Objective-C applications will no longer flip to the Agent for passcode authentication nor will it share a passcode with apps which are outside of its own keychain cluster.

Note: Anchor app refers to either Agent, Container, or Workspace ONE.

What is the plan for the Objective-C SDK?

The Objective-C version of the iOS SDK will be in maintenance mode and new features/capabilities will be exclusive to the new Swift SDK.

Get in on the conversation!

Join VMware {code}

Become a part of one of the fastest-growing developer communities devoted to cloud infrastructure and enterprise mobility.

 

Learn More

Check out the VMware EUC blog post on developing enterprise applications with the Workspace ONE SDK here.

Getting Started with the vSphere Automation SDK for Python

We’ve been looking at how to get started using the new vSphere Automation SDKs. In the last couple parts of the series we looked at the SDK for REST, which included Postman REST client samples, as well as some JavaScript samples. This time, we’ll be looking at the vSphere Automation SDK for Python!

Prerequisites

There are a handful of ways to install and setup Python on your workstation, I will be walking through a high level configuration for my Mac.

First things first, clone the vSphere Automation SDK for Python from the VMware GitHub repository located here.

Cloning the Python SDK repo

After that’s complete, we’ll need to install the Python prerequisites. These include the GNU Complier Collection (GCC), a C compiler, and HomeBrew, a package management system.

GCC can be installed in multiple ways, but I’ve found it’s easiest to obtain it by installing the Xcode Command Line Tools. This can be done with the following command, then following the prompts:
xcode-select --install

XCode Installation

Next, we’ll need to install the package manager, Homebrew. It can be easily downloaded and installed with the following command: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Homebrew Installation

Finally, we’ll install Python in the recommended version of 3.6. It’s worth noting here that Mac OS X 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:
brew install python3

Python 3.6 Installation

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:
python3 -m venv SDKDemo
source SDKDemo/bin/activate

Creating a virtual development environment

Lastly, 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:
pip3 install -r requirements.txt

Requirement Installation

One other item worth mentioning is an IDE. This will make editing, running and debugging the code a lot easier to deal with. I’ll be using PyCharm, which is available here.

Running Sample Setup Script

To really show off the capabilities of the SDK, there’s a sample script which takes an un-configured vSphere environment and performs all of those normal configuration steps. The environment requirements to run the script are as follows:

  • 1 vCenter Server
  • 2 ESXi Hosts
  • 1 NFS Datastore (minimum of 3GB free)

We’ll first need to open up the testbed.py file and populate lines 17 through 29 as follows:

Modification of the Testbed File

We’re now ready to set the environment up with the sample script! However, before running the script we should take a look at what it’s doing. The script is available in the SDK directory at: /bin/run_sample.sh The goal of the script is to do the following actions:

  • Create 2 Datacenters
  • Create a Cluster
  • Create Test Folders for VM Storage
  • Attach the Hosts
  • Create a Distributed Switch
  • Create a Distributed PortGroup
  • Attach the NFS Datastore (if Selected) to the hosts
  • Copy the Photon OS ISO image downloaded from VMware’s bintray server to the Datastore
  • Create directories to add sample ports

One note before running the script, the ISO image being downloaded is roughly 200MB and could take a while depending on your bandwidth. My tests ranged anywhere between 30 seconds and 5 minutes.

The sample script can be run with the following command:
./run_sample.sh ../samples/vsphere/vcenter/setup/main.py –sv

Configuring an environment with the main.py file

Create a VM with Defaults

Now that our environment is setup, let’s take a look at adding a VM to this environment. The easiest way is to create a default VM. This action means the API takes care of all the configuration settings based on the Guest OS version. There are some prerequisites that are required for placement such as desired datacenter, VM folder, and datastore. These are all referenced from the testbed.py configuration file we referenced in the first example.

Updating the Testbed File for VM Tasks

The VM can then be created with the following command:
./run_sample.sh ../samples/vsphere/vcenter/vm/create/create_default_vm.py –v

Default VM Creation Sample

Notice in the above example how even though we didn’t populate all of the settings, the VM received required items like a CPU, a disk, and so forth.

To verify the VM does indeed exist, we can obtain a list of VMs with the following command:
./run_sample.sh ../samples/vsphere/vcenter/vm/list_vms.py –v

List VMs Sample

VM Power Actions

The next logical step after creating a VM is to power it on. There’s a sample within the vm folder named power.py, which shows off all of the power actions. This file references the ‘VM_NAME_DEFAULT’ input from the testbed.py file.

When running the command as is, the VM will be put through the following power states:

  • Obtain current power state
  • Power Off (NOTE: Only if the VM is currently powered on)
  • Power On
  • Suspend the VM
  • Resume the VM
  • Reset the VM

The command can be run with the following:
./run_sample.sh ../samples/vsphere/vcenter/vm/power.py –v

VM Power State Sample

Summary

This post shows you how to easily get started with the vSphere Automation SDK for Python. It takes you through the setup of an entire environment, as well as using 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 SDK 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 the series:

vSphere Automation SDKs – Open Sourced!

It’s an exciting time! We have started the process of open sourcing our vSphere Automation SDKs! The first ones to be released are the Software Development Kits (SDKs) for REST and Python: https://vmware.github.io/vsphere-automation-sdk

Alan Renouf, the Product Line Manager for the vSphere Automation SDKs (among other things), has a great post detailing the significance of it over on the VMware Open Source blog: https://blogs.vmware.com/opensource/2017/03/09/integration-vmware-vsphere-using-new-open-sourced-software-development-kits

vSphere Automation SDK Open Source Logo

What to Expect

Open sourcing these SDKs are going to have a considerable impact on how they’re consumed, so what should you be expecting with these changes?

The biggest impact: these SDKs are available on GitHub, with no authentication required. Users can clone or download the repository locally or even fork it to their own GitHub account. The use of modern Github integrated tools can ensure these SDKs fit well into your development tooling and procedures.

The first part leads to the next big impact: the frequency of updates. These SDKs being on GitHub allow us to release updates, bug fixes, and other corrections on a much quicker basis!

One of the other big impacts this change is going to have is on contributions. We are actively seeking contributions! Regardless of whether it’s a new sample, an update, or even a request, we want to hear from you! We are dedicated in making these samples relevant to you and making your development experience easier and better than ever before. Please, let us know how we can help you do this.

Getting Started

There are a lot of ways to get started with this new method of access. The easiest way is to check each repo’s README and follow the instructions there.

However, let’s walk through an example. One of the simplest ways, downloading it directly from the SDK’s repo.

Using the vSphere Automation SDK for Python:
Repository Link: https://github.com/vmware/vsphere-automation-sdk-python

Click the “Clone or Download” button, selecting the “Download ZIP” option.
Find the downloaded zip file and expand it.

Downloading the vSphere Automation SDK for Python

Contributions

If you happen to hit an issue when using one of the SDKs in your environment, or if you’re doing something that doesn’t already exist as a sample, there’s a good chance someone else could benefit from that input. Therefore, we highly encourage contributions to these SDKs.

Each SDK will have the contribution and/or issue process documented in the README. However, I’ll provide an overview of both the sample and issue submission process.

Sample Submission:

  • Include information as part of the resource or folder’s README:
    • Author Name (basic contact info)
    • Date
    • Description (high level description)
    • Known Limitations or Dependencies
    • vSphere Version/s Developed and/or Tested (suggested, but not mandatory)
    • SDK Version/s Developed and/or Tested (suggested, but not mandatory)
    • Language Version/s Developed and/or Tested (suggested, but not mandatory)

Contribution Process:

  1. Follow the GitHub process
  2. Use one branch per sample or change-set
  3. Use one commit and pull request per sample
  4. Post the sample output along with the pull request
  5. If including a license with the sample, use the project license

Issue Submission: Each repo has their own “Issues” tab and should be used to submit any issues or requests

  1. Once on the “Issues” tab, click the green “New issue” button
  2. Provide a title and as much detail as possible in the comment section

vSphere Automation Issue Submission

If you’re submitting a sample, we also recommend adding them to the VMware Code Sample Exchange!

Wrap-Up

This transition to open source is a big step for us at VMware. This is also just one of the first steps of many which are focused on helping to enable developers and automation focused admins!

Keep an eye on this blog, the Open Source blog, and especially the vSphere Automation SDK page for all the exciting updates and additional news.