sudo87 commented on code in PR #13325:
URL: https://github.com/apache/cloudstack/pull/13325#discussion_r4230305021


##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -2663,14 +2668,20 @@ public NetworkResponse 
createNetworkResponse(ResponseView view, Network network)
             response.setVlan(vlan);
         }
 
-        // return network details only to Root admin
+        int networkRate;
+        // return network details only to Root admin, and take the network 
rate from them to save a lookup
         if (view == ResponseView.Full) {
             Map<String, String> details = new HashMap<>();
             for (NetworkDetailVO detail: 
networkDetailsDao.listDetails(network.getId())) {
                 details.put(detail.getName(),detail.getValue());
             }
             response.setDetails(details);
+            networkRate = 
NumberUtils.toInt(details.get(ApiConstants.NETWORKRATE), -1);
+        } else {
+            NetworkDetailVO networkRateDetail = 
networkDetailsDao.findDetail(network.getId(), ApiConstants.NETWORKRATE);
+            networkRate = networkRateDetail != null ? 
NumberUtils.toInt(networkRateDetail.getValue(), -1) : -1;
         }
+        response.setNetworkRate(networkRate > 0 ? networkRate : -1);

Review Comment:
   The detail is set on network creation and offering change, and the upgrade 
backfills it. It should only be missing if a write failed, which I’d fix there.



-- 
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