Got PowerShell? Let Integra expose it via REST

  • Posted on: 13 March 2015
  • By: David La Motta


No kidding, right?  With Integra, you can expose _any_ PowerShell (PS) module's cmdlets as Integra actions in a matter of minutes and without writing a single line of code.  The beauty of this is that now your PS benefits from everything Integra provides.  To name a few, your PS module gets:

  • authentication (see the different types we support)
  • an automatically generated REST API
  • access via SDKs in 8 programming languages
  • remote execution via Integra's CLI
  • remote execution via Integra's mobile portal
  • ...and more
In this post I am going to concentrate on showing you what you need to do to expose your PS cmdlets via REST.  The PowerShell module we are going to use in this example is the Nimble PS module provided by Justin Rich (thanks, Justin!).  As you will see, you could follow the same steps for any other PowerShell module.

Requirements

There are only a few things you will need to follow this awesome example:

  1. Integra--get a free trial here.  The PowerShell Provider is in beta as of this writing, so please make sure to request it.
  2. vCenter Server Appliance for the Integra vCenter plugin
  3. Nimble PS module
  4. CentOS VM for hosting Integra
  5. Windows VM for hosting the PS module
We are going to end up with a wildly distributed application, on purpose.  Technically speaking, you could run absolutely everything from a single Windows machine, but that would be no fun.  Instead, we will have the Integra Reactor running on CentOS communicating with the PowerShell provider running on Windows.  Connecting to the vCenter client and REST endpoint will be done from my laptop.  It is very important to mention that direct communication with the providers is not allowed; instead, the Reactor acts as the gatekeeper to the provider for a number of reasons: security, communication, scheduling, among other things.

Get Ready

I am not going to cover installing Integra, as that is detailed here and here.  Instead, we'll assume that Integra is up and running on that CentOS VM, and the PowerShell provider is running on the Windows VM.  Our CentOS VM is running in a datacenter here in the RTP area of NC, and our Windows VM is running in the Azure cloud.  Your environment should look similar to the following image.



Get Set

With Integra configured and the Nimble (our PS provider in disguise) provider connected, the next thing to do is to install the Nimble PS module on your Windows VM.  This allows us to import it into the Integra runspace.  Create a new action called Import Module, set the Name field to Nimble, and execute the action.  Now the Nimble module's cmdlets are all available as Integra actions, ready to be configured and executed.  It doesn't get any simpler than that!



Go

Now that the hard (right?) part is over, let us take a look at what the REST API looks like.  We will configure one action and show you the XML that is returned by the Integra Reactor.  With that in hand, you can use Integra's REST model to execute any action that you may have configured (as in this example).  You can change parameters to match your environment via REST, so you have all the control over what gets set and executed.




You can either interact with Integra's REST API via JSON or XML.  For example, our newly configured action Connect Nimble Array looks like this:



The parameters have been previously set in the Integra vCenter UI, but nothing prevents you from altering those values before sending the REST request.

Conclusion

In this short post we saw how to expose a PowerShell module via REST using Integra.  There are extremely important takeaways from this example--do not let its simplicity fool you into thinking that this doesn't pack a punch:

  1. Time to market: the speed of adding new functionality to Integra is unparalleled via the PowerShell provider.  If you have a PowerShell module, you can import it and start using it right away.
  2. PowerShell cmdlets normalized into Integra actions can now be piped, be executed sequentially or concurrently, use Integra variables, be scheduled or ran on demand, have validation in the UI, etc.
  3. An otherwise confined-to-Windows PowerShell module can have a new meaning in life and be accessed from anywhere via REST.  This means that you can concentrate on providing the best PowerShell module you possibly can, and letting Integra handle the REST (pun intended :-).
  4. True cross-platform operations are now a reality.  You may have an Integra workflow that executes a core Windows PowerShell action, whose output is fed to an action on Linux, whose output is fed to the Nimble array, and at the end everything is packed in an email and sent to you.  The possibilities become endless.
  5. Integra provides SDKs in many different languages.  REST is not your cup of tea?  With Integra you can execute the same PowerShell cmdlets from Java, Python, Ruby or more by leveraging the Integra SDKs.
At Emitrom we are extremely excited about this new PowerShell provider; it is currently in beta, and we have a few more goodies that we are adding as we speak.  Do drop us a line if you have any questions.  You can always find us via Google+, Twitter, LinkedIn, or Facebook.

Happy RESTing  ;-)

--