On Mon, 2010-04-26 at 15:36 +0100, Eoghan Glynn wrote:
Folks,
I've pushed the first cut of a CLI client using the command completion
infrastructure from the Apache Felix Karaf shell. Its on a remote branch
called "cli", only VM-related commands for now.
Nice work!
Some of the things that make this nice include:
- auto-completion (e.g. 'vms:start vm<tab>' completes matching vms)
- auto-generated help docs
- nice error handling from the karaf core itself
I like it, but as we discussed earlier it probably won't be usable as a
tool to run from shell scripts e.g.
#!/bin/bash
for vm in $(rhevmadmin vms:list); do
rhevmadmin vms:start $vm
done
as the shell itself is so heavyweight. That probably means it only makes
sense as an interactive admin console.
Also, we might be setting ourselves up for a bit of quagmire (given the
dependencies) if/when we decide to package it as an RPM.
Still, the more different style clients we have, the better - it's a
great way to validate the API design.
Mark - can you cast your eye over this before I push it up to master?
It all looks good to push, the comments below are all minor
Some comments/questions:
- the api package is now a 'bundle' ... so, a bundle is just a jar
with some extra stuff in MANIFEST.MF ... what would happen if we
wanted to add some other metadata to the manifest? Just a
theoretical question, but it seems a little wrong that our core
would be a bundle just for the sake of the cli. Ignore me, it's not
an issue and I'm just being ignorant about OSGi :)
- features.xml confused me for a minute:
+<features>
+ <feature name="rhevm-api-cli">
+ <feature>cxf-jaxrs</feature>
+
<bundle>wrap:mvn:org.jboss.resteasy/resteasy-jaxb-provider/2.0-beta-2</bundle>
+
<bundle>wrap:mvn:org.jboss.resteasy/resteasy-jettison-provider/2.0-beta-2</bundle>
+ <bundle>mvn:com.redhat.rhevm.api/rhevm-api/0.1-SNAPSHOT</bundle>
+ <bundle>mvn:com.redhat.rhevm.api/rhevm-api-cli-vms/0.1-SNAPSHOT</bundle>
+ </feature>
+</features>
that means that the rhevm-api-cli feature depends on the cxf-jaxrs
feature (we're using CXF's REST client here), the jettison/jaxb
providers (because the api jar requires them) and then the two
bundles for the cli itself. Right?
- can we do better error handling here:
+ protected void doAction(String action) throws Exception {
...
+ System.err.println("VM[" + name + "] not found.");
- the api jar has a Link header parser you could use
- This looks dubious to me:
+ try {
+ VMs vms = vmClient.getVMs();
+ for (VM vm : vms.getVMs()) {
+ delegate.getStrings().add(vm.getName());
+ }
+ } catch (Exception e) {
+ // Ignore
+ }
what exception are you ignoring here exactly?
- In the toplevel POM, felix.karaf.version isn't needed, but it might
be nice to have a property for the maven-bundle-plugin version
Cheers,
Mark.