CLOUDSTACK-1461: Don't set dns server for non-default ipv6 network

The non-default parameter can be used by ipv4 as well in the future.
This commit is contained in:
Sheng Yang 2013-03-08 17:42:06 -08:00
parent e40ebcce8f
commit e35ce6587a
8 changed files with 44 additions and 9 deletions

View File

@ -31,6 +31,7 @@ public class DhcpEntryCommand extends NetworkElementCommand {
String vmIp6Address;
String ip6Gateway;
String duid;
private boolean isDefault;
protected DhcpEntryCommand() {
@ -46,6 +47,7 @@ public class DhcpEntryCommand extends NetworkElementCommand {
this.vmIpAddress = vmIpAddress;
this.vmName = vmName;
this.vmIp6Address = vmIp6Address;
this.setDefault(true);
}
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String vmIp6Address, String dns, String gateway, String ip6Gateway) {
@ -129,4 +131,12 @@ public class DhcpEntryCommand extends NetworkElementCommand {
public void setVmIp6Address(String ip6Address) {
this.vmIp6Address = ip6Address;
}
public boolean isDefault() {
return isDefault;
}
public void setDefault(boolean isDefault) {
this.isDefault = isDefault;
}
}

View File

@ -600,6 +600,10 @@ public class VirtualRoutingResource implements Manager {
command.add("-6", cmd.getVmIp6Address());
command.add("-u", cmd.getDuid());
}
if (!cmd.isDefault()) {
command.add("-z");
}
final String result = command.execute();
return new Answer(cmd, result==null, result);

View File

@ -425,7 +425,6 @@ setup_dnsmasq() {
sed -r -i s/^[#]?domain=.*$/domain=$DOMAIN/ /etc/dnsmasq.conf
#answer all local domain queries
sed -i -e "s/^[#]*local=.*$/local=\/$DOMAIN\//" /etc/dnsmasq.conf
fi
if [ -n "$DNS_SEARCH_ORDER" ]
@ -447,6 +446,9 @@ setup_dnsmasq() {
if [ $DHCP_RANGE_IP6 ]
then
sed -i -e "s/^dhcp-range_ip6=.*$/dhcp-range=$DHCP_RANGE_IP6,static/" /etc/dnsmasq.conf
# For nondefault6 tagged host, don't send dns-server information
sed -i /nondefault6/d /etc/dnsmasq.conf
echo "dhcp-option=nondefault6,option6:dns-server" >> /etc/dnsmasq.conf
else
sed -i -e "s/^dhcp-range_ip6=.*$//" /etc/dnsmasq.conf
fi

View File

@ -27,7 +27,7 @@
# $6 : comma separated static routes
usage() {
printf "Usage: %s: -m <MAC address> -4 <IPv4 address> -6 <IPv6 address> -h <hostname> -d <default router> -n <name server address> -s <Routes> -u <DUID>\n" $(basename $0) >&2
printf "Usage: %s: -m <MAC address> -4 <IPv4 address> -6 <IPv6 address> -h <hostname> -d <default router> -n <name server address> -s <Routes> -u <DUID> [-N]\n" $(basename $0) >&2
}
mac=
@ -38,8 +38,9 @@ dflt=
dns=
routes=
duid=
nondefault=
while getopts 'm:4:h:d:n:s:6:u:' OPTION
while getopts 'm:4:h:d:n:s:6:u:N' OPTION
do
case $OPTION in
m) mac="$OPTARG"
@ -58,6 +59,8 @@ do
;;
s) routes="$OPTARG"
;;
N) nondefault=1
;;
?) usage
exit 2
;;
@ -120,7 +123,12 @@ then
fi
if [ $ipv6 ]
then
echo "id:$duid,[$ipv6],$host,infinite" >>$DHCP_HOSTS
if [ $nondefault ]
then
echo "id:$duid,set:nondefault6,[$ipv6],$host,infinite" >>$DHCP_HOSTS
else
echo "id:$duid,[$ipv6],$host,infinite" >>$DHCP_HOSTS
fi
fi
#delete leases to supplied mac and ip addresses
@ -176,8 +184,8 @@ then
if [ "$dflt" == "0.0.0.0" ]
then
logger -t cloud "$0: unset default router for $ipv4"
logger -t cloud "$0: unset dns server for $ipv4"
echo "$tag,3" >> $DHCP_OPTS
logger -t cloud "$0: setting dns server for $ipv4 to $dns"
echo "$tag,6" >> $DHCP_OPTS
echo "$tag,15" >> $DHCP_OPTS
fi

View File

@ -1755,7 +1755,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
args += " -6 " + cmd.getVmIp6Address();
args += " -u " + cmd.getDuid();
}
if (!cmd.isDefault()) {
args += " -N";
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/edithosts.sh " + args);
}

View File

@ -1890,6 +1890,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
args += " -u " + cmd.getDuid();
}
if (!cmd.isDefault()) {
args += " -z";
}
String result = callHostPlugin(conn, "vmops", "saveDhcpEntry", "args", args);
if (result == null || result.isEmpty()) {
return new Answer(cmd, false, "DhcpEntry failed");

View File

@ -22,7 +22,7 @@
# @VERSION@
usage() {
printf "Usage: %s: -r <domr-ip> -m <vm mac> -v <vm ip> -n <vm name> -s <static route> -d <default router> -N <dns> -6 <vm IPv6> -u <duid>\n" $(basename $0) >&2
printf "Usage: %s: -r <domr-ip> -m <vm mac> -v <vm ip> -n <vm name> -s <static route> -d <default router> -N <dns> -6 <vm IPv6> -u <duid> [-z]\n" $(basename $0) >&2
exit 2
}
@ -40,7 +40,7 @@ duid=
opts=
while getopts 'r:m:v:n:d:s:N:6:u:' OPTION
while getopts 'r:m:v:n:d:s:N:6:u:z' OPTION
do
case $OPTION in
r) domrIp="$OPTARG"
@ -69,6 +69,8 @@ do
u) duid="$OPTARG"
opts="$opts -u $duid"
;;
z) opts="$opts -N"
;;
?) usage
exit 1
;;

View File

@ -3116,9 +3116,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
if (guestOS.getDisplayName().startsWith(name)) {
needGateway = true;
break;
}
}
}
}
if (!needGateway) {
gatewayIp = "0.0.0.0";
}
@ -3126,6 +3126,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
dhcpCommand.setIp6Gateway(nic.getIp6Gateway());
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
dhcpCommand.setDuid(NetUtils.getDuidLL(nic.getMacAddress()));
dhcpCommand.setDefault(nic.isDefaultNic());
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());