first commit for prefix hostname feature
This commit is contained in:
parent
b832cb5023
commit
afb15362f3
@ -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){
|
||||
|
@ -1325,7 +1325,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.',
|
||||
@ -1343,6 +1343,13 @@ nics => {
|
||||
<nic1>!<ext1>|<ext2>,<nic2>!<ext1>|<ext2>,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6.
|
||||
The xCAT object definition commands support to use nichostnamesuffixes.<nicname> 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:
|
||||
<nic1>!<ext1>,<nic2>!<ext2>,..., for example, eth0!eth0-,ib0!ib-
|
||||
If multiple ip addresses are associcated with each NIC:
|
||||
<nic1>!<ext1>|<ext2>,<nic2>!<ext1>|<ext2>,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-.
|
||||
The xCAT object definition commands support to use nichostnameprefixes.<nicname> 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. <nic1>!<type1>,<nic2>!<type2>, e.g. eth0!Ethernet,ib0!Infiniband. The xCAT object definition commands support to use nictypes.<nicname> as the sub attributes.',
|
||||
niccustomscripts => 'Comma-separated list of custom scripts per NIC. <nic1>!<script1>,<nic2>!<script2>, e.g. eth0!configeth eth0, ib0!configib ib0. The xCAT object definition commands support to use niccustomscripts.<nicname> as the sub attribute
|
||||
.',
|
||||
|
@ -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
|
||||
|
@ -93,7 +93,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
|
||||
@ -568,6 +568,7 @@ sub donics
|
||||
$node,
|
||||
[
|
||||
'nicips', 'nichostnamesuffixes',
|
||||
'nichostnameprefixes',
|
||||
'nicnetworks', 'nicaliases'
|
||||
]
|
||||
);
|
||||
@ -613,6 +614,7 @@ sub donics
|
||||
}
|
||||
|
||||
my @nicandsufx = split(',', $et->{'nichostnamesuffixes'});
|
||||
my @nicandprfx = split(',', $et->{'nichostnameprefixes'});
|
||||
|
||||
foreach (@nicandsufx)
|
||||
{
|
||||
@ -634,12 +636,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";
|
||||
@ -710,6 +732,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];
|
||||
|
||||
@ -718,7 +741,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');
|
||||
|
Loading…
Reference in New Issue
Block a user