return newMachine;
}
private void ensureConfiguration(MasterSpec machineSpec) {
VmSpec vmSpec = machineSpec.getVmSpec();
NetworkSpec networkSpec = machineSpec.getNetworkSpec();
String vmName = vmSpec.getVmName();
// Change BootOrder
Map<Long, DeviceType> positionAndDeviceType = ImmutableMap.of(1l, DeviceType.HardDisk);
ensureMachineHasDesiredBootOrder(vmName, positionAndDeviceType);
// Change RAM
ensureMachineHasMemory(vmName, vmSpec.getMemory());
Set<StorageController> controllers = vmSpec.getControllers();
if (controllers.isEmpty()) {
throw new IllegalStateException(missingIDEControllersMessage(vmSpec));
}
StorageController controller = controllers.iterator().next();
ensureMachineHasStorageControllerNamed(vmName, controller);
setupHardDisksForController(vmName, controller);
setupDvdsForController(vmSpec, vmName, controller);
// Networking
for (NetworkInterfaceCard networkInterfaceCard : networkSpec.getNetworkInterfaceCards()) {
new AttachNicToMachine(vmName, machineUtils).apply(networkInterfaceCard);
}
}