mirror of https://github.com/apache/jclouds.git
Updated NovaComputeService and FloatingIp cache to deal with extensibility
This commit is contained in:
parent
931aa7838a
commit
7d70b5ddc3
|
@ -155,7 +155,7 @@ public class NovaComputeService extends BaseComputeService {
|
||||||
Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
|
Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
|
||||||
if (keyPairApi.isPresent()) {
|
if (keyPairApi.isPresent()) {
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
for (Map<String, KeyPair> view : keyPairApi.get().listKeyPairs()) {
|
for (Map<String, ? extends KeyPair> view : keyPairApi.get().listKeyPairs()) {
|
||||||
for (KeyPair pair : Iterables.filter(view.values(),
|
for (KeyPair pair : Iterables.filter(view.values(),
|
||||||
KeyPairPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
|
KeyPairPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
|
||||||
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
|
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class NovaComputeServiceContextModule extends
|
||||||
|
|
||||||
bind(TemplateOptions.class).to(NovaTemplateOptions.class);
|
bind(TemplateOptions.class).to(NovaTemplateOptions.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<CacheLoader<ZoneAndId, Iterable<FloatingIP>>>() {
|
bind(new TypeLiteral<CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>>>() {
|
||||||
}).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
|
}).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
|
||||||
|
|
||||||
bind(new TypeLiteral<Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>>() {
|
bind(new TypeLiteral<Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>>() {
|
||||||
|
@ -163,8 +163,8 @@ public class NovaComputeServiceContextModule extends
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("FLOATINGIP")
|
@Named("FLOATINGIP")
|
||||||
protected LoadingCache<ZoneAndId, Iterable<FloatingIP>> instanceToFloatingIps(
|
protected LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
|
||||||
@Named("FLOATINGIP") CacheLoader<ZoneAndId, Iterable<FloatingIP>> in) {
|
@Named("FLOATINGIP") CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> in) {
|
||||||
return CacheBuilder.newBuilder().build(in);
|
return CacheBuilder.newBuilder().build(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,11 @@ public class AllocateAndAddFloatingIpToNode implements
|
||||||
|
|
||||||
private final Predicate<AtomicReference<NodeMetadata>> nodeRunning;
|
private final Predicate<AtomicReference<NodeMetadata>> nodeRunning;
|
||||||
private final NovaApi novaApi;
|
private final NovaApi novaApi;
|
||||||
private final LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache;
|
private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
|
public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
|
||||||
NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache) {
|
NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
|
||||||
this.nodeRunning = checkNotNull(nodeRunning, "nodeRunning");
|
this.nodeRunning = checkNotNull(nodeRunning, "nodeRunning");
|
||||||
this.novaApi = checkNotNull(novaApi, "novaApi");
|
this.novaApi = checkNotNull(novaApi, "novaApi");
|
||||||
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
||||||
|
|
|
@ -47,11 +47,11 @@ public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final NovaApi novaApi;
|
private final NovaApi novaApi;
|
||||||
private final LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache;
|
private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RemoveFloatingIpFromNodeAndDeallocate(NovaApi novaApi,
|
public RemoveFloatingIpFromNodeAndDeallocate(NovaApi novaApi,
|
||||||
@Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<FloatingIP>> floatingIpCache) {
|
@Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
|
||||||
this.novaApi = checkNotNull(novaApi, "novaApi");
|
this.novaApi = checkNotNull(novaApi, "novaApi");
|
||||||
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import com.google.common.collect.Iterables;
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<FloatingIP>> {
|
public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> {
|
||||||
private final NovaApi api;
|
private final NovaApi api;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -49,7 +49,7 @@ public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<FloatingIP> load(final ZoneAndId key) throws Exception {
|
public Iterable<? extends FloatingIP> load(final ZoneAndId key) throws Exception {
|
||||||
String zone = key.getZone();
|
String zone = key.getZone();
|
||||||
Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
|
Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
|
||||||
if (ipApiOptional.isPresent()) {
|
if (ipApiOptional.isPresent()) {
|
||||||
|
|
Loading…
Reference in New Issue