|
27 | 27 | import java.net.URLDecoder; |
28 | 28 | import java.util.ArrayList; |
29 | 29 | import java.util.Arrays; |
| 30 | +import java.util.Collections; |
30 | 31 | import java.util.Date; |
31 | 32 | import java.util.HashMap; |
32 | 33 | import java.util.HashSet; |
@@ -3094,7 +3095,7 @@ public UserVm updateVirtualMachine(long id, String displayName, String group, Bo |
3094 | 3095 | if (zone.getNetworkType() == NetworkType.Basic) { |
3095 | 3096 | // Get default guest network in Basic zone |
3096 | 3097 | defaultNetwork = _networkModel.getExclusiveGuestNetwork(zone.getId()); |
3097 | | - } else if (zone.isSecurityGroupEnabled()) { |
| 3098 | + } else if (_networkModel.checkSecurityGroupSupportForNetwork(zone, Collections.emptyList(), securityGroupIdList)) { |
3098 | 3099 | NicVO defaultNic = _nicDao.findDefaultNicForVM(vm.getId()); |
3099 | 3100 | if (defaultNic != null) { |
3100 | 3101 | defaultNetwork = _networkDao.findById(defaultNic.getNetworkId()); |
@@ -6153,7 +6154,8 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE |
6153 | 6154 | dataDiskTemplateToDiskOfferingMap, userVmOVFProperties, dynamicScalingEnabled, overrideDiskOfferingId); |
6154 | 6155 | } |
6155 | 6156 | } else { |
6156 | | - if (zone.isSecurityGroupEnabled()) { |
| 6157 | + if (_networkModel.checkSecurityGroupSupportForNetwork(zone, networkIds, |
| 6158 | + cmd.getSecurityGroupIdList())) { |
6157 | 6159 | vm = createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, networkIds, getSecurityGroupIdList(cmd, zone, template, owner), owner, name, |
6158 | 6160 | displayName, diskOfferingId, size, group, cmd.getHypervisor(), cmd.getHttpMethod(), userData, userDataId, userDataDetails, sshKeyPairNames, cmd.getIpToNetworkMap(), addrs, displayVm, keyboard, |
6159 | 6161 | cmd.getAffinityGroupIdList(), cmd.getDetails(), cmd.getCustomId(), cmd.getDhcpOptionsMap(), |
@@ -7573,7 +7575,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) { |
7573 | 7575 | Set<NetworkVO> applicableNetworks = new LinkedHashSet<>(); |
7574 | 7576 | Map<Long, String> requestedIPv4ForNics = new HashMap<>(); |
7575 | 7577 | Map<Long, String> requestedIPv6ForNics = new HashMap<>(); |
7576 | | - if (zone.isSecurityGroupEnabled()) { // advanced zone with security groups |
| 7578 | + if (_networkModel.checkSecurityGroupSupportForNetwork(zone, networkIdList, securityGroupIdList)) { // advanced zone with security groups |
7577 | 7579 | // cleanup the old security groups |
7578 | 7580 | _securityGroupMgr.removeInstanceFromGroups(cmd.getVmId()); |
7579 | 7581 | // if networkIdList is null and the first network of vm is shared network, then keep it if possible |
@@ -8794,7 +8796,7 @@ private LinkedHashMap<Integer, Long> getVmOvfNetworkMapping(DataCenter zone, Acc |
8794 | 8796 |
|
8795 | 8797 | private Network getNetworkForOvfNetworkMapping(DataCenter zone, Account owner) throws InsufficientCapacityException, ResourceAllocationException { |
8796 | 8798 | Network network = null; |
8797 | | - if (zone.isSecurityGroupEnabled()) { |
| 8799 | + if (zone.isSecurityGroupEnabled() || _networkModel.isSecurityGroupSupportedForZone(zone.getId())) { |
8798 | 8800 | network = _networkModel.getNetworkWithSGWithFreeIPs(zone.getId()); |
8799 | 8801 | if (network == null) { |
8800 | 8802 | throw new InvalidParameterValueException("No network with security enabled is found in zone ID: " + zone.getUuid()); |
|
0 commit comments