cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aprat...@apache.org
Subject git commit: updated refs/heads/master to 0a69b82
Date Mon, 03 Jun 2013 13:43:43 GMT
Updated Branches:
  refs/heads/master e0f0e9d01 -> 0a69b8289


CLOUDSTACK-2620 [Multiple_IP_Ranges] Guest vm's nameserver is not set to VRs guest IP address
in case of multiple subnets

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


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

Branch: refs/heads/master
Commit: 0a69b828993088487876ce859e6c00e96e4b545c
Parents: e0f0e9d
Author: Bharat Kumar <bharat.kumar@citrix.com>
Authored: Mon Jun 3 16:54:28 2013 +0530
Committer: Abhinandan Prateek <aprateek@apache.org>
Committed: Mon Jun 3 19:09:01 2013 +0530

----------------------------------------------------------------------
 api/src/com/cloud/agent/api/to/DnsmasqTO.java      |   13 ++++++-
 .../src/com/cloud/network/DnsMasqConfigurator.java |   30 ++++++--------
 .../router/VirtualNetworkApplianceManagerImpl.java |   12 ++++-
 3 files changed, 34 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a69b828/api/src/com/cloud/agent/api/to/DnsmasqTO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/to/DnsmasqTO.java b/api/src/com/cloud/agent/api/to/DnsmasqTO.java
index f99878c..c7be04d 100644
--- a/api/src/com/cloud/agent/api/to/DnsmasqTO.java
+++ b/api/src/com/cloud/agent/api/to/DnsmasqTO.java
@@ -20,11 +20,14 @@ public class DnsmasqTO {
     String routerIp;
     String gateway;
     String netmask;
+    String startIpOfSubnet;
 
-    public DnsmasqTO(String routerIp, String gateway, String netmask) {
+    public DnsmasqTO(String routerIp, String gateway, String netmask, String StartIpOfSubnet)
{
         this.routerIp = routerIp;
+        this.startIpOfSubnet = StartIpOfSubnet;
         this.gateway = gateway;
         this.netmask =netmask;
+
     }
 
     public void setRouterIp(String routerIp){
@@ -39,6 +42,10 @@ public class DnsmasqTO {
         this.netmask = netmask ;
     }
 
+    public void setStartIpOfSubnet( String ipOfSubNet) {
+        startIpOfSubnet = ipOfSubNet;
+    }
+
     public String getRouterIp() {
         return routerIp;
     }
@@ -50,4 +57,8 @@ public class DnsmasqTO {
     public String getNetmask() {
         return netmask;
     }
+    public String getStartIpOfSubnet() {
+        return startIpOfSubnet;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a69b828/core/src/com/cloud/network/DnsMasqConfigurator.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/network/DnsMasqConfigurator.java b/core/src/com/cloud/network/DnsMasqConfigurator.java
index ee8e5fc..dd34926 100644
--- a/core/src/com/cloud/network/DnsMasqConfigurator.java
+++ b/core/src/com/cloud/network/DnsMasqConfigurator.java
@@ -71,7 +71,7 @@ import java.util.List;
                                            "conf-dir=/etc/dnsmasq.d\n",
                                            "dhcp-option=tag:net1,3,ipaddress\n",
                                            "dhcp-option=tag:net1,1,netmask\n",
-                                           "dhcp-option=6,10.147.28.149,8.8.8.8\n",
+                                           "dhcp-option=6,router_ip,external_dns\n",
                                            "dhcp-optsfile=/etc/dhcpopts.txt\n",
 
 
@@ -85,11 +85,21 @@ import java.util.List;
          String netmask="";
          String domain= dnsMasqconfigcmd.getDomain();
          String dnsServers="";
+         String dns_external="";
+         if (dnsMasqconfigcmd.getDns1()!= null) {
+             dns_external = dnsMasqconfigcmd.getDns1()+",";
+         }
+         if (dnsMasqconfigcmd.getDns2() != null) {
+             dns_external = dns_external+dnsMasqconfigcmd.getDns2()+",";
+         }
+         dns_external = dns_external + "*";
+         dns_external = dns_external.replace(",*","");
          int i=0;
          for (; i< dnsmasqTOs.size(); i++) {
-              range=range + "dhcp-range=set:range"+i+","+dnsmasqTOs.get(i).getRouterIp()+",static\n";
+              range=range + "dhcp-range=set:range"+i+","+dnsmasqTOs.get(i).getStartIpOfSubnet()+",static\n";
               gateway=gateway +"dhcp-option=tag:range"+i+",3,"+dnsmasqTOs.get(i).getGateway()+"\n";
               netmask=netmask +"dhcp-option=tag:range"+i+",1,"+dnsmasqTOs.get(i).getNetmask()+"\n";
+              dnsServers=dnsServers+"dhcp-option=tag:range"+i+",6,"+dnsmasqTOs.get(i).getRouterIp()+","+dns_external+"\n";
          }
          dnsMasqconf.set(12, "domain="+domain+"\n");
          dnsMasqconf.set(14, "domain="+domain+"\n");
@@ -97,21 +107,7 @@ import java.util.List;
          dnsMasqconf.set(18, range);
          dnsMasqconf.set(22, gateway);
          dnsMasqconf.set(23, netmask);
-         if (dnsMasqconfigcmd.getInternal_dns1() != null) {
-             dnsServers = dnsServers+dnsMasqconfigcmd.getInternal_dns1()+",";
-         }
-         if (dnsMasqconfigcmd.getInternal_dns2() != null) {
-             dnsServers = dnsServers+dnsMasqconfigcmd.getInternal_dns2()+",";
-         }
-         if (dnsMasqconfigcmd.getDns1() != null) {
-             dnsServers = dnsServers+dnsMasqconfigcmd.getDns1()+",";
-         }
-         if (dnsMasqconfigcmd.getDns2() != null) {
-             dnsServers = dnsServers+dnsMasqconfigcmd.getDns2()+",";
-         }
-         dnsServers = dnsServers +"*";
-         dnsServers = dnsServers.replace(",*", "");
-         dnsMasqconf.set(24,"dhcp-option=6,"+dnsServers);
+         dnsMasqconf.set(24,dnsServers);
          return dnsMasqconf.toArray( new  String[dnsMasqconf.size()]);
      }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a69b828/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 c71d037..020dbda 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -3395,10 +3395,16 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
         List<NicIpAliasVO> ipAliasVOList = _nicIpAliasDao.getAliasIpForVm(router.getId());
         List<DnsmasqTO> ipList = new ArrayList<DnsmasqTO>();
 
-        NicVO router_guest_ip = _nicDao.findByNtwkIdAndInstanceId(network.getId(), router.getId());
-        ipList.add(new DnsmasqTO(router_guest_ip.getIp4Address(),router_guest_ip.getGateway(),router_guest_ip.getNetmask()));
+        NicVO router_guest_nic = _nicDao.findByNtwkIdAndInstanceId(network.getId(), router.getId());
+        String cidr = NetUtils.getCidrFromGatewayAndNetmask(router_guest_nic.getGateway(),
router_guest_nic.getNetmask());
+        String[] cidrPair = cidr.split("\\/");
+        String cidrAddress = cidrPair[0];
+        long cidrSize = Long.parseLong(cidrPair[1]);
+        String startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize);
+
+        ipList.add(new DnsmasqTO(router_guest_nic.getIp4Address(),router_guest_nic.getGateway(),router_guest_nic.getNetmask(),
startIpOfSubnet));
         for (NicIpAliasVO ipAliasVO : ipAliasVOList) {
-             DnsmasqTO dnsmasqTO = new DnsmasqTO(ipAliasVO.getStartIpOfSubnet(), ipAliasVO.getGateway(),
ipAliasVO.getNetmask());
+             DnsmasqTO dnsmasqTO = new DnsmasqTO(ipAliasVO.getIp4Address(), ipAliasVO.getGateway(),
ipAliasVO.getNetmask(), ipAliasVO.getStartIpOfSubnet());
              ipList.add(dnsmasqTO);
         }
         DataCenterVO dcvo = _dcDao.findById(router.getDataCenterId());


Mime
View raw message