#223868: [7R2][Usability]Hard to get MACs for 7R2 CNs.
This commit is contained in:
parent
6de247254f
commit
6c68d3c8cc
@ -465,6 +465,17 @@ Usage:
|
||||
}
|
||||
}
|
||||
|
||||
# Get no mac address nodes when user only defined CEC in NIF for 7R2 support.
|
||||
setrsp_progress("Checking MACs...");
|
||||
my @nomacnodes = ();
|
||||
foreach my $nomacnode(@nodelist){
|
||||
if(defined($hostinfo_dict{$nomacnode}{'cec'}) &&
|
||||
not (defined($hostinfo_dict{$nomacnode}{'mac'})) &&
|
||||
not (defined($hostinfo_dict{$nomacnode}{'switch'}))){
|
||||
push @nomacnodes, $nomacnode;
|
||||
}
|
||||
}
|
||||
|
||||
# Create the full hostinfo dict.
|
||||
xCAT::MsgUtils->message('S', "Generating new hostinfo string.");
|
||||
my ($retcode_gen, $retstr_gen) = gen_new_hostinfo_dict(\%hostinfo_dict);
|
||||
@ -481,7 +492,7 @@ Usage:
|
||||
$warnstr = "Warning: failed to import some nodes.";
|
||||
setrsp_progress($warnstr);
|
||||
}
|
||||
|
||||
|
||||
setrsp_progress("Configuring nodes...");
|
||||
my $retref = xCAT::Utils->runxcmd({command=>["kitnodeadd"], node=>\@nodelist, sequential=>[1], macflag=>[$mac_addr_mode]}, $request_command, 0, 2);
|
||||
my $retstrref = parse_runxcmd_ret($retref);
|
||||
@ -492,6 +503,59 @@ Usage:
|
||||
}
|
||||
}
|
||||
|
||||
# Use the xcat command: getmacs <noderanges> -D to automatically get node mac address
|
||||
# and if some of nodes can not get mac address, then finally remove them with warning msg.
|
||||
if(@nomacnodes){
|
||||
$retref = xCAT::Utils->runxcmd({command=>["getmacs"], node=>\@nomacnodes, arg=>['-D']}, $request_command, 0, 2);
|
||||
$retstrref = parse_runxcmd_ret($retref);
|
||||
if($::RUNCMD_RC != 0){
|
||||
$warnstr .= "Warning: Failed to run command getmacs to get node mac address.";
|
||||
}
|
||||
|
||||
# Parse the output of "getmacs <noderange> -D" to filter success and failed nodes.
|
||||
my @successnodes = ();
|
||||
my @failednodes = ();
|
||||
my $nodelistref = $retref->{'node'};
|
||||
my $index = 0;
|
||||
my $name = '';
|
||||
my $contents = '';
|
||||
if($nodelistref){
|
||||
foreach(@$nodelistref){
|
||||
# Get node name.
|
||||
if($nodelistref->[$index]->{'name'}){
|
||||
$name = $nodelistref->[$index]->{'name'}->[0];
|
||||
}
|
||||
# Get node data contents.
|
||||
if($nodelistref->[$index]->{'data'}->[0]->{'contents'}){
|
||||
$contents = $nodelistref->[$index]->{'data'}->[0]->{'contents'}->[0];
|
||||
}
|
||||
# Get success and failed nodes list.
|
||||
if(defined($name) and $contents =~ /[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}/){
|
||||
push @successnodes, $name;
|
||||
}else{
|
||||
push @failednodes, $name;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
# Remove these nodes that can not get mac address by xcat command: getmacs <noderange> -D.
|
||||
my $nodermretref = xCAT::Utils->runxcmd({command=>["noderm"], node=>\@failednodes}, $request_command, 0, 2);
|
||||
my $nodermretstrref = parse_runxcmd_ret($nodermretref);
|
||||
if($::RUNCMD_RC != 0){
|
||||
setrsp_progress("Warning: Cannot remove all nodes. The noderm command failed to remove some of the nodes.");
|
||||
$warnstr .= "Warning: Cannot remove all nodes. The noderm command failed to remove some of the nodes.";
|
||||
if($nodermretstrref->[1]){
|
||||
$warnstr .= "Details: $nodermretstrref->[1]";
|
||||
}
|
||||
}
|
||||
# Push the success nodes to nodelist.
|
||||
push @nodelist, @successnodes;
|
||||
if(@failednodes and $::RUNCMD_RC == 0){
|
||||
$warnstr .= "Warning: Removed all nodes that can not get mac address: @failednodes.";
|
||||
}
|
||||
}
|
||||
|
||||
setrsp_progress("Imported nodes.");
|
||||
#TODO: get the real nodelist here.
|
||||
setrsp_success(\@nodelist, $warnstr);
|
||||
@ -2055,11 +2119,12 @@ sub validate_node_entry{
|
||||
if (exists $allhostnames{$node_name}) {
|
||||
$errmsg .= "Node name $node_name already exists. You must use a new node name.\n";
|
||||
}
|
||||
# Must specify either MAC or switch + port.
|
||||
if (exists $node_entry{"mac"} ||
|
||||
exists $node_entry{"switch"} && exists $node_entry{"switchport"}){
|
||||
# Must specify either MAC, CEC or switch + port.
|
||||
if (exists $node_entry{"mac"} ||
|
||||
exists $node_entry{"switch"} && exists $node_entry{"switchport"} ||
|
||||
exists $node_entry{"cec"}){
|
||||
} else{
|
||||
$errmsg .= "MAC address, switch and port is not specified. You must specify the MAC address or switch and port.\n";
|
||||
$errmsg .= "MAC address, cec, switch and port is not specified. You must specify the MAC address, CEC name or switch and port.\n";
|
||||
}
|
||||
|
||||
if (! xCAT::NetworkUtils->isValidHostname($node_name)){
|
||||
|
Loading…
x
Reference in New Issue
Block a user