č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