add makehosts support for otherinterfaces

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3710 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mellor 2009-07-06 20:39:39 +00:00
parent 9bff78a0b7
commit 3bc4bfe0b6
2 changed files with 31 additions and 5 deletions

View File

@ -141,13 +141,14 @@ deps => {
},
},
hosts => {
cols => [qw(node ip hostnames comments disable)],
cols => [qw(node ip hostnames otherinterfaces comments disable)],
keys => [qw(node)],
table_desc => 'IP address and hostnames of nodes. This info can be used to populate /etc/hosts or DNS.',
descriptions => {
node => 'The node name or group name.',
ip => 'The IP address of the node.',
hostnames => 'Hostname aliases added to /etc/hosts for this node.',
otherinterfaces => 'Other IP addresses to add for this node. Format: -<ext>:<ip>,<intfhostname>:ip>,...',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
@ -1243,6 +1244,10 @@ my @nodeattrs = (
tabentry => 'hosts.hostnames',
access_tabentry => 'hosts.node=attr:node',
},
{attr_name => 'otherinterfaces',
tabentry => 'hosts.otherinterfaces',
access_tabentry => 'hosts.node=attr:node',
},
{attr_name => 'usercomment',
tabentry => 'nodelist.comments',
access_tabentry => 'nodelist.node=attr:node',

View File

@ -32,7 +32,7 @@ sub addnode {
my $foundone=0;
while ($idx <= $#hosts) {
if ($hosts[$idx] =~ /^${ip}\s/ or $hosts[$idx] =~ /^\d+\.\d+\.\d+\.\d+\s+${node}[\s\.]/) {
if ($hosts[$idx] =~ /^${ip}\s/ or $hosts[$idx] =~ /^\d+\.\d+\.\d+\.\d+\s+${node}[\s\.r]/) {
if ($foundone) {
$hosts[$idx]="";
} else {
@ -80,6 +80,21 @@ sub build_line {
}
sub addotherinterfaces {
my $node = shift;
my $otherinterfaces = shift;
my $domain = shift;
my @itf_pairs=split(/,/, $otherinterfaces);
foreach (@itf_pairs) {
my ($itf,$ip)=split(/:/, $_);
if ($itf =~ /^-/ ) {
$itf = $node.$itf };
addnode $itf,$ip,'',$domain;
}
}
sub process_request {
Getopt::Long::Configure("bundling") ;
$Getopt::Long::ignorecase=0;
@ -143,15 +158,21 @@ sub process_request {
}
if ($req->{node}) {
my $hostscache = $hoststab->getNodesAttribs($req->{node},[qw(ip node hostnames)]);
my $hostscache = $hoststab->getNodesAttribs($req->{node},[qw(ip node hostnames otherinterfaces)]);
foreach(@{$req->{node}}) {
my $ref = $hostscache->{$_}->[0]; #$hoststab->getNodeAttribs($_,[qw(ip node hostnames)]);
my $ref = $hostscache->{$_}->[0]; #$hoststab->getNodeAttribs($_,[qw(ip node hostnames otherinterfaces)]);
addnode $ref->{node},$ref->{ip},$ref->{hostnames},$domain;
if (defined($ref->{otherinterfaces})){
addotherinterfaces $ref->{node},$ref->{otherinterfaces},$domain;
}
}
} else {
my @hostents = $hoststab->getAllNodeAttribs(['ip','node','hostnames']);
my @hostents = $hoststab->getAllNodeAttribs(['ip','node','hostnames','otherinterfaces']);
foreach (@hostents) {
addnode $_->{node},$_->{ip},$_->{hostnames},$domain;
if (defined($_->{otherinterfaces})){
addotherinterfaces $_->{node},$_->{otherinterfaces},$domain;
}
}
}
writeout();