Skip to content

Commit c080246

Browse files
committed
mgmt: Small fixes
- set physical size to snapshot - set qc tag when creating volume from a snapshot with disk offerings that have tier as a detail
1 parent 7ceb876 commit c080246

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,26 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
632632
VolumeInfo vinfo = (VolumeInfo)dstData;
633633
final String volumeName = vinfo.getUuid();
634634
final Long size = vinfo.getSize();
635+
String tier = null;
636+
String template = null;
637+
if (vinfo.getDiskOfferingId() != null) {
638+
tier = getTierFromOfferingDetail(vinfo.getDiskOfferingId());
639+
if (tier == null) {
640+
template = getTemplateFromOfferingDetail(vinfo.getDiskOfferingId());
641+
}
642+
}
635643
SpConnectionDesc conn = StorPoolUtil.getSpConnection(vinfo.getDataStore().getUuid(), vinfo.getDataStore().getId(), storagePoolDetailsDao, primaryStoreDao);
636-
SpApiResponse resp = StorPoolUtil.volumeCreate(volumeName, snapshotName, size, null, null, "volume", sinfo.getBaseVolume().getMaxIops(), conn);
644+
SpApiResponse resp = null;
645+
if (tier != null || template != null) {
646+
Map<String, String> tags = StorPoolHelper.addStorPoolTags(volumeName, null, "volume", null, tier);
647+
648+
StorPoolUtil.spLog(
649+
"Creating volume [%s] with template [%s] or tier tags [%s] described in disk/service offerings details",
650+
vinfo.getUuid(), template, tier);
651+
resp = StorPoolUtil.volumeCreate(size, snapshotName, template, tags, conn);
652+
} else {
653+
resp = StorPoolUtil.volumeCreate(volumeName, snapshotName, size, null, null, "volume", sinfo.getBaseVolume().getMaxIops(), conn);
654+
}
637655
if (resp.getError() == null) {
638656
updateStoragePool(dstData.getDataStore().getId(), size);
639657

@@ -669,6 +687,7 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
669687
// bypass secondary storage
670688
if (StorPoolConfigurationManager.BypassSecondaryStorage.value() || snapshotDetail != null) {
671689
SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData.getTO();
690+
snapshot.setPhysicalSize(sinfo.getSize());
672691
answer = new CopyCmdAnswer(snapshot);
673692
} else {
674693
// copy snapshot to secondary storage (backup snapshot)

0 commit comments

Comments
 (0)