From 53c9bb4d387ddc298744879526a40d1d2ca4e394 Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Thu, 3 Sep 2015 09:38:56 +0200 Subject: [PATCH] CLOUDSTACK-8759 - Fix guets nic allocation - When stopping/detroying a VPC router and creating a new one via the addition os a VM, the networks are no plugged correctly - The ETH1 ends up with the IP of the guest nic, which remains down. This causes routes problems and the VMs are not reachable via the pub IPs --- .../cloud/network/router/NetworkHelperImpl.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/server/src/com/cloud/network/router/NetworkHelperImpl.java b/server/src/com/cloud/network/router/NetworkHelperImpl.java index dd45e9f3d13..62dd7893abc 100644 --- a/server/src/com/cloud/network/router/NetworkHelperImpl.java +++ b/server/src/com/cloud/network/router/NetworkHelperImpl.java @@ -623,12 +623,7 @@ public class NetworkHelperImpl implements NetworkHelper { networks.put(controlConfig, new ArrayList()); - // 2) Guest Network - final LinkedHashMap> guestNic = configureGuestNic(routerDeploymentDefinition); - // The guest nic has to be added after the Control Nic. - networks.putAll(guestNic); - - // 3) Public network + // 2) Public network if (routerDeploymentDefinition.isPublicNetwork()) { s_logger.debug("Adding nic for Virtual Router in Public network "); // if source nat service is supported by the network, get the source @@ -651,10 +646,7 @@ public class NetworkHelperImpl implements NetworkHelper { defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag())); defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag())); } - //If guest nic has already been addedd we will have 2 devices in the list. - if (networks.size() > 1) { - defaultNic.setDeviceId(2); - } + final NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0); final List publicNetworks = _networkMgr.setupNetwork(s_systemAccount, publicOffering, routerDeploymentDefinition.getPlan(), null, null, false); final String publicIp = defaultNic.getIPv4Address(); @@ -668,6 +660,11 @@ public class NetworkHelperImpl implements NetworkHelper { networks.put(publicNetworks.get(0), new ArrayList(Arrays.asList(defaultNic))); } + // 3) Guest Network + final LinkedHashMap> guestNic = configureGuestNic(routerDeploymentDefinition); + // The guest nic has to be added after the Control and Public nics. + networks.putAll(guestNic); + return networks; }