mirror of https://github.com/apache/jclouds.git
Issue 382: stubbed out live testing for libvirt
This commit is contained in:
parent
fb93e81301
commit
2291c42b45
|
@ -33,9 +33,10 @@
|
|||
<properties>
|
||||
<!-- when instances are hung, open a ticket and add here -->
|
||||
<jclouds.compute.blacklist.nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist.nodes>
|
||||
<test.libvirt.endpoint>https://libvirt.com</test.libvirt.endpoint>
|
||||
<test.libvirt.endpoint>test:///default</test.libvirt.endpoint>
|
||||
<test.libvirt.apiversion>1.0</test.libvirt.apiversion>
|
||||
<test.libvirt.identity>FIXME</test.libvirt.identity>
|
||||
<test.libvirt.credential>FIXME</test.libvirt.credential>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -117,6 +118,10 @@
|
|||
<name>test.libvirt.identity</name>
|
||||
<value>${test.libvirt.identity}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>test.libvirt.credential</name>
|
||||
<value>${test.libvirt.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.compute.blacklist.nodes</name>
|
||||
<value>${jclouds.compute.blacklist.nodes}</value>
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.libvirt;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* This would be replaced with the real java object related to the underlying hardware
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Hardware {
|
||||
|
||||
public int id;
|
||||
public String name;
|
||||
public int cores;
|
||||
public int ram;
|
||||
public float disk;
|
||||
|
||||
public Hardware(int id, String name, int cores, int ram, float disk) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.cores = cores;
|
||||
this.ram = ram;
|
||||
this.disk = disk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name, cores, ram, disk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that == null)
|
||||
return false;
|
||||
return Objects.equal(this.toString(), that.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).add("id", id).add("name", name).add("cores", cores).add("ram", ram)
|
||||
.add("disk", disk).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,6 @@ import java.util.Properties;
|
|||
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
|
||||
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
|
||||
import org.jclouds.libvirt.Datacenter;
|
||||
import org.jclouds.libvirt.Hardware;
|
||||
import org.jclouds.libvirt.Image;
|
||||
import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule;
|
||||
import org.libvirt.Domain;
|
||||
|
@ -47,7 +46,7 @@ public class LibvirtComputeServiceContextBuilder extends StandaloneComputeServic
|
|||
modules.add(createContextModule());
|
||||
}
|
||||
|
||||
public StandaloneComputeServiceContextModule<Domain, Hardware, Image, Datacenter> createContextModule() {
|
||||
public StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> createContextModule() {
|
||||
return new LibvirtComputeServiceContextModule();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,15 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.Constants;
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.suppliers.DefaultLocationSupplier;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.libvirt.Datacenter;
|
||||
import org.jclouds.libvirt.Hardware;
|
||||
import org.jclouds.libvirt.Image;
|
||||
import org.jclouds.libvirt.compute.functions.DatacenterToLocation;
|
||||
import org.jclouds.libvirt.compute.functions.DomainToHardware;
|
||||
import org.jclouds.libvirt.compute.functions.DomainToNodeMetadata;
|
||||
import org.jclouds.libvirt.compute.functions.LibvirtHardwareToHardware;
|
||||
import org.jclouds.libvirt.compute.functions.LibvirtImageToImage;
|
||||
import org.jclouds.libvirt.compute.strategy.LibvirtComputeServiceAdapter;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
|
@ -53,11 +53,11 @@ import com.google.inject.TypeLiteral;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class LibvirtComputeServiceContextModule extends
|
||||
StandaloneComputeServiceContextModule<Domain, Hardware, Image, Datacenter> {
|
||||
StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> {
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(new TypeLiteral<ComputeServiceAdapter<Domain, Hardware, Image, Datacenter>>() {
|
||||
bind(new TypeLiteral<ComputeServiceAdapter<Domain, Domain, Image, Datacenter>>() {
|
||||
}).to(LibvirtComputeServiceAdapter.class);
|
||||
bind(new TypeLiteral<Supplier<Location>>() {
|
||||
}).to(DefaultLocationSupplier.class);
|
||||
|
@ -65,8 +65,8 @@ public class LibvirtComputeServiceContextModule extends
|
|||
}).to(DomainToNodeMetadata.class);
|
||||
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
|
||||
}).to(LibvirtImageToImage.class);
|
||||
bind(new TypeLiteral<Function<Hardware, org.jclouds.compute.domain.Hardware>>() {
|
||||
}).to(LibvirtHardwareToHardware.class);
|
||||
bind(new TypeLiteral<Function<Domain, Hardware>>() {
|
||||
}).to(DomainToHardware.class);
|
||||
bind(new TypeLiteral<Function<Datacenter, Location>>() {
|
||||
}).to(DatacenterToLocation.class);
|
||||
}
|
||||
|
|
|
@ -19,31 +19,45 @@
|
|||
|
||||
package org.jclouds.libvirt.compute.functions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.HardwareBuilder;
|
||||
import org.jclouds.compute.domain.Processor;
|
||||
import org.jclouds.compute.domain.Volume;
|
||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.LibvirtException;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class LibvirtHardwareToHardware implements Function<org.jclouds.libvirt.Hardware, Hardware> {
|
||||
public class DomainToHardware implements Function<Domain, Hardware> {
|
||||
|
||||
@Override
|
||||
public Hardware apply(org.jclouds.libvirt.Hardware from) {
|
||||
public Hardware apply(Domain from) {
|
||||
HardwareBuilder builder = new HardwareBuilder();
|
||||
builder.ids(from.id + "");
|
||||
builder.name(from.name);
|
||||
builder.processors(ImmutableList.of(new Processor(from.cores, 1.0)));
|
||||
builder.ram(from.ram);
|
||||
builder.volumes(ImmutableList.<Volume> of(new VolumeImpl(from.disk, true, false)));
|
||||
try {
|
||||
builder.id(from.getUUIDString());
|
||||
|
||||
builder.providerId(from.getID() + "");
|
||||
builder.name(from.getName());
|
||||
List<Processor> processors = Lists.newArrayList();
|
||||
for (int i = 0; i < from.getInfo().nrVirtCpu; i++) {
|
||||
processors.add(new Processor(i + 1, 1));
|
||||
}
|
||||
builder.processors(processors);
|
||||
|
||||
builder.ram((int) from.getInfo().maxMem);
|
||||
// TODO volumes
|
||||
} catch (LibvirtException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
|
@ -35,14 +35,16 @@ import org.jclouds.compute.domain.Image;
|
|||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.compute.domain.OperatingSystemBuilder;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.DomainInfo;
|
||||
import org.libvirt.LibvirtException;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -50,20 +52,25 @@ import com.google.common.collect.ImmutableSet;
|
|||
@Singleton
|
||||
public class DomainToNodeMetadata implements Function<Domain, NodeMetadata> {
|
||||
|
||||
// public static final Map<Domain.Status, NodeState> serverStatusToNodeState = ImmutableMap
|
||||
// .<Domain.Status, NodeState> builder().put(Domain.Status.ACTIVE, NodeState.RUNNING)//
|
||||
// .put(Domain.Status.BUILD, NodeState.PENDING)//
|
||||
// .put(Domain.Status.TERMINATED, NodeState.TERMINATED)//
|
||||
// .put(Domain.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
||||
// .build();
|
||||
public static final Map<DomainInfo.DomainState, NodeState> domainStateToNodeState = ImmutableMap
|
||||
.<DomainInfo.DomainState, NodeState> builder()
|
||||
.put(DomainInfo.DomainState.VIR_DOMAIN_RUNNING, NodeState.RUNNING)//
|
||||
.put(DomainInfo.DomainState.VIR_DOMAIN_BLOCKED, NodeState.PENDING)//
|
||||
.put(DomainInfo.DomainState.VIR_DOMAIN_PAUSED, NodeState.SUSPENDED)//
|
||||
.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTDOWN, NodeState.SUSPENDED)//
|
||||
.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF, NodeState.SUSPENDED)//
|
||||
.put(DomainInfo.DomainState.VIR_DOMAIN_CRASHED, NodeState.ERROR)//
|
||||
|
||||
private final FindHardwareForDomain findHardwareForDomain;
|
||||
.put(DomainInfo.DomainState.VIR_DOMAIN_NOSTATE, NodeState.UNRECOGNIZED)//
|
||||
.build();
|
||||
|
||||
private final Function<Domain, Hardware> findHardwareForDomain;
|
||||
private final FindLocationForDomain findLocationForDomain;
|
||||
private final FindImageForDomain findImageForDomain;
|
||||
private final Map<String, Credentials> credentialStore;
|
||||
|
||||
@Inject
|
||||
DomainToNodeMetadata(Map<String, Credentials> credentialStore, FindHardwareForDomain findHardwareForDomain,
|
||||
DomainToNodeMetadata(Map<String, Credentials> credentialStore, Function<Domain, Hardware> findHardwareForDomain,
|
||||
FindLocationForDomain findLocationForDomain, FindImageForDomain findImageForDomain) {
|
||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||
this.findHardwareForDomain = checkNotNull(findHardwareForDomain, "findHardwareForDomain");
|
||||
|
@ -73,40 +80,31 @@ public class DomainToNodeMetadata implements Function<Domain, NodeMetadata> {
|
|||
|
||||
@Override
|
||||
public NodeMetadata apply(Domain from) {
|
||||
|
||||
// convert the result object to a jclouds NodeMetadata
|
||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||
// builder.ids(from.id + "");
|
||||
// builder.name(from.name);
|
||||
// builder.location(findLocationForDomain.apply(from));
|
||||
// builder.tag(parseTagFromName(from.name));
|
||||
// builder.imageId(from.imageId + "");
|
||||
// Image image = findImageForDomain.apply(from);
|
||||
// if (image != null)
|
||||
// builder.operatingSystem(image.getOperatingSystem());
|
||||
// builder.hardware(findHardwareForDomain.apply(from));
|
||||
// builder.state(serverStatusToNodeState.get(from.status));
|
||||
try {
|
||||
builder.id(from.getUUIDString());
|
||||
builder.providerId(from.getID() + "");
|
||||
builder.name(from.getName());
|
||||
builder.location(findLocationForDomain.apply(from));
|
||||
builder.tag(parseTagFromName(from.getName()));
|
||||
|
||||
builder.operatingSystem(new OperatingSystemBuilder().description(from.getOSType()).build());
|
||||
builder.hardware(findHardwareForDomain.apply(from));
|
||||
|
||||
builder.state(domainStateToNodeState.get(from.getInfo().state));
|
||||
// builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
|
||||
// builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress));
|
||||
// builder.credentials(credentialStore.get(from.id + ""));
|
||||
builder.credentials(credentialStore.get(from.getUUIDString()));
|
||||
|
||||
} catch (LibvirtException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindHardwareForDomain extends FindResourceInSet<Domain, Hardware> {
|
||||
|
||||
@Inject
|
||||
public FindHardwareForDomain(@Memoized Supplier<Set<? extends Hardware>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Domain from, Hardware input) {
|
||||
// TODO
|
||||
// return input.getProviderId().equals(from.hardwareId + "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindImageForDomain extends FindResourceInSet<Domain, Image> {
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jclouds.libvirt.compute.strategy;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -12,13 +13,15 @@ import org.jclouds.compute.ComputeServiceAdapter;
|
|||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.libvirt.Datacenter;
|
||||
import org.jclouds.libvirt.Hardware;
|
||||
import org.jclouds.libvirt.Image;
|
||||
import org.libvirt.Connect;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.LibvirtException;
|
||||
import org.libvirt.jna.Libvirt;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* defines the connection between the {@link Libvirt} implementation and the jclouds
|
||||
|
@ -26,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domain, Hardware, Image, Datacenter> {
|
||||
public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domain, Domain, Image, Datacenter> {
|
||||
private final Connect client;
|
||||
|
||||
@Inject
|
||||
|
@ -47,10 +50,8 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Hardware> listHardware() {
|
||||
return ImmutableSet.of();
|
||||
// TODO
|
||||
// return client.listHardware();
|
||||
public Iterable<Domain> listHardware() {
|
||||
return listNodes();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,9 +63,21 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
|
||||
@Override
|
||||
public Iterable<Domain> listNodes() {
|
||||
return ImmutableSet.of();
|
||||
// TODO
|
||||
// return client.listDomains();
|
||||
try {
|
||||
List<Domain> domains = Lists.newArrayList();
|
||||
for (int domain : client.listDomains()) {
|
||||
domains.add(client.domainLookupByID(domain));
|
||||
}
|
||||
return domains;
|
||||
} catch (LibvirtException e) {
|
||||
return propogate(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> T propogate(LibvirtException e) {
|
||||
Throwables.propagate(e);
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,18 +87,28 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
|
|||
|
||||
@Override
|
||||
public Domain getNode(String id) {
|
||||
// int serverId = Integer.parseInt(id);
|
||||
// return client.getDomain(serverId);
|
||||
return null;
|
||||
try {
|
||||
return client.domainLookupByUUIDString(id);
|
||||
} catch (LibvirtException e) {
|
||||
return propogate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyNode(String id) {
|
||||
// client.destroyDomain(Integer.parseInt(id));
|
||||
try {
|
||||
client.domainLookupByUUIDString(id).destroy();
|
||||
} catch (LibvirtException e) {
|
||||
propogate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootNode(String id) {
|
||||
// client.rebootDomain(Integer.parseInt(id));
|
||||
try {
|
||||
client.domainLookupByUUIDString(id).reboot(0);
|
||||
} catch (LibvirtException e) {
|
||||
propogate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
package org.jclouds.libvirt.compute;
|
||||
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.compute.StandaloneComputeServiceContextSpec;
|
||||
import org.jclouds.libvirt.Datacenter;
|
||||
import org.jclouds.libvirt.Hardware;
|
||||
import org.jclouds.libvirt.Image;
|
||||
import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule;
|
||||
import org.libvirt.Connect;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.LibvirtException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -37,18 +32,11 @@ public class LibvirtComputeServiceContextBuilderTest {
|
|||
@Test
|
||||
public void testCanBuildWithComputeService() {
|
||||
ComputeServiceContext context = new ComputeServiceContextFactory()
|
||||
.createContext(new StandaloneComputeServiceContextSpec<Domain, Hardware, Image, Datacenter>("libvirt",
|
||||
"stub", "1", "identity", "credential", new StubLibvirtComputeServiceContextModule(), ImmutableSet
|
||||
.<Module> of()));
|
||||
.createContext(new StandaloneComputeServiceContextSpec<Domain, Domain, Image, Datacenter>("libvirt",
|
||||
"test:///default", "1", "identity", "credential", new LibvirtComputeServiceContextModule(),
|
||||
ImmutableSet.<Module> of()));
|
||||
System.err.println(context.getComputeService().listNodes());
|
||||
context.close();
|
||||
}
|
||||
|
||||
private static class StubLibvirtComputeServiceContextModule extends LibvirtComputeServiceContextModule {
|
||||
|
||||
@Override
|
||||
protected Connect createConnection(URI endpoint, String identity, String credential) throws LibvirtException {
|
||||
return createMock(Connect.class);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.libvirt.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.compute.StandaloneComputeServiceContextSpec;
|
||||
import org.jclouds.libvirt.Datacenter;
|
||||
import org.jclouds.libvirt.Image;
|
||||
import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule;
|
||||
import org.libvirt.Domain;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "libvirt.LibvirtExperimentLiveTest")
|
||||
public class LibvirtExperimentLiveTest {
|
||||
protected String provider = "libvirt";
|
||||
protected String identity;
|
||||
protected String credential;
|
||||
protected String endpoint;
|
||||
protected String apiversion;
|
||||
|
||||
@BeforeClass
|
||||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = System.getProperty("test." + provider + ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndExperiment() {
|
||||
ComputeServiceContext context = null;
|
||||
try {
|
||||
context = new ComputeServiceContextFactory()
|
||||
.createContext(new StandaloneComputeServiceContextSpec<Domain, Domain, Image, Datacenter>("libvirt",
|
||||
endpoint, apiversion, identity, credential, new LibvirtComputeServiceContextModule(), ImmutableSet
|
||||
.<Module> of()));
|
||||
|
||||
context.getComputeService().listNodes();
|
||||
|
||||
} finally {
|
||||
if (context != null)
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.servermanager.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.compute.StandaloneComputeServiceContextSpec;
|
||||
import org.jclouds.servermanager.Datacenter;
|
||||
import org.jclouds.servermanager.Hardware;
|
||||
import org.jclouds.servermanager.Image;
|
||||
import org.jclouds.servermanager.Server;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "servermanager.ServerManagerExperimentLiveTest")
|
||||
public class ServerManagerExperimentLiveTest {
|
||||
protected String provider = "servermanager";
|
||||
protected String identity;
|
||||
protected String credential;
|
||||
protected String endpoint;
|
||||
protected String apiversion;
|
||||
|
||||
@BeforeClass
|
||||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = System.getProperty("test." + provider + ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndExperiment() {
|
||||
ComputeServiceContext context = null;
|
||||
try {
|
||||
context = new ComputeServiceContextFactory()
|
||||
.createContext(new StandaloneComputeServiceContextSpec<Server, Hardware, Image, Datacenter>(
|
||||
"servermanager", endpoint, apiversion, identity, credential,
|
||||
ServerManagerComputeServiceContextBuilder.createContextModule(), ImmutableSet.<Module> of()));
|
||||
|
||||
context.getComputeService().listNodes();
|
||||
|
||||
} finally {
|
||||
if (context != null)
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue