Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,11 @@ protected Void managedCopyBaseImageCallback(AsyncCallbackDispatcher<VolumeServic
volume.setPath(templateObjectTo.getPath());

if (templateObjectTo.getFormat() != null) {
volume.setFormat(templateObjectTo.getFormat());
PrimaryDataStore primaryDataStore = context.getPrimaryDataStore();
boolean isOntap = primaryDataStore != null && DataStoreProvider.ONTAP_PLUGIN_NAME.equals(primaryDataStore.getStorageProviderName());
if (!isOntap || volume.getFormat() == null) {
volume.setFormat(templateObjectTo.getFormat());
}
}

volDao.update(volume.getId(), volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void createAsync(DataStore dataStore, DataObject dataObject, AsyncComplet

volumeVO.setPoolType(storagePool.getPoolType());
volumeVO.setPoolId(storagePool.getId());
volumeVO.setFormat(getImageFormatByHypervisor(storagePool.getHypervisor()));
volumeVO.setFormat(getImageFormatByHypervisor(storagePool.getHypervisor(), details.get(OntapStorageConstants.PROTOCOL)));
logger.info("createAsync: Volume format set to [{}] for hypervisor [{}]", volumeVO.getFormat(), storagePool.getHypervisor());

if (ProtocolType.ISCSI.name().equalsIgnoreCase(details.get(OntapStorageConstants.PROTOCOL))) {
Expand Down Expand Up @@ -988,9 +988,14 @@ private String buildSnapshotName(String cloudStackSnapshotName, long snapshotId)
}


private Storage.ImageFormat getImageFormatByHypervisor(HypervisorType hypervisorType) {
private Storage.ImageFormat getImageFormatByHypervisor(HypervisorType hypervisorType, String protocol) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, update the unit test cases and automation also

if (HypervisorType.KVM.equals(hypervisorType)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use switch instead multiple if else

return Storage.ImageFormat.QCOW2;
if (ProtocolType.NFS3.name().equalsIgnoreCase(protocol)) {
return Storage.ImageFormat.QCOW2;
} else if (ProtocolType.ISCSI.name().equalsIgnoreCase(protocol)) {
return Storage.ImageFormat.RAW;
}
throw new CloudRuntimeException("Unsupported protocol [" + protocol + "] for ONTAP image format resolution");
}
throw new CloudRuntimeException("Unsupported hypervisor [" + hypervisorType + "] for ONTAP image format resolution");
}
Expand Down
Loading