bhouse-nexthop commented on code in PR #14767:
URL: https://github.com/apache/cloudstack/pull/14767#discussion_r4734531868


##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -840,7 +840,7 @@ public static DataStoreRole getDataStoreRole(Snapshot 
snapshot, SnapshotDataStor
 
         if (mapCapabilities != null) {

Review Comment:
   I'd rather leave this line as it is. The `if (mapCapabilities != null)` 
block is unchanged from before the merge; this PR only restores `parseBoolean`. 
The result is already the same either way: with an empty map, `get()` returns 
null and `parseBoolean(null)` is false, so it falls through to `Image`. I added 
a test for the null and empty map cases (see the test thread).
   



##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -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";

Review Comment:
   I kept the literals on purpose. This PR only puts back `valueIn(zoneId)` on 
a line that already had them, and the same line in 
`TemplateManagerImpl.registerPostUploadInternal` uses the same literals 
(`UseHttpsToUpload.valueIn(...) ? "https" : "http"`). `HttpConstants` in 
`utils` has `HTTPS` but no `HTTP`, so using constants here means adding one and 
changing both upload paths. I'd keep that out of this fix.
   



##########
server/src/test/java/com/cloud/api/ApiResponseHelperTest.java:
##########
@@ -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() {

Review Comment:
   Added, in 888bd33e02:
   - `TRUE` and `True` give `Primary`.
   - `yes` and an empty string give `Image`.
   - A driver that returns null or an empty capabilities map gives `Image`.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to