diff --git a/xCAT-server/lib/xcat/plugins/aixinstall.pm b/xCAT-server/lib/xcat/plugins/aixinstall.pm index 644f141da..fbba569c4 100644 --- a/xCAT-server/lib/xcat/plugins/aixinstall.pm +++ b/xCAT-server/lib/xcat/plugins/aixinstall.pm @@ -771,11 +771,163 @@ sub nimnodeset $error = 0; foreach my $node (@nodelist) { + # set the NIM machine type + my $type = "standalone"; + if ($imagehash{$image_name}{nimtype}) + { + $type = $imagehash{$image_name}{nimtype}; + } + chomp $type; # get the image name to use for this node my $image_name = $nodeosi{$node}; chomp $image_name; + + # define the node if it doesn't exist + if (!grep(/^$node$/, @machines)) + { + + # get, check the node IP + # TODO - need IPv6 update + #my $IP = inet_ntoa(inet_aton($node)); + my $IP = xCAT::NetworkUtils->getipaddr($node); + chomp $IP; + + unless (($IP =~ /\d+\.\d+\.\d+\.\d+/) || ($IP =~ /:/)) + { + my $rsp; + push @{$rsp->{data}}, + "$Sname: Could not get valid IP address for node $node.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + push(@nodesfailed, $node); + next; + } + # could be diskful + # mask, gateway, cosi, root, dump, paging + # TODO - need to fix this check for shared_root + if ( !$nethash{$node}{'mask'} + || !$nethash{$node}{'gateway'} + || !$imagehash{$image_name}{spot}) + { + my $rsp; + push @{$rsp->{data}}, + "$Sname: Missing required information for node \'$node\'.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + push(@nodesfailed, $node); + next; + } + + # set some default values + # overwrite with cmd line values - if any + my $speed = "100"; + my $duplex = "full"; + if ($attrs{duplex}) + { + $duplex = $attrs{duplex}; + } + if ($attrs{speed}) + { + $speed = $attrs{speed}; + } + + # define the node + my $mac_or_local_link_addr; + my $adaptertype; + my $netmask; + my $if = 1; + my $netname; + + # need a short hostname to define in NIM + my $nodeshorthost; + ($nodeshorthost = $node) =~ s/\..*$//; + chomp $nodeshorthost; + + my $nim_name = $nodeshorthost; + + # Use -F to workaround ping time during diskless node defined in nim + my $defcmd = "/usr/sbin/nim -Fo define -t $type "; + + $objhash{$node}{'mac'} =~ s/://g; # strip out colons if any + my @macs = split /\|/, $objhash{$node}{'mac'}; + foreach my $mac (@macs) + { + + if (xCAT::NetworkUtils->getipaddr($nodeshorthost) =~ /:/) #ipv6 node + { + $mac_or_local_link_addr = xCAT::NetworkUtils->linklocaladdr($mac); + $adaptertype = "ent6"; + $netmask = xCAT::NetworkUtils->prefixtomask($nethash{$node}{'mask'}); + } else { + $mac_or_local_link_addr = $mac; + # only support Ethernet for management interfaces + if ($nethash{$node}{'mgtifname'} =~ /hf/) + { + $adaptertype = "hfi0"; + } else { + $adaptertype = "ent"; + } + $netmask = $nethash{$node}{'mask'}; + } + + $netname = $nethash{$node}{'netname'}; + + if ($::NEWNAME) + { + $defcmd .= "-a if$if='find_net $nodeshorthost 0' "; + } else + { + $defcmd .= + + + "-a if$if='find_net $nodeshorthost $mac_or_local_link_addr $adaptertype' "; + } + + $defcmd .= "-a cable_type$if=N/A "; + $if = $if + 1; + } + + $defcmd .= "-a netboot_kernel=mp "; + + if ($nethash{$node}{'mgtifname'} !~ /hf/) + { + $defcmd .= + "-a net_definition='$adaptertype $netmask $nethash{$node}{'gateway'}' "; + $defcmd .= "-a net_settings1='$speed $duplex' "; + } + + $defcmd .= "$nim_name 2>&1"; + if ($::VERBOSE) + { + my $rsp; + push @{$rsp->{data}}, "$Sname: Creating NIM node definition.\n"; + xCAT::MsgUtils->message("I", $rsp, $callback); + } else { + my $rsp; + push @{$rsp->{data}}, "$Sname: Creating NIM client definition \'$nim_name.\'\n"; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + my $output = xCAT::Utils->runcmd("$defcmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, + "$Sname: Could not create a NIM definition for \'$nim_name\'.\n"; + if ($::VERBOSE) + { + push @{$rsp->{data}}, "$output"; + } + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + push(@nodesfailed, $node); + next; + } + } + + + # check if node is in ready state my $shorthost; ($shorthost = $node) =~ s/\..*$//; @@ -864,7 +1016,13 @@ sub nimnodeset my $nim_name; ($nim_name = $node) =~ s/\..*$//; chomp $nim_name; - if (!grep(/^$nim_name$/, @machines)) + + # read machines again to make sure they have been defined + my $cmd = + qq~/usr/sbin/lsnim -c machines | /usr/bin/cut -f1 -d' ' 2>/dev/null~; + my @updatedmachines = xCAT::Utils->runcmd("$cmd", -1); + + if (!grep(/^$nim_name$/, @updatedmachines)) { my $rsp; push @{$rsp->{data}},