From a084808f7e7fa95318d353dc4a7c95ff3edc7ae0 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sun, 15 Mar 2009 18:54:05 +0000 Subject: [PATCH] -Attempt insertion of an FQDN first (kerberos for one is particularly more happy this way) git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2907 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/hosts.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 522aff783..2e7d6f166 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -24,24 +24,43 @@ sub addnode { my $ip = shift; unless ($node and $ip) { return; } #bail if requested to do something that could zap /etc/hosts badly my $othernames = shift; + my $domain = shift; my $idx=0; my $foundone=0; while ($idx <= $#hosts) { if ($hosts[$idx] =~ /^${ip}\s/ or $hosts[$idx] =~ /^\d+\.\d+\.\d+\.\d+\s+${node}\s/) { #TODO: if foundone, delete a dupe - $hosts[$idx] = "$ip $node $othernames\n"; + if ($domain and $node !~ /\./) { + $hosts[$idx] = "$ip $node.$domain $node $othernames\n"; + } else { + $hosts[$idx] = "$ip $node $othernames\n"; + } $foundone=1; } $idx++; } if ($foundone) { return;} + if ($domain and $node !~ /\./) { + push @hosts,"$ip $node.$domain $node $othernames\n"; + } else { + push @hosts,"$ip $node $othernames\n"; + } push @hosts,"$ip $node $othernames\n"; } sub process_request { my $req = shift; my $callback = shift; my $hoststab = xCAT::Table->new('hosts'); + my $sitetab = xCAT::Table->new('site'); + my $domain; + if ($sitetab) { + my $dent = $sitetab->getAttribs({key=>'domain'},'value'); + if ($dent and $dent->{value}) { + $domain=$dent->{value}; + } + } + @hosts = (); if (grep /-h/,@{$req->{arg}}) { $callback->({data=>$usage{makehosts}}); @@ -71,12 +90,12 @@ sub process_request { my $hostscache = $hoststab->getNodesAttribs($req->{node},[qw(ip node hostnames)]); foreach(@{$req->{node}}) { my $ref = $hostscache->{$_}->[0]; #$hoststab->getNodeAttribs($_,[qw(ip node hostnames)]); - addnode $ref->{node},$ref->{ip},$ref->{hostnames}; + addnode $ref->{node},$ref->{ip},$ref->{hostnames},$domain; } } else { my @hostents = $hoststab->getAllNodeAttribs(['ip','node','hostnames']); foreach (@hostents) { - addnode $_->{node},$_->{ip},$_->{hostnames}; + addnode $_->{node},$_->{ip},$_->{hostnames},$domain; } } writeout();