我编写的代码使用了jclouds的惠普云计算服务,一切运行良好。
昨天我在HP上开了一个新帐户,代码失败了。得到关于版本的错误 - 所以我假设HP升级了他们的openstack版本,但是我找不到任何应该在jclodus中更改的文档。
这是我的代码
public static ComputeServiceContext createJcloudsContext(String project, String key, String secretKey ) {
ServerConfig serverConfig = ApplicationContext.get().conf().server;
ComputeServiceContext context;
Properties overrides = new Properties();
overrides.put("jclouds.keystone.credential-type", "apiAccessKeyCredentials");
context = ContextBuilder.newBuilder( serverConfig.cloudProvider.label )
.credentials( project + ":" + key, secretKey )
.overrides(overrides)
.buildView(ComputeServiceContext.class);
return context;
}
这就是错误
java.util.NoSuchElementException: no endpoints for apiType compute are of version 1.1, or version agnostic: [Service{type=compute, name=Compute, endpoints=[Endpoint{versionId=2, region=region-a.geo-1, publicURL=https://region-a.geo-1.compute.hpcloudsvc.com/v2/10050594585198, internalURL=null, adminURL=null, versionInfo=https://region-a.geo-1.compute.hpcloudsvc.com/v2/, versionList=https://region-a.geo-1.compute.hpcloudsvc.com, tenantId=10050594585198}, Endpoint{versionId=2, region=region-b.geo-1, publicURL=https://region-b.geo-1.compute.hpcloudsvc.com/v2/10050594585198, internalURL=null, adminURL=null, versionInfo=https://region-b.geo-1.compute.hpcloudsvc.com/v2/, versionList=https://region-b.geo-1.compute.hpcloudsvc.com, tenantId=10050594585198}]}]
编辑: Barak的答案对我发布的代码片段很有用 - 用于复制的最小代码片段。 似乎后来我得到了另一条线的相同错误。下面是完整的代码段。 这是我的代码
final String provider = "hpcloud-compute";
final String user = USER_VALUE;
final String key = KEY_VALUE;
Properties overrides = new Properties();
overrides.setProperty("jclouds.keystone.credential-type", "apiAccessKeyCredentials");
overrides.setProperty(Constants.PROPERTY_ENDPOINT, "https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/");
overrides.setProperty("jclouds.api-version", "2");
ComputeServiceContext context = ContextBuilder
.newBuilder(provider)
.credentials(user, key)
.overrides(overrides)
.buildView(ComputeServiceContext.class);
Set<? extends ComputeMetadata> computeMetadatas = context.getComputeService().listNodes();
((RestContext<NovaApi, NovaAsyncApi>)context.unwrap()).getApi().getKeyPairExtensionForZone(zone);
((RestContext<NovaApi, NovaAsyncApi>)context.unwrap()).getApi().getSecurityGroupExtensionForZone(zone);
编辑:
事实证明,新的HP云没有可用区“az1”,“az2”...... 相反,我需要传递“region-b.geo-1”并且它有效!
答案 0 :(得分:1)
添加以下覆盖:
overrides.put("jclouds.api-version":"2")
您可能需要查看此论坛帖子了解更多详情:https://cloudifysource.zendesk.com/entries/30497773-Can-we-use-cloudify-with-HP-Cloud-environment-13-5-