当我尝试连接我的openstack时,我遇到了一些问题。我正在使用jclouds,这是我的代码:
context = ContextBuilder.newBuilder("openstack-nova")
.endpoint("http://xxx.xxx.xxx.xxx:5000/v2.0/")
.credentials("tenantname:username", "password")
.modules(ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule()))
.buildView(ComputeServiceContext.class);
service = context.getComputeService();
for(ComputeMetadata node: service.listNodes()) {
System.out.println("NODE: " + node.getId());
}
但总是会返回以下错误:
DEBUG [org.jclouds.rest.internal.InvokeHttpMethod] [main] >> invoking AuthenticationApi.authenticateWithTenantNameAndCredentials
DEBUG [org.jclouds.http.internal.JavaUrlHttpCommandExecutorService] [main] Sending request -1502473400: POST http://xxx.xxx.xxx.xxx:5000/v2.0/tokens HTTP/1.1
ERROR [org.jclouds.http.internal.JavaUrlHttpCommandExecutorService] [main] Command not considered safe to retry because request method is POST: [method=org.jclouds.openstack.keystone.v2_0.AuthenticationApi.public abstract org.jclouds.openstack.keystone.v2_0.domain.Access org.jclouds.openstack.keystone.v2_0.AuthenticationApi.authenticateWithTenantNameAndCredentials(java.lang.String,org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials)[tenantname, PasswordCredentials{username=username, password=*****}], request=POST http://xxx.xxx.xxx.xxx:5000/v2.0/tokens HTTP/1.1]
我正在开发eclipse和Intellij IDEA。我一直在检查代理配置,但一切正常。
拜托,有人可以帮助我吗?
谢谢!
答案 0 :(得分:0)
代码看起来不错,但如果您需要通过代理,则可能需要在jclouds中配置代理属性。类似于以下内容,具有正确的代理值:
Properties overrides = new Properties();
overrides.setProperty(Constants.PROPERTY_PROXY_HOST, "localhost");
overrides.setProperty(Constants.PROPERTY_PROXY_PORT, "8888");
您可以将属性传递给ContextBuilder的overrides
方法。
您还可以启用jclouds.wire
日志以查看正在发送的每个请求和响应。这将显示确切的网络错误或OpenStack安装返回的错误。看看:http://jclouds.apache.org/reference/logging/