mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
e40ebcce8f
commit
e35ce6587a
@ -31,6 +31,7 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
|||||||
String vmIp6Address;
|
String vmIp6Address;
|
||||||
String ip6Gateway;
|
String ip6Gateway;
|
||||||
String duid;
|
String duid;
|
||||||
|
private boolean isDefault;
|
||||||
|
|
||||||
protected DhcpEntryCommand() {
|
protected DhcpEntryCommand() {
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ public class DhcpEntryCommand extends NetworkElementCommand {
|
|||||||
this.vmIpAddress = vmIpAddress;
|
this.vmIpAddress = vmIpAddress;
|
||||||
this.vmName = vmName;
|
this.vmName = vmName;
|
||||||
this.vmIp6Address = vmIp6Address;
|
this.vmIp6Address = vmIp6Address;
|
||||||
|
this.setDefault(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DhcpEntryCommand(String vmMac, String vmIpAddress, String vmName, String vmIp6Address, String dns, String gateway, String ip6Gateway) {
|
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) {
|
public void setVmIp6Address(String ip6Address) {
|
||||||
this.vmIp6Address = ip6Address;
|
this.vmIp6Address = ip6Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDefault() {
|
||||||
|
return isDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefault(boolean isDefault) {
|
||||||
|
this.isDefault = isDefault;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -601,6 +601,10 @@ public class VirtualRoutingResource implements Manager {
|
|||||||
command.add("-u", cmd.getDuid());
|
command.add("-u", cmd.getDuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cmd.isDefault()) {
|
||||||
|
command.add("-z");
|
||||||
|
}
|
||||||
|
|
||||||
final String result = command.execute();
|
final String result = command.execute();
|
||||||
return new Answer(cmd, result==null, result);
|
return new Answer(cmd, result==null, result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -425,7 +425,6 @@ setup_dnsmasq() {
|
|||||||
sed -r -i s/^[#]?domain=.*$/domain=$DOMAIN/ /etc/dnsmasq.conf
|
sed -r -i s/^[#]?domain=.*$/domain=$DOMAIN/ /etc/dnsmasq.conf
|
||||||
#answer all local domain queries
|
#answer all local domain queries
|
||||||
sed -i -e "s/^[#]*local=.*$/local=\/$DOMAIN\//" /etc/dnsmasq.conf
|
sed -i -e "s/^[#]*local=.*$/local=\/$DOMAIN\//" /etc/dnsmasq.conf
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$DNS_SEARCH_ORDER" ]
|
if [ -n "$DNS_SEARCH_ORDER" ]
|
||||||
@ -447,6 +446,9 @@ setup_dnsmasq() {
|
|||||||
if [ $DHCP_RANGE_IP6 ]
|
if [ $DHCP_RANGE_IP6 ]
|
||||||
then
|
then
|
||||||
sed -i -e "s/^dhcp-range_ip6=.*$/dhcp-range=$DHCP_RANGE_IP6,static/" /etc/dnsmasq.conf
|
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
|
else
|
||||||
sed -i -e "s/^dhcp-range_ip6=.*$//" /etc/dnsmasq.conf
|
sed -i -e "s/^dhcp-range_ip6=.*$//" /etc/dnsmasq.conf
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
# $6 : comma separated static routes
|
# $6 : comma separated static routes
|
||||||
|
|
||||||
usage() {
|
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=
|
mac=
|
||||||
@ -38,8 +38,9 @@ dflt=
|
|||||||
dns=
|
dns=
|
||||||
routes=
|
routes=
|
||||||
duid=
|
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
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
m) mac="$OPTARG"
|
m) mac="$OPTARG"
|
||||||
@ -58,6 +59,8 @@ do
|
|||||||
;;
|
;;
|
||||||
s) routes="$OPTARG"
|
s) routes="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
N) nondefault=1
|
||||||
|
;;
|
||||||
?) usage
|
?) usage
|
||||||
exit 2
|
exit 2
|
||||||
;;
|
;;
|
||||||
@ -120,8 +123,13 @@ then
|
|||||||
fi
|
fi
|
||||||
if [ $ipv6 ]
|
if [ $ipv6 ]
|
||||||
then
|
then
|
||||||
|
if [ $nondefault ]
|
||||||
|
then
|
||||||
|
echo "id:$duid,set:nondefault6,[$ipv6],$host,infinite" >>$DHCP_HOSTS
|
||||||
|
else
|
||||||
echo "id:$duid,[$ipv6],$host,infinite" >>$DHCP_HOSTS
|
echo "id:$duid,[$ipv6],$host,infinite" >>$DHCP_HOSTS
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#delete leases to supplied mac and ip addresses
|
#delete leases to supplied mac and ip addresses
|
||||||
if [ $ipv4 ]
|
if [ $ipv4 ]
|
||||||
@ -176,8 +184,8 @@ then
|
|||||||
if [ "$dflt" == "0.0.0.0" ]
|
if [ "$dflt" == "0.0.0.0" ]
|
||||||
then
|
then
|
||||||
logger -t cloud "$0: unset default router for $ipv4"
|
logger -t cloud "$0: unset default router for $ipv4"
|
||||||
|
logger -t cloud "$0: unset dns server for $ipv4"
|
||||||
echo "$tag,3" >> $DHCP_OPTS
|
echo "$tag,3" >> $DHCP_OPTS
|
||||||
logger -t cloud "$0: setting dns server for $ipv4 to $dns"
|
|
||||||
echo "$tag,6" >> $DHCP_OPTS
|
echo "$tag,6" >> $DHCP_OPTS
|
||||||
echo "$tag,15" >> $DHCP_OPTS
|
echo "$tag,15" >> $DHCP_OPTS
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -1756,6 +1756,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
args += " -u " + cmd.getDuid();
|
args += " -u " + cmd.getDuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cmd.isDefault()) {
|
||||||
|
args += " -N";
|
||||||
|
}
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/edithosts.sh " + args);
|
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/edithosts.sh " + args);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1890,6 +1890,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
args += " -u " + cmd.getDuid();
|
args += " -u " + cmd.getDuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cmd.isDefault()) {
|
||||||
|
args += " -z";
|
||||||
|
}
|
||||||
|
|
||||||
String result = callHostPlugin(conn, "vmops", "saveDhcpEntry", "args", args);
|
String result = callHostPlugin(conn, "vmops", "saveDhcpEntry", "args", args);
|
||||||
if (result == null || result.isEmpty()) {
|
if (result == null || result.isEmpty()) {
|
||||||
return new Answer(cmd, false, "DhcpEntry failed");
|
return new Answer(cmd, false, "DhcpEntry failed");
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
# @VERSION@
|
# @VERSION@
|
||||||
|
|
||||||
usage() {
|
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
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ duid=
|
|||||||
|
|
||||||
opts=
|
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
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
r) domrIp="$OPTARG"
|
r) domrIp="$OPTARG"
|
||||||
@ -69,6 +69,8 @@ do
|
|||||||
u) duid="$OPTARG"
|
u) duid="$OPTARG"
|
||||||
opts="$opts -u $duid"
|
opts="$opts -u $duid"
|
||||||
;;
|
;;
|
||||||
|
z) opts="$opts -N"
|
||||||
|
;;
|
||||||
?) usage
|
?) usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -3126,6 +3126,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
|||||||
dhcpCommand.setIp6Gateway(nic.getIp6Gateway());
|
dhcpCommand.setIp6Gateway(nic.getIp6Gateway());
|
||||||
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
|
dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId()));
|
||||||
dhcpCommand.setDuid(NetUtils.getDuidLL(nic.getMacAddress()));
|
dhcpCommand.setDuid(NetUtils.getDuidLL(nic.getMacAddress()));
|
||||||
|
dhcpCommand.setDefault(nic.isDefaultNic());
|
||||||
|
|
||||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
|
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
|
||||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user