Merge "hadoop-swiftfs: Allow configuring container.tenant"
This commit is contained in:
commit
8cd6d7b0ca
|
@ -155,6 +155,7 @@ public final class RestClientBindings {
|
||||||
copy(conf, prefix + DOT_DOMAIN_NAME, props, SWIFT_DOMAIN_NAME_PROPERTY, false);
|
copy(conf, prefix + DOT_DOMAIN_NAME, props, SWIFT_DOMAIN_NAME_PROPERTY, false);
|
||||||
copy(conf, prefix + DOT_DOMAIN_ID, props, SWIFT_DOMAIN_ID_PROPERTY, false);
|
copy(conf, prefix + DOT_DOMAIN_ID, props, SWIFT_DOMAIN_ID_PROPERTY, false);
|
||||||
copy(conf, prefix + DOT_TENANT, props, SWIFT_TENANT_PROPERTY, false);
|
copy(conf, prefix + DOT_TENANT, props, SWIFT_TENANT_PROPERTY, false);
|
||||||
|
copy(conf, prefix + DOT_CONTAINER_TENANT, props, SWIFT_CONTAINER_TENANT_PROPERTY, false);
|
||||||
copy(conf, prefix + DOT_REGION, props, SWIFT_REGION_PROPERTY, false);
|
copy(conf, prefix + DOT_REGION, props, SWIFT_REGION_PROPERTY, false);
|
||||||
copy(conf, prefix + DOT_HTTP_PORT, props, SWIFT_HTTP_PORT_PROPERTY, false);
|
copy(conf, prefix + DOT_HTTP_PORT, props, SWIFT_HTTP_PORT_PROPERTY, false);
|
||||||
copy(conf, prefix +
|
copy(conf, prefix +
|
||||||
|
|
|
@ -207,6 +207,7 @@ public class SwiftProtocolConstants {
|
||||||
public static final String DOT_AUTH_URL = ".auth.url";
|
public static final String DOT_AUTH_URL = ".auth.url";
|
||||||
public static final String DOT_AUTH_ENDPOINT_PREFIX = ".auth.endpoint.prefix";
|
public static final String DOT_AUTH_ENDPOINT_PREFIX = ".auth.endpoint.prefix";
|
||||||
public static final String DOT_TENANT = ".tenant";
|
public static final String DOT_TENANT = ".tenant";
|
||||||
|
public static final String DOT_CONTAINER_TENANT = ".container.tenant";
|
||||||
public static final String DOT_USERNAME = ".username";
|
public static final String DOT_USERNAME = ".username";
|
||||||
public static final String DOT_PASSWORD = ".password";
|
public static final String DOT_PASSWORD = ".password";
|
||||||
public static final String DOT_TRUST_ID = ".trust.id";
|
public static final String DOT_TRUST_ID = ".trust.id";
|
||||||
|
@ -233,6 +234,7 @@ public class SwiftProtocolConstants {
|
||||||
public static final String SWIFT_AUTH_ENDPOINT_PREFIX =
|
public static final String SWIFT_AUTH_ENDPOINT_PREFIX =
|
||||||
FS_SWIFT + DOT_AUTH_ENDPOINT_PREFIX;
|
FS_SWIFT + DOT_AUTH_ENDPOINT_PREFIX;
|
||||||
public static final String SWIFT_TENANT_PROPERTY = FS_SWIFT + DOT_TENANT;
|
public static final String SWIFT_TENANT_PROPERTY = FS_SWIFT + DOT_TENANT;
|
||||||
|
public static final String SWIFT_CONTAINER_TENANT_PROPERTY = FS_SWIFT + DOT_CONTAINER_TENANT;
|
||||||
public static final String SWIFT_USERNAME_PROPERTY = FS_SWIFT + DOT_USERNAME;
|
public static final String SWIFT_USERNAME_PROPERTY = FS_SWIFT + DOT_USERNAME;
|
||||||
public static final String SWIFT_PASSWORD_PROPERTY = FS_SWIFT + DOT_PASSWORD;
|
public static final String SWIFT_PASSWORD_PROPERTY = FS_SWIFT + DOT_PASSWORD;
|
||||||
public static final String SWIFT_TRUST_ID_PROPERTY = FS_SWIFT + DOT_TRUST_ID;
|
public static final String SWIFT_TRUST_ID_PROPERTY = FS_SWIFT + DOT_TRUST_ID;
|
||||||
|
|
|
@ -180,6 +180,7 @@ public final class SwiftRestClient {
|
||||||
*/
|
*/
|
||||||
private final String container;
|
private final String container;
|
||||||
private final String serviceDescription;
|
private final String serviceDescription;
|
||||||
|
private final String containerTenant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access token (Secret)
|
* Access token (Secret)
|
||||||
|
@ -502,6 +503,9 @@ public final class SwiftRestClient {
|
||||||
region = props.getProperty(SWIFT_REGION_PROPERTY);
|
region = props.getProperty(SWIFT_REGION_PROPERTY);
|
||||||
//tenant is optional
|
//tenant is optional
|
||||||
tenant = props.getProperty(SWIFT_TENANT_PROPERTY);
|
tenant = props.getProperty(SWIFT_TENANT_PROPERTY);
|
||||||
|
//containerTenant is optional
|
||||||
|
containerTenant = props.getProperty(SWIFT_CONTAINER_TENANT_PROPERTY);
|
||||||
|
|
||||||
//service is used for diagnostics
|
//service is used for diagnostics
|
||||||
serviceProvider = props.getProperty(SWIFT_SERVICE_PROPERTY);
|
serviceProvider = props.getProperty(SWIFT_SERVICE_PROPERTY);
|
||||||
container = props.getProperty(SWIFT_CONTAINER_PROPERTY);
|
container = props.getProperty(SWIFT_CONTAINER_PROPERTY);
|
||||||
|
@ -1303,6 +1307,15 @@ public final class SwiftRestClient {
|
||||||
|
|
||||||
accessToken = access.getToken();
|
accessToken = access.getToken();
|
||||||
String path = getAuthEndpointPrefix() + accessToken.getTenant().getId();
|
String path = getAuthEndpointPrefix() + accessToken.getTenant().getId();
|
||||||
|
|
||||||
|
// Overwrite the user tenant with the shared container tenant id (container.tenant)
|
||||||
|
if (containerTenant != null) {
|
||||||
|
path = getAuthEndpointPrefix() + containerTenant;
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("overwritten path: " + path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String host = endpointURI.getHost();
|
String host = endpointURI.getHost();
|
||||||
try {
|
try {
|
||||||
objectLocation = new URI(endpointURI.getScheme(),
|
objectLocation = new URI(endpointURI.getScheme(),
|
||||||
|
@ -1318,6 +1331,13 @@ public final class SwiftRestClient {
|
||||||
+ " + " + path,
|
+ " + " + path,
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overwrite the user tenant with the shared container tenant id (container.tenant)
|
||||||
|
if (containerTenant != null) {
|
||||||
|
endpointURI = objectLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setAuthDetails(endpointURI, objectLocation, accessToken);
|
setAuthDetails(endpointURI, objectLocation, accessToken);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
|
@ -1377,6 +1397,15 @@ public final class SwiftRestClient {
|
||||||
|
|
||||||
URI objectLocation = null;
|
URI objectLocation = null;
|
||||||
String path = getAuthEndpointPrefix() + token.getTenant().getId();
|
String path = getAuthEndpointPrefix() + token.getTenant().getId();
|
||||||
|
|
||||||
|
// Overwrite the user tenant with the shared container tenant id (container.tenant)
|
||||||
|
if (containerTenant != null) {
|
||||||
|
path = getAuthEndpointPrefix() + containerTenant;
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("overwritten path: " + path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
objectLocation = new URI(endpointURI.getScheme(),
|
objectLocation = new URI(endpointURI.getScheme(),
|
||||||
null,
|
null,
|
||||||
|
@ -1392,6 +1421,11 @@ public final class SwiftRestClient {
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overwrite the user tenant with the shared container tenant id (container.tenant)
|
||||||
|
if (containerTenant != null) {
|
||||||
|
endpointURI = objectLocation;
|
||||||
|
}
|
||||||
|
|
||||||
setAuthDetails(endpointURI, objectLocation, token);
|
setAuthDetails(endpointURI, objectLocation, token);
|
||||||
createDefaultContainer();
|
createDefaultContainer();
|
||||||
return token;
|
return token;
|
||||||
|
@ -1970,6 +2004,14 @@ public final class SwiftRestClient {
|
||||||
return tenant;
|
return tenant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tenant to which this client is bound
|
||||||
|
* @return the tenant
|
||||||
|
*/
|
||||||
|
public String getContainerTenant() {
|
||||||
|
return containerTenant;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the username this client identifies itself as
|
* Get the username this client identifies itself as
|
||||||
* @return the username
|
* @return the username
|
||||||
|
|
Loading…
Reference in New Issue