I think that's a great idea! I was thinking along those same lines as well but wasn't sure if that was too destructive of a change. I'll put something together and send it in. Thanks Ignasi.
-----Original Message----- From: Ignasi Barrera [mailto:ignasi.barr...@gmail.com] Sent: Thursday, July 03, 2014 4:03 AM To: dev@jclouds.apache.org Subject: Re: On getting variables from NovaTemplateOptions to AllocateAndAddFloatingIpToNode I wouldn't use the node metadata as a "transport" for the properties between methods. Instead, I would: * Create a new type to transport the information, say NodeAndOptions or NodeAndTemplate, that has a reference to the NodeMetadata and to the TemplateOptions (or Template). * Modify the deflaration of the AllocateAndAddFloatingIpToNode class to accept that type as an input. * Modify the ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet here [1]. That line transforms each node with the function to allocate and add the IPs. You could chain the transformations: first convert them to NodeAndOptions and then apply the allocation IP function. WDYT? I. [1] https://github.com/jclouds/jclouds/blob/master/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java#L155 On 3 July 2014 02:42, Dancy, Chris <chris.da...@pega.com> wrote: > Hey Guys, > > So this is with respect to the PR here: > > https://github.com/jclouds/jclouds/pull/425#issuecomment-47813143 > > PR is actually good and fixes the bug where inside > "AllocateAndAddFloatingIpToNode.apply()" we get a null returned when calling > "FloatingIpApi.create()". The solution however is to iterate over > "FloatingIpApi.list()" searching for an available FloatingIP. This works but > I wonder if we can do better. We have the method > "FloatingIpApi.allocate(String poolName)" which works if you pass it in a > valid floating-ip-pool-name. The problem is how to get a pool-name down to > "AllocateAndAddFloatingIpToNode.apply()" which is called way down the chain > when invoking ComputeService.createNodesInGroup() like below: > > NovaTemplateOptions options = > NovaTemplateOptions.Builder. > > autoAssignFloatingIp(true). > > blockUntilRunning(true). > > securityGroupNames(securityGroups); > > Template template = > computeServiceContext.getComputeService().templateBuilder(). > imageId(imageID). > > hardwareId(hardwareID). > options(options). > build(); > > Set<NodeMetadata> groupNodes = > (Set<NodeMetadata>)computeServiceContext.getComputeService().createNod > esInGroup(groupName, count, template); > > The ideal solution, IMO, would be to alter the above NovaTemplateOptions to > do something like: > > NovaTemplateOptions options = > NovaTemplateOptions.Builder. > > autoAssignFloatingIp(true). > > floatingIpPoolNames(String ...poolNames). // adding this method call to set > pool names > > blockUntilRunning(true). > > securityGroupNames(securityGroups); > > problem is I've no idea, short of changing the TemplateOptions class which > looks to be a no-no, to get it down to > "AllocateAndAddFloatingIpToNode.apply()". Now one thing that did work, though > I'm not sure if others would approve, is to set the pool-names inside > NodeMetadata.getUserMetadata() (which returns a map) much earlier on in the > call chain, which is possible, and then check for their existence inside > "AllocateAndAddFloatingIpToNode.apply()" once we reach that point. I've > gotten this to work but was not sure if there was a better I'm completely > missing. Thoughts and ideas are more than welcome.