gpt4 book ai didi

java - 如何在 Java 中启动一个新的 OpenStack 实例?

转载 作者:行者123 更新时间:2023-12-02 12:39:01 25 4
gpt4 key购买 nike

我试图通过引用下面的 URL 在 Java 中启动新的开放堆栈实例。

https://help.dreamhost.com/hc/en-us/articles/216456877-How-to-launch-and-delete-OpenStack-instances-using-Java-and-Jclouds

这是我的 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、 flavor 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}}]

最佳答案

您必须指定用于启动实例的风格、镜像和网络。我看到你已经指定了 flavor 和形象。但是,您还必须指定要使用的网络。检查以下链接中的答案

jcloud_create_instance_with_network

关于java - 如何在 Java 中启动一个新的 OpenStack 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45013893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com