You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/07/17 00:44:06 UTC

[5/22] git commit: VPC: CS-15598 - update ipVO object after getting system ip as a part of elastic LB

VPC: CS-15598 - update ipVO object after getting system ip as a part of elastic LB

Conflicts:

	server/src/com/cloud/network/NetworkManagerImpl.java
	server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java


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

Branch: refs/heads/vpc
Commit: a3d4ee3d878cfa267cf443e30fe0237b462b30ae
Parents: 4a7149e
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Mon Jul 16 11:00:06 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Mon Jul 16 15:42:36 2012 -0700

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkManagerImpl.java  |    3 +-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |   54 +++++++--------
 2 files changed, 28 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a3d4ee3d/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 81d9041..4514b3f 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -7230,7 +7230,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
             }
             
             if (network.getVpcId() != null) {
-                throw new InvalidParameterValueException("Specify vpcId to associate ip address to VPC");
+                throw new InvalidParameterValueException("Can't assign ip to the network directly when network belongs" +
+                		" to VPC.Specify vpcId to associate ip address to VPC");
             }
             return associateIPToGuestNetwork(ipId, networkId);
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a3d4ee3d/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index d4ba141..14ea41c 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -718,15 +718,9 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         IPAddressVO ipVO = null;
         if (ipAddrId != null) {
             ipVO = _ipAddressDao.findById(ipAddrId);
-
-            // Validate ip address
-            if (ipVO == null) {
-                throw new InvalidParameterValueException("Unable to create load balance rule; ip id=" + ipAddrId + "" +
-                		" doesn't exist in the system");
-            } else if (ipVO.isOneToOneNat()) {
-                throw new NetworkRuleConflictException("Can't do load balance on ip address: " + ipVO.getAddress());
-            }
         }
+        
+        Network network = _networkMgr.getNetwork(lb.getNetworkId());
 
         // FIXME: breaking the dependency on ELB manager. This breaks functionality of ELB using virtual router
         // Bug CS-15411 opened to document this
@@ -734,32 +728,36 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         LoadBalancer result = null;
         if (result == null) {
             IpAddress systemIp = null;
-            Network guestNetwork = _networkMgr.getNetwork(lb.getNetworkId());
-            NetworkOffering off = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
-            if (off.getElasticLb() && ipVO == null) {
+            NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
+            if (off.getElasticLb() && ipVO == null && network.getVpcId() == null) {
                 systemIp = _networkMgr.assignSystemIp(lb.getNetworkId(), lbOwner, true, false);
                 lb.setSourceIpAddressId(systemIp.getId());
+                ipVO = _ipAddressDao.findById(systemIp.getId());
+            }
+            
+            // Validate ip address
+            if (ipVO == null) {
+                throw new InvalidParameterValueException("Unable to create load balance rule; can't find/allocate source IP");
+            } else if (ipVO.isOneToOneNat()) {
+                throw new NetworkRuleConflictException("Can't do load balance on ip address: " + ipVO.getAddress());
             }
              
             boolean performedIpAssoc = false;
             try {
-                Network network = _networkMgr.getNetwork(lb.getNetworkId());
-                if (ipVO != null) {
-                    if (ipVO.getAssociatedWithNetworkId() == null) {
-                        boolean assignToVpcNtwk = network.getVpcId() != null 
-                                && ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
-                        if (assignToVpcNtwk) {
-                            //set networkId just for verification purposes
-                            ipVO.setAssociatedWithNetworkId(lb.getNetworkId());
-                            _networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
-
-                            s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
-                            ipVO = _networkMgr.associateIPToGuestNetwork(ipAddrId, lb.getNetworkId());
-                            performedIpAssoc = true;
-                        }
-                    } else {
-                        _networkMgr.checkIpForService(ipVO, Service.Lb, null);
-                    } 
+                if (ipVO.getAssociatedWithNetworkId() == null) {
+                    boolean assignToVpcNtwk = network.getVpcId() != null 
+                            && ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
+                    if (assignToVpcNtwk) {
+                        //set networkId just for verification purposes
+                        ipVO.setAssociatedWithNetworkId(lb.getNetworkId());
+                        _networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
+
+                        s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
+                        ipVO = _networkMgr.associateIPToGuestNetwork(ipAddrId, lb.getNetworkId());
+                        performedIpAssoc = true;
+                    }
+                } else {
+                    _networkMgr.checkIpForService(ipVO, Service.Lb, null);
                 }
                 
                 if (ipVO.getAssociatedWithNetworkId() == null) {