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().createNodesInGroup(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.

Reply via email to