private String generateCopyUrl(TemplateInfo srcTemplate) { DataStore srcStore = srcTemplate.getDataStore(); EndPoint ep = _epSelector.select(srcTemplate); if (ep != null) { if (ep.getPublicAddr() == null) { s_logger.warn("A running secondary storage vm has a null public ip?"); return null; } return generateCopyUrl(ep.getPublicAddr(), ((ImageStoreEntity)srcStore).getMountPoint(), srcTemplate.getInstallPath()); } VMTemplateVO tmplt = _templateDao.findById(srcTemplate.getId()); HypervisorType hyperType = tmplt.getHypervisorType(); /*No secondary storage vm yet*/ if (hyperType != null && hyperType == HypervisorType.KVM) { return "file://" + ((ImageStoreEntity)srcStore).getMountPoint() + "/" + srcTemplate.getInstallPath(); } return null; }
private void deleteTemplate(TemplateInfo template, long storagePoolId) { try { SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, storagePoolDetailsDao); long sfTemplateVolumeId = getVolumeIdFrom_iScsiPath(template.getInstallPath()); SolidFireUtil.deleteVolume(sfConnection, sfTemplateVolumeId); StoragePoolVO storagePool = storagePoolDao.findById(storagePoolId); // getUsedBytes(StoragePool) will not include the template to delete because the "template_spool_ref" table has already been updated by this point long usedBytes = getUsedBytes(storagePool); storagePool.setUsedBytes(usedBytes < 0 ? 0 : usedBytes); storagePoolDao.update(storagePoolId, storagePool); } catch (Exception ex) { LOGGER.debug(SolidFireUtil.LOG_PREFIX + "Failed to delete SolidFire template volume. CloudStack template ID: " + template.getId(), ex); throw ex; } }
throw new CloudRuntimeException("Cannot find an entry in template_store_ref for template " + templateId + " on region store: " + store.getName()); if (tmplOnStore.getInstallPath() == null || tmplOnStore.getInstallPath().length() == 0) {
details.put(PrimaryDataStore.STORAGE_HOST, destPrimaryDataStore.getHostAddress()); 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(ModifyTargetsCommand.IQN, templateOnPrimary.getInstallPath());
private long getSolidFireVolumeId(DataObject dataObject, boolean grantAccess) { if (dataObject.getType() == DataObjectType.VOLUME) { final VolumeInfo volumeInfo = (VolumeInfo)dataObject; final long volumeId = volumeInfo.getId(); if (grantAccess && isBasicGrantAccess(volumeId)) { volumeDetailsDao.removeDetail(volumeInfo.getId(), BASIC_GRANT_ACCESS); final Long sfVolumeId = getBasicSfVolumeId(volumeId); Preconditions.checkNotNull(sfVolumeId, "'sfVolumeId' should not be 'null' (basic grant access)."); return sfVolumeId; } else if (!grantAccess && isBasicRevokeAccess(volumeId)) { volumeDetailsDao.removeDetail(volumeInfo.getId(), BASIC_REVOKE_ACCESS); final Long sfVolumeId = getBasicSfVolumeId(volumeId); Preconditions.checkNotNull(sfVolumeId, "'sfVolumeId' should not be 'null' (basic revoke access)."); return sfVolumeId; } return Long.parseLong(volumeInfo.getFolder()); } if (dataObject.getType() == DataObjectType.SNAPSHOT) { SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(dataObject.getId(), SolidFireUtil.VOLUME_ID); if (snapshotDetails == null || snapshotDetails.getValue() == null) { throw new CloudRuntimeException("Unable to locate the volume ID associated with the following snapshot ID: " + dataObject.getId()); } return Long.parseLong(snapshotDetails.getValue()); } if (dataObject.getType() == DataObjectType.TEMPLATE) { return getVolumeIdFrom_iScsiPath(((TemplateInfo)dataObject).getInstallPath()); } throw new CloudRuntimeException("Invalid DataObjectType (" + dataObject.getType() + ") passed to getSolidFireVolumeId(DataObject, boolean)"); }
tmpltStore.createEntityExtractUrl(srcTemplate.getInstallPath(), srcTemplate.getFormat(), srcTemplate);
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(), template.getUuid(), tmpl.getInstallPath(), tmpl .getChecksum(), tmpl.getType().toString(), template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole().toString());
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(); }
String extractUrl = tmpltStore.createEntityExtractUrl(templateObject.getInstallPath(), template.getFormat(), templateObject); tmpltStoreRef.setExtractUrl(extractUrl); tmpltStoreRef.setExtractUrlCreated(DateUtil.now());