Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/src/main/java/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ public static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStor

if (mapCapabilities != null) {
String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
boolean supportsStorageSystemSnapshots = Boolean.getBoolean(value);
boolean supportsStorageSystemSnapshots = Boolean.parseBoolean(value);

if (supportsStorageSystemSnapshots) {
return DataStoreRole.Primary;
Expand Down
10 changes: 5 additions & 5 deletions server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public GetUploadParamsResponse doInTransaction(TransactionStatus status) throws
GetUploadParamsResponse response = new GetUploadParamsResponse();

String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
String protocol = UseHttpsToUpload.value() ? "https" : "http";
String protocol = UseHttpsToUpload.valueIn(zoneId) ? "https" : "http";

String url = ImageStoreUtil.generatePostUploadUrl(ssvmUrlDomain, ep.getPublicAddr(), vol.getUuid(), protocol);
response.setPostURL(new URL(url));
Expand Down Expand Up @@ -1819,10 +1819,10 @@ protected VolumeVO retrieveAndValidateVolume(long volumeId, Account caller) {
*
* A volume can be destroyed if it is not in any of the following states.
* <ul>
* <li> {code}Volume.State#Destroy{code};
* <li> {code}Volume.State#Expunging{code};
* <li> {code}Volume.State#Expunged{code};
* <li> {code}Volume.State#Allocated{code}.
* <li> {@code Volume.State#Destroy};
* <li> {@code Volume.State#Expunging};
* <li> {@code Volume.State#Expunged};
* <li> {@code Volume.State#Allocated}.
* </ul>
*
* The volume is destroyed via {@link VolumeService#destroyVolume(long)} method.
Expand Down
35 changes: 35 additions & 0 deletions server/src/test/java/com/cloud/api/ApiResponseHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
import org.apache.cloudstack.api.response.UsageRecordResponse;
import org.apache.cloudstack.api.response.TrafficTypeResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.cloudstack.usage.UsageService;
import org.apache.cloudstack.vm.UnmanagedInstanceTO;

Expand All @@ -84,7 +90,9 @@
import com.cloud.server.ResourceIcon;
import com.cloud.server.ResourceIconManager;
import com.cloud.server.ResourceTag;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.GuestOsCategory;
import com.cloud.storage.Snapshot;
import com.cloud.storage.VMTemplateVO;
import com.cloud.usage.UsageVO;
import com.cloud.user.Account;
Expand Down Expand Up @@ -850,4 +858,31 @@ public void showVmInfoForSharedNetworksTestRouterPlaceholderOnly() {
verify(ipResponse, Mockito.never()).setVirtualMachineId(Mockito.anyString());
}
}

private DataStoreRole getDataStoreRoleForStorageSystemSnapshotCapability(String capability) {
Snapshot snapshot = Mockito.mock(Snapshot.class);
when(snapshot.getId()).thenReturn(1L);
SnapshotDataStoreVO snapshotStore = Mockito.mock(SnapshotDataStoreVO.class);
when(snapshotStore.getDataStoreId()).thenReturn(2L);
SnapshotDataStoreDao snapshotStoreDao = Mockito.mock(SnapshotDataStoreDao.class);
when(snapshotStoreDao.findOneBySnapshotAndDatastoreRole(1L, DataStoreRole.Primary)).thenReturn(snapshotStore);
DataStoreDriver driver = Mockito.mock(DataStoreDriver.class);
when(driver.getCapabilities()).thenReturn(Map.of(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString(), capability));
DataStore dataStore = Mockito.mock(DataStore.class);
when(dataStore.getDriver()).thenReturn(driver);
DataStoreManager dataStoreMgr = Mockito.mock(DataStoreManager.class);
when(dataStoreMgr.getDataStore(2L, DataStoreRole.Primary)).thenReturn(dataStore);

return ApiResponseHelper.getDataStoreRole(snapshot, snapshotStoreDao, dataStoreMgr);
}

@Test
public void getDataStoreRoleTestStorageSystemSnapshotSupported() {
assertEquals(DataStoreRole.Primary, getDataStoreRoleForStorageSystemSnapshotCapability("true"));
}

@Test
public void getDataStoreRoleTestStorageSystemSnapshotNotSupported() {
assertEquals(DataStoreRole.Image, getDataStoreRoleForStorageSystemSnapshotCapability("false"));
}
}
Loading