One of the things I like most about my job is bringing together different technologies to produce useful outcomes. Therefore, as both a long-time member of the XenServer team, and a user and fan of Citrix’s Octoblu “integration of everything” platform, I was excited when the opportunity arose to spend time with the Octoblu team working on, amongst other things, an integration between both products.

As a result of this collaboration I’m pleased to announce the availability of a XenServer connector for Octoblu; this enables Octoblu flows to manage operations on XenServer hosts and clusters, turning the hypervisor into an IoT “thing”.

I’ll show you how to get started with the connector in a moment, but first let’s look at how everything fits together and what you can do with it.

XenServer-Octoblu-Connector architectureOctoblu connects services (e.g. web services via REST APIs) and things (such as physical devices or software entities) using its notion of “flows” – message-based visual programs. In this model a XenServer cluster is a thing which connects to Octoblu via a connector – an agent service that runs somewhere it can talk to the thing (XenServer’s XML-RPC API in this case) and to the Octoblu messaging platform (“Meshblu”).

The XenServer connector is available for Linux, Windows, or Mac. The Octoblu connector framework takes care of running the connector as a system service, keeping it up to date, and so on. The connector uses Octoblu’s secure platform to store XenServer credentials (using token-based authentication is a future goal). The connector waits for messages coming from Octoblu flows and on receipt, sends the relevant API command to XenServer, returning the output back to Octoblu.

The initial version of the connector can start and shutdown VMs by name. Over time we will add more functionality to the connector to expand the range of administration and monitoring tasks it can perform.

Possible use-cases for the connector include:

  1. start and shutting down VMs based on external stimuli such as an incoming text message
  2. creating a simple HTTPS REST API for managing VMs (using Octoblu’s HTTPS trigger tool)
  3. restarting VMs on a schedule (e.g. shutdown and restart every Sunday at midnight)

Getting started

Ready to get started? If you don’t already have an Octoblu account, sign up and have a play with the example flows and blueprints. Here’s a step-by-step guide to connecting XenServer with Octoblu.

Create a “thing” and download a connector

In the Octoblu web app navigate to the “Things” page and then the “All Things” tab. From here scroll down to find the “CITRIX” section and click on the “CITRIX XENSERVER” thing.

Select XenServer Connector from Octoblu's "All Things" page

You now have the option to choose a version of the connector. In general, you’ll always want to choose the latest version. So click “Use this Version”.

Choose the connector version

Octoblu will try to determine the right platform assuming that you will run the connector on the same PC that you are running the web browser on. If it gets it wrong, or you intend to run on a different platform, simply choose the right platform from the “Other Install Options” link. For this guide I’m using a Windows 64-bit desktop so I’ll use the detected platform. Click “Download for Windows x64”.

Download the connector

Save the downloaded file – this has a one-time password baked-into the image to enable the connector to register with Octoblu for your specific account and instance of the thing.

Save the downloaded connector installer

Unpack the downloaded zip file (e.g. right-click and “Extract All…”) into a folder

Extract the contents of the zip file

Run the MeshbluConnectorInstaller.exe application to install the connector – for initial testing and evaluation I recommend installing as the current user, rather than as an administrator – click “Begin Install”

Run the connector installer

Once installation is complete close the installer window and return to the Octoblu web app and click “Next: Configure”

After installation, move to configuration

You should now see a page that says “connector is running”. Click the “Open in Octoblu” button.

Confirm the connector is running

You can now set the credentials and URL for the XenServer host or cluster. Beware that this form will show the password back in clear text (adding token-based authentication is on the list for the future). For the URL you can simply enter an IP address. Click “SAVE”

Configuring the connector

Create a flow

The connector can be used in one or more Octoblu flows. The flow is the visual program the determines what happens to things based on incoming messages from other things or services. We’ll build a simple test flow that can start a VM.

Click on the “Flows” tab in the Octoblu web app then on the big “+” symbol to create a new flow.

Create a new flow

We’re now in the flow designer. Click the “Things” tab in the tool bar on the right hand side of the screen. From here click on the XenServer connector we just created.

Find the XenServer "thing"

You will now see the XenServer thing in the main part of the screen and a couple of dialogs in the right-hand tool bar. Firstly, click on “UPDATE PERMISSIONS” to allow the connector to send messages to this flow. Secondly, in the “THING INSPECTOR” dialog, select “Start a VM” from the “Message Type” drop-down, and enter a VM name in the “name” box. I’m using “MyVM”.

Set up the XenServer thing

Click on the “Tools” tab and scroll down to find the “Trigger” tool. Click this to deposit a trigger icon on the main canvas. You’ll need to click “UPDATE PERMISSIONS” again. Move (drag and drop) the trigger to somewhere to the left of the XenServer icon.

Add a Trigger tool

To connect the trigger to the XenServer thing click-and-hold in the grey box on the right hand side of the trigger icon and drag the mouse to the grey box on the left hand side of the XenServer icon, then release the mouse. This creates a connection between the things such that messages from the trigger are sent to the XenServer thing.

Connect the Trigger to the XenServer thing

We’re now ready to deploy the flow and try it out. Click the play button in the top right hand corner of the window.

Deploying the flow

Once the play button has gone green our flow is running. Check the test VM is not already running and click the triangle next to the trigger icon. You should see both icons pulse and then, if everything is working properly, the VM should start.

Activating the Trigger

VM running on XenServer

Advanced use

In the above guide we used the basic “Start a VM” message. This is great for simple cases but what if you want programmatic control of the operation to perform (in contrast with the manual selection from a drop-down list here)? One option is to use Octoblu’s “Use Incoming Message” option for the XenServer thing – this removes all the drop-downs and other editable fields and instead expects the incoming message (from the Trigger tool in the above example) to be suitably structured with the message type and parameters. Doing this requires knowledge of the object structure used to invoke connectors and therefore can be difficult to do correctly and could be fragile.

Instead a more generic message type can be used: “Execute a VM lifecycle operation” (available from version 1.1.4 of the XenServer connector) with the specific operation (“start”, “shutdown” or “reboot”) supplied as a parameter along with either the VM’s name or UUID. To use this programmatically we can use Octoblu’s mustache syntax: this pulls out individual fields from the incoming message using double braces: for example “{{msg.operation}}” extracts the “operation” key from the message object.

A simple example is to have three separate triggers for each of the three available lifecycle operations. We’ll hard-code the VM name for now (that could also be supplied programmatically with mustache syntax if desired) but provide the operation as part of the message sent to the XenServer thing. To start with we’ll create three instances of the Trigger tool and for each we’ll use the “THING INSPECTOR” to configure a payload type of “String” with a payload of “start”, “shutdown” and “reboot” respectively.

Configuring trigger tool payloads

Next we’ll connect the three triggers to our existing XenServer thing and change the XenServer thing’s message type to “Execute a VM lifecycle operation”, leave the name as “MyVM”, and set the operation to “{{msg.payload}}” to take the operation from the message generated by the Trigger. After clicking the green play button to restart the flow we can test it by pressing each of the Triggers (using the little triangle like we did earlier) and checking that the appropriate VM action took place.

Using mustache syntax to programmatically drive the connector

In conclusion

XenServer joins a growing list of Citrix products that can be managed and automated with Octoblu. As we get more of the Citrix stack connected to Octoblu, administrators will be able to build their own customized workflows to automate actions at multiple layers of the stack in a single flow. The flexibility brought by the Octoblu platform means it is easy to bring external services and devices into the mix and integrate them with Citrix stack automation. Stay tuned for my next blog post where I’ll show how to connect the Slack messaging platform to XenServer to enable natural-language administration of the hypervisor.

I hope you found this blog post to be a useful and informative guide to getting started with automating XenServer using Octoblu. Please do share your experiences and feedback, either in the comments here or via Twitter (@jamesbulpin); in particular, I’d love to hear which XenServer tasks/commands you’d like to be able to use via Octoblu and which use-cases and workflows you want to automate.

octoblu banner