jclouds/jclouds-labs — pull request #25 by nacx (2013-08-23 09:10:43+00:00)
Title: JCLOUDS-205: Do not create duplicated groups in Abiquo

Refactored the `AbiquoComputeServiceAdapter` to avoid creating more than one group with the same name, when creating multiple nodes concurrently.

There is a little room for improvement in this pull request, and I'd appreciate some advice. Currently I've overridden the [CreateNodesWithGroupEncodedIntoNameThenAddToSet#execute](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java#L118-L128) method to create the group before starting the creation of the nodes. This works fine, but there are two (not expensive, though) api calls that are going to be repeated for each deployed node, and I'd like to save them.

In order to do that, I'd need to pass a reference to the retrieved objects to the `createNodeWithGroupEncodedIntoName` method. This would require to also override the [CreateNodesWithGroupEncodedIntoNameThenAddToSet#createNodeInGroupWithNameAndTemplate](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java#L166-L169) method, and the [CreateNodesWithGroupEncodedIntoNameThenAddToSet#AddNode](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java#L75-L83) class, so I can invoke the new method with the additional objects. This has the counterpart that the new method would not be part of the [CreateNodeWithGroupEncodedIntoName](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/CreateNodeWithGroupEncodedIntoName.java) strategy interface.

So:

* Do not override those method and assume those repeated api calls.
* Implement the mentioned changes even if we end up calling a method that is not part of the strategy interface (which shouldn't be a problem and shouldn't cause side-effects).
* Does anyone have better/smarter ideas?

Thx!