简体   繁体   English

jclouds的第一步

[英]First steps in jclouds

I'm having some problems when I try to connect with my openstack. 尝试连接OpenStack时遇到一些问题。 I'm using jclouds and this is my code: 我正在使用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());
    }

But always it return the following error: 但始终会返回以下错误:

 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]

I'm developing in eclipse and Intellij IDEA. 我正在Eclipse和Intellij IDEA中进行开发。 I've been reviewing the proxy configuration, but everything is normal. 我一直在审查代理配置,但是一切正常。

Please, can anyone help me? 拜托,有人可以帮我吗?

Thanks! 谢谢!

The code looks good, but if you need to go through a proxy you may need to configure the proxy properties in jclouds. 代码看起来不错,但是如果您需要通过代理,则可能需要在jclouds中配置代理属性。 Something like the following, with the right values for your proxy: 类似于以下内容的代理具有正确的值:

Properties overrides = new Properties();
overrides.setProperty(Constants.PROPERTY_PROXY_HOST, "localhost");
overrides.setProperty(Constants.PROPERTY_PROXY_PORT, "8888");

You can pass the properties to the overrides method of the ContextBuilder. 您可以将属性传递给ContextBuilder的overrides方法。

You can also enable the jclouds.wire logs to see every request and response that are being sent. 您还可以启用jclouds.wire日志以查看正在发送的每个请求和响应。 This will show the exact network error or the one returned by your OpenStack installation. 这将显示确切的网络错误或您的OpenStack安装返回的错误。 Have a look at: http://jclouds.apache.org/reference/logging/ 看看: http : //jclouds.apache.org/reference/logging/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM