From 86e4d6f80c5c74847a77848eb4152e367fec2fb3 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Tue, 6 Aug 2013 17:14:01 +0530 Subject: [PATCH] CLOUDSTACK-4013: [PortableIP] [MultiplePhysicalNetworks] Associate portable IP is trying to insert network id as physical network id ensuring network id, physical network id, source network id are properly set for portable ip in user_ip_address and vlan tables --- .../src/com/cloud/network/NetworkManagerImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index effee96c55d..ad79a2fb5b3 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -830,11 +830,11 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L Network network =_networkModel.getSystemNetworkByZoneAndTrafficType(dcId, TrafficType.Public); String range = allocatedPortableIp.getAddress() + "-" + allocatedPortableIp.getAddress(); VlanVO vlan = new VlanVO(VlanType.VirtualNetwork, allocatedPortableIp.getVlan(), allocatedPortableIp.getGateway(), - allocatedPortableIp.getNetmask(), dcId, range, network.getId(), network.getId(), null, null, null); + allocatedPortableIp.getNetmask(), dcId, range, network.getId(), physicalNetworkId, null, null, null); vlan = _vlanDao.persist(vlan); // provision the portable IP in to user_ip_address table - ipaddr = new IPAddressVO(new Ip(allocatedPortableIp.getAddress()), dcId, networkId, vpcID, network.getId(), + ipaddr = new IPAddressVO(new Ip(allocatedPortableIp.getAddress()), dcId, networkId, vpcID, physicalNetworkId, network.getId(), vlan.getId(), true); ipaddr.setState(State.Allocated); ipaddr.setAllocatedTime(new Date()); @@ -1150,20 +1150,23 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L // in user_ip_address and vlan tables so as to emulate portable IP as provisioned in destination data center if (srcNetwork.getDataCenterId() != dstNetwork.getDataCenterId()) { txn.start(); - ip.setDataCenterId(dstNetwork.getDataCenterId()); - ip.setPhysicalNetworkId(dstNetwork.getPhysicalNetworkId()); - _ipAddressDao.update(ipAddrId, ip); long physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType( dstNetwork.getDataCenterId(), TrafficType.Public).getId(); long publicNetworkId =_networkModel.getSystemNetworkByZoneAndTrafficType( dstNetwork.getDataCenterId(), TrafficType.Public).getId(); + ip.setDataCenterId(dstNetwork.getDataCenterId()); + ip.setPhysicalNetworkId(physicalNetworkId); + ip.setSourceNetworkId(publicNetworkId); + _ipAddressDao.update(ipAddrId, ip); + VlanVO vlan = _vlanDao.findById(ip.getVlanId()); vlan.setPhysicalNetworkId(physicalNetworkId); vlan.setNetworkId(publicNetworkId); vlan.setDataCenterId(dstNetwork.getDataCenterId()); _vlanDao.update(ip.getVlanId(), vlan); + txn.commit(); }