openstack-nova: wiring in LoadFloatingIpsForInstance

This commit is contained in:
Adam Lowe 2012-03-18 14:46:47 +00:00 committed by Adrian Cole
parent d7b4a31e70
commit dd4d13d6bb
1 changed files with 22 additions and 4 deletions

View File

@ -18,6 +18,11 @@
*/
package org.jclouds.openstack.nova.v1_1.compute.config;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.inject.Provides;
import com.google.inject.name.Names;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
import org.jclouds.compute.domain.Hardware;
@ -30,10 +35,8 @@ import org.jclouds.functions.IdentityFunction;
import org.jclouds.openstack.nova.v1_1.NovaAsyncClient;
import org.jclouds.openstack.nova.v1_1.NovaClient;
import org.jclouds.openstack.nova.v1_1.compute.NovaComputeServiceAdapter;
import org.jclouds.openstack.nova.v1_1.compute.functions.FlavorToHardware;
import org.jclouds.openstack.nova.v1_1.compute.functions.NovaImageToImage;
import org.jclouds.openstack.nova.v1_1.compute.functions.NovaImageToOperatingSystem;
import org.jclouds.openstack.nova.v1_1.compute.functions.ServerToNodeMetadata;
import org.jclouds.openstack.nova.v1_1.compute.domain.RegionAndName;
import org.jclouds.openstack.nova.v1_1.compute.functions.*;
import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions;
import org.jclouds.openstack.nova.v1_1.domain.Flavor;
import org.jclouds.openstack.nova.v1_1.domain.Server;
@ -41,6 +44,9 @@ import org.jclouds.openstack.nova.v1_1.domain.Server;
import com.google.common.base.Function;
import com.google.inject.TypeLiteral;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* Module for building a compute service context for Nova
*
@ -77,5 +83,17 @@ public class NovaComputeServiceContextModule
}).to((Class) IdentityFunction.class);
bind(TemplateOptions.class).to(NovaTemplateOptions.class);
bind(new TypeLiteral<CacheLoader<RegionAndName, Iterable<String>>>() {
}).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
}
@Provides
@Singleton
@Named("FLOATINGIP")
protected LoadingCache<RegionAndName, Iterable<String>> instanceToFloatingIps(
@Named("FLOATINGIP") CacheLoader<RegionAndName, Iterable<String>> in) {
return CacheBuilder.newBuilder().build(in);
}
}