You need to create a Properties object and add the following property to it:
properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "true”); and set that via the builder.overrides(). That should do the trick. -Chris -- Chris Custine On July 26, 2014 at 4:46:00 PM, merlinlabs ([email protected]) wrote: > Can someone please explain what I need to do to have jclouds/openstack > auto-assign a floating ip on a node creation? I am trying to connect to > the node to execute on it but it times out with the "600000" msec error > and I suspect it is because it needs an ip alias to connect through. > > The '.floatingIpPoolNames("public")' property does not appear to be > enough to facilitate this. > > This fails on versions 1.7.4 and 1.8.0 ( the option was not even > available in 1.7.3). > > The controller OS is Centos 6.5. > Openstack is on icehouse. > > I have attached a horizon image of the node, post-creation. > > I have attached the code below. > > Thanks > -danR > > > > > > //import static com.google.common.collect.Iterables.concat; > import java.io.Closeable; > import java.io.IOException; > import java.util.Map; > import java.util.Map.Entry; > import java.util.Set; > > import org.jclouds.ContextBuilder; > import org.jclouds.compute.ComputeService; > import org.jclouds.compute.ComputeServiceContext; > import org.jclouds.compute.domain.ExecResponse; > import org.jclouds.compute.domain.NodeMetadata; > import org.jclouds.compute.domain.OsFamily; > import org.jclouds.compute.domain.Template; > import org.jclouds.compute.options.TemplateOptions; > import org.jclouds.openstack.nova.v2_0.NovaApi; > import > org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions; > import org.jclouds.sshj.config.SshjSshClientModule; > > import com.google.common.collect.ImmutableSet; > > public class Fip implements Closeable { > private ComputeService compute; > // private RestContext nova; > private Set zones; > private NovaApi novaApi; > public static void main(String[] args) throws IOException { > Fip jCloudsNova = new Fip(); > > try { > jCloudsNova.init(); > } > catch (Exception e) { > e.printStackTrace(); > } > finally { > jCloudsNova.close(); > } > } > > private void init() { > System.out.println(" vvvvvvvvvvv init: " ); > > ComputeServiceContext context = > ContextBuilder.newBuilder("openstack-nova") > .endpoint("http://192.170.0.105:5000/v2.0/") > .credentials("demo:demo", "demo") > .modules(ImmutableSet.of(new SshjSshClientModule())) > .buildView(ComputeServiceContext.class); > > try { > System.out.println("Execute 'context.getComputeService()' "); > ComputeService compute = context.getComputeService(); > TemplateOptions options = compute.templateOptions(); > System.out.println("Execute 'build template' "); > Template template = compute.templateBuilder() > .osFamily(OsFamily.UBUNTU).minRam(2000) > .options(options.as(NovaTemplateOptions.class).generateKeyPair(true).floatingIpPoolNames("public")) > > .build(); > System.out.println("Execute 'createNodesInGroup(mygroup, 1, > template)' "); > compute.createNodesInGroup("mygroup", 1, template); > System.out.println("Back from 'compute.createNodesInGroup(mygroup, 1, > template)' "); > Map responses; > try { > System.out.println(" execute on the node .. "); > responses=compute.runScriptOnNodesMatching(// > > org.jclouds.compute.predicates.NodePredicates.inGroup("mygroup"), > "uptime"); > } catch (Exception e) { > responses = null; > e.printStackTrace(); > } > System.out.println(" process response .. "); > for (Entry response : > responses.entrySet()) { > System.out.printf("<< node %s: %s%n", > response.getKey().getId()+":"+ > response.getKey().getPrivateAddresses(), > response.getKey().getPublicAddresses()); > System.out.printf("<< %s%n", response.getValue()); > } > } catch (Exception e) { > e.printStackTrace(); > } > } > @Override > public void close() throws IOException { > System.out.println("close(): " ); > // TODO Auto-generated method stub > > } > > } >
