mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
IPv6: Enable VR's ability to provide DHCPv6 service
This commit is contained in:
parent
f89c66070b
commit
8f66d266b3
@ -569,7 +569,9 @@ public class VirtualRoutingResource implements Manager {
|
|||||||
protected synchronized Answer execute (final DhcpEntryCommand cmd) {
|
protected synchronized Answer execute (final DhcpEntryCommand cmd) {
|
||||||
final Script command = new Script(_dhcpEntryPath, _timeout, s_logger);
|
final Script command = new Script(_dhcpEntryPath, _timeout, s_logger);
|
||||||
command.add("-r", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
command.add("-r", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
|
||||||
command.add("-v", cmd.getVmIpAddress());
|
if (cmd.getVmIpAddress() != null) {
|
||||||
|
command.add("-v", cmd.getVmIpAddress());
|
||||||
|
}
|
||||||
command.add("-m", cmd.getVmMac());
|
command.add("-m", cmd.getVmMac());
|
||||||
command.add("-n", cmd.getVmName());
|
command.add("-n", cmd.getVmName());
|
||||||
|
|
||||||
@ -583,6 +585,11 @@ public class VirtualRoutingResource implements Manager {
|
|||||||
if (cmd.getDefaultDns() != null) {
|
if (cmd.getDefaultDns() != null) {
|
||||||
command.add("-N", cmd.getDefaultDns());
|
command.add("-N", cmd.getDefaultDns());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd.getVmIp6Address() != null) {
|
||||||
|
command.add("-6", cmd.getVmIp6Address());
|
||||||
|
command.add("-u", cmd.getDuid());
|
||||||
|
}
|
||||||
|
|
||||||
final String result = command.execute();
|
final String result = command.execute();
|
||||||
return new Answer(cmd, result==null, result);
|
return new Answer(cmd, result==null, result);
|
||||||
|
|||||||
@ -141,7 +141,8 @@ domain=2.vmops-test.vmops.com
|
|||||||
# a lease time. If you have more than one network, you will need to
|
# a lease time. If you have more than one network, you will need to
|
||||||
# repeat this for each network on which you want to supply DHCP
|
# repeat this for each network on which you want to supply DHCP
|
||||||
# service.
|
# service.
|
||||||
dhcp-range=10.1.1.1,static
|
dhcp-range_ip4=10.1.1.1,static
|
||||||
|
dhcp-range_ip6=::1,static
|
||||||
dhcp-hostsfile=/etc/dhcphosts.txt
|
dhcp-hostsfile=/etc/dhcphosts.txt
|
||||||
|
|
||||||
# This is an example of a DHCP range where the netmask is given. This
|
# This is an example of a DHCP range where the netmask is given. This
|
||||||
|
|||||||
@ -398,7 +398,8 @@ setup_common() {
|
|||||||
|
|
||||||
setup_dnsmasq() {
|
setup_dnsmasq() {
|
||||||
log_it "Setting up dnsmasq"
|
log_it "Setting up dnsmasq"
|
||||||
[ -z $DHCP_RANGE ] && DHCP_RANGE=$ETH0_IP
|
[ -z $DHCP_RANGE ] && [ $ETH0_IP ] && DHCP_RANGE=$ETH0_IP
|
||||||
|
[ $ETH0_IP6 ] && DHCP_RANGE_IP6=$ETH0_IP6
|
||||||
[ -z $DOMAIN ] && DOMAIN="cloudnine.internal"
|
[ -z $DOMAIN ] && DOMAIN="cloudnine.internal"
|
||||||
|
|
||||||
if [ -n "$DOMAIN" ]
|
if [ -n "$DOMAIN" ]
|
||||||
@ -422,8 +423,20 @@ setup_dnsmasq() {
|
|||||||
sed -i s/[#]*dhcp-option=15.*$/dhcp-option=15,\""$DNS_SEARCH_ORDER"\"/ /etc/dnsmasq.conf
|
sed -i s/[#]*dhcp-option=15.*$/dhcp-option=15,\""$DNS_SEARCH_ORDER"\"/ /etc/dnsmasq.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i -e "s/^dhcp-range=.*$/dhcp-range=$DHCP_RANGE,static/" /etc/dnsmasq.conf
|
if [ $DHCP_RANGE ]
|
||||||
sed -i -e "s/^[#]*listen-address=.*$/listen-address=$ETH0_IP/" /etc/dnsmasq.conf
|
then
|
||||||
|
sed -i -e "s/^dhcp-range_ip4=.*$/dhcp-range=$DHCP_RANGE,static/" /etc/dnsmasq.conf
|
||||||
|
else
|
||||||
|
sed -i -e "s/^dhcp-range_ip4=.*$//" /etc/dnsmasq.conf
|
||||||
|
fi
|
||||||
|
if [ $DHCP_RANGE_IP6 ]
|
||||||
|
then
|
||||||
|
sed -i -e "s/^dhcp-range_ip6=.*$/dhcp-range=$DHCP_RANGE_IP6,static/" /etc/dnsmasq.conf
|
||||||
|
else
|
||||||
|
sed -i -e "s/^dhcp-range_ip6=.*$//" /etc/dnsmasq.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i -e "s/^[#]*listen-address=.*$/listen-address=$LOCAL_ADDRS/" /etc/dnsmasq.conf
|
||||||
|
|
||||||
if [ "$RROUTER" == "1" ]
|
if [ "$RROUTER" == "1" ]
|
||||||
then
|
then
|
||||||
@ -707,14 +720,15 @@ setup_dhcpsrvr() {
|
|||||||
if [ "$DEFAULTROUTE" != "false" ]
|
if [ "$DEFAULTROUTE" != "false" ]
|
||||||
then
|
then
|
||||||
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
|
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
|
||||||
echo "dhcp-option=option:router,$GW" >> /etc/dnsmasq.conf
|
[ $GW ] && echo "dhcp-option=option:router,$GW" >> /etc/dnsmasq.conf
|
||||||
#for now set up ourself as the dns server as well
|
#for now set up ourself as the dns server as well
|
||||||
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
|
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
|
||||||
if [ "$USE_EXTERNAL_DNS" == "true" ]
|
if [ "$USE_EXTERNAL_DNS" == "true" ]
|
||||||
then
|
then
|
||||||
echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
|
echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
|
||||||
else
|
else
|
||||||
echo "dhcp-option=6,$ETH0_IP,$NS" >> /etc/dnsmasq.conf
|
[ $ETH0_IP ] && echo "dhcp-option=6,$ETH0_IP,$NS" >> /etc/dnsmasq.conf
|
||||||
|
[ $ETH0_IP6 ] && echo "dhcp-option=option6:dns-server,[::]" >> /etc/dnsmasq.conf
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
|
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
|
||||||
@ -1034,8 +1048,11 @@ for i in $CMDLINE
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
|
||||||
|
|
||||||
|
[ $ETH0_IP ] && LOCAL_ADDRS=$ETH0_IP
|
||||||
|
[ $ETH0_IP6 ] && LOCAL_ADDRS=$ETH0_IP6
|
||||||
|
[ $ETH0_IP ] && [ $ETH0_IP6 ] && LOCAL_ADDRS="$ETH0_IP,$ETH0_IP6"
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
|
|||||||
@ -27,23 +27,29 @@
|
|||||||
# $6 : comma separated static routes
|
# $6 : comma separated static routes
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf "Usage: %s: -m <MAC address> -4 <IPv4 address> -h <hostname> -d <default router> -n <name server address> -s <Routes> \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" $(basename $0) >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
mac=
|
mac=
|
||||||
ipv4=
|
ipv4=
|
||||||
|
ipv6=
|
||||||
host=
|
host=
|
||||||
dflt=
|
dflt=
|
||||||
dns=
|
dns=
|
||||||
routes=
|
routes=
|
||||||
|
duid=
|
||||||
|
|
||||||
while getopts 'm:4:h:d:n:s:' OPTION
|
while getopts 'm:4:h:d:n:s:6:u:' OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
m) mac="$OPTARG"
|
m) mac="$OPTARG"
|
||||||
;;
|
;;
|
||||||
4) ipv4="$OPTARG"
|
4) ipv4="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
6) ipv6="$OPTARG"
|
||||||
|
;;
|
||||||
|
u) duid="$OPTARG"
|
||||||
|
;;
|
||||||
h) host="$OPTARG"
|
h) host="$OPTARG"
|
||||||
;;
|
;;
|
||||||
d) dflt="$OPTARG"
|
d) dflt="$OPTARG"
|
||||||
@ -95,26 +101,69 @@ logger -t cloud "edithosts: update $1 $2 $3 to hosts"
|
|||||||
[ ! -f $DHCP_LEASES ] && touch $DHCP_LEASES
|
[ ! -f $DHCP_LEASES ] && touch $DHCP_LEASES
|
||||||
|
|
||||||
#delete any previous entries from the dhcp hosts file
|
#delete any previous entries from the dhcp hosts file
|
||||||
sed -i /$mac/d $DHCP_HOSTS
|
sed -i /$mac/d $DHCP_HOSTS
|
||||||
sed -i /$ipv4,/d $DHCP_HOSTS
|
if [ $ipv4 ]
|
||||||
sed -i /$host,/d $DHCP_HOSTS
|
then
|
||||||
|
sed -i /$ipv4,/d $DHCP_HOSTS
|
||||||
|
fi
|
||||||
|
if [ $ipv6 ]
|
||||||
|
then
|
||||||
|
sed -i /$ipv6,/d $DHCP_HOSTS
|
||||||
|
fi
|
||||||
|
sed -i /$host,/d $DHCP_HOSTS
|
||||||
|
|
||||||
|
|
||||||
#put in the new entry
|
#put in the new entry
|
||||||
echo "$mac,$ipv4,$host,infinite" >>$DHCP_HOSTS
|
if [ $ipv4 ]
|
||||||
|
then
|
||||||
|
echo "$mac,$ipv4,$host,infinite" >>$DHCP_HOSTS
|
||||||
|
fi
|
||||||
|
if [ $ipv6 ]
|
||||||
|
then
|
||||||
|
echo "id:$duid,[$ipv6],$host,infinite" >>$DHCP_HOSTS
|
||||||
|
fi
|
||||||
|
|
||||||
#delete leases to supplied mac and ip addresses
|
#delete leases to supplied mac and ip addresses
|
||||||
sed -i /$mac/d $DHCP_LEASES
|
if [ $ipv4 ]
|
||||||
sed -i /"$ipv4 "/d $DHCP_LEASES
|
then
|
||||||
|
sed -i /$mac/d $DHCP_LEASES
|
||||||
|
sed -i /"$ipv4 "/d $DHCP_LEASES
|
||||||
|
fi
|
||||||
|
if [ $ipv6 ]
|
||||||
|
then
|
||||||
|
sed -i /$duid/d $DHCP_LEASES
|
||||||
|
sed -i /"$ipv6 "/d $DHCP_LEASES
|
||||||
|
fi
|
||||||
sed -i /"$host "/d $DHCP_LEASES
|
sed -i /"$host "/d $DHCP_LEASES
|
||||||
|
|
||||||
#put in the new entry
|
#put in the new entry
|
||||||
echo "0 $mac $ipv4 $host *" >> $DHCP_LEASES
|
if [ $ipv4 ]
|
||||||
|
then
|
||||||
|
echo "0 $mac $ipv4 $host *" >> $DHCP_LEASES
|
||||||
|
fi
|
||||||
|
if [ $ipv6 ]
|
||||||
|
then
|
||||||
|
echo "0 $duid $ipv6 $host *" >> $DHCP_LEASES
|
||||||
|
fi
|
||||||
|
|
||||||
#edit hosts file as well
|
#edit hosts file as well
|
||||||
sed -i /"$ipv4 "/d $HOSTS
|
if [ $ipv4 ]
|
||||||
|
then
|
||||||
|
sed -i /"$ipv4 "/d $HOSTS
|
||||||
|
fi
|
||||||
|
if [ $ipv6 ]
|
||||||
|
then
|
||||||
|
sed -i /"$ipv6 "/d $HOSTS
|
||||||
|
fi
|
||||||
sed -i /" $host$"/d $HOSTS
|
sed -i /" $host$"/d $HOSTS
|
||||||
echo "$ipv4 $host" >> $HOSTS
|
if [ $ipv4 ]
|
||||||
|
then
|
||||||
|
echo "$ipv4 $host" >> $HOSTS
|
||||||
|
fi
|
||||||
|
if [ $ipv6 ]
|
||||||
|
then
|
||||||
|
echo "$ipv6 $host" >> $HOSTS
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$dflt" != "" ]
|
if [ "$dflt" != "" ]
|
||||||
then
|
then
|
||||||
|
|||||||
@ -1630,7 +1630,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
// ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/root/edithosts.sh $mac $ip $vm $dfltrt $ns $staticrt" >/dev/null
|
// ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/root/edithosts.sh $mac $ip $vm $dfltrt $ns $staticrt" >/dev/null
|
||||||
String args = " -m " + cmd.getVmMac();
|
String args = " -m " + cmd.getVmMac();
|
||||||
args += " -4 " + cmd.getVmIpAddress();
|
if (cmd.getVmIpAddress() != null) {
|
||||||
|
args += " -4 " + cmd.getVmIpAddress();
|
||||||
|
}
|
||||||
args += " -h " + cmd.getVmName();
|
args += " -h " + cmd.getVmName();
|
||||||
|
|
||||||
if (cmd.getDefaultRouter() != null) {
|
if (cmd.getDefaultRouter() != null) {
|
||||||
@ -1642,7 +1644,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.getStaticRoutes() != null) {
|
if (cmd.getStaticRoutes() != null) {
|
||||||
args += " -s " + cmd.getStaticRoutes();
|
args += " -s " + cmd.getStaticRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd.getVmIp6Address() != null) {
|
||||||
|
args += " -6 " + cmd.getVmIp6Address();
|
||||||
|
args += " -u " + cmd.getDuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
|||||||
@ -1750,7 +1750,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
protected synchronized Answer execute(final DhcpEntryCommand cmd) {
|
protected synchronized Answer execute(final DhcpEntryCommand cmd) {
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
String args = "-r " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
String args = "-r " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
|
||||||
args += " -v " + cmd.getVmIpAddress();
|
if (cmd.getVmIpAddress() != null) {
|
||||||
|
args += " -v " + cmd.getVmIpAddress();
|
||||||
|
}
|
||||||
args += " -m " + cmd.getVmMac();
|
args += " -m " + cmd.getVmMac();
|
||||||
args += " -n " + cmd.getVmName();
|
args += " -n " + cmd.getVmName();
|
||||||
if (cmd.getDefaultRouter() != null) {
|
if (cmd.getDefaultRouter() != null) {
|
||||||
@ -1764,6 +1766,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
args += " -N " + cmd.getDefaultDns();
|
args += " -N " + cmd.getDefaultDns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd.getVmIp6Address() != null) {
|
||||||
|
args += " -6 " + cmd.getVmIp6Address();
|
||||||
|
args += " -u " + cmd.getDuid();
|
||||||
|
}
|
||||||
|
|
||||||
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>\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>\n" $(basename $0) >&2
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,10 +35,12 @@ vmName=
|
|||||||
staticrt=
|
staticrt=
|
||||||
dfltrt=
|
dfltrt=
|
||||||
dns=
|
dns=
|
||||||
|
ipv6=
|
||||||
|
duid=
|
||||||
|
|
||||||
opts=
|
opts=
|
||||||
|
|
||||||
while getopts 'r:m:v:n:d:s:N:' OPTION
|
while getopts 'r:m:v:n:d:s:N:6:u:' OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
r) domrIp="$OPTARG"
|
r) domrIp="$OPTARG"
|
||||||
@ -61,6 +63,12 @@ do
|
|||||||
N) dns="$OPTARG"
|
N) dns="$OPTARG"
|
||||||
opts="$opts -n $dns"
|
opts="$opts -n $dns"
|
||||||
;;
|
;;
|
||||||
|
6) ipv6="$OPTARG"
|
||||||
|
opts="$opts -6 $ipv6"
|
||||||
|
;;
|
||||||
|
u) duid="$OPTARG"
|
||||||
|
opts="$opts -u $duid"
|
||||||
|
;;
|
||||||
?) usage
|
?) usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user