mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.
This commit is contained in:
parent
53e6825b74
commit
d72f8a695d
@ -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),
|
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
|
//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),
|
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),
|
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"),
|
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"),
|
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),
|
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"),
|
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"),
|
||||||
|
|||||||
@ -341,6 +341,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
int _routerCheckInterval = 30;
|
int _routerCheckInterval = 30;
|
||||||
protected ServiceOfferingVO _offering;
|
protected ServiceOfferingVO _offering;
|
||||||
private String _dnsBasicZoneUpdates = "all";
|
private String _dnsBasicZoneUpdates = "all";
|
||||||
|
private Set<String> _guestOSNeedGatewayOnNonDefaultNetwork = new HashSet<String>();
|
||||||
|
|
||||||
private boolean _disable_rp_filter = false;
|
private boolean _disable_rp_filter = false;
|
||||||
int _routerExtraPublicNics = 2;
|
int _routerExtraPublicNics = 2;
|
||||||
@ -592,6 +593,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
|
|
||||||
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
|
_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");
|
String value = configs.get("start.retry");
|
||||||
_retry = NumbersUtil.parseInt(value, 2);
|
_retry = NumbersUtil.parseInt(value, 2);
|
||||||
|
|
||||||
@ -2931,14 +2940,22 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||||||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName());
|
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName());
|
||||||
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn());
|
||||||
String gatewayIp = findGatewayIp(vm.getId());
|
String gatewayIp = findGatewayIp(vm.getId());
|
||||||
|
boolean needGateway = true;
|
||||||
if (!gatewayIp.equals(nic.getGateway())) {
|
if (!gatewayIp.equals(nic.getGateway())) {
|
||||||
|
needGateway = false;
|
||||||
GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId());
|
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
|
// Do set dhcp:router option for non-default nic on certain OS(including Windows), and leave other OS unset.
|
||||||
// This is tricky, we may need to update this when we have more information on various OS's behavior
|
// Because some OS(e.g. CentOS) would set routing on wrong interface
|
||||||
if (guestOS.getDisplayName().startsWith("CentOS") || guestOS.getDisplayName().startsWith("Red Hat Enterprise")) {
|
for (String name : _guestOSNeedGatewayOnNonDefaultNetwork) {
|
||||||
gatewayIp = "0.0.0.0";
|
if (guestOS.getDisplayName().startsWith(name)) {
|
||||||
|
needGateway = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!needGateway) {
|
||||||
|
gatewayIp = "0.0.0.0";
|
||||||
|
}
|
||||||
dhcpCommand.setDefaultRouter(gatewayIp);
|
dhcpCommand.setDefaultRouter(gatewayIp);
|
||||||
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
|
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
|
||||||
|
|
||||||
|
|||||||
@ -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`;
|
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.');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user