incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [6/9] git commit: Add new global configuration option to enable user specify guest OS DHCP policy
Date Fri, 21 Dec 2012 20:53:31 GMT
Add new global configuration option to enable user specify guest OS DHCP policy

This is improvement of:

commit 1ca493e4facf190a288012bf9b888f90e2bc2855
Author: Sheng Yang <sheng.yang@cloud.com>
Date:   Wed Feb 29 17:43:50 2012 -0800

    bug 14042: Don't set dhcp:router option on DHCP server for non-default
network on CentOS/RHEL

The old solution only works on CentOS/RHEL, this one would enable the ability to more
guest OS, and enable user to choose what policy should be for each guest os
type.


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

Branch: refs/heads/ui-plugins
Commit: d72f8a695dc7e43b5ecc280f811196a8ac2464bb
Parents: 53e6825
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Wed Sep 26 20:28:01 2012 -0700
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Thu Dec 20 19:21:02 2012 -0800

----------------------------------------------------------------------
 server/src/com/cloud/configuration/Config.java     |    3 ++
 .../router/VirtualNetworkApplianceManagerImpl.java |   25 ++++++++++++--
 setup/db/db/schema-40to41.sql                      |    2 +
 3 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d72f8a69/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 2eb269f..ea32025 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -105,6 +105,8 @@ public enum Config {
 	
 	SecurityGroupDefaultAdding("Network", ManagementServer.class, Boolean.class, "network.securitygroups.defaultadding",
"true", "If true, the user VM would be added to the default security group by default", null),
 	
+	GuestOSNeedGatewayOnNonDefaultNetwork("Network", NetworkManager.class, String.class, "network.dhcp.nondefaultnetwork.setgateway.guestos",
"Windows", "The guest OS's name start with this fields would result in DHCP server response
gateway information even when the network it's on is not default network. Names are separated
by comma.", null),
+	
 	//VPN
 	RemoteAccessVpnPskLength("Network", AgentManager.class, Integer.class, "remote.access.vpn.psk.length",
"24", "The length of the ipsec preshared key (minimum 8, maximum 256)", null),
 	RemoteAccessVpnClientIpRange("Network", AgentManager.class, String.class, "remote.access.vpn.client.iprange",
"10.1.2.1-10.1.2.8", "The range of ips to be allocated to remote access vpn clients. The first
ip in the range is used by the VPN server", null),
@@ -293,6 +295,7 @@ public enum Config {
 	VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600",
"Time (in seconds) to wait before cleanuping up any vm work items", "Seconds"),
 	VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval",
"3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"),
 	
+	
 	DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500",
"Default page size for API list* commands", null),
 	
 	TaskCleanupRetryInterval("Advanced", ManagementServer.class, Integer.class, "task.cleanup.retry.interval",
"600", "Time (in seconds) to wait before retrying cleanup of tasks if the cleanup failed previously.
 0 means to never retry.", "Seconds"),

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d72f8a69/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 0af034f..208bd9b 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -341,6 +341,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
     int _routerCheckInterval = 30;
     protected ServiceOfferingVO _offering;
     private String _dnsBasicZoneUpdates = "all";
+    private Set<String> _guestOSNeedGatewayOnNonDefaultNetwork = new HashSet<String>();
 
     private boolean _disable_rp_filter = false;
     int _routerExtraPublicNics = 2;
@@ -592,6 +593,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
 
         _routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()),
2);
 
+        String guestOSString = configs.get("network.dhcp.nondefaultnetwork.setgateway.guestos");
+        if (guestOSString != null) {
+            String[] guestOSList = guestOSString.split(",");
+            for (String os : guestOSList) {
+                _guestOSNeedGatewayOnNonDefaultNetwork.add(os);
+            }
+        }
+        
         String value = configs.get("start.retry");
         _retry = NumbersUtil.parseInt(value, 2);
 
@@ -2931,14 +2940,22 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(),
vm.getHostName());
         DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
         String gatewayIp = findGatewayIp(vm.getId());
+        boolean needGateway = true;
         if (!gatewayIp.equals(nic.getGateway())) {
+            needGateway = false;
             GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId());
-            // Don't set dhcp:router option for non-default nic on CentOS/RHEL, because they
would set routing on wrong interface
-            // This is tricky, we may need to update this when we have more information on
various OS's behavior
-            if (guestOS.getDisplayName().startsWith("CentOS") || guestOS.getDisplayName().startsWith("Red
Hat Enterprise")) {
-                gatewayIp = "0.0.0.0";
+            // Do set dhcp:router option for non-default nic on certain OS(including Windows),
and leave other OS unset.
+            // Because some OS(e.g. CentOS) would set routing on wrong interface
+            for (String name : _guestOSNeedGatewayOnNonDefaultNetwork) {
+                if (guestOS.getDisplayName().startsWith(name)) {
+                    needGateway = true;
+                    break;
+                }
             }
         }
+        if (!needGateway) {
+            gatewayIp = "0.0.0.0";
+        }
         dhcpCommand.setDefaultRouter(gatewayIp);
         dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d72f8a69/setup/db/db/schema-40to41.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-40to41.sql b/setup/db/db/schema-40to41.sql
index 51afde4..61cb4a2 100644
--- a/setup/db/db/schema-40to41.sql
+++ b/setup/db/db/schema-40to41.sql
@@ -21,3 +21,5 @@
 
 
 ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned
NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default
when EIP service is enabled.' AFTER `elastic_ip_service`;
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network','DEFAULT','NetworkManager','network.dhcp.nondefaultnetwork.setgateway.guestos','Windows','The
guest OS\'s name start with this fields would result in DHCP server response gateway information
even when the network it\'s on is not default network. Names are separated by comma.');


Mime
View raw message