I was trying to launch new open-stack instance in Java by referring below URL.
And here is how my createInstance method looks like :-
public void createInstance(String instanceName) {
for (String region : regions) {
ServerApi serverApi = novaApi.getServerApi(region);
System.out.println("server api : " + serverApi.toString());
String imageId = "7d246e9a-dd2a-4342-97f7-32accd0f9c35";
String flavorId = "8041379d-7261-401d-90cf-e2d97184fe94";
/*Launch an instance*/
ServerCreated ser = serverApi.create(instanceName, imageId, flavorId);
Server server = serverApi.get(ser.getId());
while (server.getStatus().value().equals("ACTIVE") == false) {
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
server = serverApi.get(ser.getId());
}
System.out.println(ser.getId());
}
}
I am getting HttpResponseException but able to get image Id, flavor Id etc.
exception : org.jclouds.http.HttpResponseException: command: POST http://192.168.1.224:8774/v2/e02b6387fa5a4b619bc2ba554661ea99/servers HTTP/1.1 failed with response: HTTP/1.1 400 Bad Request; content: [{"badRequest": {"message": "Multiple possible networks found, use a Network ID to be more specific.", "code": 400}}]
You have to specify the flavor, image and networks to be used to launching an instance. I see you have specified the flavor and image. However, you also have to specify the networks to be used. Check the answer in the below link