0

我编写了使用 jclouds 的 HP 云计算服务的代码,一切运行良好。

昨天我在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);

编辑:

事实证明,新的惠普云没有可用区“az1”、“az2”......相反,我需要通过“region-b.geo-1”并且它可以工作!

4

1 回答 1

1

添加以下覆盖:

overrides.put("jclouds.api-version":"2")

您可能想查看此论坛帖子以了解更多详细信息:https ://cloudifysource.zendesk.com/entries/30497773-Can-we-use-cloudify-with-HP-Cloud-environment-13-5-

于 2014-01-16T08:44:54.300 回答