This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch debian9-systemvmtemplate in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 02d479b928c830687d877a2771fbc4bc14fa2112 Author: Rohit Yadav <rohit.ya...@shapeblue.com> AuthorDate: Wed Dec 13 01:28:18 2017 +0530 CLOUDSTACK-10187: Don't delete vifs for VPCs with source nat On XenServer, both redundant router's vifs were getting deleted when any PF rule is removed from any of the acquired public IPs. This fix ensures that lastIp is set to `false` when processed by hypervisor resources to avoid removing of VIFs when VPCs have any source nat IP. Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> --- .../com/cloud/network/router/CommandSetupHelper.java | 19 ++++++++++++++----- test/integration/smoke/test_vpc_redundant.py | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/network/router/CommandSetupHelper.java b/server/src/com/cloud/network/router/CommandSetupHelper.java index cadaf4f..c8d85fe 100644 --- a/server/src/com/cloud/network/router/CommandSetupHelper.java +++ b/server/src/com/cloud/network/router/CommandSetupHelper.java @@ -475,7 +475,7 @@ public class CommandSetupHelper { public void createAssociateIPCommands(final VirtualRouter router, final List<? extends PublicIpAddress> ips, final Commands cmds, final long vmId) { final String ipAssocCommand = "IPAssocCommand"; - createRedundantAssociateIPCommands(router, ips, cmds, ipAssocCommand, vmId); + createRedundantAssociateIPCommands(router, ips, cmds, ipAssocCommand, false); } public void createNetworkACLsCommands(final List<? extends NetworkACLItem> rules, final VirtualRouter router, final Commands cmds, final long guestNetworkId, @@ -645,7 +645,7 @@ public class CommandSetupHelper { final String ipAssocCommand = "IPAssocVpcCommand"; if (router.getIsRedundantRouter()) { - createRedundantAssociateIPCommands(router, ips, cmds, ipAssocCommand, 0); + createRedundantAssociateIPCommands(router, ips, cmds, ipAssocCommand, true); return; } @@ -742,7 +742,7 @@ public class CommandSetupHelper { } } - public void createRedundantAssociateIPCommands(final VirtualRouter router, final List<? extends PublicIpAddress> ips, final Commands cmds, final String ipAssocCommand, final long vmId) { + public void createRedundantAssociateIPCommands(final VirtualRouter router, final List<? extends PublicIpAddress> ips, final Commands cmds, final String ipAssocCommand, final boolean isVPC) { // Ensure that in multiple vlans case we first send all ip addresses of // vlan1, then all ip addresses of vlan2, etc.. @@ -840,7 +840,16 @@ public class CommandSetupHelper { } // for network if the ips does not have any rules, then only last ip - List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(associatedWithNetworkId, null); + final List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(associatedWithNetworkId, null); + boolean hasSourceNat = false; + if (isVPC && userIps.size() > 0 && userIps.get(0) != null) { + // All ips should belong to a VPC + final Long vpcId = userIps.get(0).getVpcId(); + final List<IPAddressVO> sourceNatIps = _ipAddressDao.listByAssociatedVpc(vpcId, true); + if (sourceNatIps != null && sourceNatIps.size() > 0) { + hasSourceNat = true; + } + } int ipsWithrules = 0; int ipsStaticNat = 0; @@ -864,7 +873,7 @@ public class CommandSetupHelper { cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString()); // if there is 1 static nat then it will be checked for remove at the resource - if (ipsWithrules == 0 && ipsStaticNat == 0) { + if (ipsWithrules == 0 && ipsStaticNat == 0 && !hasSourceNat) { // there is only one ip address for the network. cmd.setAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP, "true"); } else { diff --git a/test/integration/smoke/test_vpc_redundant.py b/test/integration/smoke/test_vpc_redundant.py index b87ce43..e7b29b1 100644 --- a/test/integration/smoke/test_vpc_redundant.py +++ b/test/integration/smoke/test_vpc_redundant.py @@ -610,7 +610,7 @@ class TestVPCRedundancy(cloudstackTestCase): gc_wait = Configurations.list(self.apiclient, name="network.gc.wait") gc_interval = Configurations.list(self.apiclient, name="network.gc.interval") - + self.logger.debug("network.gc.wait is ==> %s" % gc_wait) self.logger.debug("network.gc.interval is ==> %s" % gc_interval) @@ -628,7 +628,7 @@ class TestVPCRedundancy(cloudstackTestCase): @attr(tags=["advanced", "intervlan"], required_hardware="true") def test_05_rvpc_multi_tiers(self): - """ Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics""" + """ Create a redundant VPC with multiple tiers""" self.logger.debug("Starting test_05_rvpc_multi_tiers") self.query_routers() -- To stop receiving notification emails like this one, please contact "commits@cloudstack.apache.org" <commits@cloudstack.apache.org>.