throw new CloudRuntimeException("Failed to find template " + template.getUniqueName() + " in storage pool " + dataStore.getId()); } else { if (s_logger.isDebugEnabled()) { s_logger.debug("Found template " + template.getUniqueName() + " in storage pool " + dataStore.getId() + " with VMTemplateStoragePool id: " + templatePoolRef.getId()); if (templatePoolRef != null && templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) { s_logger.info( "Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId + ", But Template " + template.getUniqueName() + " is already copied to primary storage, skip copying"); createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, dataStore, future); return; s_logger.info("Template " + template.getUniqueName() + " is already copied to primary storage, skip copying"); createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, dataStore, future); return;
public TemplateObjectTO(TemplateInfo template) { this.path = template.getInstallPath(); this.uuid = template.getUuid(); this.id = template.getId(); this.origUrl = template.getUrl(); this.displayText = template.getDisplayText(); this.checksum = template.getChecksum(); this.hvm = template.isRequiresHvm(); this.accountId = template.getAccountId(); this.name = template.getUniqueName(); this.format = template.getFormat(); this.uniqueName = template.getUniqueName(); this.size = template.getSize(); if (template.getDataStore() != null) { this.imageDataStore = template.getDataStore().getTO(); } this.hypervisorType = template.getHypervisorType(); }
throw new CloudRuntimeException("Failed to create template " + srcTemplateInfo.getUniqueName() + " on primary storage: " + destDataStoreId); throw new CloudRuntimeException("Failed to find template " + srcTemplateInfo.getUniqueName() + " in storage pool " + destPrimaryDataStore.getId());
/** * Clones the template volume on managed storage to the ROOT volume * * @param volumeInfo ROOT volume to create * @param templateOnPrimary Template from which to clone the ROOT volume * @param destPrimaryDataStore Primary storage of the volume * @param future For async */ private void createManagedVolumeCloneTemplateAsync(VolumeInfo volumeInfo, TemplateInfo templateOnPrimary, PrimaryDataStore destPrimaryDataStore, AsyncCallFuture<VolumeApiResult> future) { VMTemplateStoragePoolVO templatePoolRef = _tmpltPoolDao.findByPoolTemplate(destPrimaryDataStore.getId(), templateOnPrimary.getId()); if (templatePoolRef == null) { throw new CloudRuntimeException("Failed to find template " + templateOnPrimary.getUniqueName() + " in storage pool " + destPrimaryDataStore.getId()); } //XXX: not sure if this the right thing to do here. We can always fallback to the "copy from sec storage" if (templatePoolRef.getDownloadState() == Status.NOT_DOWNLOADED) { throw new CloudRuntimeException("Template " + templateOnPrimary.getUniqueName() + " has not been downloaded to primary storage."); } try { volumeInfo.processEvent(Event.CreateOnlyRequested); CreateVolumeFromBaseImageContext<VolumeApiResult> context = new CreateVolumeFromBaseImageContext<>(null, volumeInfo, destPrimaryDataStore, templateOnPrimary, future, null); AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(null, null)); caller.setContext(context); motionSrv.copyAsync(templateOnPrimary, volumeInfo, caller); } catch (Throwable e) { s_logger.debug("Failed to clone template on primary storage", e); volumeInfo.processEvent(Event.OperationFailed); throw new CloudRuntimeException(e.getMessage()); } }
details.put(PrimaryDataStore.STORAGE_PORT, String.valueOf(destPrimaryDataStore.getPort())); details.put(PrimaryDataStore.MANAGED_STORE_TARGET, templateOnPrimary.getInstallPath()); details.put(PrimaryDataStore.MANAGED_STORE_TARGET_ROOT_VOLUME, srcTemplateInfo.getUniqueName()); details.put(PrimaryDataStore.REMOVE_AFTER_COPY, Boolean.TRUE.toString()); details.put(PrimaryDataStore.VOLUME_SIZE, String.valueOf(templateOnPrimary.getSize()));
s_logger.warn("Unable to start/resume copy of template " + srcTemplate.getUniqueName() + " to " + destStore.getName() + ", no secondary storage vm in running state in source zone"); throw new CloudRuntimeException("No secondary VM in running state in source template zone ");
private AsyncCallFuture<TemplateApiResult> syncToRegionStoreAsync(TemplateInfo template, DataStore store) { AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>(); // no need to create entry on template_store_ref here, since entries are already created when prepareSecondaryStorageForMigration is invoked. // But we need to set default install path so that sync can be done in the right s3 path TemplateInfo templateOnStore = _templateFactory.getTemplate(template, store); String installPath = TemplateConstants.DEFAULT_TMPLT_ROOT_DIR + "/" + TemplateConstants.DEFAULT_TMPLT_FIRST_LEVEL_DIR + template.getAccountId() + "/" + template.getId() + "/" + template.getUniqueName(); ((TemplateObject)templateOnStore).setInstallPath(installPath); TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<TemplateApiResult>(null, (TemplateObject)templateOnStore, future); AsyncCallbackDispatcher<TemplateServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().syncTemplateCallBack(null, null)).setContext(context); _motionSrv.copyAsync(template, templateOnStore, caller); return future; }
extraDetails = new HashMap<>(); String extraDetailsVmdk = templateInfo.getUniqueName() + ".vmdk";
private SolidFireUtil.SolidFireVolume createSolidFireVolume(SolidFireUtil.SolidFireConnection sfConnection, DataObject dataObject, long storagePoolId, long sfAccountId) { final Long minIops; final Long maxIops; final Long volumeSize; final String volumeName; final Map<String, String> mapAttributes; if (dataObject.getType() == DataObjectType.VOLUME) { VolumeInfo volumeInfo = (VolumeInfo)dataObject; minIops = volumeInfo.getMinIops(); maxIops = volumeInfo.getMaxIops(); volumeSize = getDataObjectSizeIncludingHypervisorSnapshotReserve(volumeInfo, storagePoolDao.findById(storagePoolId)); volumeName = volumeInfo.getName(); mapAttributes = getVolumeAttributes(volumeInfo); } else if (dataObject.getType() == DataObjectType.TEMPLATE) { TemplateInfo templateInfo = (TemplateInfo)dataObject; minIops = MIN_IOPS_FOR_TEMPLATE_VOLUME; maxIops = MAX_IOPS_FOR_TEMPLATE_VOLUME; volumeSize = getDataObjectSizeIncludingHypervisorSnapshotReserve(templateInfo, storagePoolDao.findById(storagePoolId)); volumeName = templateInfo.getUniqueName(); mapAttributes = getTemplateAttributes(templateInfo); } else { throw new CloudRuntimeException("Invalid type passed to createSolidFireVolume: " + dataObject.getType()); } final Iops iops = getIops(minIops, maxIops, storagePoolId); long sfVolumeId = SolidFireUtil.createVolume(sfConnection, SolidFireUtil.getSolidFireVolumeName(volumeName), sfAccountId, volumeSize, true, mapAttributes, iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops()); return SolidFireUtil.getVolume(sfConnection, sfVolumeId); }
throw new CloudRuntimeException("Failed to find template " + srcTemplateInfo.getUniqueName() + " in storage pool " + destPrimaryDataStore.getId());
if (dataStore.getTO() instanceof S3TO) { TemplateInfo tmpl = (TemplateInfo)obj; installPath += "/" + tmpl.getUniqueName(); // for S3, we