issue 384: add link between Image and Hardware in IMachineToHardware

This commit is contained in:
andreaturli 2011-09-27 23:15:08 +01:00
parent ea148929ff
commit de4ad5ba9a
3 changed files with 7 additions and 4 deletions

View File

@ -21,15 +21,17 @@
package org.jclouds.virtualbox.functions; 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.Hardware;
import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.HardwareBuilder;
import org.jclouds.compute.predicates.ImagePredicates;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.virtualbox_4_1.IGuestOSType; import org.virtualbox_4_1.IGuestOSType;
import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.VirtualBoxManager; import org.virtualbox_4_1.VirtualBoxManager;
import javax.inject.Inject; import com.google.common.base.Function;
public class IMachineToHardware implements Function<IMachine, Hardware> { public class IMachineToHardware implements Function<IMachine, Hardware> {
@ -49,6 +51,7 @@ public class IMachineToHardware implements Function<IMachine, Hardware> {
Boolean is64Bit = guestOSType.getIs64Bit(); Boolean is64Bit = guestOSType.getIs64Bit();
HardwareBuilder hardwareBuilder = new HardwareBuilder(); HardwareBuilder hardwareBuilder = new HardwareBuilder();
hardwareBuilder.ids(vm.getId()); hardwareBuilder.ids(vm.getId());
hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getId()));
hardwareBuilder.is64Bit(is64Bit); hardwareBuilder.is64Bit(is64Bit);
return hardwareBuilder.build(); return hardwareBuilder.build();
} }

View File

@ -50,7 +50,6 @@ public class IMachineToImage implements Function<IMachine, Image> {
IGuestOSType guestOSType = virtualboxManager.getVBox().getGuestOSType(from.getOSTypeId()); IGuestOSType guestOSType = virtualboxManager.getVBox().getGuestOSType(from.getOSTypeId());
//Somehow this method gets called with the correct product item.
OsFamily family = osFamily().apply(guestOSType.getDescription()); OsFamily family = osFamily().apply(guestOSType.getDescription());
OperatingSystem os = OperatingSystem.builder() OperatingSystem os = OperatingSystem.builder()
.description(guestOSType.getDescription()) .description(guestOSType.getDescription())

View File

@ -48,12 +48,13 @@ public class IMachineToHardwareTest {
String machineId = "hw-machineId"; String machineId = "hw-machineId";
expect(vm.getOSTypeId()).andReturn("os-type").anyTimes(); expect(vm.getOSTypeId()).andReturn("os-type").anyTimes();
expect(vm.getId()).andReturn(machineId).anyTimes();
expect(vm.getDescription()).andReturn(linuxDescription).anyTimes(); expect(vm.getDescription()).andReturn(linuxDescription).anyTimes();
expect(vBox.getGuestOSType(eq("os-type"))).andReturn(guestOsType); expect(vBox.getGuestOSType(eq("os-type"))).andReturn(guestOsType);
expect(vbm.getVBox()).andReturn(vBox); expect(vbm.getVBox()).andReturn(vBox);
expect(guestOsType.getIs64Bit()).andReturn(true); expect(guestOsType.getIs64Bit()).andReturn(true);
expect(vm.getId()).andReturn(machineId);
replay(vbm, vBox, vm, guestOsType); replay(vbm, vBox, vm, guestOsType);