weizhouapache commented on code in PR #9415:
URL: https://github.com/apache/cloudstack/pull/9415#discussion_r1728636747


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -6165,6 +6165,28 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) 
throws InsufficientCapacityE
         return vm;
     }
 
+    private boolean checkSecurityGroupSupportForNetwork(DataCenter zone, 
List<Long> networkIds,
+                                                        List<Long> 
securityGroupsIds) {
+        if (zone.isSecurityGroupEnabled()) {
+            return true;
+        }
+        if (CollectionUtils.isNotEmpty(networkIds)) {
+            for (Long networkId : networkIds) {
+                Network network = _networkDao.findById(networkId);
+                if (network == null) {
+                    throw new InvalidParameterValueException("Unable to find 
network by id " + networkId);
+                }
+                if (network.getGuestType() == Network.GuestType.Shared && 
_networkModel.isSecurityGroupSupportedInNetwork(network)) {
+                    return true;
+                }
+            }
+        } else if (CollectionUtils.isNotEmpty(securityGroupsIds)) {
+            Network networkWithSecurityGroup = 
_networkModel.getNetworkWithSGWithFreeIPs(zone.getId());

Review Comment:
   got it
   
   as discussed, if securityGroupsIds is specified but networkids are not, ACS 
will choose a shared network with SG to deploy the vm



-- 
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: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to