incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aprat...@apache.org
Subject git commit: giving diff ip to VR
Date Fri, 17 Aug 2012 08:20:10 GMT
Updated Branches:
  refs/heads/master 63f47e4ae -> 98ae20497


giving diff ip to VR

Signed-off-by: Abhinandan Prateek <aprateek@apache.org>


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

Branch: refs/heads/master
Commit: 98ae204972e9ad88d0daef3b0be637ffcfd9132e
Parents: 63f47e4
Author: Jayapal <jayapalreddy.uradi@citrix.com>
Authored: Fri Aug 17 13:44:23 2012 +0530
Committer: Abhinandan Prateek <aprateek@apache.org>
Committed: Fri Aug 17 13:49:39 2012 +0530

----------------------------------------------------------------------
 .../com/cloud/network/guru/GuestNetworkGuru.java   |   19 +++++++++++++-
 1 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/98ae2049/server/src/com/cloud/network/guru/GuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
index 212de2f..9bfcfb1 100755
--- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
@@ -73,6 +73,8 @@ import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
+import com.cloud.network.Network.Provider;
+import com.cloud.network.Network.Service;
 
 @Local(value = NetworkGuru.class)
 public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
@@ -361,16 +363,29 @@ public abstract class GuestNetworkGuru extends AdapterBase implements
NetworkGur
         if (nic.getIp4Address() == null) {
             nic.setBroadcastUri(network.getBroadcastUri());
             nic.setIsolationUri(network.getBroadcastUri());
+            nic.setGateway(network.getGateway()); 
 
             String guestIp = null;
             if (network.getSpecifyIpRanges()) {
                 _networkMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIp());
             } else {
-                //if Vm is router vm, set ip4 to the network gateway
+                //if Vm is router vm and source nat is enabled in the network, set ip4 to
the network gateway
+                boolean isGateway = false;
                 if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter)
{
+                    if (network.getVpcId() != null) {
+                        if (_networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(),
Service.SourceNat, Provider.VPCVirtualRouter)) {
+                            isGateway = true;
+                        }
+                    } else {
+                        if (_networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(),
Service.SourceNat, Provider.VirtualRouter)) {
+                            isGateway = true;
+                        }
+                    }
+                }
+                
+                if (isGateway) {
                     guestIp = network.getGateway();
                 } else {
-                    nic.setGateway(network.getGateway());
                     guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp());
                     if (guestIp == null) {
                         throw new InsufficientVirtualNetworkCapcityException("Unable to acquire
Guest IP" +


Mime
View raw message