vishesh92 commented on code in PR #12706:
URL: https://github.com/apache/cloudstack/pull/12706#discussion_r3233349170


##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -5405,8 +5418,27 @@ public FirewallResponse 
createIpv6FirewallRuleResponse(FirewallRule fwRule) {
         response.setIcmpCode(fwRule.getIcmpCode());
         response.setIcmpType(fwRule.getIcmpType());
 
-        Network network = ApiDBUtils.findNetworkById(fwRule.getNetworkId());
-        response.setNetworkId(network.getUuid());
+        Long networkId = fwRule.getNetworkId();
+        if (networkId != null) {
+            Network network = ApiDBUtils.findNetworkById(networkId);
+            if (network != null) {
+                response.setNetworkId(network.getUuid());
+            }
+        }
+
+        Long vpcId = fwRule.getVpcId();
+        if (vpcId == null && networkId != null) {
+            Network network = ApiDBUtils.findNetworkById(networkId);
+            if (network != null) {
+                vpcId = network.getVpcId();
+            }
+        }

Review Comment:
   ```suggestion
           Long vpcId = fwRule.getVpcId();
           if (networkId != null) {
               Network network = ApiDBUtils.findNetworkById(networkId);
               if (network != null) {
   response.setNetworkId(network.getUuid());
                   if (vpcId == null) {
                       vpcId = network.getVpcId();
                   }
               }
           }
   ```
   This will prevent 2 DB calls.



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