Search code examples
javaibm-cloudobject-storage

Object Storage - Can't access container in region "London"


I have created a contained through dashboard in region "London". But when I try to access it, the program checks -apparently as default region as also stated here- only the region "Dallas" even though the region in my credentials is "London". I tried to create a container through my program and the container was created in the region "Dallas".

How can I make my program access the container in region "London"? Any advice on how to specify the region is appreciated.

My code to list containers looks like below;

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();
}

Solution

  • After initiating the os object, can you try forcing the region?

    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();
    }
    

    For more information, see here: http://www.openstack4j.com/learn/identity/identity-v3