|
83 | 83 | import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; |
84 | 84 | import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; |
85 | 85 | import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity; |
| 86 | +import org.apache.cloudstack.storage.to.TemplateObjectTO; |
86 | 87 |
|
87 | 88 | import com.cloud.agent.AgentManager; |
88 | 89 | import com.cloud.agent.api.Answer; |
|
159 | 160 | import com.cloud.storage.secondary.SecondaryStorageVmManager; |
160 | 161 | import com.cloud.storage.upload.UploadMonitor; |
161 | 162 | import com.cloud.template.TemplateAdapter.TemplateAdapterType; |
| 163 | +import com.cloud.template.VirtualMachineTemplate.BootloaderType; |
162 | 164 | import com.cloud.user.Account; |
163 | 165 | import com.cloud.user.AccountManager; |
164 | 166 | import com.cloud.user.AccountService; |
|
184 | 186 | import com.cloud.vm.UserVmVO; |
185 | 187 | import com.cloud.vm.VMInstanceVO; |
186 | 188 | import com.cloud.vm.VirtualMachine.State; |
| 189 | +import com.cloud.vm.VirtualMachineProfile; |
187 | 190 | import com.cloud.vm.dao.UserVmDao; |
188 | 191 | import com.cloud.vm.dao.UserVmDetailsDao; |
189 | 192 | import com.cloud.vm.dao.VMInstanceDao; |
@@ -492,6 +495,38 @@ private String extract(Account caller, Long templateId, String url, Long zoneId, |
492 | 495 | return tmpltStore.createEntityExtractUrl(templateObject.getInstallPath(), template.getFormat(), templateObject); |
493 | 496 | } |
494 | 497 |
|
| 498 | + @Override |
| 499 | + public void prepareIsoForVmProfile(VirtualMachineProfile profile) { |
| 500 | + UserVmVO vm = _userVmDao.findById(profile.getId()); |
| 501 | + if (vm.getIsoId() != null) { |
| 502 | + TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId()); |
| 503 | + if (template == null){ |
| 504 | + s_logger.error("Failed to prepare ISO on secondary or cache storage"); |
| 505 | + throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache storage"); |
| 506 | + } |
| 507 | + if (template.isBootable()) { |
| 508 | + profile.setBootLoaderType(BootloaderType.CD); |
| 509 | + } |
| 510 | + |
| 511 | + GuestOSVO guestOS = _guestOSDao.findById(template.getGuestOSId()); |
| 512 | + String displayName = null; |
| 513 | + if (guestOS != null) { |
| 514 | + displayName = guestOS.getDisplayName(); |
| 515 | + } |
| 516 | + |
| 517 | + TemplateObjectTO iso = (TemplateObjectTO)template.getTO(); |
| 518 | + iso.setGuestOsType(displayName); |
| 519 | + DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO); |
| 520 | + profile.addDisk(disk); |
| 521 | + } else { |
| 522 | + TemplateObjectTO iso = new TemplateObjectTO(); |
| 523 | + iso.setFormat(ImageFormat.ISO); |
| 524 | + DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO); |
| 525 | + profile.addDisk(disk); |
| 526 | + } |
| 527 | + |
| 528 | + } |
| 529 | + |
495 | 530 | public void prepareTemplateInAllStoragePools(final VMTemplateVO template, long zoneId) { |
496 | 531 | List<StoragePoolVO> pools = _poolDao.listByStatus(StoragePoolStatus.Up); |
497 | 532 | for (final StoragePoolVO pool : pools) { |
|
0 commit comments