diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/FlavorToHardware.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/FlavorToHardware.java index 216286a915..4b70a8765c 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/FlavorToHardware.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/FlavorToHardware.java @@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableList; @Singleton public class FlavorToHardware implements Function { 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. of(new VolumeImpl((float) from.getDisk(), true, true))).build(); } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java index 8eb2b6742a..c5fb91b033 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java @@ -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.of(new VolumeImpl(size, true, true))).build()); } return hardware.build(); diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java index 7e6bfc88dd..81052ea44a 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java @@ -99,7 +99,7 @@ public class ServerInfoToNodeMetadata implements Function> getIPForwardingRulesByVirtualMachine; @Inject VirtualMachineToNodeMetadata(FindLocationForVirtualMachine findLocationForVirtualMachine, - FindHardwareForVirtualMachine findHardwareForVirtualMachine, FindImageForVirtualMachine findImageForVirtualMachine, LoadingCache> getIPForwardingRulesByVirtualMachine) { this.findLocationForVirtualMachine = checkNotNull(findLocationForVirtualMachine, "findLocationForVirtualMachine"); - this.findHardwareForVirtualMachine = checkNotNull(findHardwareForVirtualMachine, "findHardwareForVirtualMachine"); this.findImageForVirtualMachine = checkNotNull(findImageForVirtualMachine, "findImageForVirtualMachine"); this.getIPForwardingRulesByVirtualMachine = checkNotNull(getIPForwardingRulesByVirtualMachine, "getIPForwardingRulesByVirtualMachine"); @@ -108,10 +108,15 @@ public class VirtualMachineToNodeMetadata implements Function> locationSupplier = Suppliers.> ofInstance(ImmutableSet . of(ZoneToLocationTest.one, ZoneToLocationTest.two)); - Supplier> hardwareSupplier = Suppliers.> ofInstance(ImmutableSet - . of(ServiceOfferingToHardwareTest.one, ServiceOfferingToHardwareTest.two)); - Supplier> imageSupplier = Suppliers.> ofInstance(ImmutableSet . of(TemplateToImageTest.one, TemplateToImageTest.two)); VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(new FindLocationForVirtualMachine( - locationSupplier), new FindHardwareForVirtualMachine(hardwareSupplier), new FindImageForVirtualMachine( + locationSupplier), new FindImageForVirtualMachine( imageSupplier), CacheBuilder.newBuilder().> build( new CacheLoader>() { @@ -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> locationSupplier = Suppliers.> ofInstance(ImmutableSet . of(ZoneToLocationTest.one, ZoneToLocationTest.two)); - Supplier> hardwareSupplier = Suppliers.> ofInstance(ImmutableSet - . of(ServiceOfferingToHardwareTest.one, ServiceOfferingToHardwareTest.two)); - Supplier> imageSupplier = Suppliers.> ofInstance(ImmutableSet . of(TemplateToImageTest.one, TemplateToImageTest.two)); VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(new FindLocationForVirtualMachine( - locationSupplier), new FindHardwareForVirtualMachine(hardwareSupplier), new FindImageForVirtualMachine( + locationSupplier), new FindImageForVirtualMachine( imageSupplier), CacheBuilder.newBuilder().> build( new CacheLoader>() { @@ -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(); + } } diff --git a/apis/ec2/src/test/resources/describe_instances.xml b/apis/ec2/src/test/resources/describe_instances.xml index 2b0e6414d5..524a81c740 100644 --- a/apis/ec2/src/test/resources/describe_instances.xml +++ b/apis/ec2/src/test/resources/describe_instances.xml @@ -37,6 +37,7 @@ aki-ba3adfd3 ari-badbad00 + xen i-28a64435 @@ -66,6 +67,7 @@ aki-ba3adfd3 ari-badbad00 + xen diff --git a/apis/ec2/src/test/resources/describe_instances_ebs.xml b/apis/ec2/src/test/resources/describe_instances_ebs.xml index 3ab1c907d7..d73877f44c 100644 --- a/apis/ec2/src/test/resources/describe_instances_ebs.xml +++ b/apis/ec2/src/test/resources/describe_instances_ebs.xml @@ -40,6 +40,7 @@ hvm 10.210.209.157 75.101.203.146 + xen ebs /dev/sda1 diff --git a/apis/ec2/src/test/resources/describe_instances_running.xml b/apis/ec2/src/test/resources/describe_instances_running.xml index d3813d4356..5f15e85fb5 100644 --- a/apis/ec2/src/test/resources/describe_instances_running.xml +++ b/apis/ec2/src/test/resources/describe_instances_running.xml @@ -37,6 +37,7 @@ 10.243.42.70 174.129.81.68 + xen diff --git a/apis/ec2/src/test/resources/run_instances.xml b/apis/ec2/src/test/resources/run_instances.xml index 36e330889a..0b547fae5f 100644 --- a/apis/ec2/src/test/resources/run_instances.xml +++ b/apis/ec2/src/test/resources/run_instances.xml @@ -26,6 +26,7 @@ enabled + xen i-2bc64242 @@ -46,6 +47,7 @@ enabled + xen i-2be64332 @@ -66,6 +68,7 @@ enabled + xen \ No newline at end of file diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java index d2904595ad..6b30b560a1 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java @@ -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. of(new VolumeImpl(size, true, true))).build()); } return hardware.build(); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java index 3c4b243f3c..84f9ba05bd 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java @@ -100,7 +100,7 @@ public class ServerInfoToNodeMetadata implements Function { 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(); } } \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java index ac14181132..50a038b9b5 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java @@ -75,6 +75,7 @@ public class HardwareForVAppTemplate implements Function } builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage( ImagePredicates.idEquals(from.getHref().toASCIIString())); + builder.hypervisor("VMware"); return builder.build(); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/HardwareForVCloudExpressVApp.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/HardwareForVCloudExpressVApp.java index c8c729da44..a5719ba756 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/HardwareForVCloudExpressVApp.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/HardwareForVCloudExpressVApp.java @@ -62,6 +62,7 @@ public class HardwareForVCloudExpressVApp implements Function { 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()); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/StaticHardwareSupplier.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/StaticHardwareSupplier.java index 7027f24167..237c5055ca 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/StaticHardwareSupplier.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/StaticHardwareSupplier.java @@ -45,7 +45,7 @@ public class StaticHardwareSupplier implements Supplier> 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. of(new VolumeImpl(10f, true, true))).build()); + .volumes(ImmutableList. of(new VolumeImpl(10f, true, true))).hypervisor("VMware").build()); } return hardware; } diff --git a/compute/src/main/java/org/jclouds/compute/domain/Hardware.java b/compute/src/main/java/org/jclouds/compute/domain/Hardware.java index ec6f5e1234..60045c1f87 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/Hardware.java +++ b/compute/src/main/java/org/jclouds/compute/domain/Hardware.java @@ -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; @@ -42,7 +43,7 @@ public interface Hardware extends ComputeMetadata { * Amount of RAM provided in MB (256M, 1740) */ int getRam(); - + /** * volumes associated with this. */ @@ -53,4 +54,9 @@ public interface Hardware extends ComputeMetadata { */ Predicate supportsImage(); + /** + * @return hypervisor type, if this is a virtual machine and the type is known + */ + @Nullable + String getHypervisor(); } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java index 78546b18ce..f935ae4cbd 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java @@ -43,6 +43,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder { protected int ram; protected List volumes = Lists.newArrayList(); protected Predicate 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()); } } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java index 3365b0329b..e31d5264a0 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/HardwareImpl.java @@ -52,15 +52,17 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware { private final int ram; private final List volumes; private final Predicate supportsImage; + private final String hypervisor; public HardwareImpl(String providerId, String name, String id, @Nullable Location location, URI uri, Map userMetadata, Set tags, Iterable processors, int ram, - Iterable volumes, Predicate supportsImage) { + Iterable volumes, Predicate 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 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 + "]"; } /** diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java index 3c4ff2d8da..913d40a63e 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java @@ -52,6 +52,7 @@ public class IMachineToHardware implements Function { hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getId())); hardwareBuilder.is64Bit(is64Bit); hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getId())); + hardwareBuilder.hypervisor("VirtualBox"); return hardwareBuilder.build(); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java index 6ac3308c77..66ba9e35fc 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java @@ -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; @@ -72,10 +73,19 @@ public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetad if (creds != null) 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 tags = AWSRunningInstance.class.cast(instance).getTags(); + AWSRunningInstance awsInstance = AWSRunningInstance.class.cast(instance); + Map tags = awsInstance.getTags(); return super.buildInstance(instance, builder).name(tags.get("Name")).tags( filterValues(tags, equalTo("")).keySet()).userMetadata(filterValues(tags, not(equalTo("")))); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java index eb428895bd..0776ecc716 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java @@ -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 securityGroupIdToNames = Maps.newLinkedHashMap(); private Map tags = Maps.newLinkedHashMap(); @@ -117,6 +119,11 @@ public class AWSRunningInstance extends RunningInstance { this.vpcId = vpcId; return this; } + + public Builder hypervisor(Hypervisor hypervisor) { + this.hypervisor = hypervisor; + return this; + } @Override public Builder amiLaunchIndex(String 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 securityGroupIdToNames; private final Map 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 ebsBlockDevices, MonitoringState monitoringState, String placementGroup, Iterable productCodes, String subnetId, - String spotInstanceRequestId, String vpcId, Map tags) { + String spotInstanceRequestId, String vpcId, Hypervisor hypervisor, Map 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. copyOf(checkNotNull(securityGroupIdToNames, "securityGroupIdToNames")); this.tags = ImmutableMap. copyOf(checkNotNull(tags, "tags")); @@ -323,7 +332,15 @@ public class AWSRunningInstance extends RunningInstance { public String getVpcId() { 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,20 +409,22 @@ 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; } @Override public String toString() { 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 + "]"; + + ", 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 + + ", hypervisor=" + hypervisor + ", vpcId=" + vpcId + ", tags=" + tags + "]"; } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java index 0cef5d0e93..314e1daca0 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java @@ -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 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")) { diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java index 2053d4a95f..d305b71515 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java @@ -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( diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java index 4f08e4a59c..d41fc990e3 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java @@ -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()); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java index 1183cdf649..9af948b628 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java @@ -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> 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 diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java index b9d61235bd..bd9783e3c5 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java @@ -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"); diff --git a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMSpecToHardware.java b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMSpecToHardware.java index 7b9ece6527..66acfca310 100644 --- a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMSpecToHardware.java +++ b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMSpecToHardware.java @@ -49,6 +49,7 @@ public class VMSpecToHardware implements Function { for (Entry 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(); } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java index e773cbf162..8b024aebef 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/FlavorToHardware.java @@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableList; @Singleton public class FlavorToHardware implements Function { 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. of(new VolumeImpl((from.getRam() * 4) / 1024.0f, true, true))).build(); } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java index 7316e0c0de..caca779246 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java @@ -90,7 +90,9 @@ public class ProductItemsToHardware implements Function, 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() { @Override