From 36511ab6fd2372a896b412333b69a1709fc024b7 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 29 Sep 2011 17:26:09 -0700 Subject: [PATCH] bug 11604: Assign guest ip for each router Then every router would have one guest ip. The gateway ip would be used if the router is not redundant, otherwise the guest ip would be used for guest network. --- .../router/VirtualNetworkApplianceManagerImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 08612bef7b8..eb6d9d41d14 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1073,11 +1073,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian List publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false, false); networks.add(new Pair(publicNetworks.get(0), defaultNic)); NicProfile gatewayNic = new NicProfile(); - if (isRedundant) { - gatewayNic.setIp4Address(_networkMgr.acquireGuestIpAddress(guestNetwork, null)); - } else { - gatewayNic.setIp4Address(guestNetwork.getGateway()); - } + gatewayNic.setIp4Address(_networkMgr.acquireGuestIpAddress(guestNetwork, null)); gatewayNic.setBroadcastUri(guestNetwork.getBroadcastUri()); gatewayNic.setBroadcastType(guestNetwork.getBroadcastDomainType()); gatewayNic.setIsolationUri(guestNetwork.getBroadcastUri()); @@ -1396,7 +1392,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian for (NicProfile nic : profile.getNics()) { int deviceId = nic.getDeviceId(); - buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address()); + Network net = _networkMgr.getNetwork(nic.getNetworkId()); + String guestIp = nic.getIp4Address(); + if (nic.getTrafficType() == TrafficType.Guest && !router.getIsRedundantRouter()) { + guestIp = net.getGateway(); + } + buf.append(" eth").append(deviceId).append("ip=").append(guestIp); buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask()); if (nic.isDefaultNic()) { buf.append(" gateway=").append(nic.getGateway()); @@ -1443,7 +1444,6 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian controlNic = nic; } else if (nic.getTrafficType() == TrafficType.Guest && isRedundant) { - Network net = _networkMgr.getNetwork(nic.getNetworkId()); buf.append(" guestgw=").append(net.getGateway()); String brd = NetUtils.long2Ip(NetUtils.ip2Long(nic.getIp4Address()) | ~NetUtils.ip2Long(nic.getNetmask())); buf.append(" guestbrd=").append(brd);