You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ya...@apache.org on 2013/01/27 08:24:27 UTC
[6/7] git commit: IPv6: Enable VR's ability to provide DHCPv6 service
IPv6: Enable VR's ability to provide DHCPv6 service
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8f66d266
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8f66d266
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8f66d266
Branch: refs/heads/ipv6
Commit: 8f66d266b3c7ec5aae4afa18cb619684a06fa925
Parents: f89c660
Author: Sheng Yang <sh...@citrix.com>
Authored: Thu Jan 24 20:09:37 2013 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Sat Jan 26 23:14:42 2013 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 9 ++-
patches/systemvm/debian/config/etc/dnsmasq.conf | 3 +-
.../debian/config/etc/init.d/cloud-early-config | 29 +++++--
patches/systemvm/debian/config/root/edithosts.sh | 71 ++++++++++++---
.../hypervisor/vmware/resource/VmwareResource.java | 11 ++-
.../xen/resource/CitrixResourceBase.java | 9 ++-
scripts/network/domr/dhcp_entry.sh | 12 ++-
7 files changed, 120 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f66d266/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 18a0426..b30fcbf 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -569,7 +569,9 @@ public class VirtualRoutingResource implements Manager {
protected synchronized Answer execute (final DhcpEntryCommand cmd) {
final Script command = new Script(_dhcpEntryPath, _timeout, s_logger);
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("-n", cmd.getVmName());
@@ -583,6 +585,11 @@ public class VirtualRoutingResource implements Manager {
if (cmd.getDefaultDns() != null) {
command.add("-N", cmd.getDefaultDns());
}
+
+ if (cmd.getVmIp6Address() != null) {
+ command.add("-6", cmd.getVmIp6Address());
+ command.add("-u", cmd.getDuid());
+ }
final String result = command.execute();
return new Answer(cmd, result==null, result);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f66d266/patches/systemvm/debian/config/etc/dnsmasq.conf
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/etc/dnsmasq.conf b/patches/systemvm/debian/config/etc/dnsmasq.conf
index c01e754..7d656cb 100644
--- a/patches/systemvm/debian/config/etc/dnsmasq.conf
+++ b/patches/systemvm/debian/config/etc/dnsmasq.conf
@@ -141,7 +141,8 @@ domain=2.vmops-test.vmops.com
# 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
# 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
# This is an example of a DHCP range where the netmask is given. This
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f66d266/patches/systemvm/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
index 74b963b..ebe2fa4 100755
--- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config
+++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
@@ -398,7 +398,8 @@ setup_common() {
setup_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"
if [ -n "$DOMAIN" ]
@@ -422,8 +423,20 @@ setup_dnsmasq() {
sed -i s/[#]*dhcp-option=15.*$/dhcp-option=15,\""$DNS_SEARCH_ORDER"\"/ /etc/dnsmasq.conf
fi
- sed -i -e "s/^dhcp-range=.*$/dhcp-range=$DHCP_RANGE,static/" /etc/dnsmasq.conf
- sed -i -e "s/^[#]*listen-address=.*$/listen-address=$ETH0_IP/" /etc/dnsmasq.conf
+ if [ $DHCP_RANGE ]
+ 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" ]
then
@@ -707,14 +720,15 @@ setup_dhcpsrvr() {
if [ "$DEFAULTROUTE" != "false" ]
then
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
sed -i -e "/^[#]*dhcp-option=6.*$/d" /etc/dnsmasq.conf
if [ "$USE_EXTERNAL_DNS" == "true" ]
then
echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
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
else
sed -i -e "/^[#]*dhcp-option=option:router.*$/d" /etc/dnsmasq.conf
@@ -1034,8 +1048,11 @@ for i in $CMDLINE
;;
esac
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
start)
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f66d266/patches/systemvm/debian/config/root/edithosts.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/edithosts.sh b/patches/systemvm/debian/config/root/edithosts.sh
index acc421b..3cf2742 100755
--- a/patches/systemvm/debian/config/root/edithosts.sh
+++ b/patches/systemvm/debian/config/root/edithosts.sh
@@ -27,23 +27,29 @@
# $6 : comma separated static routes
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=
ipv4=
+ipv6=
host=
dflt=
dns=
routes=
+duid=
-while getopts 'm:4:h:d:n:s:' OPTION
+while getopts 'm:4:h:d:n:s:6:u:' OPTION
do
case $OPTION in
m) mac="$OPTARG"
;;
4) ipv4="$OPTARG"
;;
+ 6) ipv6="$OPTARG"
+ ;;
+ u) duid="$OPTARG"
+ ;;
h) host="$OPTARG"
;;
d) dflt="$OPTARG"
@@ -95,26 +101,69 @@ logger -t cloud "edithosts: update $1 $2 $3 to hosts"
[ ! -f $DHCP_LEASES ] && touch $DHCP_LEASES
#delete any previous entries from the dhcp hosts file
-sed -i /$mac/d $DHCP_HOSTS
-sed -i /$ipv4,/d $DHCP_HOSTS
-sed -i /$host,/d $DHCP_HOSTS
+sed -i /$mac/d $DHCP_HOSTS
+if [ $ipv4 ]
+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
-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
-sed -i /$mac/d $DHCP_LEASES
-sed -i /"$ipv4 "/d $DHCP_LEASES
+if [ $ipv4 ]
+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
#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
-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
-echo "$ipv4 $host" >> $HOSTS
+if [ $ipv4 ]
+then
+ echo "$ipv4 $host" >> $HOSTS
+fi
+if [ $ipv6 ]
+then
+ echo "$ipv6 $host" >> $HOSTS
+fi
if [ "$dflt" != "" ]
then
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f66d266/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 0ca25a8..37bff2a 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -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
String args = " -m " + cmd.getVmMac();
- args += " -4 " + cmd.getVmIpAddress();
+ if (cmd.getVmIpAddress() != null) {
+ args += " -4 " + cmd.getVmIpAddress();
+ }
args += " -h " + cmd.getVmName();
if (cmd.getDefaultRouter() != null) {
@@ -1642,7 +1644,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
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()) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f66d266/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 065d3be..3470352 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -1750,7 +1750,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
protected synchronized Answer execute(final DhcpEntryCommand cmd) {
Connection conn = getConnection();
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 += " -n " + cmd.getVmName();
if (cmd.getDefaultRouter() != null) {
@@ -1764,6 +1766,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
args += " -N " + cmd.getDefaultDns();
}
+ if (cmd.getVmIp6Address() != null) {
+ args += " -6 " + cmd.getVmIp6Address();
+ args += " -u " + cmd.getDuid();
+ }
+
String result = callHostPlugin(conn, "vmops", "saveDhcpEntry", "args", args);
if (result == null || result.isEmpty()) {
return new Answer(cmd, false, "DhcpEntry failed");
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8f66d266/scripts/network/domr/dhcp_entry.sh
----------------------------------------------------------------------
diff --git a/scripts/network/domr/dhcp_entry.sh b/scripts/network/domr/dhcp_entry.sh
index b964eb4..e417f72 100755
--- a/scripts/network/domr/dhcp_entry.sh
+++ b/scripts/network/domr/dhcp_entry.sh
@@ -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>\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
}
@@ -35,10 +35,12 @@ vmName=
staticrt=
dfltrt=
dns=
+ipv6=
+duid=
opts=
-while getopts 'r:m:v:n:d:s:N:' OPTION
+while getopts 'r:m:v:n:d:s:N:6:u:' OPTION
do
case $OPTION in
r) domrIp="$OPTARG"
@@ -61,6 +63,12 @@ do
N) dns="$OPTARG"
opts="$opts -n $dns"
;;
+ 6) ipv6="$OPTARG"
+ opts="$opts -6 $ipv6"
+ ;;
+ u) duid="$OPTARG"
+ opts="$opts -u $duid"
+ ;;
?) usage
exit 1
;;