Creating Groups by VM Guest OS with the Turbonomic API

Document created by discoposse Expert on Oct 17, 2016Last modified by discoposse Expert on Oct 21, 2016
Version 3Show Document
  • View in full screen mode

One of the first things that I do when setting up a Turbonomic instance is to create a set ofdefault groups.  As you know, we have the ability to use either static or dynamic group membership, and for flexibility, dynamic ensures that the group member ship is continuously up to date.Make-an-API.jpg


When we think about policy management in general, it always should start with "what do we want to apply the policy to?" which leads us to creating good groups for more granular control within the environment.  If nothing, it just makes it super easy to browse through your inventory to profile certain machines.


Making groups is simple but since I'm all about leveraging an API wherever I can, this is something that may help you with setting up a few samples.


What you need:

  • cURL - available for all OS types here:
  • Your Turbonomic instance IP or DNS hostname
  • Your Turbonomic instance credentials with administrative privileges (username and password)


Crafting the cURL command


We are using the traditional API for this first example.  There will be more posts coming as we look into using the new API for the same capabilities in the coming weeks.


Data that we pass to the API include the following:

  • groupName=AllWindowsVMs
  • seType=VirtualMachine
  • reportEnabled=False
  • xmlId=vmsByGuestName
  • expVal=.*Windows.*


These parameters mean that we are creating a group named AllWindowsVMs where the selection is Virtual Machine, we aren't creating a report of the group, the selection criteria is vmsByGuestName and the value of the RegEx will be .*Windows.* which is the same as doing this in the UI:


This gives us the data section of what we will pass to cURL:


--data "groupName=AllWindowsVMs&seType=VirtualMachine&reportEnabled=False&xmlId=vmsByGuestName&expVal=.*Windows.*"


We also need to have the URL section which will use the following format:




Replace the USERNAME with your username.  Replace the PASSWORD with your password.   Replace the INSTANCEURL with your IP address or DNS hostname of your Turbonomic instance.  It's just that easy!  You can see from the URL we are using that we target the groups (/vmturbo/api/groups).


This is what the command line will look like to use the API based on the sample we have shown above:


curl --data "groupName=AllWindowsVMs&seType=VirtualMachine&reportEnabled=False&xmlId=vmsByGuestName&expVal=.*Windows.*" http://USERNAME:PASSWORD@INSTANCEURL/vmturbo/api/groups


After running the command, you can refresh your groups view and you will now see this:




Yay!  Now we know how to create groups by just passing the name and RegEx parameters to the cURL command.  Let's try a couple of other samples.


Group Name: AllLinuxVMs

RegEx: .*linux.*



curl --data "groupName=AllLinuxVMs&seType=VirtualMachine&reportEnabled=False&xmlId=vmsByGuestName&expVal=.*linux.*" http://USERNAME:PASSWORD@INSTANCEURL/vmturbo/api/groups


Group Name: AllUbuntuVMs

RegEx: .*ubuntu.*



curl --data "groupName=AllUbuntuVMs&seType=VirtualMachine&reportEnabled=False&xmlId=vmsByGuestName&expVal=.*ubuntu.*" http://USERNAME:PASSWORD@INSTANCEURL/vmturbo/api/groups


Group Name: AllCentOSVMs

RegEx: .*centos.*



curl --data "groupName=AllCentosVMs&seType=VirtualMachine&reportEnabled=False&xmlId=vmsByGuestName&expVal=.*centos.*" http://USERNAME:PASSWORD@INSTANCEURL/vmturbo/api/groups


You can see the pattern.  This makes it easy to take our example and expand out further with doing the same for other parameters and groupings.


Some API examples are available at my GitHub repo here:  GitHub - discoposse/turbonomic-api-examples: API Samples for Turbonomic using the legacy and new API


Hope this is helpful!

4 people found this helpful