Purging Integra, Using Integra

  • Posted on: 29 July 2015
  • By: David La Motta


...or like the old adage goes, we like to eat our own dog food.  See, with the Apply Logic action we can do RESTful calls straight into the Reactor, which essentially gives us the ability to operate on Integra from Integra itself.  In this very short blog post we are going to show you how we use a Groovy script from within Integra itself to do a complete purge of the system. 

A word of caution: this is a VERY destructive example.  Please take care to export any workflow to GitHub you may wish to preserve, as the script below will essentially nuke all of your Integra data.

The Problem

In using Integra over time, you will create actions, try them out, clone them, add some more actions... until you realize that you have an excess of baggage that you may want to get rid of.  You can certainly delete things from the UI, or organize actions using tags, but the OCD in me likes to keep things neat and tidy: only keep what we are using, the rest can be nuked as far as I am concerned.  In this particular scenario I want to nuke everything so that I can start with a clean slate, no baggage left behind whatsoever.  

Let's see what we are starting out with below.



The Solution

The solution consists of a Groovy script that does RESTful calls to the Integra Reactor orchestrating all the providers and actions above.  The script is part of an Apply Logic action which we will execute directly from the Actions tab.  Let's check out what the script looks like:



The first line downloads and installs the HTTPBuilder library on the fly, and then we proceed to delete schedule results, schedules, workflows, actions and providers.  Just so that we don't pull the rug from underneath our own feet, we will skip anything that starts with an underscore (see the straightFace variable on line 10 :-). You may get more creative and look for other things such as a tag or a different character; the point is to be careful and not shoot yourself in the foot.

You can take this script and run it from the command line or, like we are doing, you can copy and paste it into an Integra advanced Apply Logic action.   The last line returns a maps with information on the amounts of items that were deleted.



Actions of Mass Destruction

Now that we have our _Nuke action we can simply click on the green execute button to run it.  After we drop our bomb the only things standing will be the _Nuke action and the provider that hosts it, called _SSH (as you can see in the image above).  The results display the contents of the postMortem map defined in the script above.

We deleted 7 schedule results, 3 schedules, 4 workflows, 32 actions and 5 providers in the blink of an eye.




As promised, only our _Nuke action and _SSH Provider remain.



Conclusion

This quick blog shows the power of Integra in a very succinct way.  You don't have to step outside of the world of Integra to script solutions that manipulate Integra, or to execute scripts that talk to any other web services.  Moreover, you can now store those scripts in GitHub straight from Integra so that they are available to you, your peers or your customers.

In summary: if there is anything that Integra doesn't give you out of the box today, know that there is a way to do it via this scripting mechanism.  The opportunities for doing great things with Integra are ripe for the taking.  Rule your IT world!

Happy nuking (and please be careful)!

--