From 0d2ea2a9ed06cb7c515f0abd3b6c676501181469 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 15 Feb 2011 20:54:40 +0000 Subject: [PATCH] -Allow per-network ddns suffix -Change the genduiduuid script to avoid the quote as ascii git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8852 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Schema.pm | 3 ++- xCAT-server/lib/xcat/plugins/ddns.pm | 19 ++++++++------ xCAT-server/lib/xcat/plugins/dhcp.pm | 25 ++++++++++++++++--- xCAT-server/share/xcat/scripts/genduiduuid.sh | 2 +- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 0f1884356..fc6e18c55 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -425,7 +425,7 @@ mpa => { }, }, networks => { - cols => [qw(netname net mask mgtifname gateway dhcpserver tftpserver nameservers ntpservers logservers dynamicrange nodehostname comments disable)], + cols => [qw(netname net mask mgtifname gateway dhcpserver tftpserver nameservers ntpservers logservers dynamicrange nodehostname ddnsdomain comments disable)], keys => [qw(net mask)], table_desc => 'Describes the networks in the cluster and info necessary to set up nodes on that network.', descriptions => { @@ -441,6 +441,7 @@ networks => { logservers => 'The log servers for this network. Used in creating the DHCP network definition. Assumed to be the DHCP server if not set.', dynamicrange => 'The IP address range used by DHCP to assign dynamic IP addresses for requests on this network. This should not overlap with entities expected to be configured with static host declarations, i.e. anything ever expected to be a node with an address registered in the mac table.', nodehostname => 'A regular expression used to specify node name to network-specific hostname. i.e. "/\z/-secondary/" would mean that the hostname of "n1" would be n1-secondary on this network. By default, the nodename is assumed to equal the hostname, followed by nodename-interfacename.', + ddnsdomain => 'A domain to be combined with nodename to construct FQDN for DDNS updates induced by DHCP. This is not passed down to the client as "domain"', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", }, diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index efb9bd692..a51f43964 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -22,9 +22,13 @@ sub handled_commands return {"makedns" => "site:dnshandler"}; } sub getzonesfornet { - my $net = shift; - my $mask = shift; + my $netent = shift; + my $net = $netent->{net}; + my $mask = $netent->{mask}; my @zones = (); + if ($netent->{ddnsdomain}) { + push @zones,$netent->{ddnsdomain}; + } if ($net =~ /:/) {#ipv6, for now do the simple stuff under the assumption we won't have a mask indivisible by 4 $net =~ s/\/(.*)//; my $maskbits=$1; @@ -46,7 +50,8 @@ sub getzonesfornet { $nibbs--; } $rev.="ip6.arpa."; - return ($rev); + push @zones,$rev; + return @zones; } #return all in-addr reverse zones for a given mask and net #for class a,b,c, the answer is easy @@ -220,8 +225,8 @@ sub process_request { s/^[ \t\n]*//; #remove leading whitespace next unless ($_); #skip empty lines ($addr,$names) = split /[ \t]+/,$_,2; - if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/) { - xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, only IPv4 format entries are supported currently", $callback); + if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/ and $addr !~ /^[abcdef0123456789:]+$/) { + xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, address seems malformed.", $callback); next; } unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) { @@ -263,7 +268,7 @@ sub process_request { $ctx->{nodes} = \@nodes; my $networkstab = xCAT::Table->new('networks',-create=>0); unless ($networkstab) { xCAT::SvrUtils::sendmsg([1,'Unable to enumerate networks, try to run makenetworks'], $callback); } - my @networks = $networkstab->getAllAttribs('net','mask'); + my @networks = $networkstab->getAllAttribs('net','mask','ddnsdomain'); foreach (@networks) { my $maskn; if ($_->{mask}) { #better be IPv4, we only do CIDR for v6, use the v4/v6 agnostic just in case @@ -285,7 +290,7 @@ sub process_request { $net =~ s/\/.*//; $ctx->{nets}->{$_->{net}}->{netn} = getipaddr($net,GetNumber=>1); my $currzone; - foreach $currzone (getzonesfornet($_->{net},$_->{mask})) { + foreach $currzone (getzonesfornet($_)) { $ctx->{zonestotouch}->{$currzone} = 1; } } diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index a0c38476d..ccfb54769 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -448,6 +448,7 @@ sub addrangedetection { my $begin; my $end; $netcfgs{$net->{net}}->{nameservers} = $net->{nameservers}; + $netcfgs{$net->{net}}->{ddnsdomain} = $net->{ddnsdomain}; $netcfgs{$net->{net}}->{domain} = $domain; #TODO: finer grained domains unless ($netcfgs{$net->{net}}->{nameservers}) { $netcfgs{$net->{net}}->{nameservers} = $::XCATSITEVALS{nameservers}; @@ -856,7 +857,7 @@ sub process_request } } my $nettab = xCAT::Table->new("networks"); - my @vnets = $nettab->getAllAttribs('net','mgtifname','mask','dynamicrange','nameservers'); + my @vnets = $nettab->getAllAttribs('net','mgtifname','mask','dynamicrange','nameservers','ddnsdomain'); foreach (@vnets) { if ($_->{net} =~ /:/) { #IPv6 detected $usingipv6=1; @@ -1396,8 +1397,17 @@ sub addnet6 } my $ddnserver = $nameservers; $ddnserver =~ s/,.*//; + my $ddnsdomain; + if ($netcfgs{$net}->{ddnsdomain}) { + $ddnsdomain = $netcfgs{$net}->{ddnsdomain}; + } if ($::XCATSITEVALS{dnshandler} =~ /ddns/) { + if ($ddnsdomain) { + push @netent, " ddns-domain-name \"".$ddnsdomain."\";\n"; + push @netent, " zone $ddnsdomain. {\n"; + } else { push @netent, " zone $domain. {\n"; + } push @netent, " primary $ddnserver; key xcat_key; \n"; push @netent, " }\n"; foreach (getzonesfornet($net)) { @@ -1612,8 +1622,17 @@ sub addnet } my $ddnserver = $nameservers; $ddnserver =~ s/,.*//; - if ($::XCATSITEVALS{dnshandler} =~ /ddns/) { - push @netent, "zone $domain. {\n"; + my $ddnsdomain; + if ($netcfgs{$net}->{ddnsdomain}) { + $ddnsdomain = $netcfgs{$net}->{ddnsdomain}; + } + if ($::XCATSITEVALS{dnshandler} =~ /ddns/) { + if ($ddnsdomain) { + push @netent, " ddns-domain-name \"".$ddnsdomain."\";\n"; + push @netent, " zone $ddnsdomain. {\n"; + } else { + push @netent, " zone $domain. {\n"; + } push @netent, " primary $ddnserver; key xcat_key; \n"; push @netent, " }\n"; foreach (getzonesfornet($net,$mask)) { diff --git a/xCAT-server/share/xcat/scripts/genduiduuid.sh b/xCAT-server/share/xcat/scripts/genduiduuid.sh index 016046316..697e73ac3 100644 --- a/xCAT-server/share/xcat/scripts/genduiduuid.sh +++ b/xCAT-server/share/xcat/scripts/genduiduuid.sh @@ -6,7 +6,7 @@ if [ -r /sys/devices/virtual/dmi/id/product_uuid ]; then for i in `sed -e s/-//g -e 's/\(..\)/\1 /g' /sys/devices/virtual/dmi/id/product_uuid`; do num=`printf "%d" 0x$i` octnum=`printf "\\%03o" 0x$i` - if [ $num -lt 127 -a $num -gt 31 ]; then + if [ $num -lt 127 -a $num -gt 34 ]; then octnum=`printf $octnum` fi duid=$duid$octnum