Skip to content

Commit 0032ff2

Browse files
committed
CLOUDSTACK-3418: if primary storage not in up state, wont' take snapshot
1 parent e88377a commit 0032ff2

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@
2626
import javax.inject.Inject;
2727

2828
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
29+
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
2930
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
3031
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
3132
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
3233
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
3334
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
35+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
3436
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
3537
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
3638
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
37-
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
3839
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
39-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
4040
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
41+
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
4142
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
4243
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
43-
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
4444
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
4545
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
4646
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
@@ -77,11 +77,12 @@
7777
import com.cloud.storage.DataStoreRole;
7878
import com.cloud.storage.ScopeType;
7979
import com.cloud.storage.StoragePool;
80+
import com.cloud.storage.StoragePoolStatus;
8081
import com.cloud.storage.VMTemplateStoragePoolVO;
8182
import com.cloud.storage.VMTemplateStorageResourceAssoc;
8283
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
83-
import com.cloud.storage.Volume.State;
8484
import com.cloud.storage.Volume;
85+
import com.cloud.storage.Volume.State;
8586
import com.cloud.storage.VolumeVO;
8687
import com.cloud.storage.dao.VMTemplatePoolDao;
8788
import com.cloud.storage.dao.VolumeDao;
@@ -1302,6 +1303,13 @@ private Map<Long, TemplateProp> listVolume(DataStore store) {
13021303

13031304
@Override
13041305
public SnapshotInfo takeSnapshot(VolumeInfo volume) {
1306+
PrimaryDataStore store = (PrimaryDataStore)volume.getDataStore();
1307+
1308+
if (store.getStatus() != StoragePoolStatus.Up) {
1309+
throw new CloudRuntimeException("store is not in up state");
1310+
}
1311+
1312+
13051313
SnapshotInfo snapshot = null;
13061314
try {
13071315
snapshot = snapshotMgr.takeSnapshot(volume);

0 commit comments

Comments
 (0)