Issue 382: stubbed out live testing for libvirt

This commit is contained in:
Adrian Cole 2010-10-24 23:51:39 -05:00
parent fb93e81301
commit 2291c42b45
10 changed files with 262 additions and 150 deletions

View File

@ -33,9 +33,10 @@
<properties> <properties>
<!-- when instances are hung, open a ticket and add here --> <!-- when instances are hung, open a ticket and add here -->
<jclouds.compute.blacklist.nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist.nodes> <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.apiversion>1.0</test.libvirt.apiversion>
<test.libvirt.identity>FIXME</test.libvirt.identity> <test.libvirt.identity>FIXME</test.libvirt.identity>
<test.libvirt.credential>FIXME</test.libvirt.credential>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -117,6 +118,10 @@
<name>test.libvirt.identity</name> <name>test.libvirt.identity</name>
<value>${test.libvirt.identity}</value> <value>${test.libvirt.identity}</value>
</property> </property>
<property>
<name>test.libvirt.credential</name>
<value>${test.libvirt.credential}</value>
</property>
<property> <property>
<name>jclouds.compute.blacklist.nodes</name> <name>jclouds.compute.blacklist.nodes</name>
<value>${jclouds.compute.blacklist.nodes}</value> <value>${jclouds.compute.blacklist.nodes}</value>

View File

@ -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();
}
}

View File

@ -25,7 +25,6 @@ import java.util.Properties;
import org.jclouds.compute.StandaloneComputeServiceContextBuilder; import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
import org.jclouds.compute.config.StandaloneComputeServiceContextModule; import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
import org.jclouds.libvirt.Datacenter; import org.jclouds.libvirt.Datacenter;
import org.jclouds.libvirt.Hardware;
import org.jclouds.libvirt.Image; import org.jclouds.libvirt.Image;
import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule; import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule;
import org.libvirt.Domain; import org.libvirt.Domain;
@ -47,7 +46,7 @@ public class LibvirtComputeServiceContextBuilder extends StandaloneComputeServic
modules.add(createContextModule()); modules.add(createContextModule());
} }
public StandaloneComputeServiceContextModule<Domain, Hardware, Image, Datacenter> createContextModule() { public StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> createContextModule() {
return new LibvirtComputeServiceContextModule(); return new LibvirtComputeServiceContextModule();
} }

View File

@ -27,15 +27,15 @@ import javax.inject.Singleton;
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.StandaloneComputeServiceContextModule;
import org.jclouds.compute.domain.Hardware;
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;
import org.jclouds.libvirt.Datacenter; import org.jclouds.libvirt.Datacenter;
import org.jclouds.libvirt.Hardware;
import org.jclouds.libvirt.Image; import org.jclouds.libvirt.Image;
import org.jclouds.libvirt.compute.functions.DatacenterToLocation; 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.DomainToNodeMetadata;
import org.jclouds.libvirt.compute.functions.LibvirtHardwareToHardware;
import org.jclouds.libvirt.compute.functions.LibvirtImageToImage; import org.jclouds.libvirt.compute.functions.LibvirtImageToImage;
import org.jclouds.libvirt.compute.strategy.LibvirtComputeServiceAdapter; import org.jclouds.libvirt.compute.strategy.LibvirtComputeServiceAdapter;
import org.jclouds.rest.annotations.Provider; import org.jclouds.rest.annotations.Provider;
@ -53,11 +53,11 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class LibvirtComputeServiceContextModule extends public class LibvirtComputeServiceContextModule extends
StandaloneComputeServiceContextModule<Domain, Hardware, Image, Datacenter> { StandaloneComputeServiceContextModule<Domain, Domain, Image, Datacenter> {
@Override @Override
protected void configure() { protected void configure() {
super.configure(); super.configure();
bind(new TypeLiteral<ComputeServiceAdapter<Domain, Hardware, Image, Datacenter>>() { bind(new TypeLiteral<ComputeServiceAdapter<Domain, Domain, Image, Datacenter>>() {
}).to(LibvirtComputeServiceAdapter.class); }).to(LibvirtComputeServiceAdapter.class);
bind(new TypeLiteral<Supplier<Location>>() { bind(new TypeLiteral<Supplier<Location>>() {
}).to(DefaultLocationSupplier.class); }).to(DefaultLocationSupplier.class);
@ -65,8 +65,8 @@ public class LibvirtComputeServiceContextModule extends
}).to(DomainToNodeMetadata.class); }).to(DomainToNodeMetadata.class);
bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() { bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
}).to(LibvirtImageToImage.class); }).to(LibvirtImageToImage.class);
bind(new TypeLiteral<Function<Hardware, org.jclouds.compute.domain.Hardware>>() { bind(new TypeLiteral<Function<Domain, Hardware>>() {
}).to(LibvirtHardwareToHardware.class); }).to(DomainToHardware.class);
bind(new TypeLiteral<Function<Datacenter, Location>>() { bind(new TypeLiteral<Function<Datacenter, Location>>() {
}).to(DatacenterToLocation.class); }).to(DatacenterToLocation.class);
} }

View File

@ -19,31 +19,45 @@
package org.jclouds.libvirt.compute.functions; package org.jclouds.libvirt.compute.functions;
import java.util.List;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.HardwareBuilder;
import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Processor;
import org.jclouds.compute.domain.Volume; import org.libvirt.Domain;
import org.jclouds.compute.domain.internal.VolumeImpl; import org.libvirt.LibvirtException;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class LibvirtHardwareToHardware implements Function<org.jclouds.libvirt.Hardware, Hardware> { public class DomainToHardware implements Function<Domain, Hardware> {
@Override @Override
public Hardware apply(org.jclouds.libvirt.Hardware from) { public Hardware apply(Domain from) {
HardwareBuilder builder = new HardwareBuilder(); HardwareBuilder builder = new HardwareBuilder();
builder.ids(from.id + ""); try {
builder.name(from.name); builder.id(from.getUUIDString());
builder.processors(ImmutableList.of(new Processor(from.cores, 1.0)));
builder.ram(from.ram); builder.providerId(from.getID() + "");
builder.volumes(ImmutableList.<Volume> of(new VolumeImpl(from.disk, true, false))); 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(); return builder.build();
} }

View File

@ -35,14 +35,16 @@ import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.libvirt.Domain; import org.libvirt.Domain;
import org.libvirt.DomainInfo;
import org.libvirt.LibvirtException;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -50,20 +52,25 @@ import com.google.common.collect.ImmutableSet;
@Singleton @Singleton
public class DomainToNodeMetadata implements Function<Domain, NodeMetadata> { public class DomainToNodeMetadata implements Function<Domain, NodeMetadata> {
// public static final Map<Domain.Status, NodeState> serverStatusToNodeState = ImmutableMap public static final Map<DomainInfo.DomainState, NodeState> domainStateToNodeState = ImmutableMap
// .<Domain.Status, NodeState> builder().put(Domain.Status.ACTIVE, NodeState.RUNNING)// .<DomainInfo.DomainState, NodeState> builder()
// .put(Domain.Status.BUILD, NodeState.PENDING)// .put(DomainInfo.DomainState.VIR_DOMAIN_RUNNING, NodeState.RUNNING)//
// .put(Domain.Status.TERMINATED, NodeState.TERMINATED)// .put(DomainInfo.DomainState.VIR_DOMAIN_BLOCKED, NodeState.PENDING)//
// .put(Domain.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)// .put(DomainInfo.DomainState.VIR_DOMAIN_PAUSED, NodeState.SUSPENDED)//
// .build(); .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 FindLocationForDomain findLocationForDomain;
private final FindImageForDomain findImageForDomain; private final FindImageForDomain findImageForDomain;
private final Map<String, Credentials> credentialStore; private final Map<String, Credentials> credentialStore;
@Inject @Inject
DomainToNodeMetadata(Map<String, Credentials> credentialStore, FindHardwareForDomain findHardwareForDomain, DomainToNodeMetadata(Map<String, Credentials> credentialStore, Function<Domain, Hardware> findHardwareForDomain,
FindLocationForDomain findLocationForDomain, FindImageForDomain findImageForDomain) { FindLocationForDomain findLocationForDomain, FindImageForDomain findImageForDomain) {
this.credentialStore = checkNotNull(credentialStore, "credentialStore"); this.credentialStore = checkNotNull(credentialStore, "credentialStore");
this.findHardwareForDomain = checkNotNull(findHardwareForDomain, "findHardwareForDomain"); this.findHardwareForDomain = checkNotNull(findHardwareForDomain, "findHardwareForDomain");
@ -73,40 +80,31 @@ public class DomainToNodeMetadata implements Function<Domain, NodeMetadata> {
@Override @Override
public NodeMetadata apply(Domain from) { public NodeMetadata apply(Domain from) {
// convert the result object to a jclouds NodeMetadata // convert the result object to a jclouds NodeMetadata
NodeMetadataBuilder builder = new NodeMetadataBuilder(); NodeMetadataBuilder builder = new NodeMetadataBuilder();
// builder.ids(from.id + ""); try {
// builder.name(from.name); builder.id(from.getUUIDString());
// builder.location(findLocationForDomain.apply(from)); builder.providerId(from.getID() + "");
// builder.tag(parseTagFromName(from.name)); builder.name(from.getName());
// builder.imageId(from.imageId + ""); builder.location(findLocationForDomain.apply(from));
// Image image = findImageForDomain.apply(from); builder.tag(parseTagFromName(from.getName()));
// if (image != null)
// builder.operatingSystem(image.getOperatingSystem()); builder.operatingSystem(new OperatingSystemBuilder().description(from.getOSType()).build());
// builder.hardware(findHardwareForDomain.apply(from)); builder.hardware(findHardwareForDomain.apply(from));
// builder.state(serverStatusToNodeState.get(from.status));
builder.state(domainStateToNodeState.get(from.getInfo().state));
// builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress)); // builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
// builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress)); // 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(); 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 @Singleton
public static class FindImageForDomain extends FindResourceInSet<Domain, Image> { public static class FindImageForDomain extends FindResourceInSet<Domain, Image> {

View File

@ -2,6 +2,7 @@ package org.jclouds.libvirt.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -12,13 +13,15 @@ import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.libvirt.Datacenter; import org.jclouds.libvirt.Datacenter;
import org.jclouds.libvirt.Hardware;
import org.jclouds.libvirt.Image; import org.jclouds.libvirt.Image;
import org.libvirt.Connect; import org.libvirt.Connect;
import org.libvirt.Domain; import org.libvirt.Domain;
import org.libvirt.LibvirtException;
import org.libvirt.jna.Libvirt; import org.libvirt.jna.Libvirt;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
/** /**
* defines the connection between the {@link Libvirt} implementation and the jclouds * defines the connection between the {@link Libvirt} implementation and the jclouds
@ -26,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
* *
*/ */
@Singleton @Singleton
public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domain, Hardware, Image, Datacenter> { public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domain, Domain, Image, Datacenter> {
private final Connect client; private final Connect client;
@Inject @Inject
@ -47,10 +50,8 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
} }
@Override @Override
public Iterable<Hardware> listHardware() { public Iterable<Domain> listHardware() {
return ImmutableSet.of(); return listNodes();
// TODO
// return client.listHardware();
} }
@Override @Override
@ -62,9 +63,21 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
@Override @Override
public Iterable<Domain> listNodes() { public Iterable<Domain> listNodes() {
return ImmutableSet.of(); try {
// TODO List<Domain> domains = Lists.newArrayList();
// return client.listDomains(); 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 @Override
@ -74,18 +87,28 @@ public class LibvirtComputeServiceAdapter implements ComputeServiceAdapter<Domai
@Override @Override
public Domain getNode(String id) { public Domain getNode(String id) {
// int serverId = Integer.parseInt(id); try {
// return client.getDomain(serverId); return client.domainLookupByUUIDString(id);
return null; } catch (LibvirtException e) {
return propogate(e);
}
} }
@Override @Override
public void destroyNode(String id) { public void destroyNode(String id) {
// client.destroyDomain(Integer.parseInt(id)); try {
client.domainLookupByUUIDString(id).destroy();
} catch (LibvirtException e) {
propogate(e);
}
} }
@Override @Override
public void rebootNode(String id) { public void rebootNode(String id) {
// client.rebootDomain(Integer.parseInt(id)); try {
client.domainLookupByUUIDString(id).reboot(0);
} catch (LibvirtException e) {
propogate(e);
}
} }
} }

View File

@ -1,21 +1,16 @@
package org.jclouds.libvirt.compute; package org.jclouds.libvirt.compute;
import static org.easymock.classextension.EasyMock.createMock;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.StandaloneComputeServiceContextSpec; import org.jclouds.compute.StandaloneComputeServiceContextSpec;
import org.jclouds.libvirt.Datacenter; import org.jclouds.libvirt.Datacenter;
import org.jclouds.libvirt.Hardware;
import org.jclouds.libvirt.Image; import org.jclouds.libvirt.Image;
import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule; import org.jclouds.libvirt.compute.domain.LibvirtComputeServiceContextModule;
import org.libvirt.Connect;
import org.libvirt.Domain; import org.libvirt.Domain;
import org.libvirt.LibvirtException;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -37,18 +32,11 @@ public class LibvirtComputeServiceContextBuilderTest {
@Test @Test
public void testCanBuildWithComputeService() { public void testCanBuildWithComputeService() {
ComputeServiceContext context = new ComputeServiceContextFactory() ComputeServiceContext context = new ComputeServiceContextFactory()
.createContext(new StandaloneComputeServiceContextSpec<Domain, Hardware, Image, Datacenter>("libvirt", .createContext(new StandaloneComputeServiceContextSpec<Domain, Domain, Image, Datacenter>("libvirt",
"stub", "1", "identity", "credential", new StubLibvirtComputeServiceContextModule(), ImmutableSet "test:///default", "1", "identity", "credential", new LibvirtComputeServiceContextModule(),
.<Module> of())); ImmutableSet.<Module> of()));
System.err.println(context.getComputeService().listNodes());
context.close(); context.close();
} }
private static class StubLibvirtComputeServiceContextModule extends LibvirtComputeServiceContextModule {
@Override
protected Connect createConnection(URI endpoint, String identity, String credential) throws LibvirtException {
return createMock(Connect.class);
}
}
} }

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}