Hawtio & Apache jClouds
Hawtio & Apache jClouds
Join the DZone community and get the full member experience.Join For Free
I've spent some time lately working on an Apache Jclouds plugin for Hawtio. While there is still a lot of pending work, I couldn't hold my excitement and wanted to share...
What is this Hawtio anyway?
Whenever a cool open source project is brought to my attention, I usually subscribe to the mailing lists so that I can get a better feel of the projects progress, direction etc. Sooner or later there is always an email with the topic "[Discuss] - Webconsole for our cool project".
Such emails quite often end up in a long discussion about what's the best web framework to use, what should be the target platform and how the console could be integrated with upstream/downstream projects.
A very good example is Apache ServiceMix. ServiceMix runs on Apache Karaf, which runs on Apache Felix and also embeds Apache ActiveMQ and every single of those projects has its own webconsole.
The number of consoles grows so big, that users have to hire a personal assistance just to keep track of the URLs of each web console. Well, maybe that's an overstatement but you get the idea. And if we also take into consideration that some projects are bound to a specific runtime, while others are not then we have a perfect webconsole storm.
Hawtio solves this problem, by providing a lightweight HTML5 modular web console with tons of plugins. Hawtio can run everywhere as its not bound to a specific runtime, and its modular, which means that its pretty easy to write and hook your own plugins.
Writing plugins for Hawtio
Hawtio is a full client framework. Whenever it requires communication with the backend it can use rest. To make things easier it also use Jolokia that exposes JMX with JSON over HTTP. This makes it pretty easy to hook frameworks even if they don't already provide a rest interface, but expose things over JMX.
Once, the communication with the backend is sorted, its pretty easy to create a plugin. Hawtio uses AngularJS, which makes development of webapps a real pleasure.
The Jclouds plugin
Apache Jclouds doesn't have yet a rest interface, nor it has JMX support. Well actually it has pluggable JMX support as of 1.6.1-incubating release. All you need to do is to create a Apache Jclouds Context using the ManagementLifecycle module:
ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi). .credentials(identity, credential) .modules(ImmutableSet.<Module>of(new ManagementLifecycle(BaseManagementContext.INSTANCE))) .build();
Note: Users that are using the jclouds-karaf project, will get that for free (no need to do anything at all).
When the ManagementLifecycle plugin is used, it will create and register Apache Jclouds MBeans to JMX. If those mbeans are discovered by Hawtio, a new tab will be added in the Hawtio user interface:
|The main Jclouds plugin Page|
From there the user is able to browse all installed Apache Jclouds providers, apis and services. If for example, you have created a compute service context with the MangementLifecycle module, you'll be able to see in it under the " Compute Service" tab:
|List of Compute Services - Amazon AWS & A Stub service.|
By selecting one of the available services, a details bar appears, which helps you navigate to all service specific tabs. For a compute service its:
A detailed list of all running nodes, with the ability to reboot, destroy, suspend & resume a node.
A list of images, with an operating system filter.
|A blobstore browser|
|Visual representation of a route that polls EC2 for running instances and sends email notifications|
|Searching the logs for jclouds related errors|
|The code that generated the log entry|
This is only a first draft of the jclouds plugin and there are more cool things to be added, like executing scripts, downloading blobs and also have a better way of creating new services (the last is already supported but could be really improved).
If you want to see more of Hawtio in action you can have a look at James Strachan's demonstation of a Camel based iPaas which is basically Hawtio + Fuse Fabric + Apache Camel.
Published at DZone with permission of Ioannis Canellos , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.