mirror of https://github.com/apache/cloudstack.git
CS-16178 - when remove PF rule, in VPC setup make sure if the rule is the last one for the network, disassociate it from the network
Reviewed-by: Sheng Yang
This commit is contained in:
parent
a594889053
commit
f939cee219
|
|
@ -37,6 +37,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
|
|
@ -447,6 +448,11 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
|
|||
success = false;
|
||||
} else {
|
||||
removeRule(rule);
|
||||
if (rule.getSourceIpAddressId() != null) {
|
||||
//if the rule is the last one for the ip address assigned to VPC, unassign it from the network
|
||||
IpAddress ip = _ipAddressDao.findById(rule.getSourceIpAddressId());
|
||||
_vpcMgr.unassignIPFromVpcNetwork(ip.getId(), rule.getNetworkId());
|
||||
}
|
||||
}
|
||||
} else if (rule.getState() == FirewallRule.State.Add) {
|
||||
FirewallRuleVO ruleVO = _firewallDao.findById(rule.getId());
|
||||
|
|
|
|||
|
|
@ -626,7 +626,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
Map<String, String> vlanMacAddress = new HashMap<String, String>();
|
||||
List<PublicIpAddress> ipsToSend = new ArrayList<PublicIpAddress>();
|
||||
for (PublicIpAddress ipAddr : ipAddress) {
|
||||
|
||||
String broadcastURI = BroadcastDomainType.Vlan.toUri(ipAddr.getVlanTag()).toString();
|
||||
Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ipAddr.getNetworkId(),
|
||||
router.getId(), broadcastURI);
|
||||
|
|
@ -645,8 +644,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
ipsToSend.add(ipAddr);
|
||||
}
|
||||
}
|
||||
createVpcAssociatePublicIPCommands(router, ipsToSend, cmds, vlanMacAddress);
|
||||
return sendCommandsToRouter(router, cmds);
|
||||
if (!ipsToSend.isEmpty()) {
|
||||
createVpcAssociatePublicIPCommands(router, ipsToSend, cmds, vlanMacAddress);
|
||||
return sendCommandsToRouter(router, cmds);
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
if(result && netUsagecmds.size() > 0){
|
||||
|
|
|
|||
Loading…
Reference in New Issue