|
142 | 142 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; |
143 | 143 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities; |
144 | 144 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; |
| 145 | +import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; |
145 | 146 | import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory; |
146 | 147 | import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; |
147 | 148 | import org.apache.cloudstack.framework.jobs.AsyncJob; |
@@ -493,7 +494,9 @@ public SnapshotResponse createSnapshotResponse(Snapshot snapshot) { |
493 | 494 | snapshotInfo = (SnapshotInfo)snapshot; |
494 | 495 | } else { |
495 | 496 | DataStoreRole dataStoreRole = getDataStoreRole(snapshot, _snapshotStoreDao, _dataStoreMgr); |
496 | | - |
| 497 | + if (dataStoreRole == null){ |
| 498 | + return null; |
| 499 | + } |
497 | 500 | snapshotInfo = snapshotfactory.getSnapshot(snapshot.getId(), dataStoreRole); |
498 | 501 | } |
499 | 502 |
|
@@ -526,16 +529,18 @@ public static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStor |
526 | 529 | } |
527 | 530 |
|
528 | 531 | long storagePoolId = snapshotStore.getDataStoreId(); |
529 | | - DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); |
| 532 | + if (! snapshotStore.getState().equals(ObjectInDataStoreStateMachine.State.Destroyed)){ |
| 533 | + DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); |
530 | 534 |
|
531 | | - Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); |
| 535 | + Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities(); |
532 | 536 |
|
533 | | - if (mapCapabilities != null) { |
534 | | - String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); |
535 | | - Boolean supportsStorageSystemSnapshots = new Boolean(value); |
| 537 | + if (mapCapabilities != null) { |
| 538 | + String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); |
| 539 | + Boolean supportsStorageSystemSnapshots = new Boolean(value); |
536 | 540 |
|
537 | | - if (supportsStorageSystemSnapshots) { |
538 | | - return DataStoreRole.Primary; |
| 541 | + if (supportsStorageSystemSnapshots) { |
| 542 | + return DataStoreRole.Primary; |
| 543 | + } |
539 | 544 | } |
540 | 545 | } |
541 | 546 |
|
|
0 commit comments