Updated Branches:
  refs/heads/vm-snapshot 3a60d5e16 -> a3808478f

bug CS-15398: fix for basic zone dns issue in multiple pods


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

Branch: refs/heads/vm-snapshot
Commit: a3808478f95d78456ac3c3fa7f1a8ee80a38967d
Parents: 3a60d5e
Author: Jayapal <[email protected]>
Authored: Wed Aug 29 14:29:25 2012 +0530
Committer: Mice Xia <[email protected]>
Committed: Fri Aug 31 11:06:33 2012 +0800

----------------------------------------------------------------------
 .../router/VirtualNetworkApplianceManagerImpl.java |   52 ++++++++------
 1 files changed, 30 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a3808478/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 0d812a2..3400493 100755
--- 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -2411,28 +2411,36 @@ public class VirtualNetworkApplianceManagerImpl 
implements VirtualNetworkApplian
         });
     }
 
-       private String findDefaultDnsIp(long userVmId) {
-               NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
-               
-               //check if DNS provider is the domR
-               if 
(!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), 
Service.Dns, Provider.VirtualRouter)) {
-                       return null;
-               }
-               
-               NetworkOfferingVO offering = 
_networkOfferingDao.findById(_networkDao.findById(defaultNic.getNetworkId()).getNetworkOfferingId());
-               if (offering.getRedundantRouter()) {
-                   return findGatewayIp(userVmId);
-               }
-               
-               //find domR's nic in the network
-               NicVO domrDefaultNic = 
_nicDao.findByNetworkIdTypeAndGateway(defaultNic.getNetworkId(), 
VirtualMachine.Type.DomainRouter, defaultNic.getGateway());
-               return domrDefaultNic.getIp4Address();
-       }
-       
-       private String findGatewayIp(long userVmId) {
-               NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
-               return defaultNic.getGateway();
-       }
+    private String findDefaultDnsIp(long userVmId) {
+        NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
+        
+        //check if DNS provider is the domR
+        if 
(!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), 
Service.Dns, Provider.VirtualRouter)) {
+            return null;
+        }
+        
+        NetworkOfferingVO offering = 
_networkOfferingDao.findById(_networkDao.findById(defaultNic.getNetworkId()).getNetworkOfferingId());
+        if (offering.getRedundantRouter()) {
+            return findGatewayIp(userVmId);
+        }
+        
+        DataCenter dc = 
_dcDao.findById(_networkMgr.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
+        boolean isZoneBasic = (dc.getNetworkType() == NetworkType.Basic);
+        
+        //find domR's nic in the network
+        NicVO domrDefaultNic;
+        if (isZoneBasic){
+            domrDefaultNic = 
_nicDao.findByNetworkIdTypeAndGateway(defaultNic.getNetworkId(), 
VirtualMachine.Type.DomainRouter, defaultNic.getGateway());
+        } else{
+            domrDefaultNic = 
_nicDao.findByNetworkIdAndType(defaultNic.getNetworkId(), 
VirtualMachine.Type.DomainRouter);
+        }
+        return domrDefaultNic.getIp4Address();
+    }
+
+    private String findGatewayIp(long userVmId) {
+        NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
+        return defaultNic.getGateway();
+     }
 
     @Override
     public boolean applyUserData(Network network, final NicProfile nic, 
VirtualMachineProfile<UserVm> profile, DeployDestination dest, 
List<DomainRouterVO> routers)

Reply via email to