You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ap...@apache.org on 2012/08/17 10:20:10 UTC
git commit: giving diff ip to VR
Updated Branches:
refs/heads/master 63f47e4ae -> 98ae20497
giving diff ip to VR
Signed-off-by: Abhinandan Prateek <ap...@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 <ja...@citrix.com>
Authored: Fri Aug 17 13:44:23 2012 +0530
Committer: Abhinandan Prateek <ap...@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" +