2014-01-16 21 views
0

我編寫了使用jclouds的HP雲計算服務的代碼,並且一切運行良好。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}]}] 

編輯: 巴拉克的回答是不錯的代碼段我張貼 - 最小的代碼片段再現。 看來,以後我得到另一行相同的錯誤。下面是完整的代碼片段。 這裏是我的代碼

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」 ...... 相反,我需要通過「區域 - b.geo-1「,它的工作原理!

回答

1

添加以下重寫:

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

你可能想看看這個論壇後獲取更多詳情:https://cloudifysource.zendesk.com/entries/30497773-Can-we-use-cloudify-with-HP-Cloud-environment-13-5-

+0

當我做到這一點,老用戶會失敗。有沒有解決方案可以使這兩個工作? –

+0

這取決於每個用戶使用哪個區域。使用Openstack Grizzly的新區域需要修改後的api-version標誌 – Barak

+0

我添加了代碼片斷,失敗.. –