Issue 824:add field for hypervisor

This commit is contained in:
Adrian Cole 2012-01-30 22:52:35 -08:00
parent f50e3f5b8e
commit abeffc1119
32 changed files with 146 additions and 47 deletions

View File

@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableList;
@Singleton
public class FlavorToHardware implements Function<Flavor, Hardware> {
public Hardware apply(Flavor from) {
return new HardwareBuilder().ids(from.getId() + "").name(from.getName())
return new HardwareBuilder().ids(from.getId() + "").name(from.getName()).hypervisor("xen")
.processors(ImmutableList.of(new Processor(from.getDisk() / 10.0, 1.0))).ram(from.getRam())
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDisk(), true, true))).build();
}

View File

@ -161,7 +161,7 @@ public class CloudSigmaComputeServiceAdapter implements
return "sizeLessThanOrEqual(" + size + ")";
}
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu)))
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu))).hypervisor("kvm")
.volumes(ImmutableList.<Volume>of(new VolumeImpl(size, true, true))).build());
}
return hardware.build();

View File

@ -99,7 +99,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
builder.operatingSystem(image.getOperatingSystem());
}
}
builder.hardware(new HardwareBuilder().ids(from.getUuid())
builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm")
.processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
.volumes(Iterables.transform(from.getDevices().values(), deviceToVolume)).build());
builder.state(serverStatusToNodeState.get(from.getStatus()));

View File

@ -41,6 +41,7 @@ public class ServiceOfferingToHardware implements Function<ServiceOffering, Hard
.tags(offering.getTags())
.processors(ImmutableList.of(new Processor(offering.getCpuNumber(), offering.getCpuSpeed())))
.ram(offering.getMemory())//
// TODO: hypervisor probably from zone?
// TODO .volumes()
// displayText
// created

View File

@ -35,10 +35,12 @@ import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.collect.FindResourceInSet;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.HardwareBuilder;
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.Processor;
import org.jclouds.domain.Location;
import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.util.InetAddresses2;
@ -49,6 +51,7 @@ import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.UncheckedExecutionException;
@ -72,17 +75,14 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
.put(VirtualMachine.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
private final FindLocationForVirtualMachine findLocationForVirtualMachine;
private final FindHardwareForVirtualMachine findHardwareForVirtualMachine;
private final FindImageForVirtualMachine findImageForVirtualMachine;
private final LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine;
@Inject
VirtualMachineToNodeMetadata(FindLocationForVirtualMachine findLocationForVirtualMachine,
FindHardwareForVirtualMachine findHardwareForVirtualMachine,
FindImageForVirtualMachine findImageForVirtualMachine,
LoadingCache<Long, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine) {
this.findLocationForVirtualMachine = checkNotNull(findLocationForVirtualMachine, "findLocationForVirtualMachine");
this.findHardwareForVirtualMachine = checkNotNull(findHardwareForVirtualMachine, "findHardwareForVirtualMachine");
this.findImageForVirtualMachine = checkNotNull(findImageForVirtualMachine, "findImageForVirtualMachine");
this.getIPForwardingRulesByVirtualMachine = checkNotNull(getIPForwardingRulesByVirtualMachine,
"getIPForwardingRulesByVirtualMachine");
@ -109,9 +109,14 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
builder.operatingSystem(image.getOperatingSystem());
}
Hardware hardware = findHardwareForVirtualMachine.apply(from);
if (hardware != null)
builder.hardware(hardware);
builder.hardware(new HardwareBuilder()
.ids(from.getServiceOfferingId() + "")
.name(from.getServiceOfferingName() + "")
// .tags() TODO
.processors(ImmutableList.of(new Processor(from.getCpuCount(), from.getCpuSpeed())))
.ram((int)from.getMemory())//
.hypervisor(from.getHypervisor())//
.build());
builder.state(vmStateToNodeState.get(from.getState()));

View File

@ -23,13 +23,13 @@ import static org.testng.Assert.assertEquals;
import java.net.UnknownHostException;
import java.util.Set;
import org.jclouds.cloudstack.compute.functions.VirtualMachineToNodeMetadata.FindHardwareForVirtualMachine;
import org.jclouds.cloudstack.compute.functions.VirtualMachineToNodeMetadata.FindImageForVirtualMachine;
import org.jclouds.cloudstack.compute.functions.VirtualMachineToNodeMetadata.FindLocationForVirtualMachine;
import org.jclouds.cloudstack.domain.IPForwardingRule;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.parse.ListVirtualMachinesResponseTest;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.HardwareBuilder;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeMetadataBuilder;
@ -57,13 +57,10 @@ public class VirtualMachineToNodeMetadataTest {
Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
.<Location> of(ZoneToLocationTest.one, ZoneToLocationTest.two));
Supplier<Set<? extends Hardware>> hardwareSupplier = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
.<Hardware> of(ServiceOfferingToHardwareTest.one, ServiceOfferingToHardwareTest.two));
Supplier<Set<? extends Image>> imageSupplier = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
.<Image> of(TemplateToImageTest.one, TemplateToImageTest.two));
VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(new FindLocationForVirtualMachine(
locationSupplier), new FindHardwareForVirtualMachine(hardwareSupplier), new FindImageForVirtualMachine(
locationSupplier), new FindImageForVirtualMachine(
imageSupplier), CacheBuilder.newBuilder().<Long, Set<IPForwardingRule>> build(
new CacheLoader<Long, Set<IPForwardingRule>>() {
@ -84,7 +81,8 @@ public class VirtualMachineToNodeMetadataTest {
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3")
.location(ZoneToLocationTest.one).state(NodeState.PENDING).hostname("i-3-54-VM")
.privateAddresses(ImmutableSet.of("10.1.1.18")).publicAddresses(ImmutableSet.of("1.1.1.1"))
.hardware(ServiceOfferingToHardwareTest.one).imageId(TemplateToImageTest.one.getId())
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
.imageId(TemplateToImageTest.one.getId())
.operatingSystem(TemplateToImageTest.one.getOperatingSystem()).build().toString());
}
@ -95,13 +93,10 @@ public class VirtualMachineToNodeMetadataTest {
Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
.<Location> of(ZoneToLocationTest.one, ZoneToLocationTest.two));
Supplier<Set<? extends Hardware>> hardwareSupplier = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
.<Hardware> of(ServiceOfferingToHardwareTest.one, ServiceOfferingToHardwareTest.two));
Supplier<Set<? extends Image>> imageSupplier = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
.<Image> of(TemplateToImageTest.one, TemplateToImageTest.two));
VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(new FindLocationForVirtualMachine(
locationSupplier), new FindHardwareForVirtualMachine(hardwareSupplier), new FindImageForVirtualMachine(
locationSupplier), new FindImageForVirtualMachine(
imageSupplier), CacheBuilder.newBuilder().<Long, Set<IPForwardingRule>> build(
new CacheLoader<Long, Set<IPForwardingRule>>() {
@ -121,9 +116,14 @@ public class VirtualMachineToNodeMetadataTest {
node.toString(),
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3")
.location(ZoneToLocationTest.one).state(NodeState.PENDING).hostname("i-3-54-VM")
.privateAddresses(ImmutableSet.of("10.1.1.18")).hardware(ServiceOfferingToHardwareTest.one)
.privateAddresses(ImmutableSet.of("10.1.1.18"))
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
.imageId(TemplateToImageTest.one.getId())
.operatingSystem(TemplateToImageTest.one.getOperatingSystem()).build().toString());
}
protected Hardware addHypervisor(Hardware in, String hypervisor) {
return HardwareBuilder.fromHardware(in).hypervisor(hypervisor).build();
}
}

View File

@ -37,6 +37,7 @@
</monitoring>
<kernelId>aki-ba3adfd3</kernelId>
<ramdiskId>ari-badbad00</ramdiskId>
<hypervisor>xen</hypervisor>
</item>
<item>
<instanceId>i-28a64435</instanceId>
@ -66,6 +67,7 @@
</monitoring>
<kernelId>aki-ba3adfd3</kernelId>
<ramdiskId>ari-badbad00</ramdiskId>
<hypervisor>xen</hypervisor>
</item>
</instancesSet>
</item>

View File

@ -40,6 +40,7 @@
<virtualizationType>hvm</virtualizationType>
<privateIpAddress>10.210.209.157</privateIpAddress>
<ipAddress>75.101.203.146</ipAddress>
<hypervisor>xen</hypervisor>
<rootDeviceType>ebs</rootDeviceType>
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping>

View File

@ -37,6 +37,7 @@
</monitoring>
<privateIpAddress>10.243.42.70</privateIpAddress>
<ipAddress>174.129.81.68</ipAddress>
<hypervisor>xen</hypervisor>
</item>
</instancesSet>
</item>

View File

@ -26,6 +26,7 @@
<monitoring>
<state>enabled</state>
</monitoring>
<hypervisor>xen</hypervisor>
</item>
<item>
<instanceId>i-2bc64242</instanceId>
@ -46,6 +47,7 @@
<monitoring>
<state>enabled</state>
</monitoring>
<hypervisor>xen</hypervisor>
</item>
<item>
<instanceId>i-2be64332</instanceId>
@ -66,6 +68,7 @@
<monitoring>
<state>enabled</state>
</monitoring>
<hypervisor>xen</hypervisor>
</item>
</instancesSet>
</RunInstancesResponse>

View File

@ -153,7 +153,7 @@ public class ElasticStackComputeServiceAdapter implements
return "sizeLessThanOrEqual(" + size + ")";
}
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu)))
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu))).hypervisor("kvm")
.volumes(ImmutableList.<Volume> of(new VolumeImpl(size, true, true))).build());
}
return hardware.build();

View File

@ -100,7 +100,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
builder.operatingSystem(image.getOperatingSystem());
}
}
builder.hardware(new HardwareBuilder().ids(from.getUuid())
builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm")
.processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
.volumes((List) ImmutableList.of(Iterables.transform(from.getDevices().values(), deviceToVolume))).build());
builder.state(serverStatusToNodeState.get(from.getStatus()));

View File

@ -67,6 +67,7 @@ public class HardwareForVApp implements Function<VApp, Hardware> {
builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC()));
builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
ImagePredicates.idEquals(from.getHref().toASCIIString()));
builder.hypervisor("VMware");
return builder.build();
}
}

View File

@ -75,6 +75,7 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
}
builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
ImagePredicates.idEquals(from.getHref().toASCIIString()));
builder.hypervisor("VMware");
return builder.build();
}

View File

@ -62,6 +62,7 @@ public class HardwareForVCloudExpressVApp implements Function<VApp, Hardware> {
builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC()));
builder.ids(from.getHref().toASCIIString()).name(from.getName())
.supportsImage(ImagePredicates.idEquals(from.getHref().toASCIIString()));
builder.hypervisor("VMware");
return builder.build();
} catch (NoSuchElementException e) {
logger.debug("incomplete data to form vApp %s", from.getHref());

View File

@ -45,7 +45,7 @@ public class StaticHardwareSupplier implements Supplier<Set<? extends Hardware>>
for (int ram : new int[] { 512, 1024, 2048, 4096, 8192, 16384 }) {
String id = String.format("cpu=%d,ram=%s,disk=%d", cpus, ram, 10);
hardware.add(new HardwareBuilder().ids(id).ram(ram).processors(ImmutableList.of(new Processor(cpus, 1.0)))
.volumes(ImmutableList.<Volume> of(new VolumeImpl(10f, true, true))).build());
.volumes(ImmutableList.<Volume> of(new VolumeImpl(10f, true, true))).hypervisor("VMware").build());
}
return hardware;
}

View File

@ -21,6 +21,7 @@ package org.jclouds.compute.domain;
import java.util.List;
import org.jclouds.compute.domain.internal.HardwareImpl;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Predicate;
import com.google.inject.ImplementedBy;
@ -53,4 +54,9 @@ public interface Hardware extends ComputeMetadata {
*/
Predicate<Image> supportsImage();
/**
* @return hypervisor type, if this is a virtual machine and the type is known
*/
@Nullable
String getHypervisor();
}

View File

@ -43,6 +43,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
protected int ram;
protected List<Volume> volumes = Lists.newArrayList();
protected Predicate<Image> supportsImage = any();
protected String hypervisor;
public HardwareBuilder() {
super(ComputeType.HARDWARE);
@ -78,6 +79,11 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
return this;
}
public HardwareBuilder hypervisor(String hypervisor) {
this.hypervisor = hypervisor;
return this;
}
public HardwareBuilder is64Bit(boolean is64Bit) {
supportsImage(is64Bit ? ImagePredicates.is64Bit() : not(ImagePredicates.is64Bit()));
return this;
@ -126,7 +132,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
@Override
public Hardware build() {
return new HardwareImpl(providerId, name, id, location, uri, userMetadata, tags, processors, ram, volumes,
supportsImage);
supportsImage, hypervisor);
}
@SuppressWarnings("unchecked")
@ -134,6 +140,6 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name(
in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors(
List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes()))
.supportsImage(in.supportsImage());
.supportsImage(in.supportsImage()).hypervisor(in.getHypervisor());
}
}

View File

@ -52,15 +52,17 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
private final int ram;
private final List<Volume> volumes;
private final Predicate<Image> supportsImage;
private final String hypervisor;
public HardwareImpl(String providerId, String name, String id, @Nullable Location location, URI uri,
Map<String, String> userMetadata, Set<String> tags, Iterable<? extends Processor> processors, int ram,
Iterable<? extends Volume> volumes, Predicate<Image> supportsImage) {
Iterable<? extends Volume> volumes, Predicate<Image> supportsImage, @Nullable String hypervisor) {
super(ComputeType.HARDWARE, providerId, name, id, location, uri, userMetadata, tags);
this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors"));
this.ram = ram;
this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes"));
this.supportsImage = supportsImage;
this.hypervisor = hypervisor;
}
/**
@ -87,6 +89,15 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
return volumes;
}
/**
* {@inheritDoc}
*/
@Override
@Nullable
public String getHypervisor() {
return hypervisor;
}
/**
* {@inheritDoc}
*/
@ -94,8 +105,9 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
public int compareTo(ResourceMetadata<ComputeType> that) {
if (that instanceof Hardware) {
Hardware thatHardware = Hardware.class.cast(that);
return ComparisonChain.start().compare(getCoresAndSpeed(this), getCoresAndSpeed(thatHardware))
.compare(this.getRam(), thatHardware.getRam()).compare(getSpace(this), getSpace(thatHardware)).result();
return ComparisonChain.start().compare(getCoresAndSpeed(this), getCoresAndSpeed(thatHardware)).compare(
this.getRam(), thatHardware.getRam()).compare(getSpace(this), getSpace(thatHardware)).compare(
getHypervisor(), thatHardware.getHypervisor()).result();
} else {
return super.compareTo(that);
}
@ -107,7 +119,8 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
@Override
public String toString() {
return "[id=" + getId() + ", providerId=" + getProviderId() + ", name=" + getName() + ", processors="
+ processors + ", ram=" + ram + ", volumes=" + volumes + ", supportsImage=" + supportsImage + ", tags=" + tags + "]";
+ processors + ", ram=" + ram + ", volumes=" + volumes + ", hypervisor=" + hypervisor
+ ", supportsImage=" + supportsImage + ", tags=" + tags + "]";
}
/**

View File

@ -52,6 +52,7 @@ public class IMachineToHardware implements Function<IMachine, Hardware> {
hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getId()));
hardwareBuilder.is64Bit(is64Bit);
hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getId()));
hardwareBuilder.hypervisor("VirtualBox");
return hardwareBuilder.build();
}
}

View File

@ -31,6 +31,7 @@ import javax.inject.Singleton;
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.HardwareBuilder;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.compute.domain.NodeState;
@ -73,9 +74,18 @@ public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetad
builder.credentials(creds);
}
protected Hardware parseHardware(RunningInstance instance) {
Hardware in = super.parseHardware(instance);
if (in == null)
return null;
AWSRunningInstance awsInstance = AWSRunningInstance.class.cast(instance);
return HardwareBuilder.fromHardware(in).hypervisor(awsInstance.getHypervisor().toString()).build();
}
@Override
protected NodeMetadataBuilder buildInstance(RunningInstance instance, NodeMetadataBuilder builder) {
Map<String, String> tags = AWSRunningInstance.class.cast(instance).getTags();
AWSRunningInstance awsInstance = AWSRunningInstance.class.cast(instance);
Map<String, String> tags = awsInstance.getTags();
return super.buildInstance(instance, builder).name(tags.get("Name")).tags(
filterValues(tags, equalTo("")).keySet()).userMetadata(filterValues(tags, not(equalTo(""))));
}

View File

@ -24,13 +24,14 @@ import java.util.Date;
import java.util.Map;
import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.RootDeviceType;
import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -56,6 +57,7 @@ public class AWSRunningInstance extends RunningInstance {
private String subnetId;
private String spotInstanceRequestId;
private String vpcId;
private Hypervisor hypervisor;
private Map<String, String> securityGroupIdToNames = Maps.newLinkedHashMap();
private Map<String, String> tags = Maps.newLinkedHashMap();
@ -118,6 +120,11 @@ public class AWSRunningInstance extends RunningInstance {
return this;
}
public Builder hypervisor(Hypervisor hypervisor) {
this.hypervisor = hypervisor;
return this;
}
@Override
public Builder amiLaunchIndex(String amiLaunchIndex) {
return Builder.class.cast(super.amiLaunchIndex(amiLaunchIndex));
@ -244,7 +251,7 @@ public class AWSRunningInstance extends RunningInstance {
instanceState, instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone,
virtualizationType, platform, privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType,
rootDeviceName, ebsBlockDevices, monitoringState, placementGroup, productCodes, subnetId,
spotInstanceRequestId, vpcId, tags);
spotInstanceRequestId, vpcId, hypervisor, tags);
}
}
@ -259,6 +266,7 @@ public class AWSRunningInstance extends RunningInstance {
private final String spotInstanceRequestId;
@Nullable
private final String vpcId;
private final Hypervisor hypervisor;
private final Map<String, String> securityGroupIdToNames;
private final Map<String, String> tags;
@ -268,7 +276,7 @@ public class AWSRunningInstance extends RunningInstance {
String virtualizationType, String platform, String privateDnsName, String privateIpAddress, String ramdiskId,
String reason, RootDeviceType rootDeviceType, String rootDeviceName, Map<String, BlockDevice> ebsBlockDevices,
MonitoringState monitoringState, String placementGroup, Iterable<String> productCodes, String subnetId,
String spotInstanceRequestId, String vpcId, Map<String, String> tags) {
String spotInstanceRequestId, String vpcId, Hypervisor hypervisor, Map<String, String> tags) {
super(region, securityGroupIdToNames.values(), amiLaunchIndex, dnsName, imageId, instanceId, instanceState,
instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone, virtualizationType, platform,
privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType, rootDeviceName, ebsBlockDevices);
@ -278,6 +286,7 @@ public class AWSRunningInstance extends RunningInstance {
this.subnetId = subnetId;
this.spotInstanceRequestId = spotInstanceRequestId;
this.vpcId = vpcId;
this.hypervisor = checkNotNull(hypervisor, "hypervisor");
this.securityGroupIdToNames = ImmutableMap.<String, String> copyOf(checkNotNull(securityGroupIdToNames,
"securityGroupIdToNames"));
this.tags = ImmutableMap.<String, String> copyOf(checkNotNull(tags, "tags"));
@ -324,6 +333,14 @@ public class AWSRunningInstance extends RunningInstance {
return vpcId;
}
/**
* hypervisor of the VM
* @see Hypervisor
*/
public Hypervisor getHypervisor() {
return hypervisor;
}
/**
* Specifies the subnet ID in which the instance is running (Amazon Virtual
* Private Cloud).
@ -348,6 +365,7 @@ public class AWSRunningInstance extends RunningInstance {
result = prime * result + ((spotInstanceRequestId == null) ? 0 : spotInstanceRequestId.hashCode());
result = prime * result + ((subnetId == null) ? 0 : subnetId.hashCode());
result = prime * result + ((vpcId == null) ? 0 : vpcId.hashCode());
result = prime * result + ((hypervisor == null) ? 0 : hypervisor.hashCode());
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
return result;
}
@ -391,6 +409,8 @@ public class AWSRunningInstance extends RunningInstance {
return false;
} else if (!tags.equals(other.tags))
return false;
if (!Objects.equal(hypervisor, other.hypervisor))
return false;
return true;
}
@ -399,12 +419,12 @@ public class AWSRunningInstance extends RunningInstance {
return "[region=" + region + ", availabilityZone=" + availabilityZone + ", instanceId=" + instanceId
+ ", instanceState=" + instanceState + ", instanceType=" + instanceType + ", virtualizationType="
+ virtualizationType + ", imageId=" + imageId + ", ipAddress=" + ipAddress + ", dnsName=" + dnsName
+ ", privateIpAddress=" + privateIpAddress + ", privateDnsName=" + privateDnsName + ", keyName=" + keyName
+ ", platform=" + platform + ", launchTime=" + launchTime + ", rootDeviceName=" + rootDeviceName
+ ", rootDeviceType=" + rootDeviceType + ", ebsBlockDevices=" + ebsBlockDevices + ", monitoringState="
+ monitoringState + ", placementGroup=" + placementGroup + ", productCodes=" + productCodes
+ ", spotInstanceRequestId=" + spotInstanceRequestId + ", subnetId=" + subnetId + ", vpcId=" + vpcId
+ ", tags=" + tags + "]";
+ ", privateIpAddress=" + privateIpAddress + ", privateDnsName=" + privateDnsName + ", keyName="
+ keyName + ", platform=" + platform + ", launchTime=" + launchTime + ", rootDeviceName="
+ rootDeviceName + ", rootDeviceType=" + rootDeviceType + ", ebsBlockDevices=" + ebsBlockDevices
+ ", monitoringState=" + monitoringState + ", placementGroup=" + placementGroup + ", productCodes="
+ productCodes + ", spotInstanceRequestId=" + spotInstanceRequestId + ", subnetId=" + subnetId
+ ", hypervisor=" + hypervisor + ", vpcId=" + vpcId + ", tags=" + tags + "]";
}
}

View File

@ -24,6 +24,7 @@ import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.aws.ec2.domain.LaunchSpecification;
import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.InstanceState;
import com.google.common.base.Function;
@ -58,6 +59,8 @@ public class SpotInstanceRequestToAWSRunningInstance implements Function<SpotIns
builder.ramdiskId(spec.getRamdiskId());
builder.monitoringState(Boolean.TRUE.equals(spec.isMonitoringEnabled()) ? MonitoringState.PENDING
: MonitoringState.DISABLED);
//TODO: determine the exact hypervisor
builder.hypervisor(Hypervisor.XEN);
return builder.build();
}

View File

@ -27,6 +27,7 @@ import javax.inject.Inject;
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.Reservation;
import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.location.Region;

View File

@ -34,6 +34,7 @@ import org.jclouds.aws.util.AWSUtils;
import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.Reservation;
import org.jclouds.ec2.domain.RootDeviceType;
@ -133,6 +134,8 @@ public abstract class BaseAWSReservationHandler<T> extends HandlerForGeneratedRe
builder.spotInstanceRequestId(currentOrNull(currentText));
} else if (equalsOrSuffix(qName, "vpcId")) {
builder.vpcId(currentOrNull(currentText));
} else if (equalsOrSuffix(qName, "hypervisor")) {
builder.hypervisor(Hypervisor.fromValue(currentOrNull(currentText)));
} else if (equalsOrSuffix(qName, "productCode")) {
builder.productCode(currentOrNull(currentText));
} else if (equalsOrSuffix(qName, "instancesSet")) {

View File

@ -39,6 +39,7 @@ import org.jclouds.ec2.compute.domain.RegionAndName;
import org.jclouds.ec2.compute.functions.ImagesToRegionAndIdMap;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.RootDeviceType;
import org.testng.annotations.BeforeTest;
@ -101,6 +102,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
.virtualizationType("paravirtual")
.tag("Name", "foo")
.tag("Empty", "")
.hypervisor(Hypervisor.XEN)
.build(),//
new AWSRunningInstance.Builder()
.region(defaultRegion)
@ -123,6 +125,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
.rootDeviceName("/dev/sda1")
.device("/dev/sda1", new BlockDevice("vol-5029fc3a", Attachment.Status.ATTACHED, dateService.iso8601DateParse("2011-08-16T13:41:19.000Z"), true))
.virtualizationType("paravirtual")
.hypervisor(Hypervisor.XEN)
.build());
assertEquals(

View File

@ -25,6 +25,7 @@ import org.jclouds.aws.ec2.domain.LaunchSpecification;
import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.InstanceState;
import org.testng.annotations.Test;
@ -64,6 +65,7 @@ public class SpotInstanceRequestToAWSRunningInstanceTest {
.groupId("default").instanceType("m1.large")
.tag("foo", "bar")
.tag("empty", "")
.hypervisor(Hypervisor.XEN)
.monitoringState(MonitoringState.PENDING).build());
}

View File

@ -29,6 +29,7 @@ import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.Reservation;
@ -91,6 +92,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.privateIpAddress("10.243.42.70")
.ramdiskId("ari-a51cf9cc")
.rootDeviceType(RootDeviceType.INSTANCE_STORE)
.hypervisor(Hypervisor.XEN)
.build()),
"993194456877", null, "r-a3c508cb"));
@ -127,6 +129,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
"/dev/sda1",
new BlockDevice("vol-5829fc32", Attachment.Status.ATTACHED, dateService
.iso8601DateParse("2011-08-16T13:41:19.000Z"), true))
.hypervisor(Hypervisor.XEN)
.virtualizationType("paravirtual").build(),//
new AWSRunningInstance.Builder()
.region(defaultRegion)
@ -152,6 +155,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
"/dev/sda1",
new BlockDevice("vol-5029fc3a", Attachment.Status.ATTACHED, dateService
.iso8601DateParse("2011-08-16T13:41:19.000Z"), true))
.hypervisor(Hypervisor.XEN)
.virtualizationType("paravirtual").build()), defaultRegion, defaultRegion, defaultRegion));
Set<Reservation<? extends RunningInstance>> result = parseAWSRunningInstances("/describe_instances_latest.xml");
@ -176,6 +180,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.monitoringState(MonitoringState.DISABLED).availabilityZone("us-east-1b")
.virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal")
.productCode("774F4FF8").ramdiskId("ari-badbad00")
.hypervisor(Hypervisor.XEN)
.rootDeviceType(RootDeviceType.INSTANCE_STORE).build(),
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("23")
.dnsName("ec2-72-44-33-6.compute-1.amazonaws.com").imageId("ami-6ea54007")
@ -185,6 +190,7 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.monitoringState(MonitoringState.DISABLED).availabilityZone("us-east-1b")
.virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal")
.productCode("774F4FF8").ramdiskId("ari-badbad00")
.hypervisor(Hypervisor.XEN)
.rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM",
null, "r-44a5402d"));
@ -217,8 +223,10 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
.privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal")
.privateIpAddress("10.210.209.157")
.ramdiskId("ari-a51cf9cc")
.hypervisor(Hypervisor.XEN)
.rootDeviceType(RootDeviceType.EBS)
.rootDeviceName("/dev/sda1")
.hypervisor(Hypervisor.XEN)
.device(
"/dev/sda1",
new BlockDevice("vol-dc6ca8b5", Attachment.Status.ATTACHED, dateService

View File

@ -28,6 +28,7 @@ import java.io.InputStream;
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.date.DateService;
import org.jclouds.ec2.domain.Hypervisor;
import org.jclouds.ec2.domain.InstanceState;
import org.jclouds.ec2.domain.InstanceType;
import org.jclouds.ec2.domain.Reservation;
@ -85,18 +86,21 @@ public class AWSRunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
.imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING)
.instanceType(InstanceType.M1_SMALL).keyName("example-key-name")
.launchTime(dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))
.hypervisor(Hypervisor.XEN)
.monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1")
.imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING)
.instanceType(InstanceType.M1_SMALL).keyName("example-key-name")
.launchTime(dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))
.hypervisor(Hypervisor.XEN)
.monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2")
.imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING)
.instanceType(InstanceType.M1_SMALL).keyName("example-key-name")
.launchTime(dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))
.hypervisor(Hypervisor.XEN)
.monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
, "AIDADH4IGTRXXKCD", null, "r-47a5402e");

View File

@ -49,6 +49,7 @@ public class VMSpecToHardware implements Function<VMSpec, Hardware> {
for (Entry<String, Integer> disk : from.getDataDiskDeviceNameToSizeInGig().entrySet())
builder.volume(new VolumeBuilder().type(Volume.Type.LOCAL).device(disk.getKey()).size(
new Float(disk.getValue())).durable(true).build());
builder.hypervisor("VMware");
return builder.build();
}

View File

@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableList;
@Singleton
public class FlavorToHardware implements Function<Flavor, Hardware> {
public Hardware apply(Flavor from) {
return new HardwareBuilder().ids(from.getId() + "").name(from.getName())
return new HardwareBuilder().ids(from.getId() + "").name(from.getName()).hypervisor("xen")
.processors(ImmutableList.of(new Processor(from.getRam() / 1024.0, 1.0))).ram(from.getRam())
.volumes(ImmutableList.<Volume> of(new VolumeImpl((from.getRam() * 4) / 1024.0f, true, true))).build();
}

View File

@ -90,7 +90,9 @@ public class ProductItemsToHardware implements Function<Iterable<ProductItem>, H
int ram = ProductItems.capacity().apply(ramItem).intValue();
return new HardwareBuilder().ids(hardwareId).processors(ImmutableList.of(new Processor(cores, coreSpeed))).ram(
ram).volumes(
ram)
.hypervisor("XenServer")
.volumes(
Iterables.transform(filter(items, categoryCodeMatches(diskCategoryRegex)),
new Function<ProductItem, Volume>() {
@Override