From de4ad5ba9ac675f78c4786a5b6bdb2896d47277d Mon Sep 17 00:00:00 2001 From: andreaturli Date: Tue, 27 Sep 2011 23:15:08 +0100 Subject: [PATCH] issue 384: add link between Image and Hardware in IMachineToHardware --- .../jclouds/virtualbox/functions/IMachineToHardware.java | 7 +++++-- .../org/jclouds/virtualbox/functions/IMachineToImage.java | 1 - .../virtualbox/functions/IMachineToHardwareTest.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java index fe271a501c..fa56108ee5 100644 --- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java +++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToHardware.java @@ -21,15 +21,17 @@ package org.jclouds.virtualbox.functions; -import com.google.common.base.Function; +import javax.inject.Inject; + import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; +import org.jclouds.compute.predicates.ImagePredicates; import org.jclouds.javax.annotation.Nullable; import org.virtualbox_4_1.IGuestOSType; import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.VirtualBoxManager; -import javax.inject.Inject; +import com.google.common.base.Function; public class IMachineToHardware implements Function { @@ -49,6 +51,7 @@ public class IMachineToHardware implements Function { Boolean is64Bit = guestOSType.getIs64Bit(); HardwareBuilder hardwareBuilder = new HardwareBuilder(); hardwareBuilder.ids(vm.getId()); + hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getId())); hardwareBuilder.is64Bit(is64Bit); return hardwareBuilder.build(); } diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToImage.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToImage.java index b0d4d3f5f4..8b4f9a3312 100644 --- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToImage.java +++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToImage.java @@ -50,7 +50,6 @@ public class IMachineToImage implements Function { IGuestOSType guestOSType = virtualboxManager.getVBox().getGuestOSType(from.getOSTypeId()); - //Somehow this method gets called with the correct product item. OsFamily family = osFamily().apply(guestOSType.getDescription()); OperatingSystem os = OperatingSystem.builder() .description(guestOSType.getDescription()) diff --git a/sandbox-apis/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToHardwareTest.java b/sandbox-apis/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToHardwareTest.java index d3f86ea718..61f5ea6ee8 100644 --- a/sandbox-apis/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToHardwareTest.java +++ b/sandbox-apis/virtualbox/src/test/java/org/jclouds/virtualbox/functions/IMachineToHardwareTest.java @@ -48,12 +48,13 @@ public class IMachineToHardwareTest { String machineId = "hw-machineId"; expect(vm.getOSTypeId()).andReturn("os-type").anyTimes(); + expect(vm.getId()).andReturn(machineId).anyTimes(); + expect(vm.getDescription()).andReturn(linuxDescription).anyTimes(); expect(vBox.getGuestOSType(eq("os-type"))).andReturn(guestOsType); expect(vbm.getVBox()).andReturn(vBox); expect(guestOsType.getIs64Bit()).andReturn(true); - expect(vm.getId()).andReturn(machineId); replay(vbm, vBox, vm, guestOsType);