mirror of https://github.com/apache/jclouds.git
moved host module creation to contextbuilder
This commit is contained in:
parent
00c16d5315
commit
ad6b655ea1
|
@ -48,7 +48,7 @@ public abstract class ComputeServiceContextBuilder<S, A> extends RestContextBuil
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Injector buildInjector() {
|
public Injector buildInjector() {
|
||||||
addImageResolutionModuleIfNotPresent();
|
addHostModuleIfNotPresent();
|
||||||
return super.buildInjector();
|
return super.buildInjector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public abstract class ComputeServiceContextBuilder<S, A> extends RestContextBuil
|
||||||
asyncClientType)));
|
asyncClientType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addImageResolutionModuleIfNotPresent() {
|
protected void addHostModuleIfNotPresent() {
|
||||||
if (!Iterables.any(modules, new Predicate<Module>() {
|
if (!Iterables.any(modules, new Predicate<Module>() {
|
||||||
public boolean apply(Module input) {
|
public boolean apply(Module input) {
|
||||||
return input.getClass().isAnnotationPresent(ResolvesImages.class);
|
return input.getClass().isAnnotationPresent(ResolvesImages.class);
|
||||||
|
|
|
@ -19,13 +19,20 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox;
|
package org.jclouds.virtualbox;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.byon.Node;
|
||||||
|
import org.jclouds.byon.config.CacheNodeStoreModule;
|
||||||
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
|
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule;
|
import org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +50,25 @@ public class VirtualBoxContextBuilder extends StandaloneComputeServiceContextBui
|
||||||
@Override
|
@Override
|
||||||
protected void addContextModule(List<Module> modules) {
|
protected void addContextModule(List<Module> modules) {
|
||||||
modules.add(new VirtualBoxComputeServiceContextModule());
|
modules.add(new VirtualBoxComputeServiceContextModule());
|
||||||
|
addHostModuleIfNotPresent(modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addHostModuleIfNotPresent(List<Module> modules) {
|
||||||
|
if (!Iterables.any(modules, new Predicate<Module>() {
|
||||||
|
public boolean apply(Module input) {
|
||||||
|
return input.getClass().equals(CacheNodeStoreModule.class);
|
||||||
|
}
|
||||||
|
})) {
|
||||||
|
CacheNodeStoreModule hostModule = new CacheNodeStoreModule(ImmutableMap.of(
|
||||||
|
"host",
|
||||||
|
Node.builder().id("host").name("host installing virtualbox").hostname("localhost")
|
||||||
|
.osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name"))
|
||||||
|
.osVersion(System.getProperty("os.version")).group("ssh")
|
||||||
|
.username(System.getProperty("user.name"))
|
||||||
|
.credentialUrl(URI.create("file://" + System.getProperty("user.home") + "/.ssh/id_rsa"))
|
||||||
|
.build()));
|
||||||
|
modules.add(hostModule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,16 +176,8 @@ public class VirtualBoxComputeServiceContextModule extends
|
||||||
String provider = "byon";
|
String provider = "byon";
|
||||||
String identity = "";
|
String identity = "";
|
||||||
String credential = "";
|
String credential = "";
|
||||||
CacheNodeStoreModule hostModule = new CacheNodeStoreModule(ImmutableMap.of(
|
|
||||||
"host",
|
|
||||||
Node.builder().id("host").name("host installing virtualbox").hostname("localhost")
|
|
||||||
.osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name"))
|
|
||||||
.osVersion(System.getProperty("os.version")).group("ssh")
|
|
||||||
.username(System.getProperty("user.name"))
|
|
||||||
.credentialUrl(URI.create("file://" + System.getProperty("user.home") + "/.ssh/id_rsa"))
|
|
||||||
.build()));
|
|
||||||
return new ComputeServiceContextFactory().createContext(provider, identity, credential,
|
return new ComputeServiceContextFactory().createContext(provider, identity, credential,
|
||||||
ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule(), hostModule));
|
ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -135,17 +135,8 @@ public class BaseVirtualBoxClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = new VirtualBoxPropertiesBuilder(setupProperties()).build();
|
Properties overrides = new VirtualBoxPropertiesBuilder(setupProperties()).build();
|
||||||
|
|
||||||
CacheNodeStoreModule hostModule = new CacheNodeStoreModule(ImmutableMap.of(
|
|
||||||
"host",
|
|
||||||
Node.builder().id("host").name("host installing virtualbox").hostname("localhost")
|
|
||||||
.osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name"))
|
|
||||||
.osVersion(System.getProperty("os.version")).group("ssh")
|
|
||||||
.username(System.getProperty("user.name"))
|
|
||||||
.credentialUrl(URI.create("file://" + System.getProperty("user.home") + "/.ssh/id_rsa"))
|
|
||||||
.build()));
|
|
||||||
|
|
||||||
context = new ComputeServiceContextFactory().createContext(provider, identity, credential, ImmutableSet
|
context = new ComputeServiceContextFactory().createContext(provider, identity, credential, ImmutableSet
|
||||||
.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule(), hostModule, new ExecutorServiceModule(
|
.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule(), new ExecutorServiceModule(
|
||||||
singleThreadExec, singleThreadExec)), overrides);
|
singleThreadExec, singleThreadExec)), overrides);
|
||||||
|
|
||||||
context.utils().injector().injectMembers(this);
|
context.utils().injector().injectMembers(this);
|
||||||
|
|
Loading…
Reference in New Issue