Allow configuration of session renewal.
diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
index 0445321..1193fff 100644
--- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
+++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
@@ -18,6 +18,7 @@
*/
package org.jclouds.openstack.nova.v2_0;
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
@@ -82,6 +83,10 @@
properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false");
properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false");
properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500");
+ // Keystone 1.1 expires tokens after 24 hours and allows renewal 1 hour
+ // before expiry by default. We choose a value less than the latter
+ // since the former persists between jclouds invocations.
+ properties.setProperty(PROPERTY_SESSION_INTERVAL, 30 * 60 * 60 + "");
return properties;
}
diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java
index ca59b00..6a9d10f 100644
--- a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java
+++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java
@@ -18,6 +18,7 @@
*/
package org.jclouds.openstack.swift;
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
@@ -67,6 +68,10 @@
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
+ // Keystone 1.1 expires tokens after 24 hours and allows renewal 1 hour
+ // before expiry by default. We choose a value less than the latter
+ // since the former persists between jclouds invocations.
+ properties.setProperty(PROPERTY_SESSION_INTERVAL, 30 * 60 * 60 + "");
return properties;
}
@@ -100,4 +105,4 @@
return this;
}
}
-}
\ No newline at end of file
+}
diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java
index 3c89288..acfbf1a 100644
--- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java
+++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java
@@ -20,6 +20,7 @@
import static com.google.common.base.Throwables.propagate;
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -49,6 +50,7 @@
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.inject.AbstractModule;
+import com.google.inject.name.Named;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.FactoryModuleBuilder;
@@ -111,8 +113,9 @@
@Provides
@Singleton
- public LoadingCache<Credentials, Auth> provideAuthCache(Function<Credentials, Auth> getAuth) {
- return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS).build(CacheLoader.from(getAuth));
+ protected LoadingCache<Credentials, Auth> provideAuthCache(GetAuth getAuth,
+ @Named(PROPERTY_SESSION_INTERVAL) long sessionInterval) {
+ return CacheBuilder.newBuilder().expireAfterWrite(sessionInterval, TimeUnit.SECONDS).build(CacheLoader.from(getAuth));
}
@Provides