Our developers are talking about REST all of the time, with good reason. REST (REpresentation State Transfer) as you’ve read about here in an early article from our DevOps series, is an important part of Service Oriented Architecture and Resource Oriented Architecture. This is important to Systems Administrators and Ops teams because it is becoming a key component in managing many software-defined environments.
Let’s take a look at some key components of understanding the value of REST for the Ops team.
We refer to RESTful API usage when we are talking about the way that most SDDC (Software-Defined Data Center) components are managed. It isn’t that everything is done by an API call, but it is a desired way in which the underlying layers are abstracted. REST is based on a common set of HTTP verbs which are neatly described with the acronym CRUD (standing for Create, Read, Update, and Delete). These 4 verbs allow us to interact with objects and perform many actions against them.
As an example, we can look at the way that VMware vCloud exposes its REST API and from there we see that to perform actions such as create a VM, query a catalog, and much more. We can also use a REST API to interact with vCloud Orchestrator, and the new vRealize Orchestrator in a similar fashion.
In OpenStack environments, every administrative action is able to be performed via a RESTful API. In the same way that we can interact with VMware vCloud, we can also view the OpenStack APIs and do things such as create an instance, delete an instance, manage the power state, create users, networks and everything in between.
Those are just the infrastructure components for the hypervisor and cloud management, but that same methodology extends out to hardware and other software components, which provide a REST API to interact with. While many administrators may not use REST as a primary method of managing their data center and cloud infrastructure, it introduces powerful options when creating orchestration and service catalog workflows.
Making your Ops More Dev in the DevOps World
There are a lot of people making the move towards what we call Infrastructure-as-Code. This is a shift in how we manage our infrastructure components where we include repeatable scripts and orchestration runbooks into the deployment framework. A great example is where we use configuration management tools like Puppet and Chef to manage application infrastructure and server configuration. As a part of the runbook, we can also include the application code deployment recipes so that the entire build process from server up to application is a repeatable script.
That may be the deep end of the pool for a lot of people getting started with the DevOps methodology, so it is also important that we look at the first steps to get closer to those full-stack deployment recipes. Because we are concentrating on RESTful methods here, let’s take a look at a couple of practical examples of simple ways to use REST with command line tools.
With Linux and *Nix derivatives, the most common command line tool that we see is called cURL, or Command line URL. By using cURL, we can issue HTTP requests using the traditional HTTP verbs as we talked about earlier. A good practical example of this would be something on an OpenStack system where we want to query our OpenStack cloud for some information.
OpenStack uses tokens as an authentication method, so we would need to request a token using a username and password combination, which would then give us a token to use for making queries as long as the token is active. Using our cURL utility, we issue the command as shown here which would reply with a token for us to use in a JSON result:
Now, we have our token to be able to query our OpenStack cloud and we can easily list out the available tenants from Keystone, the OpenStack Identity project. Using a simple command line we will retrieve the list of tenants, which can be used in a variety of ways by other scripting and orchestration tools:
For Microsoft-centric deployments, we see PowerShell as a great tool for scripting. There is a cURL for Windows also, but rather than using a third-party tool, we could also start to lean on the native capability of the Invoke-RESTMethod CmdLet as I’ve illustrated here: http://www.discoposse.com/index.php/2012/06/30/powershell-invoke-restmethod-putting-the-curl-in-your-shell/
These are small and simple examples of how to use RESTful queries to gather information in a couple of ways. What we are trying to reinforce is that having a good understanding of API usage and REST concepts is important as an Ops team because we can both enhance the way that we do things, plus we can have a stronger understanding of what the Dev teams are doing. More awareness will create a better relationship, plus it makes us better at what we do.
In a software-defined universe, REST is best!