直接上代码
/**
*建立认证连接
**/
public OSClientV3 getOSClientV3(String tenantId,String userid,
String password,String region){
String url = "http://127.0.0.1:5000/v3";
if (tenantId == null || tenantId.equals("")) {
tenantId = "defaultTenantId";
}
OSClientV3 osv3 = OSFactory.builderV3().endpoint(url)
.credentials(userid, password)
.scopeToProject(Identifier.byId(tenantId)).authenticate();
if (region != null && !"".equals(region)) {
osv3.useRegion(region);
}
return osv3;
}