0

Can someone help me understanding how to assign a specific network to a newly created VM using the JClouds API in OpenStack? I'm using following code to create the real server:

CreateServerOptions[] serverOptions = new CreateServerOptions[0];

ServerCreated serverCreated = serverApi.create(clonedVmName, imageId, FlavourId, serverOptions);

Also I'm using v1.0-quantum APIs to fetch all the networks as follows but it's not returning any. I'm not sure what's wrong with the following code:

Iterable<Module> modules = ImmutableSet.<Module> of(
              new SLF4JLoggingModule());

      quantum = ContextBuilder.newBuilder(provider)
            .endpoint("http://10.37.53.229:5000/v2.0/")
            .credentials(identity, password)
            .modules(modules)
            .build();


      QuantumApi quanApi =  (QuantumApi)quantum.getApi();
      for(String zone : quanApi.getConfiguredZones())
      {
          System.out.println("Zone : "+ zone);
      }

      NetworkApi netApi = quanApi.getNetworkApiForZone("RegionOne");
      FluentIterable<? extends Network> nets = netApi.list();

      for(Network net : nets)
      {
          System.out.println(net.getName() +" Id : "+net.getId());
      }
Floern
  • 33,559
  • 24
  • 104
  • 119
  • The Neutron (previously Quantum) APIs have been updated in jclouds 1.7.0. Can you give those a try? See [how to install the OpenStack dependencies](http://jclouds.apache.org/documentation/quickstart/openstack/#install). – Everett Toews Jan 17 '14 at 18:15

1 Answers1

0

I use version 1.7.3 of JClouds and I build the options in the following way, giving network ids as parameters:

 CreateServerOptions options = CreateServerOptions.Builder
       .networks("00000000-0000-0000-0000-000000000000", "11111111-1111-1111-1111-111111111111")

As for listing networks here are good examples.

dzezzz
  • 985
  • 7
  • 17