如何在 Java 中启动一个新的 openstack 实例?
How to launch a new openstack instance in Java?
我试图通过参考下面 URL 在 Java 中启动新的 open-stack 实例。
这是我的 createInstance 方法的样子:-
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());
}
}
我收到 HttpResponseException,但能够获取图像 ID、风味 ID 等
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}}]
您必须指定用于启动实例的风格、图像和网络。我看到你已经指定了风味和图像。
但是,您还必须指定要使用的网络。检查下面的答案 link
jcloud_create_instance_with_network
我试图通过参考下面 URL 在 Java 中启动新的 open-stack 实例。
这是我的 createInstance 方法的样子:-
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());
}
}
我收到 HttpResponseException,但能够获取图像 ID、风味 ID 等
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}}]
您必须指定用于启动实例的风格、图像和网络。我看到你已经指定了风味和图像。 但是,您还必须指定要使用的网络。检查下面的答案 link
jcloud_create_instance_with_network