You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2013/07/15 05:34:38 UTC

git commit: updated refs/heads/4.2 to 8de3b4f

Updated Branches:
  refs/heads/4.2 6f5d39883 -> 8de3b4f46


CLOUDSTACK-3444:  Unable to transfer portalbe IP between ISOLATED network and VPC
Tiered Network

When portable IP is transferred across the zones, we emulate portable IP
as provisioned in new zone's physical network carrying public traffic
and logical public network. network Id, and physical network id both
were bieng set to same physical network id resulting in IP association
to fail. This fix ensures both network and physcial network are set
appropriatley.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8de3b4f4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8de3b4f4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8de3b4f4

Branch: refs/heads/4.2
Commit: 8de3b4f461ab67ccd5bb3d4d0793619c9e5034e0
Parents: 6f5d398
Author: Murali Reddy <mu...@gmail.com>
Authored: Mon Jul 15 08:44:23 2013 +0530
Committer: Murali Reddy <mu...@gmail.com>
Committed: Mon Jul 15 09:04:24 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/network/NetworkManagerImpl.java   | 29 ++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8de3b4f4/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 7642352..45ff2bd 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -800,7 +800,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             portableIpLock.lock(5);
 
             txn.start();
-            //TODO: get the region ID corresponding to running management server
+
             List<PortableIpVO> portableIpVOs = _portableIpDao.listByRegionIdAndState(1, PortableIp.State.Free);
             if (portableIpVOs == null || portableIpVOs.isEmpty()) {
                 InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException
@@ -816,9 +816,13 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             allocatedPortableIp.setState(PortableIp.State.Allocated);
             _portableIpDao.update(allocatedPortableIp.getId(), allocatedPortableIp);
 
-            // provision portable IP range VLAN
+            // To make portable IP available as a zone level resource we need to emulate portable IP's (which are
+            // provisioned at region level) as public IP provisioned in a zone. user_ip_address and vlan combo give the
+            // identity of a public IP in zone. Create entry for portable ip in these tables.
+
+            // provision portable IP range VLAN into the zone
             long physicalNetworkId = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Public).getId();
-            Network network = _networkModel.getNetwork(physicalNetworkId);
+            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);
@@ -1124,31 +1128,37 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
 
         assert(isPortableIpTransferableFromNetwork(ipAddrId, currentNetworkId));
 
+        // disassociate portable IP with current network/VPC network
         if (srcNetwork.getVpcId() != null) {
             _vpcMgr.unassignIPFromVpcNetwork(ipAddrId, currentNetworkId);
         } else {
             disassociatePortableIPToGuestNetwork(ipAddrId, currentNetworkId);
         }
 
+        // If portable IP need to be transferred across the zones, then mark the entry corresponding to portable ip
+        // in user_ip_address and vlan tables so as to emulate portable IP as provisioned in destination data center
         if (srcNetwork.getDataCenterId() != dstNetwork.getDataCenterId()) {
-            // portable IP need to be transferred across the zones, so mark the entry corresponding to portable ip
-            // in user_ip_address as provisioned in destination data center
             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();
+
             VlanVO vlan = _vlanDao.findById(ip.getVlanId());
-            vlan.setPhysicalNetworkId(dstNetwork.getPhysicalNetworkId());
-            vlan.setNetworkId(newNetworkId);
+            vlan.setPhysicalNetworkId(physicalNetworkId);
+            vlan.setNetworkId(publicNetworkId);
             vlan.setDataCenterId(dstNetwork.getDataCenterId());
             _vlanDao.update(ip.getVlanId(), vlan);
             txn.commit();
         }
 
+        // associate portable IP with new network/VPC network
         associatePortableIPToGuestNetwork(ipAddrId, newNetworkId, false);
 
-
         txn.start();
 
         if (dstNetwork.getVpcId() != null) {
@@ -1160,6 +1170,9 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
         _ipAddressDao.update(ipAddrId, ip);
 
         txn.commit();
+
+        // trigger an action event for the transfer of portable IP across the networks, so that external entities
+        // monitoring for this event can initiate the route advertisement for the availability of IP from the zoe
         ActionEventUtils.onActionEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, Domain.ROOT_DOMAIN,
                 EventTypes.EVENT_PORTABLE_IP_TRANSFER, "Portable IP associated is transferred from network "
                     + currentNetworkId + " to " + newNetworkId);