mirror of https://github.com/apache/jclouds.git
linked image to hardware in virtualbox
This commit is contained in:
parent
65f3bd17a3
commit
2baf711a32
|
@ -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> {
|
||||||
|
|
||||||
|
@ -50,6 +52,7 @@ public class IMachineToHardware implements Function<IMachine, Hardware> {
|
||||||
HardwareBuilder hardwareBuilder = new HardwareBuilder();
|
HardwareBuilder hardwareBuilder = new HardwareBuilder();
|
||||||
hardwareBuilder.ids(vm.getId());
|
hardwareBuilder.ids(vm.getId());
|
||||||
hardwareBuilder.is64Bit(is64Bit);
|
hardwareBuilder.is64Bit(is64Bit);
|
||||||
|
hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getId()));
|
||||||
return hardwareBuilder.build();
|
return hardwareBuilder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,19 +21,20 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Hardware;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import org.virtualbox_4_1.IGuestOSType;
|
|
||||||
import org.virtualbox_4_1.IMachine;
|
|
||||||
import org.virtualbox_4_1.IVirtualBox;
|
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
|
||||||
|
|
||||||
import static org.easymock.EasyMock.eq;
|
import static org.easymock.EasyMock.eq;
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.classextension.EasyMock.createNiceMock;
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
import static org.easymock.classextension.EasyMock.replay;
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.predicates.ImagePredicates;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.virtualbox_4_1.IGuestOSType;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IVirtualBox;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class IMachineToHardwareTest {
|
public class IMachineToHardwareTest {
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ public class IMachineToHardwareTest {
|
||||||
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);
|
expect(vm.getId()).andReturn(machineId).atLeastOnce();
|
||||||
|
|
||||||
replay(vbm, vBox, vm, guestOsType);
|
replay(vbm, vBox, vm, guestOsType);
|
||||||
|
|
||||||
|
@ -61,7 +62,10 @@ public class IMachineToHardwareTest {
|
||||||
|
|
||||||
assertEquals(hardware.getId(), machineId);
|
assertEquals(hardware.getId(), machineId);
|
||||||
assertEquals(hardware.getProviderId(), machineId);
|
assertEquals(hardware.getProviderId(), machineId);
|
||||||
}
|
// for starters assume 1-to-1 relationship hardware to image (which
|
||||||
|
// correlate to a single source IMachine)
|
||||||
|
assertEquals(hardware.supportsImage().toString(), ImagePredicates.idEquals(machineId).toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue