CLOUDSTACK-985: Make sure RvR would always have same MAC address

Even with newly created RvR using "restartNetwork&cleanup=false" API.
This commit is contained in:
Sheng Yang 2013-01-15 15:22:41 -08:00
parent c32dbec468
commit 4f889bd426

View File

@ -1699,6 +1699,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
String publicIp = defaultNic.getIp4Address();
// We want to use the identical MAC address for RvR on public interface if possible
NicVO peerNic = _nicDao.findByIp4AddressAndNetworkId(publicIp, publicNetworks.get(0).getId());
if (peerNic != null) {
s_logger.info("Use same MAC as previous RvR, the MAC is " + peerNic.getMacAddress());
defaultNic.setMacAddress(peerNic.getMacAddress());
}
networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), defaultNic));
}