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:
Alena Prokharchyk 2012-08-27 13:43:02 -07:00
parent a594889053
commit f939cee219
2 changed files with 12 additions and 3 deletions

View File

@ -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());

View File

@ -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){