čtvrtek 6. listopadu 2014

Deploy a bundle to RHQ with 10 lines of code using rhqapi.js

It's been a while ago, since I wrote rhqapi.js library that is being extensively consumed by RHQ QE team. Now I decided to push it to RHQ, so it can help as CLI module. This article tries to show how easy it is to deploy a bundle with rhqapi.js

In our example we'll write a simple script, that could run repeatedly and will upload & deploy our bundle to group of Linux platforms.

  • we need RHQ Bundle - simple bundle which just contains 1 file to be laid down
  • upload it to RHQ Server
  • create group of all Linux platforms (or skip if it already existed)
  • deploy our bundle - in case our bundle with given version already exists on server, it will just be redeployed

We'll need rhqapi.js (as it is not yet part RHQ CLI) and we'll add it to modules

cd rhq-remoting-cli-4.13.0-SNAPSHOT;
wget https://raw.githubusercontent.com/rhq-project/samples/master/cli/rhqapi/rhqapi.js -O samples/modules/rhqapi.js

The script:

Download the script and bundle and put it in rhq-remoting-cli-4.13.0-SNAPSHOT/bin.

Run:

./rhq-cli.sh -u rhqadmin -p rhqadmin -f deploy-bundle.js
Logging in with default host: [localhost]
Logging in with default port: [7080]
Remote server version is: 4.13.0-SNAPSHOT (26fc58f)
Login successful
Bundle uploaded to server
16:08:14 [INFO] Creating a group 'LinuxPlatformsGroup', with following children: '[10001] localhost.localdomain (Linux::Platforms)'
16:08:14 [INFO] Parameter baseName was not passed, using default : Root File System
Created bundle destination targetting to /tmp of 1 Linux platforms
Deploying to LinuxPlatforms
PageList[BundleVersion[id=10002,name=SampleBundle,version=1.0]]
16:08:25 [INFO] Bundle deployment finished with status : Success
Bundle has been deployed

There's more

rhqapi.js is much more powerful, there's set of examples on github and also JSDoc documentation

pátek 31. října 2014

Wildfly Extension Installer - maven plugin

I recently started to play with RHQ Metrics, especially WildFly Monitor subsystem. One thing I found annoying was copying over module to WildFly and registering it as server extension. As WildFly does not (yet) support adding extensions at runtime, I decided to write a maven plugin for it.

Plugin features

  • Install module - this is an easy one.Plugin requires a module zip file and just extracts it into your WF home.
  • Register extension - your module gets automatically added among server extensions
  • Register subsystem - if you supply subsystem xml file, plugin puts it's content to right place
  • Register socket-binding - if your subsystem requires to set socket binding and you supply socket-binding xml file, plugin puts it's content to right place
  • Support for domain.xml - all above applies to domain.xml as well, for subsystem and socket-bindings you just need to provide wich profiles and socket-binding-groups to affect.

Example usage

Prepare your module.zip (ie. using maven-assembly-plugin) see for example pom.xml and module-assembly.xml from wildfly-monitor project.

Setup your build:

Run plugin:
mvn wildfly-extension:deploy
For more details take a look at the plugin documentation.

Possible future enhancements

  • Restart server - plugin could optionally restart WildFly server after it has installed module and registered all stuff
  • Extract module only - add option to extract module without registering an extension
  • Assemble module - based on configuration and maven depenencies, plugin could generate module.xml and collect all required jars or directories
  • Add a way to uninstall module and extension from WildFly server

Ideas welcome!


Contribute

If you'd like to contribute, check out source code.