Skip to content

Commit 68ddc6d

Browse files
committed
Added pool type to volumes created from snapshots
Pool type to volumes that are created from snapshots Added StorPool tags to snapshots that are copied from remote
1 parent 6ebfd7d commit 68ddc6d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
676676
VolumeObjectTO to = (VolumeObjectTO)dstData.getTO();
677677
to.setPath(StorPoolUtil.devPath(StorPoolUtil.getNameFromResponse(resp, false)));
678678
to.setSize(size);
679+
updateVolumePoolType(vinfo);
679680

680681
answer = new CopyCmdAnswer(to);
681682
StorPoolUtil.spLog("Created volume=%s with uuid=%s from snapshot=%s with uuid=%s", StorPoolUtil.getNameFromResponse(resp, false), volumeName, snapshotName, sinfo.getUuid());

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/util/StorPoolUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,14 @@ public static String getSnapshotClusterId(String snapshotName, SpConnectionDesc
707707
return json.get("clusterId").getAsString();
708708
}
709709

710-
public static SpApiResponse snapshotFromRemote(String name, String remoteLocation, String template,
710+
public static SpApiResponse snapshotFromRemote(String name, String remoteLocation, String template, Map<String, String> tags,
711711
SpConnectionDesc conn) {
712712
Map<String, Object> json = new HashMap<>();
713713
json.put("remoteId", name);
714714
json.put("remoteLocation", remoteLocation);
715715
json.put("template", template);
716716
json.put("name", "");
717+
json.put("tags", tags);
717718
return POST("SnapshotFromRemote", json, conn);
718719
}
719720

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/snapshot/StorPoolSnapshotStrategy.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import com.cloud.utils.exception.CloudRuntimeException;
3434
import com.cloud.utils.fsm.NoTransitionException;
3535

36+
import java.util.HashMap;
37+
import java.util.Map;
3638
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
3739
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
3840
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@@ -477,11 +479,20 @@ private SpApiResponse copySnapshotFromRemote(DataObject snapshot, StoragePoolVO
477479
.valueIn(snapshot.getDataStore().getId());
478480
StoragePoolDetailVO template = storagePoolDetailsDao.findDetail(storagePoolVO.getId(),
479481
StorPoolUtil.SP_TEMPLATE);
482+
Map<String, String> tags = addStorPoolTags(snapshot);
480483
SpApiResponse respFromRemote = StorPoolUtil.snapshotFromRemote(snapshotName, localLocation,
481-
template.getValue(), connectionRemote);
484+
template.getValue(), tags, connectionRemote);
482485
return respFromRemote;
483486
}
484487

488+
@NotNull
489+
private static Map<String, String> addStorPoolTags(DataObject snapshot) {
490+
Map<String, String> tags = new HashMap<>();
491+
tags.put("cs", "snapshot");
492+
tags.put("uuid", snapshot.getUuid());
493+
return tags;
494+
}
495+
485496
private void keepExportedSnapshot(DataObject snapshot, String location, String snapshotName) {
486497

487498
String detail = "~" + snapshotName + ";" + location;

0 commit comments

Comments
 (0)