2016-12-28 25 views
1

我已通過區域「倫敦」中的儀表板創建了一個包含區域。但是當我嘗試訪問它時,程序檢查顯示爲默認區域here - 只有「達拉斯」區域,即使我的證書中的區域是「倫敦」。我試圖通過我的程序創建一個容器,並在「達拉斯」區域創建容器。對象存儲 - 無法訪問區域「倫敦」中的容器

如何讓我的程序訪問區域「倫敦」中的容器?有關如何指定區域的任何建議,我們都很感激。

我列出容器的代碼如下所示;

final private OSClient os; 

public ObjectStorageDAO(String url, String userId, String password, String project, String domainName) 
     throws Exception { 

    Identifier domainIdentifier = Identifier.byName(domainName); 
    Identifier projectIdentifier = Identifier.byName(project); 

    os = OSFactory.builderV3().endpoint(url).credentials(userId, password) 
      .scopeToProject(projectIdentifier, domainIdentifier).authenticate(); 
} 

/** 
* Returns the list of containers under the account 
*/ 
public List containers() { 
    return os.objectStorage().containers().list(); 
} 
+0

啓動'os'對象之後,你可以嘗試迫使區域?例如。 'os.useRegion('london')' - http://www.openstack4j.com/learn/identity/identity-v3 –

+0

非常感謝@SHC –

+0

好東西 - 我已經添加了這個答案。你可以接受這個答案嗎? –

回答

2

啓動os對象之後,你可以嘗試強制該區域嗎?

final private OSClient os; 

public ObjectStorageDAO(String url, String userId, String password, String project, String domainName) 
     throws Exception { 

    Identifier domainIdentifier = Identifier.byName(domainName); 
    Identifier projectIdentifier = Identifier.byName(project); 

    os = OSFactory.builderV3().endpoint(url).credentials(userId, password) 
      .scopeToProject(projectIdentifier, domainIdentifier).authenticate(); 

    ///////////////////////// 
    // force london region // 
    ///////////////////////// 

    os.useRegion('london') 
} 

/** 
* Returns the list of containers under the account 
*/ 
public List containers() { 
    return os.objectStorage().containers().list(); 
} 

欲瞭解更多信息,請參見這裏:http://www.openstack4j.com/learn/identity/identity-v3