mirror of https://github.com/apache/jclouds.git
improved hardware matching (hardware's id is now the same as the image id *without* prefix)
This commit is contained in:
parent
3370dd819d
commit
8f92009699
|
@ -25,6 +25,7 @@ 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.compute.predicates.ImagePredicates;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||||
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;
|
||||||
|
@ -44,14 +45,14 @@ public class IMachineToHardware implements Function<IMachine, Hardware> {
|
||||||
@Override
|
@Override
|
||||||
public Hardware apply(@Nullable IMachine vm) {
|
public Hardware apply(@Nullable IMachine vm) {
|
||||||
String osTypeId = vm.getOSTypeId();
|
String osTypeId = vm.getOSTypeId();
|
||||||
|
String vmNameWithoutPrefix = vm.getName().replace(VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX, "");
|
||||||
|
|
||||||
IGuestOSType guestOSType = virtualBoxManager.get().getVBox().getGuestOSType(osTypeId);
|
IGuestOSType guestOSType = virtualBoxManager.get().getVBox().getGuestOSType(osTypeId);
|
||||||
Boolean is64Bit = guestOSType.getIs64Bit();
|
Boolean is64Bit = guestOSType.getIs64Bit();
|
||||||
HardwareBuilder hardwareBuilder = new HardwareBuilder();
|
HardwareBuilder hardwareBuilder = new HardwareBuilder();
|
||||||
hardwareBuilder.ids(vm.getName());
|
hardwareBuilder.ids(vmNameWithoutPrefix);
|
||||||
hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getName()));
|
|
||||||
hardwareBuilder.is64Bit(is64Bit);
|
hardwareBuilder.is64Bit(is64Bit);
|
||||||
hardwareBuilder.supportsImage(ImagePredicates.idEquals(vm.getName()));
|
hardwareBuilder.supportsImage(ImagePredicates.idEquals(vmNameWithoutPrefix));
|
||||||
hardwareBuilder.hypervisor("VirtualBox");
|
hardwareBuilder.hypervisor("VirtualBox");
|
||||||
return hardwareBuilder.build();
|
return hardwareBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue