mirror of https://github.com/apache/jclouds.git
Issue 385: exposed way to access synch and asynch classes within skeleton compute provider
This commit is contained in:
parent
c46bb08835
commit
033277d31c
|
@ -34,7 +34,9 @@
|
||||||
|
|
||||||
(defn compute-module
|
(defn compute-module
|
||||||
[]
|
[]
|
||||||
(org.jclouds.compute.config.JCloudsNativeStandaloneComputeServiceContextModule
|
(org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule
|
||||||
|
(class ComputeService)
|
||||||
|
(class ComputeService)
|
||||||
(defrecord ClojureComputeServiceAdapter []
|
(defrecord ClojureComputeServiceAdapter []
|
||||||
org.jclouds.compute.JCloudsNativeComputeServiceAdapter
|
org.jclouds.compute.JCloudsNativeComputeServiceAdapter
|
||||||
(^NodeMetadata runNodeWithTagAndNameAndStoreCredentials [this ^String tag ^String name ^Template template ^Map credentialStore]
|
(^NodeMetadata runNodeWithTagAndNameAndStoreCredentials [this ^String tag ^String name ^Template template ^Map credentialStore]
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A means of specifying the interface between the {@link ComputeServices} and a concrete compute
|
* A means of specifying the interface between the {@link ComputeService ComputeServices} and a concrete compute
|
||||||
* cloud implementation, jclouds or otherwise.
|
* cloud implementation, jclouds or otherwise.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeService;
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
@ -49,20 +48,30 @@ import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.util.Types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class StandaloneComputeServiceContextModule<N, H, I, L> extends BaseComputeServiceContextModule {
|
public class ComputeServiceAdapterContextModule<S, A, N, H, I, L> extends BaseComputeServiceContextModule {
|
||||||
|
|
||||||
|
private Class<A> asyncClientType;
|
||||||
|
private Class<S> syncClientType;
|
||||||
|
|
||||||
|
public ComputeServiceAdapterContextModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||||
|
this.syncClientType = syncClientType;
|
||||||
|
this.asyncClientType = asyncClientType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
bindDefaultLocation();
|
bindDefaultLocation();
|
||||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||||
}).to(new TypeLiteral<ComputeServiceContextImpl<ComputeService, ComputeService>>() {
|
}).to((TypeLiteral) TypeLiteral.get(Types.newParameterizedType(ComputeServiceContextImpl.class, syncClientType,
|
||||||
}).in(Scopes.SINGLETON);
|
asyncClientType))).in(Scopes.SINGLETON);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TransformingSetSupplier<F, T> implements Supplier<Set<? extends T>> {
|
public class TransformingSetSupplier<F, T> implements Supplier<Set<? extends T>> {
|
||||||
|
@ -84,7 +93,7 @@ public class StandaloneComputeServiceContextModule<N, H, I, L> extends BaseCompu
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Set<? extends Hardware>> provideHardware(final ComputeServiceAdapter<N, H, I, L> adapter,
|
protected Supplier<Set<? extends Hardware>> provideHardware(final ComputeServiceAdapter<N, H, I, L> adapter,
|
||||||
Function<H, Hardware> transformer) {
|
Function<H, Hardware> transformer) {
|
||||||
return new TransformingSetSupplier<H, Hardware>(new Supplier<Iterable<H>>() {
|
return new TransformingSetSupplier<H, Hardware>(new Supplier<Iterable<H>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,7 +107,7 @@ public class StandaloneComputeServiceContextModule<N, H, I, L> extends BaseCompu
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Set<? extends Image>> provideImages(final ComputeServiceAdapter<N, H, I, L> adapter,
|
protected Supplier<Set<? extends Image>> provideImages(final ComputeServiceAdapter<N, H, I, L> adapter,
|
||||||
Function<I, Image> transformer) {
|
Function<I, Image> transformer) {
|
||||||
return new TransformingSetSupplier<I, Image>(new Supplier<Iterable<I>>() {
|
return new TransformingSetSupplier<I, Image>(new Supplier<Iterable<I>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,7 +126,7 @@ public class StandaloneComputeServiceContextModule<N, H, I, L> extends BaseCompu
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Supplier<Set<? extends Location>> provideLocations(final ComputeServiceAdapter<N, H, I, L> adapter,
|
protected Supplier<Set<? extends Location>> provideLocations(final ComputeServiceAdapter<N, H, I, L> adapter,
|
||||||
Function<L, Location> transformer) {
|
Function<L, Location> transformer) {
|
||||||
return new TransformingSetSupplier<L, Location>(new Supplier<Iterable<L>>() {
|
return new TransformingSetSupplier<L, Location>(new Supplier<Iterable<L>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -169,19 +178,4 @@ public class StandaloneComputeServiceContextModule<N, H, I, L> extends BaseCompu
|
||||||
protected SuspendNodeStrategy defineStopNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
|
protected SuspendNodeStrategy defineStopNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
// enum singleton pattern
|
|
||||||
public static enum IdentityFunction implements Function<Object, Object> {
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
public Object apply(Object o) {
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "identity";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -32,12 +32,13 @@ import com.google.inject.TypeLiteral;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class JCloudsNativeStandaloneComputeServiceContextModule extends
|
public class JCloudsNativeComputeServiceAdapterContextModule<S, A> extends
|
||||||
StandaloneComputeServiceContextModule<NodeMetadata, Hardware, Image, Location> {
|
ComputeServiceAdapterContextModule<S, A, NodeMetadata, Hardware, Image, Location> {
|
||||||
private final Class<? extends ComputeServiceAdapter<NodeMetadata, Hardware, Image, Location>> adapter;
|
protected final Class<? extends ComputeServiceAdapter<NodeMetadata, Hardware, Image, Location>> adapter;
|
||||||
|
|
||||||
public JCloudsNativeStandaloneComputeServiceContextModule(
|
public JCloudsNativeComputeServiceAdapterContextModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||||
Class<? extends ComputeServiceAdapter<NodeMetadata, Hardware, Image, Location>> adapter) {
|
Class<? extends ComputeServiceAdapter<NodeMetadata, Hardware, Image, Location>> adapter) {
|
||||||
|
super(syncClientType, asyncClientType);
|
||||||
this.adapter = adapter;
|
this.adapter = adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +53,28 @@ public class JCloudsNativeStandaloneComputeServiceContextModule extends
|
||||||
}).to(adapter);
|
}).to(adapter);
|
||||||
bind(IdentityFunction.class).toInstance(IdentityFunction.INSTANCE);
|
bind(IdentityFunction.class).toInstance(IdentityFunction.INSTANCE);
|
||||||
bind(new TypeLiteral<Function<NodeMetadata, NodeMetadata>>() {
|
bind(new TypeLiteral<Function<NodeMetadata, NodeMetadata>>() {
|
||||||
}).to((Class) StandaloneComputeServiceContextModule.IdentityFunction.class);
|
}).to((Class) IdentityFunction.class);
|
||||||
bind(new TypeLiteral<Function<Image, Image>>() {
|
bind(new TypeLiteral<Function<Image, Image>>() {
|
||||||
}).to((Class) StandaloneComputeServiceContextModule.IdentityFunction.class);
|
}).to((Class) IdentityFunction.class);
|
||||||
bind(new TypeLiteral<Function<Hardware, Hardware>>() {
|
bind(new TypeLiteral<Function<Hardware, Hardware>>() {
|
||||||
}).to((Class) StandaloneComputeServiceContextModule.IdentityFunction.class);
|
}).to((Class) IdentityFunction.class);
|
||||||
bind(new TypeLiteral<Function<Location, Location>>() {
|
bind(new TypeLiteral<Function<Location, Location>>() {
|
||||||
}).to((Class) StandaloneComputeServiceContextModule.IdentityFunction.class);
|
}).to((Class) IdentityFunction.class);
|
||||||
super.configure();
|
super.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enum singleton pattern
|
||||||
|
public static enum IdentityFunction implements Function<Object, Object> {
|
||||||
|
INSTANCE;
|
||||||
|
|
||||||
|
public Object apply(Object o) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "identity";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.config.JCloudsNativeStandaloneComputeServiceContextModule;
|
import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.concurrent.SingleThreaded;
|
import org.jclouds.concurrent.SingleThreaded;
|
||||||
|
|
||||||
|
@ -33,21 +33,21 @@ import com.google.inject.Provides;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@SingleThreaded
|
@SingleThreaded
|
||||||
public class StubComputeServiceContextModule extends JCloudsNativeStandaloneComputeServiceContextModule {
|
public class StubComputeServiceContextModule extends
|
||||||
|
JCloudsNativeComputeServiceAdapterContextModule<ConcurrentMap, ConcurrentMap> {
|
||||||
|
|
||||||
public StubComputeServiceContextModule() {
|
public StubComputeServiceContextModule() {
|
||||||
super(StubComputeServiceAdapter.class);
|
super(ConcurrentMap.class, ConcurrentMap.class, StubComputeServiceAdapter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that a plain class is able to be bound as getProviderSpecificContext.getApi()
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ConcurrentMap provideApi(ConcurrentMap<String, NodeMetadata> in) {
|
ConcurrentMap provideApi(ConcurrentMap<String, NodeMetadata> in) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new StubComputeServiceDependenciesModule());
|
install(new StubComputeServiceDependenciesModule());
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
@ -73,78 +73,78 @@ import com.jamesmurty.utils.XMLBuilder;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class LibvirtComputeServiceContextModule extends
|
public class LibvirtComputeServiceContextModule extends
|
||||||
StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> {
|
ComputeServiceAdapterContextModule<Connect, Connect, Domain, Domain, Image, Datacenter> {
|
||||||
@Override
|
|
||||||
protected void configure() {
|
public LibvirtComputeServiceContextModule() {
|
||||||
super.configure();
|
super(Connect.class, Connect.class);
|
||||||
bind(new TypeLiteral<ComputeServiceAdapter<Domain, Domain, Image, Datacenter>>() {
|
}
|
||||||
}).to(LibvirtComputeServiceAdapter.class);
|
|
||||||
bind(new TypeLiteral<Supplier<Location>>() {
|
|
||||||
}).to(DefaultLocationSupplier.class);
|
|
||||||
bind(new TypeLiteral<Function<Domain, NodeMetadata>>() {
|
|
||||||
}).to(DomainToNodeMetadata.class);
|
|
||||||
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
|
||||||
}).to(LibvirtImageToImage.class);
|
|
||||||
bind(new TypeLiteral<Function<Domain, Hardware>>() {
|
|
||||||
}).to(DomainToHardware.class);
|
|
||||||
bind(new TypeLiteral<Function<Datacenter, Location>>() {
|
|
||||||
}).to(DatacenterToLocation.class);
|
|
||||||
|
|
||||||
//bind(ComputeService.class).to(LibvirtComputeService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Override
|
||||||
@Singleton
|
protected void configure() {
|
||||||
protected Connect createConnection(@Provider URI endpoint, @Named(Constants.PROPERTY_IDENTITY) String identity,
|
super.configure();
|
||||||
@Named(Constants.PROPERTY_CREDENTIAL) String credential) throws LibvirtException {
|
bind(new TypeLiteral<ComputeServiceAdapter<Domain, Domain, Image, Datacenter>>() {
|
||||||
// ConnectAuth connectAuth = null;
|
}).to(LibvirtComputeServiceAdapter.class);
|
||||||
return new Connect(endpoint.toASCIIString());
|
bind(new TypeLiteral<Supplier<Location>>() {
|
||||||
}
|
}).to(DefaultLocationSupplier.class);
|
||||||
|
bind(new TypeLiteral<Function<Domain, NodeMetadata>>() {
|
||||||
|
}).to(DomainToNodeMetadata.class);
|
||||||
|
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
||||||
|
}).to(LibvirtImageToImage.class);
|
||||||
|
bind(new TypeLiteral<Function<Domain, Hardware>>() {
|
||||||
|
}).to(DomainToHardware.class);
|
||||||
|
bind(new TypeLiteral<Function<Datacenter, Location>>() {
|
||||||
|
}).to(DatacenterToLocation.class);
|
||||||
|
|
||||||
@Override
|
// bind(ComputeService.class).to(LibvirtComputeService.class);
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
}
|
||||||
String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
|
||||||
String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
|
||||||
String image = searchForImageIdInDomainDir(domainDir);
|
|
||||||
return template.hardwareId(hardwareId).imageId(image) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected Connect createConnection(@Provider URI endpoint, @Named(Constants.PROPERTY_IDENTITY) String identity,
|
||||||
|
@Named(Constants.PROPERTY_CREDENTIAL) String credential) throws LibvirtException {
|
||||||
|
// ConnectAuth connectAuth = null;
|
||||||
|
return new Connect(endpoint.toASCIIString());
|
||||||
|
}
|
||||||
|
|
||||||
private String searchForImageIdInDomainDir(String domainDir) {
|
@Override
|
||||||
// TODO
|
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||||
return "1";
|
String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
||||||
}
|
String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
||||||
|
String image = searchForImageIdInDomainDir(domainDir);
|
||||||
@SuppressWarnings("unchecked")
|
return template.hardwareId(hardwareId).imageId(image);
|
||||||
private String searchForHardwareIdInDomainDir(String domainDir) {
|
}
|
||||||
|
|
||||||
Collection<File> xmlDomains = FileUtils.listFiles( new File(domainDir), new WildcardFileFilter("*.xml"), null);
|
private String searchForImageIdInDomainDir(String domainDir) {
|
||||||
String uuid = "";
|
// TODO
|
||||||
try {
|
return "1";
|
||||||
String fromXML = Files.toString(Iterables.get(xmlDomains, 0), Charsets.UTF_8);
|
}
|
||||||
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
|
||||||
uuid = builder.xpathFind("/domain/uuid").getElement().getTextContent();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SAXException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (XPathExpressionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
@SuppressWarnings("unchecked")
|
||||||
* Map<String, URI> regions = newLinkedHashMap();
|
private String searchForHardwareIdInDomainDir(String domainDir) {
|
||||||
for (String region : Splitter.on(',').split(regionString)) {
|
|
||||||
regions.put(
|
Collection<File> xmlDomains = FileUtils.listFiles(new File(domainDir), new WildcardFileFilter("*.xml"), null);
|
||||||
region,
|
String uuid = "";
|
||||||
URI.create(injector.getInstance(Key.get(String.class,
|
try {
|
||||||
Names.named(Constants.PROPERTY_ENDPOINT + "." + region)))));
|
String fromXML = Files.toString(Iterables.get(xmlDomains, 0), Charsets.UTF_8);
|
||||||
|
XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
|
||||||
|
uuid = builder.xpathFind("/domain/uuid").getElement().getTextContent();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SAXException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (XPathExpressionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return regions;
|
return uuid;
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map<String, URI> regions = newLinkedHashMap(); for (String region :
|
||||||
|
* Splitter.on(',').split(regionString)) { regions.put( region,
|
||||||
|
* URI.create(injector.getInstance(Key.get(String.class, Names.named(Constants.PROPERTY_ENDPOINT
|
||||||
|
* + "." + region))))); } return regions;
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,7 +36,7 @@ import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
@ -69,8 +69,14 @@ import com.vmware.vim25.mo.VirtualMachine;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class ViComputeServiceContextModule extends
|
public class ViComputeServiceContextModule
|
||||||
StandaloneComputeServiceContextModule<VirtualMachine, VirtualMachine, Image, Datacenter> {
|
extends
|
||||||
|
ComputeServiceAdapterContextModule<ServiceInstance, ServiceInstance, VirtualMachine, VirtualMachine, Image, Datacenter> {
|
||||||
|
|
||||||
|
public ViComputeServiceContextModule() {
|
||||||
|
super(ServiceInstance.class, ServiceInstance.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
|
@ -98,9 +104,10 @@ public class ViComputeServiceContextModule extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
||||||
//String domainDir = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
// String domainDir = injector.getInstance(Key.get(String.class,
|
||||||
String domainDir = "";
|
// Names.named(PROPERTY_LIBVIRT_DOMAIN_DIR)));
|
||||||
String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
String domainDir = "";
|
||||||
|
String hardwareId = searchForHardwareIdInDomainDir(domainDir);
|
||||||
String image = searchForImageIdInDomainDir(domainDir);
|
String image = searchForImageIdInDomainDir(domainDir);
|
||||||
return template.hardwareId(hardwareId).imageId(image);
|
return template.hardwareId(hardwareId).imageId(image);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.jclouds.servermanager.compute.config;
|
package org.jclouds.servermanager.compute.config;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.suppliers.DefaultLocationSupplier;
|
import org.jclouds.compute.suppliers.DefaultLocationSupplier;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -28,6 +28,7 @@ import org.jclouds.servermanager.Datacenter;
|
||||||
import org.jclouds.servermanager.Hardware;
|
import org.jclouds.servermanager.Hardware;
|
||||||
import org.jclouds.servermanager.Image;
|
import org.jclouds.servermanager.Image;
|
||||||
import org.jclouds.servermanager.Server;
|
import org.jclouds.servermanager.Server;
|
||||||
|
import org.jclouds.servermanager.ServerManager;
|
||||||
import org.jclouds.servermanager.compute.functions.DatacenterToLocation;
|
import org.jclouds.servermanager.compute.functions.DatacenterToLocation;
|
||||||
import org.jclouds.servermanager.compute.functions.ServerManagerHardwareToHardware;
|
import org.jclouds.servermanager.compute.functions.ServerManagerHardwareToHardware;
|
||||||
import org.jclouds.servermanager.compute.functions.ServerManagerImageToImage;
|
import org.jclouds.servermanager.compute.functions.ServerManagerImageToImage;
|
||||||
|
@ -43,7 +44,12 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class ServerManagerComputeServiceContextModule extends
|
public class ServerManagerComputeServiceContextModule extends
|
||||||
StandaloneComputeServiceContextModule<Server, Hardware, Image, Datacenter> {
|
ComputeServiceAdapterContextModule<ServerManager, ServerManager, Server, Hardware, Image, Datacenter> {
|
||||||
|
|
||||||
|
public ServerManagerComputeServiceContextModule() {
|
||||||
|
super(ServerManager.class, ServerManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
|
|
Loading…
Reference in New Issue