Skip to content

Commit 86e4d6f

Browse files
committed
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
1 parent 1970a0d commit 86e4d6f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎server/src/com/cloud/network/NetworkManagerImpl.java‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,11 @@ public IpAddress allocatePortableIp(Account ipOwner, Account caller, long dcId,
830830
Network network =_networkModel.getSystemNetworkByZoneAndTrafficType(dcId, TrafficType.Public);
831831
String range = allocatedPortableIp.getAddress() + "-" + allocatedPortableIp.getAddress();
832832
VlanVO vlan = new VlanVO(VlanType.VirtualNetwork, allocatedPortableIp.getVlan(), allocatedPortableIp.getGateway(),
833-
allocatedPortableIp.getNetmask(), dcId, range, network.getId(), network.getId(), null, null, null);
833+
allocatedPortableIp.getNetmask(), dcId, range, network.getId(), physicalNetworkId, null, null, null);
834834
vlan = _vlanDao.persist(vlan);
835835

836836
// provision the portable IP in to user_ip_address table
837-
ipaddr = new IPAddressVO(new Ip(allocatedPortableIp.getAddress()), dcId, networkId, vpcID, network.getId(),
837+
ipaddr = new IPAddressVO(new Ip(allocatedPortableIp.getAddress()), dcId, networkId, vpcID, physicalNetworkId,
838838
network.getId(), vlan.getId(), true);
839839
ipaddr.setState(State.Allocated);
840840
ipaddr.setAllocatedTime(new Date());
@@ -1150,20 +1150,23 @@ public void transferPortableIP(long ipAddrId, long currentNetworkId, long newNet
11501150
// in user_ip_address and vlan tables so as to emulate portable IP as provisioned in destination data center
11511151
if (srcNetwork.getDataCenterId() != dstNetwork.getDataCenterId()) {
11521152
txn.start();
1153-
ip.setDataCenterId(dstNetwork.getDataCenterId());
1154-
ip.setPhysicalNetworkId(dstNetwork.getPhysicalNetworkId());
1155-
_ipAddressDao.update(ipAddrId, ip);
11561153

11571154
long physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(
11581155
dstNetwork.getDataCenterId(), TrafficType.Public).getId();
11591156
long publicNetworkId =_networkModel.getSystemNetworkByZoneAndTrafficType(
11601157
dstNetwork.getDataCenterId(), TrafficType.Public).getId();
11611158

1159+
ip.setDataCenterId(dstNetwork.getDataCenterId());
1160+
ip.setPhysicalNetworkId(physicalNetworkId);
1161+
ip.setSourceNetworkId(publicNetworkId);
1162+
_ipAddressDao.update(ipAddrId, ip);
1163+
11621164
VlanVO vlan = _vlanDao.findById(ip.getVlanId());
11631165
vlan.setPhysicalNetworkId(physicalNetworkId);
11641166
vlan.setNetworkId(publicNetworkId);
11651167
vlan.setDataCenterId(dstNetwork.getDataCenterId());
11661168
_vlanDao.update(ip.getVlanId(), vlan);
1169+
11671170
txn.commit();
11681171
}
11691172

0 commit comments

Comments
 (0)