@Override public void preReleaseVmResource(VmInstanceSpec spec, final Completion completion) { List<CdRomSpec> cdRomSpecs = spec.getCdRomSpecs(); List<String> isoUuids = spec.getCdRomSpecs().stream().map(CdRomSpec::getImageUuid).collect(Collectors.toList()); isoUuids = isoUuids.parallelStream().filter(Objects::nonNull).collect(Collectors.toList()); if (isoUuids.isEmpty()) {
@Override public void preInstantiateVmResource(final VmInstanceSpec spec, final Completion completion) { if (spec.getCdRomSpecs().isEmpty() || !operations.contains(spec.getCurrentVmOperation())) { completion.success(); return; List<String> isoUuids = spec.getCdRomSpecs().stream().map(CdRomSpec::getImageUuid).collect(Collectors.toList()); if (isoUuids.isEmpty()) { completion.success(); spec.getCdRomSpecs().forEach(cdRomSpec -> { if (cdRomSpec.getImageUuid() == null) { return; }); List<DownloadIsoToPrimaryStorageMsg> msgs = CollectionUtils.transformToList(spec.getCdRomSpecs(), new Function<DownloadIsoToPrimaryStorageMsg, CdRomSpec>() { @Override
List<CdRomSpec> cdRomSpecs = spec.getCdRomSpecs();
spec.getCdRomSpecs().get(0).setBackupStorageUuid(bsUuid); spec.getCdRomSpecs().forEach(cdRomSpec -> { if (cdRomSpec.getBackupStorageUuid() != null) { return; } else if ((VmOperation.Start == spec.getCurrentVmOperation() || VmOperation.Reboot == spec.getCurrentVmOperation()) && !spec.getCdRomSpecs().isEmpty()) { spec.getCdRomSpecs().forEach(cdRomSpec -> { if (cdRomSpec.getImageUuid() == null) { return;
protected void selectBootOrder(VmInstanceSpec spec) { if (spec.getCurrentVmOperation() == null) { throw new CloudRuntimeException("selectBootOrder must be called after VmOperation is set"); } List<CdRomSpec> cdRomSpecs = spec.getCdRomSpecs().stream() .filter(cdRom -> cdRom.getImageUuid() != null) .collect(Collectors.toList()); if (spec.getCurrentVmOperation() == VmOperation.NewCreate && !cdRomSpecs.isEmpty()) { ImageVO imageVO = dbf.findByUuid(spec.getVmInventory().getImageUuid(), ImageVO.class); assert imageVO != null; if(imageVO.getMediaType() == ImageMediaType.ISO) { spec.setBootOrders(list(VmBootDevice.CdRom.toString())); } else { spec.setBootOrders(list(VmBootDevice.HardDisk.toString())); } } else { String order = VmSystemTags.BOOT_ORDER.getTokenByResourceUuid(self.getUuid(), VmSystemTags.BOOT_ORDER_TOKEN); if (order == null) { spec.setBootOrders(list(VmBootDevice.HardDisk.toString())); } else { spec.setBootOrders(list(order.split(","))); // set vm to boot from cdrom once only if (VmSystemTags.CDROM_BOOT_ONCE.hasTag(self.getUuid(), VmInstanceVO.class)) { VmSystemTags.BOOT_ORDER.deleteInherentTag(self.getUuid()); VmSystemTags.CDROM_BOOT_ONCE.deleteInherentTag(self.getUuid()); } } } }
spec.getCdRomSpecs().add(cdRomSpec);
cmd.setNics(nics); for (VmInstanceSpec.CdRomSpec cdRomSpec : spec.getCdRomSpecs()) { CdRomTO cdRomTO = new CdRomTO(); cdRomTO.setPath(cdRomSpec.getInstallPath());