diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index 18a0426e2fa..b30fcbf2004 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); diff --git a/patches/systemvm/debian/config/etc/dnsmasq.conf b/patches/systemvm/debian/config/etc/dnsmasq.conf index c01e7549d63..7d656cb2b77 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 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 74b963b182c..ebe2fa4ab5b 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) diff --git a/patches/systemvm/debian/config/root/edithosts.sh b/patches/systemvm/debian/config/root/edithosts.sh index acc421b8a67..3cf27427653 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 -4 -h -d -n -s \n" $(basename $0) >&2 + printf "Usage: %s: -m -4 -6 -h -d -n -s -u \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 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 0ca25a888af..37bff2a4b71 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()) { 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 065d3be0bdd..34703528a71 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"); diff --git a/scripts/network/domr/dhcp_entry.sh b/scripts/network/domr/dhcp_entry.sh index b964eb4c292..e417f7273a2 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 -m -v -n -s -d -N \n" $(basename $0) >&2 + printf "Usage: %s: -r -m -v -n -s -d -N -6 -u \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 ;;