diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 1f461ed43..8bff2eace 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -265,6 +265,7 @@ sub rackformat_to_numricformat{ values are attributes of a specific nic, like: type : nic type hostnamesuffix: hostname suffix + hostnameprefix: hostname prefix customscript: custom script for this nic network: network name for this nic ip: ip address of this nic. @@ -276,7 +277,7 @@ sub get_nodes_nic_attrs{ my $nodes = shift; my $nicstab = xCAT::Table->new( 'nics'); - my $entry = $nicstab->getNodesAttribs($nodes, ['nictypes', 'nichostnamesuffixes', 'niccustomscripts', 'nicnetworks', 'nicips']); + my $entry = $nicstab->getNodesAttribs($nodes, ['nictypes', 'nichostnamesuffixes', 'nichostnameprefixes', 'niccustomscripts', 'nicnetworks', 'nicips']); my %nicsattrs; my @nicattrslist; @@ -308,6 +309,20 @@ sub get_nodes_nic_attrs{ } } + if($entry->{$node}->[0]->{'nichostnameprefixes'}){ + + @nicattrslist = split(",", $entry->{$node}->[0]->{'nichostnameprefixes'}); + foreach (@nicattrslist){ + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{$nicattrs[0]}{'hostnameprefix'} = $nicattrs[1]; + } + } + if($entry->{$node}->[0]->{'niccustomscripts'}){ @nicattrslist = split(",", $entry->{$node}->[0]->{'niccustomscripts'}); foreach (@nicattrslist){ diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index fac76f093..fc30c6de4 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1329,7 +1329,7 @@ firmware => { }, nics => { - cols => [qw(node nicips nichostnamesuffixes nictypes niccustomscripts nicnetworks nicaliases comments disable)], + cols => [qw(node nicips nichostnamesuffixes nichostnameprefixes nictypes niccustomscripts nicnetworks nicaliases comments disable)], keys => [qw(node)], tablespace =>'XCATTBS16K', table_desc => 'Stores NIC details.', @@ -1347,6 +1347,13 @@ nics => { !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention', + nichostnameprefixes => 'Comma-separated list of hostname prefixes per NIC. + If only one ip address is associated with each NIC: + !,!,..., for example, eth0!eth0-,ib0!ib- + If multiple ip addresses are associcated with each NIC: + !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. + The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. + Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention', nictypes => 'Comma-separated list of NIC types per NIC. !,!, e.g. eth0!Ethernet,ib0!Infiniband. The xCAT object definition commands support to use nictypes. as the sub attributes.', niccustomscripts => 'Comma-separated list of custom scripts per NIC. !,!, e.g. eth0!configeth eth0, ib0!configib ib0. The xCAT object definition commands support to use niccustomscripts. as the sub attribute .', diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index c38bf62cf..cc5c4a928 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -538,7 +538,7 @@ sub processArgs # --nics is the equivalent of -i nicips,nichostnamesuffixes... if ($::opt_nics) { - $::opt_i="nicips,nichostnamesuffixes,nictypes,niccustomscripts,nicnetworks,nicaliases"; + $::opt_i="nicips,nichostnamesuffixes,nihostnameprefixes,nictypes,niccustomscripts,nicnetworks,nicaliases"; } # -i and -s cannot be used together diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 661dcf507..d5426f8f8 100755 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -91,7 +91,7 @@ sub addnode # at this point "othernames", if any is just a space # delimited list - so just add the node name to the list - $othernames .= " $node"; + #$othernames .= " $node"; $hosts[$idx] = build_line($callback, $ip, $hnode, $domain, $othernames); } else { # otherwise just try to completely update the existing @@ -599,6 +599,7 @@ sub donics $node, [ 'nicips', 'nichostnamesuffixes', + 'nichostnameprefixes', 'nicnetworks', 'nicaliases' ] ); @@ -644,6 +645,7 @@ sub donics } my @nicandsufx = split(',', $et->{'nichostnamesuffixes'}); + my @nicandprfx = split(',', $et->{'nichostnameprefixes'}); foreach (@nicandsufx) { @@ -665,12 +667,32 @@ sub donics $nich->{$nicname}->{nicsufx}->[0] = $nicsufx; } } + foreach (@nicandprfx) + { + my ($nicname, $nicprfx); + if ($_ =~ /!/) { + ($nicname, $nicprfx) = split('!', $_); + } else { + ($nicname, $nicprfx) = split(':', $_); + } + + if ( $nicprfx =~ /\|/) { + my @prfs = split( /\|/, $nicprfx); + my $index=0; + foreach my $prf (@prfs) { + $nich->{$nicname}->{nicprfx}->[$index] = $prf; + $index++; + } + } else { + $nich->{$nicname}->{nicprfx}->[0] = $nicprfx; + } + } # see if we need to fill in a default suffix # nich has all the valid nics - ie. that have IPs provided! foreach my $nic (keys %{$nich}) { for (my $i = 0; $i < $nicindex{$nic}; $i++ ){ - if (!$nich->{$nic}->{nicsufx}->[$i]) { + if (!$nich->{$nic}->{nicsufx}->[$i] && !$nich->{$nic}->{nicprfx}->[$i]) { # then we have no suffix at all for this # so set a default $nich->{$nic}->{nicsufx}->[$i] = "-$nic"; @@ -741,6 +763,7 @@ sub donics my $nicip = $nich->{$nic}->{nicip}->[$i]; my $nicsuffix = $nich->{$nic}->{nicsufx}->[$i]; + my $nicprefix = $nich->{$nic}->{nicprfx}->[$i]; my $nicnetworks = $nich->{$nic}->{netwrk}->[$i]; my $nicaliases = $nich->{$nic}->{nicaliases}->[$i]; @@ -749,7 +772,7 @@ sub donics } # construct hostname for nic - my $nichostname = "$shorthost$nicsuffix"; + my $nichostname = "$nicprefix$shorthost$nicsuffix"; # get domain from network def provided by nic attr my $nt = $nettab->getAttribs({ netname => "$nicnetworks"}, 'domain');