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:33:46 UTC

git commit: updated refs/heads/master to 4466492

Updated Branches:
  refs/heads/master db74b2a04 -> 446649248


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/44664924
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/44664924
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/44664924

Branch: refs/heads/master
Commit: 44664924840a540db3727291bfcc08ae519c0055
Parents: db74b2a
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 08:48:50 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/44664924/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 dbd3c1d..42430bc 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);