Skip to content

Commit 2f3e7c9

Browse files
committed
Address comments and fix conflicts
1 parent 58e2ac3 commit 2f3e7c9

File tree

19 files changed

+205
-130
lines changed

19 files changed

+205
-130
lines changed

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreCapabilities.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,9 @@ public enum DataStoreCapabilities {
4444
/**
4545
* indicates that the driver supports copying snapshot between zones on pools of the same type
4646
*/
47-
CAN_COPY_SNAPSHOT_BETWEEN_ZONES_AND_SAME_POOL_TYPE
47+
CAN_COPY_SNAPSHOT_BETWEEN_ZONES_AND_SAME_POOL_TYPE,
48+
/**
49+
* indicates that this driver supports the option to create a template from the back-end snapshot
50+
*/
51+
CAN_CREATE_TEMPLATE_FROM_SNAPSHOT
4852
}

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,14 +578,10 @@ public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, Use
578578
SnapshotInfo snapInfo = snapshotFactory.getSnapshotWithRoleAndZone(snapshot.getId(), dataStoreRole, zoneId);
579579

580580
boolean kvmSnapshotOnlyInPrimaryStorage = snapshotHelper.isKvmSnapshotOnlyInPrimaryStorage(snapshot, dataStoreRole, volume.getDataCenterId());
581-
boolean skipCopyToSecondary = false;
582-
boolean keepOnPrimary = snapshotHelper.isStorPoolStorage(snapInfo);
581+
boolean keepOnPrimary = snapshotHelper.isStorageSupportSnapshotToTemplate(snapInfo);
583582

584-
if (kvmSnapshotOnlyInPrimaryStorage && keepOnPrimary) {
585-
skipCopyToSecondary = true;
586-
}
587583
try {
588-
if (!skipCopyToSecondary) {
584+
if (!keepOnPrimary) {
589585
snapInfo = snapshotHelper.backupSnapshotToSecondaryStorageIfNotExists(snapInfo, dataStoreRole, snapshot, kvmSnapshotOnlyInPrimaryStorage);
590586
}
591587
} catch (CloudRuntimeException e) {
@@ -599,7 +595,7 @@ public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, Use
599595
}
600596

601597
// don't try to perform a sync if the DataStoreRole of the snapshot is equal to DataStoreRole.Primary
602-
if (!DataStoreRole.Primary.equals(dataStoreRole) || (kvmSnapshotOnlyInPrimaryStorage && !skipCopyToSecondary)) {
598+
if (!DataStoreRole.Primary.equals(dataStoreRole) || !keepOnPrimary) {
603599
try {
604600
// sync snapshot to region store if necessary
605601
DataStore snapStore = snapInfo.getDataStore();

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDaoImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
import com.cloud.utils.db.SearchCriteria;
2929
import com.cloud.utils.db.TransactionLegacy;
3030
import com.cloud.utils.db.UpdateBuilder;
31+
3132
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
3233
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
3334
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
3435
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
36+
3537
import org.apache.commons.collections.CollectionUtils;
38+
3639
import org.springframework.stereotype.Component;
3740

3841
import javax.inject.Inject;

plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
package com.cloud.hypervisor.kvm.storage;
1818

1919

20+
import com.cloud.agent.api.to.DiskTO;
21+
import com.cloud.storage.Storage;
22+
import com.cloud.storage.Storage.ImageFormat;
23+
import com.cloud.storage.Storage.ProvisioningType;
24+
import com.cloud.storage.Storage.StoragePoolType;
25+
import com.cloud.utils.exception.CloudRuntimeException;
26+
import com.cloud.utils.script.OutputInterpreter;
27+
import com.cloud.utils.script.Script;
28+
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
29+
import org.apache.logging.log4j.LogManager;
30+
import org.apache.logging.log4j.Logger;
31+
2032
import java.io.BufferedWriter;
2133
import java.io.File;
2234
import java.io.FileWriter;
@@ -27,19 +39,6 @@
2739
import java.util.List;
2840
import java.util.Map;
2941

30-
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
31-
import org.apache.logging.log4j.Logger;
32-
import org.apache.logging.log4j.LogManager;
33-
34-
import com.cloud.agent.api.to.DiskTO;
35-
import com.cloud.storage.Storage;
36-
import com.cloud.storage.Storage.ImageFormat;
37-
import com.cloud.storage.Storage.ProvisioningType;
38-
import com.cloud.storage.Storage.StoragePoolType;
39-
import com.cloud.utils.exception.CloudRuntimeException;
40-
import com.cloud.utils.script.OutputInterpreter;
41-
import com.cloud.utils.script.Script;
42-
4342
public class StorPoolStorageAdaptor implements StorageAdaptor {
4443
public static void SP_LOG(String fmt, Object... args) {
4544
try (PrintWriter spLogFile = new PrintWriter(new BufferedWriter(new FileWriter("/var/log/cloudstack/agent/storpool-agent.log", true)))) {
@@ -139,6 +138,9 @@ private static boolean waitForDeviceSymlink(String devPath) {
139138
}
140139

141140
public static String getVolumeNameFromPath(final String volumeUuid, boolean tildeNeeded) {
141+
if (volumeUuid == null) {
142+
return null;
143+
}
142144
if (volumeUuid.startsWith("/dev/storpool/")) {
143145
return volumeUuid.split("/")[3];
144146
} else if (volumeUuid.startsWith("/dev/storpool-byid/")) {

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/collector/StorPoolAbandonObjectsCollector.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,21 @@
2020
package org.apache.cloudstack.storage.collector;
2121

2222
import com.cloud.dc.dao.ClusterDao;
23+
2324
import com.cloud.storage.dao.SnapshotDetailsDao;
2425
import com.cloud.storage.dao.SnapshotDetailsVO;
26+
2527
import com.cloud.utils.component.ManagerBase;
2628
import com.cloud.utils.concurrency.NamedThreadFactory;
2729
import com.cloud.utils.db.DB;
2830
import com.cloud.utils.db.Transaction;
2931
import com.cloud.utils.db.TransactionCallbackNoReturn;
3032
import com.cloud.utils.db.TransactionLegacy;
3133
import com.cloud.utils.db.TransactionStatus;
34+
3235
import com.google.gson.JsonArray;
3336
import com.google.gson.JsonObject;
37+
3438
import org.apache.cloudstack.framework.config.ConfigKey;
3539
import org.apache.cloudstack.framework.config.Configurable;
3640
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
@@ -41,6 +45,7 @@
4145
import org.apache.cloudstack.storage.datastore.util.StorPoolUtil;
4246
import org.apache.cloudstack.storage.datastore.util.StorPoolUtil.SpApiResponse;
4347
import org.apache.cloudstack.storage.datastore.util.StorPoolUtil.SpConnectionDesc;
48+
4449
import org.apache.commons.collections.CollectionUtils;
4550

4651
import javax.inject.Inject;

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

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,25 @@
1919
package org.apache.cloudstack.storage.datastore.driver;
2020

2121
import com.cloud.storage.dao.SnapshotDetailsVO;
22+
2223
import java.util.HashMap;
2324
import java.util.List;
2425
import java.util.Map;
2526

2627
import javax.inject.Inject;
2728

29+
import com.cloud.storage.dao.StoragePoolHostDao;
30+
import com.cloud.storage.dao.VMTemplateDetailsDao;
31+
import com.cloud.storage.dao.VolumeDao;
32+
import com.cloud.storage.dao.VolumeDetailsDao;
33+
import com.cloud.tags.dao.ResourceTagDao;
34+
import com.cloud.utils.Pair;
35+
import com.cloud.utils.exception.CloudRuntimeException;
36+
import com.cloud.vm.VMInstanceVO;
37+
import com.cloud.vm.VirtualMachine.State;
38+
import com.cloud.vm.VirtualMachineManager;
39+
import com.cloud.vm.dao.VMInstanceDao;
40+
2841
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
2942
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
3043
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
@@ -68,6 +81,7 @@
6881
import org.apache.cloudstack.storage.to.TemplateObjectTO;
6982
import org.apache.cloudstack.storage.to.VolumeObjectTO;
7083
import org.apache.cloudstack.storage.volume.VolumeObject;
84+
7185
import org.apache.commons.collections4.CollectionUtils;
7286
import org.apache.commons.collections4.MapUtils;
7387

@@ -112,17 +126,6 @@
112126
import com.cloud.storage.VolumeVO;
113127
import com.cloud.storage.dao.SnapshotDao;
114128
import com.cloud.storage.dao.SnapshotDetailsDao;
115-
import com.cloud.storage.dao.StoragePoolHostDao;
116-
import com.cloud.storage.dao.VMTemplateDetailsDao;
117-
import com.cloud.storage.dao.VolumeDao;
118-
import com.cloud.storage.dao.VolumeDetailsDao;
119-
import com.cloud.tags.dao.ResourceTagDao;
120-
import com.cloud.utils.Pair;
121-
import com.cloud.utils.exception.CloudRuntimeException;
122-
import com.cloud.vm.VMInstanceVO;
123-
import com.cloud.vm.VirtualMachine.State;
124-
import com.cloud.vm.VirtualMachineManager;
125-
import com.cloud.vm.dao.VMInstanceDao;
126129

127130
import org.apache.logging.log4j.LogManager;
128131
import org.apache.logging.log4j.Logger;
@@ -188,6 +191,7 @@ private SnapshotDataStoreVO getSnapshotImageStoreRef(long snapshotId, long zoneI
188191
public Map<String, String> getCapabilities() {
189192
Map<String, String> mapCapabilities = new HashMap<>();
190193
mapCapabilities.put(DataStoreCapabilities.CAN_COPY_SNAPSHOT_BETWEEN_ZONES_AND_SAME_POOL_TYPE.toString(), Boolean.TRUE.toString());
194+
mapCapabilities.put(DataStoreCapabilities.CAN_CREATE_TEMPLATE_FROM_SNAPSHOT.toString(), Boolean.TRUE.toString());
191195
return mapCapabilities;
192196
}
193197

@@ -528,14 +532,7 @@ public void deleteAsync(DataStore dataStore, DataObject data, AsyncCompletionCal
528532
err = String.format("Could not delete volume due to %s", e.getMessage());
529533
}
530534
} else if (data.getType() == DataObjectType.SNAPSHOT) {
531-
SnapshotInfo snapshot = (SnapshotInfo) data;
532-
SpConnectionDesc conn = StorPoolUtil.getSpConnection(snapshot.getDataStore().getUuid(), snapshot.getDataStore().getId(), storagePoolDetailsDao, primaryStoreDao);
533-
String name = StorPoolStorageAdaptor.getVolumeNameFromPath(snapshot.getPath(), true);
534-
SpApiResponse resp = StorPoolUtil.snapshotDelete(name, conn);
535-
if (resp.getError() != null) {
536-
err = String.format("Failed to clean-up Storpool snapshot %s. Error: %s", name, resp.getError());
537-
StorPoolUtil.spLog(err);
538-
}
535+
err = deleteSnapshot((SnapshotInfo) data, err);
539536
} else {
540537
err = String.format("Invalid DataObjectType \"%s\" passed to deleteAsync", data.getType());
541538
}
@@ -550,6 +547,18 @@ public void deleteAsync(DataStore dataStore, DataObject data, AsyncCompletionCal
550547
callback.complete(res);
551548
}
552549

550+
private String deleteSnapshot(SnapshotInfo data, String err) {
551+
SnapshotInfo snapshot = data;
552+
SpConnectionDesc conn = StorPoolUtil.getSpConnection(snapshot.getDataStore().getUuid(), snapshot.getDataStore().getId(), storagePoolDetailsDao, primaryStoreDao);
553+
String name = StorPoolStorageAdaptor.getVolumeNameFromPath(snapshot.getPath(), true);
554+
SpApiResponse resp = StorPoolUtil.snapshotDelete(name, conn);
555+
if (resp.getError() != null) {
556+
err = String.format("Failed to clean-up Storpool snapshot %s. Error: %s", name, resp.getError());
557+
StorPoolUtil.spLog(err);
558+
}
559+
return err;
560+
}
561+
553562
private void tryToSnapshotVolumeBeforeDelete(VolumeInfo vinfo, DataStore dataStore, String name, SpConnectionDesc conn) {
554563
Integer deleteAfter = StorPoolConfigurationManager.DeleteAfterInterval.valueIn(dataStore.getId());
555564
if (deleteAfter != null && deleteAfter > 0 && vinfo.getPassphraseId() == null) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.cloud.utils.exception.CloudRuntimeException;
4646
import com.cloud.vm.VMInstanceVO;
4747
import com.cloud.vm.dao.VMInstanceDao;
48+
4849
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
4950
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
5051
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
@@ -56,6 +57,7 @@
5657
import org.apache.cloudstack.storage.datastore.util.StorPoolUtil.SpApiResponse;
5758
import org.apache.cloudstack.storage.snapshot.StorPoolConfigurationManager;
5859
import org.apache.cloudstack.storage.to.VolumeObjectTO;
60+
5961
import org.apache.commons.collections4.CollectionUtils;
6062

6163
import java.sql.PreparedStatement;

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/motion/StorPoolDataMotionStrategy.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import com.cloud.vm.VMInstanceVO;
5656
import com.cloud.vm.VirtualMachineManager;
5757
import com.cloud.vm.dao.VMInstanceDao;
58+
5859
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
5960
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
6061
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@@ -86,9 +87,12 @@
8687
import org.apache.cloudstack.storage.datastore.util.StorPoolUtil.SpConnectionDesc;
8788
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
8889
import org.apache.cloudstack.storage.to.TemplateObjectTO;
90+
8991
import org.apache.commons.collections.MapUtils;
92+
9093
import org.apache.logging.log4j.LogManager;
9194
import org.apache.logging.log4j.Logger;
95+
9296
import org.springframework.stereotype.Component;
9397

9498
import javax.inject.Inject;

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

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363

6464
import org.apache.logging.log4j.LogManager;
6565
import org.apache.logging.log4j.Logger;
66+
67+
import org.jetbrains.annotations.NotNull;
6668
import org.springframework.stereotype.Component;
6769

6870
import javax.inject.Inject;
@@ -201,6 +203,7 @@ private void processResult(List<SnapshotInfo> snapshotInfos, ObjectInDataStoreSt
201203
snapshotObject.processEvent(event);
202204
}
203205
}
206+
204207
@Override
205208
public StrategyPriority canHandle(Snapshot snapshot, Long zoneId, SnapshotOperation op) {
206209
logger.debug("StorpoolSnapshotStrategy.canHandle: snapshot {}, op={}", snapshot, op);
@@ -414,38 +417,25 @@ public void copySnapshot(DataObject snapshot, DataObject snapshotDest, AsyncComp
414417
SnapshotInfo srcSnapshot = (SnapshotInfo) snapshot;
415418
SnapshotInfo destSnapshot = (SnapshotInfo) snapshotDest;
416419
String err = null;
420+
String snapshotName = StorPoolStorageAdaptor.getVolumeNameFromPath(srcSnapshot.getPath(), false);
417421
if (location != null) {
418-
SpConnectionDesc connectionLocal = StorPoolUtil.getSpConnection(snapshot.getDataStore().getUuid(),
419-
snapshot.getDataStore().getId(), storagePoolDetailsDao, _primaryDataStoreDao);
420-
String snapshotName = StorPoolStorageAdaptor.getVolumeNameFromPath(srcSnapshot.getPath(), false);
421-
Long clusterId = StorPoolHelper.findClusterIdByGlobalId(StorPoolUtil.getSnapshotClusterId("~" + snapshotName, connectionLocal), clusterDao);
422-
connectionLocal = StorPoolHelper.getSpConnectionDesc(connectionLocal, clusterId);
423-
SpApiResponse resp = StorPoolUtil.snapshotExport("~" + snapshotName, location, connectionLocal);
422+
SpApiResponse resp = exportSnapshot(snapshot, location, snapshotName);
424423
if (resp.getError() != null) {
425424
StorPoolUtil.spLog("Failed to export snapshot %s from %s due to %s", snapshotName, location, resp.getError());
426425
err = String.format("Failed to export snapshot %s from %s due to %s", snapshotName, location, resp.getError());
427-
res = new CreateCmdResult(destSnapshot.getPath(), null);
428-
res.setResult(err);
429-
callback.complete(res);
426+
completeCallback(callback, res, destSnapshot.getPath(), err);
430427
return;
431428
}
432-
String detail = "~" + snapshotName + ";" + location;
433-
SnapshotDetailsVO snapshotForRecovery = new SnapshotDetailsVO(snapshot.getId(), StorPoolUtil.SP_RECOVERED_SNAPSHOT, detail, true);
434-
_snapshotDetailsDao.persist(snapshotForRecovery);
429+
keepExportedSnapshot(snapshot, location, snapshotName);
430+
435431
SpConnectionDesc connectionRemote = StorPoolUtil.getSpConnection(storagePoolVO.getUuid(),
436432
storagePoolVO.getId(), storagePoolDetailsDao, _primaryDataStoreDao);
437-
String localLocation = StorPoolConfigurationManager.StorPoolClusterLocation
438-
.valueIn(snapshot.getDataStore().getId());
439-
StoragePoolDetailVO template = storagePoolDetailsDao.findDetail(storagePoolVO.getId(),
440-
StorPoolUtil.SP_TEMPLATE);
441-
SpApiResponse respFromRemote = StorPoolUtil.snapshotFromRemote(snapshotName, localLocation,
442-
template.getValue(), connectionRemote);
433+
SpApiResponse respFromRemote = copySnapshotFromRemote(snapshot, storagePoolVO, snapshotName, connectionRemote);
434+
443435
if (respFromRemote.getError() != null) {
444436
StorPoolUtil.spLog("Failed to copy snapshot %s to %s due to %s", snapshotName, location, respFromRemote.getError());
445437
err = String.format("Failed to copy snapshot %s to %s due to %s", snapshotName, location, respFromRemote.getError());
446-
res = new CreateCmdResult(destSnapshot.getPath(), null);
447-
res.setResult(err);
448-
callback.complete(res);
438+
completeCallback(callback, res, destSnapshot.getPath(), err);
449439
return;
450440
}
451441
StorPoolUtil.spLog("The snapshot [%s] was copied from remote", snapshotName);
@@ -454,26 +444,59 @@ public void copySnapshot(DataObject snapshot, DataObject snapshotDest, AsyncComp
454444
if (respFromRemote.getError() != null) {
455445
StorPoolUtil.spLog("Failed to reconcile snapshot %s from %s due to %s", snapshotName, location, respFromRemote.getError());
456446
err = String.format("Failed to reconcile snapshot %s from %s due to %s", snapshotName, location, respFromRemote.getError());
457-
res = new CreateCmdResult(destSnapshot.getPath(), null);
458-
res.setResult(err);
459-
callback.complete(res);
447+
completeCallback(callback, res, destSnapshot.getPath(), err);
460448
return;
461449
}
462-
SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Primary, snapshotDest.getDataStore().getId(), destSnapshot.getSnapshotId());
463-
snapshotStore.setInstallPath(srcSnapshot.getPath());
464-
_snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
465-
450+
updateSnapshotPath(snapshotDest, srcSnapshot, destSnapshot);
466451
} else {
467-
res = new CreateCmdResult(destSnapshot.getPath(), null);
468-
res.setResult("The snapshot is not in the right location");
469-
callback.complete(res);
470-
return;
452+
completeCallback(callback, res, destSnapshot.getPath(), "The snapshot is not in the right location");
471453
}
472454
SnapshotObjectTO snap = (SnapshotObjectTO) snapshotDest.getTO();
473455
snap.setPath(srcSnapshot.getPath());
474456
CreateObjectAnswer answer = new CreateObjectAnswer(snap);
475-
res = new CreateCmdResult(destSnapshot.getPath(), answer);
457+
completeCallback(callback, res, destSnapshot.getPath(), err);
458+
}
459+
460+
private void completeCallback(AsyncCompletionCallback<CreateCmdResult> callback, CreateCmdResult res, String snapshotPath, String err) {
461+
res = new CreateCmdResult(snapshotPath, null);
476462
res.setResult(err);
477463
callback.complete(res);
478464
}
465+
466+
private void updateSnapshotPath(DataObject snapshotDest, SnapshotInfo srcSnapshot, SnapshotInfo destSnapshot) {
467+
468+
SnapshotDataStoreVO snapshotStore = _snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Primary, snapshotDest.getDataStore().getId(), destSnapshot.getSnapshotId());
469+
snapshotStore.setInstallPath(srcSnapshot.getPath());
470+
_snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
471+
}
472+
473+
@NotNull
474+
private SpApiResponse copySnapshotFromRemote(DataObject snapshot, StoragePoolVO storagePoolVO, String snapshotName, SpConnectionDesc connectionRemote) {
475+
476+
String localLocation = StorPoolConfigurationManager.StorPoolClusterLocation
477+
.valueIn(snapshot.getDataStore().getId());
478+
StoragePoolDetailVO template = storagePoolDetailsDao.findDetail(storagePoolVO.getId(),
479+
StorPoolUtil.SP_TEMPLATE);
480+
SpApiResponse respFromRemote = StorPoolUtil.snapshotFromRemote(snapshotName, localLocation,
481+
template.getValue(), connectionRemote);
482+
return respFromRemote;
483+
}
484+
485+
private void keepExportedSnapshot(DataObject snapshot, String location, String snapshotName) {
486+
487+
String detail = "~" + snapshotName + ";" + location;
488+
SnapshotDetailsVO snapshotForRecovery = new SnapshotDetailsVO(snapshot.getId(), StorPoolUtil.SP_RECOVERED_SNAPSHOT, detail, true);
489+
_snapshotDetailsDao.persist(snapshotForRecovery);
490+
}
491+
492+
@NotNull
493+
private SpApiResponse exportSnapshot(DataObject snapshot, String location, String snapshotName) {
494+
495+
SpConnectionDesc connectionLocal = StorPoolUtil.getSpConnection(snapshot.getDataStore().getUuid(),
496+
snapshot.getDataStore().getId(), storagePoolDetailsDao, _primaryDataStoreDao);
497+
Long clusterId = StorPoolHelper.findClusterIdByGlobalId(StorPoolUtil.getSnapshotClusterId("~" + snapshotName, connectionLocal), clusterDao);
498+
connectionLocal = StorPoolHelper.getSpConnectionDesc(connectionLocal, clusterId);
499+
SpApiResponse resp = StorPoolUtil.snapshotExport("~" + snapshotName, location, connectionLocal);
500+
return resp;
501+
}
479502
}

0 commit comments

Comments
 (0)