From 8bfbb5e2586f89de3b44cd1d05182f71a55fb05d Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 13 Sep 2017 15:06:56 -0400 Subject: [PATCH 01/12] Handle more than one node for openbmc rflash --- xCAT-server/lib/xcat/plugins/openbmc.pm | 36 ++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index a71ce95d1..9b0dadc7d 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -161,6 +161,7 @@ my %status_info = ( RFLASH_UPDATE_ACTIVATE_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/software", + orig_url => "$openbmc_project_url/software", data => "xyz.openbmc_project.Software.Activation.RequestedActivations.Active", }, RFLASH_UPDATE_ACTIVATE_RESPONSE => { @@ -169,6 +170,7 @@ my %status_info = ( RFLASH_UPDATE_CHECK_STATE_REQUEST => { method => "GET", init_url => "$openbmc_project_url/software", + orig_url => "$openbmc_project_url/software", }, RFLASH_UPDATE_CHECK_STATE_RESPONSE => { process => \&rflash_response, @@ -183,6 +185,7 @@ my %status_info = ( RFLASH_SET_PRIORITY_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/software", + orig_url => "$openbmc_project_url/software", data => "false", # Priority state of 0 sets image to active }, RFLASH_SET_PRIORITY_RESPONSE => { @@ -2082,24 +2085,27 @@ sub rflash_response { $update_id = (split(/\//, $key_url))[ -1 ]; if (defined($content{Version}) and $content{Version}) { $update_version = $content{Version}; - } - if ($update_version eq $::UPLOAD_FILE_VERSION) { - # Found a match of uploaded file version with the image in software/enumerate + if ($update_version eq $::UPLOAD_FILE_VERSION) { + # Found a match of uploaded file version with the image in software/enumerate - # Set the image id for the activation request - $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} .= "/$update_id/attr/RequestedActivation"; - $status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{init_url} .= "/$update_id"; - $status_info{RFLASH_SET_PRIORITY_REQUEST}{init_url} .= "/$update_id/attr/Priority"; + # Set the image id for the activation request + $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} = + $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{orig_url} . "/$update_id/attr/RequestedActivation"; + $status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{init_url} = + $status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{orig_url} . "/$update_id"; + $status_info{RFLASH_SET_PRIORITY_REQUEST}{init_url} = + $status_info{RFLASH_SET_PRIORITY_REQUEST}{orig_url} . "/$update_id/attr/Priority"; - # Set next steps to activate the image - $next_status{ $node_info{$node}{cur_status} } = "RFLASH_UPDATE_ACTIVATE_REQUEST"; - $next_status{"RFLASH_UPDATE_ACTIVATE_REQUEST"} = "RFLASH_UPDATE_ACTIVATE_RESPONSE"; - $next_status{"RFLASH_UPDATE_ACTIVATE_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST"; - $next_status{"RFLASH_UPDATE_CHECK_STATE_REQUEST"} = "RFLASH_UPDATE_CHECK_STATE_RESPONSE"; + # Set next steps to activate the image + $next_status{ $node_info{$node}{cur_status} } = "RFLASH_UPDATE_ACTIVATE_REQUEST"; + $next_status{"RFLASH_UPDATE_ACTIVATE_REQUEST"} = "RFLASH_UPDATE_ACTIVATE_RESPONSE"; + $next_status{"RFLASH_UPDATE_ACTIVATE_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST"; + $next_status{"RFLASH_UPDATE_CHECK_STATE_REQUEST"} = "RFLASH_UPDATE_CHECK_STATE_RESPONSE"; - $next_status{"RFLASH_SET_PRIORITY_REQUEST"} = "RFLASH_SET_PRIORITY_RESPONSE"; - $next_status{"RFLASH_SET_PRIORITY_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST"; - last; + $next_status{"RFLASH_SET_PRIORITY_REQUEST"} = "RFLASH_SET_PRIORITY_RESPONSE"; + $next_status{"RFLASH_SET_PRIORITY_RESPONSE"} = "RFLASH_UPDATE_CHECK_STATE_REQUEST"; + last; + } } } } From 5216f62d4b5901fa15c3c82d875fb3bc572f06cc Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Fri, 15 Sep 2017 00:06:32 +0000 Subject: [PATCH 02/12] Fix #3904 : Add ability to list discoverydata by type `mtms` --- .../admin-guides/references/man1/nodediscoverls.1.rst | 8 ++++++-- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/nodediscoverls.1.rst b/docs/source/guides/admin-guides/references/man1/nodediscoverls.1.rst index 8d1458b64..666477d78 100644 --- a/docs/source/guides/admin-guides/references/man1/nodediscoverls.1.rst +++ b/docs/source/guides/admin-guides/references/man1/nodediscoverls.1.rst @@ -19,7 +19,7 @@ SYNOPSIS ******** -\ **nodediscoverls**\ [\ **-t seq | profile | switch | blade | manual | undef | all**\ ] [\ **-l**\ ] +\ **nodediscoverls**\ [\ **-t seq | profile | switch | blade | manual | mtms | undef | all**\ ] [\ **-l**\ ] \ **nodediscoverls**\ [\ **-u**\ \ *uuid*\ ] [\ **-l**\ ] @@ -47,7 +47,7 @@ OPTIONS -\ **-t seq|profile|switch|blade|manual|undef|all**\ +\ **-t seq|profile|switch|blade|manual|mtms|undef|all**\ Display the nodes that have been discovered by the specified discovery method: @@ -72,6 +72,10 @@ OPTIONS + \* \ **mtms**\ - MTMS discovery (used when node mtm and serial fields are filled in). + + + \* \ **undef**\ - Display the nodes that were in the discovery pool, but for which xCAT has not yet received a discovery request. diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index ea114681f..0a18969cc 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -808,7 +808,7 @@ sub nodediscoverls { Usage: nodediscoverls nodediscoverls [-h|--help|-v|--version] - nodediscoverls [-t seq|profile|switch|blade|manual|undef|all] [-l] + nodediscoverls [-t seq|profile|switch|blade|manual|mtms|undef|all] [-l] nodediscoverls [-u uuid] [-l] "; $rsp = (); @@ -843,7 +843,7 @@ Usage: # If the type is specified, display the corresponding type of nodes my @SEQDiscover; if ($type) { - if ($type !~ /^(seq|profile|switch|blade|manual|undef|all)$/) { + if ($type !~ /^(seq|profile|switch|blade|manual|mtms|undef|all)$/) { $usage->($callback, "The discovery type \'$type\' is not supported."); return; } From ecc6af989b85a7e30b86d71f3ca736b0757abccd Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Fri, 15 Sep 2017 00:09:37 +0000 Subject: [PATCH 03/12] Add single space between MTM and serial --- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 0a18969cc..128164279 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -917,7 +917,7 @@ Usage: } else { $ent->{'node'} = 'undef' unless ($ent->{'node'}); $ent->{'method'} = 'undef' unless ($ent->{'method'}); - push @discoverednodes, sprintf(" %-40s%-20s%-15s%-10s%-20s", $ent->{'uuid'}, $ent->{'node'}, $ent->{'method'}, $ent->{'mtm'}, substr($ent->{'serial'}, 0, 19)); + push @discoverednodes, sprintf(" %-40s%-20s%-15s%-10s %-20s", $ent->{'uuid'}, $ent->{'node'}, $ent->{'method'}, $ent->{'mtm'}, substr($ent->{'serial'}, 0, 19)); } } @@ -927,7 +927,7 @@ Usage: } if (@discoverednodes) { unless ($long) { - push @{ $rsp->{data} }, sprintf(" %-40s%-20s%-15s%-10s%-13s", 'UUID', 'NODE', 'METHOD', 'MTM', 'SERIAL'); + push @{ $rsp->{data} }, sprintf(" %-40s%-20s%-15s%-10s %-20s", 'UUID', 'NODE', 'METHOD', 'MTM', 'SERIAL'); } foreach (@discoverednodes) { push @{ $rsp->{data} }, "$_"; From 14b5c39d89b4ae9113e5da13181dad933a3ba12d Mon Sep 17 00:00:00 2001 From: XuWei Date: Sun, 17 Sep 2017 22:48:42 -0400 Subject: [PATCH 04/12] Add node name in output of reventlog for OpenBMC --- xCAT-server/lib/xcat/plugins/openbmc.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 40a9e3508..dc975e641 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1631,13 +1631,13 @@ sub reventlog_response { my $count = 0; if ($option_s) { foreach my $key ( sort { $b <=> $a } keys %output) { - xCAT::MsgUtils->message("I", { data => [$output{$key}] }, $callback, $node) if ($output{$key}); + xCAT::MsgUtils->message("I", { data => ["$node: $output{$key}"] }, $callback) if ($output{$key}); $count++; last if ($entry_string ne "all" and $count >= $entry_num); } } else { foreach my $key (sort keys %output) { - xCAT::MsgUtils->message("I", { data => [$output{$key}] }, $callback, $node) if ($output{$key}); + xCAT::MsgUtils->message("I", { data => ["$node: $output{$key}"] }, $callback) if ($output{$key}); $count++; last if ($entry_string ne "all" and $count >= $entry_num); } From 5ac1f04791007a6d414b5b16ce3e76a46e99ef74 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 18 Sep 2017 11:42:36 -0400 Subject: [PATCH 05/12] Simplify code based on review comment --- xCAT-server/lib/xcat/plugins/openbmc.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 9b0dadc7d..7f6fb3c8d 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -96,6 +96,7 @@ my %sensor_units = ( my $http_protocol="https"; my $openbmc_url = "/org/openbmc"; my $openbmc_project_url = "/xyz/openbmc_project"; +$::SOFTWARE_URL = "$openbmc_project_url/software"; #------------------------------------------------------- # The hash table to store method and url for request, @@ -161,7 +162,6 @@ my %status_info = ( RFLASH_UPDATE_ACTIVATE_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/software", - orig_url => "$openbmc_project_url/software", data => "xyz.openbmc_project.Software.Activation.RequestedActivations.Active", }, RFLASH_UPDATE_ACTIVATE_RESPONSE => { @@ -170,7 +170,6 @@ my %status_info = ( RFLASH_UPDATE_CHECK_STATE_REQUEST => { method => "GET", init_url => "$openbmc_project_url/software", - orig_url => "$openbmc_project_url/software", }, RFLASH_UPDATE_CHECK_STATE_RESPONSE => { process => \&rflash_response, @@ -185,7 +184,6 @@ my %status_info = ( RFLASH_SET_PRIORITY_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/software", - orig_url => "$openbmc_project_url/software", data => "false", # Priority state of 0 sets image to active }, RFLASH_SET_PRIORITY_RESPONSE => { @@ -2090,11 +2088,11 @@ sub rflash_response { # Set the image id for the activation request $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{init_url} = - $status_info{RFLASH_UPDATE_ACTIVATE_REQUEST}{orig_url} . "/$update_id/attr/RequestedActivation"; + $::SOFTWARE_URL . "/$update_id/attr/RequestedActivation"; $status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{init_url} = - $status_info{RFLASH_UPDATE_CHECK_STATE_REQUEST}{orig_url} . "/$update_id"; + $::SOFTWARE_URL . "/$update_id"; $status_info{RFLASH_SET_PRIORITY_REQUEST}{init_url} = - $status_info{RFLASH_SET_PRIORITY_REQUEST}{orig_url} . "/$update_id/attr/Priority"; + $::SOFTWARE_URL . "/$update_id/attr/Priority"; # Set next steps to activate the image $next_status{ $node_info{$node}{cur_status} } = "RFLASH_UPDATE_ACTIVATE_REQUEST"; From 743df92e446462838cac116399280d1390db29d1 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 18 Sep 2017 14:15:45 -0400 Subject: [PATCH 06/12] Treat 5104-22C as a ESS Boston node for rflash command --- xCAT-server/lib/xcat/plugins/ipmi.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 923aad072..5bf64ea70 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1991,10 +1991,10 @@ sub do_firmware_update { } # For IBM Power S822LC for Big Data (Supermicro) machines such as - # P9 Boston (9006-22C, 9006-12) or P8 Briggs (8001-22C) + # P9 Boston (9006-22C, 9006-12C, 5104-22C) or P8 Briggs (8001-22C) # firmware update is done using pUpdate utility expected to be in the # specified data directory along with the update files .bin for BMC or .pnor for Host - if ($output =~ /8001-22C|9006-22C|9006-12C/) { + if ($output =~ /8001-22C|9006-22C|5104-22C|9006-12C/) { # Verify valid data directory was specified unless ($pUpdate_directory) { $exit_with_error_func->($sessdata->{node}, $callback, From cb7babd8683c884a20d8e317463d9fc3c5993f3d Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Mon, 18 Sep 2017 16:52:05 -0400 Subject: [PATCH 07/12] Discover Coral PDUs with same default hostname --- .../lib/xcat/plugins/switchdiscover.pm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index edf5ce5ae..c3a16ea61 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -350,7 +350,6 @@ sub process_request { } #consolidate the results by merging the swithes with the same ip or same mac - #or same hostname my $result; my $merged; my $counter=0; @@ -366,12 +365,11 @@ sub process_request { my $new_ip = $result->{$new_mac}->{ip}; my $new_name = $result->{$new_mac}->{name}; my $new_vendor = $result->{$new_mac}->{vendor}; + my $key =$new_mac; if (($old_mac eq $new_mac) || - ($old_ip && ($old_ip eq $new_ip)) || - ($old_name && ($old_name eq $new_name))) { + ($old_ip && ($old_ip eq $new_ip))) { $same = 1; - my $key =$new_mac; if ($new_mac =~ /nomac/) { if ($old_mac =~ /nomac/) { $key = "nomac_$counter"; @@ -380,9 +378,6 @@ sub process_request { $key = $old_mac; } } - if ($old_name) { - $result->{$key}->{name} = $old_name; - } if ($old_ip) { $result->{$key}->{ip} = $old_ip; } @@ -399,6 +394,12 @@ sub process_request { delete $result->{$new_mac}; } } + if ( $old_name && ($old_name eq $new_name)) { + #appending mac address to end of hostname + my $mac_str = lc($old_mac); + $mac_str =~ s/\://g; + $result->{$key}->{name} = "$old_name-$mac_str"; + } } if (!$same) { $result->{$old_mac} = $tmp_result->{$old_mac}; @@ -1107,7 +1108,7 @@ sub get_snmphostname { my ($desc,$hostname) = split /: /, $result; if (exists($globalopt{verbose})) { - send_msg($request, 0, "switch hostname = $hostname\n" ); + send_msg($request, 0, "$device hostname = $hostname\n" ); } return $hostname; @@ -1140,7 +1141,7 @@ sub get_hostname { if ( !$host ) { my $ip_str = $ip; $ip_str =~ s/\./\-/g; - $host = "switch-$ip_str"; + $host = "$device-$ip_str"; } } return $host; From 0d31efdd6459f6e886bb3246e38efbc1ae4b9f19 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 18 Sep 2017 23:30:20 -0400 Subject: [PATCH 08/12] add another several mac prefixes for edgecore network devices --- perl-xCAT/xCAT/data/switchinfo.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/data/switchinfo.pm b/perl-xCAT/xCAT/data/switchinfo.pm index 79c36abfa..cf8f1af80 100644 --- a/perl-xCAT/xCAT/data/switchinfo.pm +++ b/perl-xCAT/xCAT/data/switchinfo.pm @@ -18,7 +18,10 @@ our %global_mac_identity = ( "fc:cf:62" => "BNT G8124 switch", "7c:fe:90" => "Mellanox IB switch", "cc:37:ab" => "Edgecore Networks Switch", - "8c:ea:1b" => "Edgecore Networks Switch" + "8c:ea:1b" => "Edgecore Networks Switch", + "a8:2b:b5" => "Edgecore Networks Switch", + "3c:2c:99" => "Edgecore Networks Switch", + "70:72:cf" => "Edgecore Networks Switch" ); #the hash to lookup switch type with vendor From 8a66d843815fd0f486133277c8ac43abbe7de755 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Tue, 19 Sep 2017 15:35:59 +0800 Subject: [PATCH 09/12] Fix 3930, 1, only re-distribute to accessible dhcpsrv; 2, for non-sharedtftp mode, run makedhcp -d -l for offline (#3954) --- xCAT-server/lib/xcat/plugins/dhcp.pm | 2 +- xCAT-server/lib/xcat/plugins/grub2.pm | 9 ++++++--- xCAT-server/lib/xcat/plugins/petitboot.pm | 15 +++++---------- xCAT-server/lib/xcat/plugins/xnba.pm | 14 +++++--------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 6494e555e..62671753b 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -1128,7 +1128,7 @@ sub preprocess_request $callback->({ error => [ "Hierarchy requested, therefore networks.dhcpserver must be set for net=" . $_->{net} . "" ], errorcode => [1] }); return []; } - push @dhcpsvrs, $_->{dhcpserver}; + push @dhcpsvrs, $_->{dhcpserver} if (xCAT::NetworkUtils->nodeonmynet($_->{dhcpserver})); xCAT::MsgUtils->trace($verbose_on_off, "d", "dhcp: dhcp server on $_->{net}: $_->{dhcpserver}"); } } diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 4f72eb452..8906d15f6 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -504,8 +504,7 @@ sub preprocess_request { if ($ntab) { foreach (@{ $ntab->getAllEntries() }) { next unless ($_->{dynamicrange}); - # if dynamicrange specified but dhcpserver was not - issue error message - push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver}) + push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver} && xCAT::NetworkUtils->nodeonmynet($_->{dhcpserver})); } } return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash, \@dhcpsvrs); @@ -854,7 +853,11 @@ sub process_request { push(@rmdhcp_nodes, $tmp_node); } } - $sub_req->({ command => ['makedhcp'], arg => ['-d'], node => \@rmdhcp_nodes }, $callback); + if ($request->{'_disparatetftp'}->[0]) { + $sub_req->({ command => ['makedhcp'], arg => ['-d', '-l'], node => \@rmdhcp_nodes }, $callback); + } else { + $sub_req->({ command => ['makedhcp'], arg => ['-d'], node => \@rmdhcp_nodes }, $callback); + } } #now run the end part of the prescripts diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index c6c9c7295..a307fab3a 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -390,8 +390,7 @@ sub preprocess_request { if ($ntab) { foreach (@{ $ntab->getAllEntries() }) { next unless ($_->{dynamicrange}); - # if dynamicrange specified but dhcpserver was not - issue error message - push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver}) + push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver} && xCAT::NetworkUtils->nodeonmynet($_->{dhcpserver})); } } return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash, \@dhcpsvrs); @@ -645,7 +644,7 @@ sub process_request { } #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time - unless (($inittime) || ($args[0] eq 'offline')) { + unless ($inittime) { #dhcp stuff my $do_dhcpsetup = 1; @@ -654,9 +653,11 @@ sub process_request { if (defined($t_entry)) { if ($t_entry =~ /0|n|N/) { $do_dhcpsetup = 0; } } - if ($do_dhcpsetup) { + # For offline operation, remove the dhcp entries whatever dhcpset is disabled in site ( existing code logic, just keep it as is) + if ($do_dhcpsetup || $args[0] eq 'offline') { my @parameter; push @parameter, '-l' if ($request->{'_disparatetftp'}->[0]); + push @parameter, '-d' if ($args[0] eq 'offline'); xCAT::MsgUtils->trace($verbose_on_off, "d", "petitboot: issue makedhcp request"); $sub_req->({ command => ['makedhcp'], @@ -668,12 +669,6 @@ sub process_request { } - if ($args[0] eq 'offline') { - - # If nodeset directive was offline we need to remove dhcp entries - $sub_req->({ command => ['makedhcp'], arg => ['-d'], node => \@normalnodeset }, $callback); - } - #now run the end part of the prescripts unless ($args[0] eq '') { # or $args[0] eq 'enact') $errored = 0; diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 1bccc87b9..7410eeb42 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -442,8 +442,7 @@ sub preprocess_request { if ($ntab) { foreach (@{ $ntab->getAllEntries() }) { next unless ($_->{dynamicrange}); - # if dynamicrange specified but dhcpserver was not - issue error message - push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver}) + push @dhcpsvrs, $_->{dhcpserver} if ($_->{dhcpserver} && xCAT::NetworkUtils->nodeonmynet($_->{dhcpserver})); } } return xCAT::Scope->get_broadcast_disjoint_scope_with_parallel($req, $sn_hash, \@dhcpsvrs); @@ -696,22 +695,19 @@ sub process_request { } xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: Finish to handle configurations"); - # for offline operation, remove the dhcp entries - if ($args[0] eq 'offline') { - $sub_req->({ command => ['makedhcp'], arg => ['-d'], node => \@nodes }, $::XNBA_callback); - } - #dhcp stuff -- inittime is set when xcatd on sn is started - unless (($inittime) || ($args[0] eq 'offline')) { + unless ($inittime) { my $do_dhcpsetup = 1; my @entries = xCAT::TableUtils->get_site_attribute("dhcpsetup"); my $t_entry = $entries[0]; if (defined($t_entry)) { if ($t_entry =~ /0|n|N/) { $do_dhcpsetup = 0; } } - if ($do_dhcpsetup) { + # For offline operation, remove the dhcp entries whatever dhcpset is disabled in site ( existing code logic, just keep it as is) + if ($do_dhcpsetup || $args[0] eq 'offline') { my @parameter; push @parameter, '-l' if ($::XNBA_request->{'_disparatetftp'}->[0]); + push @parameter, '-d' if ($args[0] eq 'offline'); xCAT::MsgUtils->trace($verbose_on_off, "d", "xnba: issue makedhcp request"); $sub_req->({ command => ['makedhcp'], From 41fc149dc97c37e812d4589f60828abb85b8d895 Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 19 Sep 2017 04:36:58 -0400 Subject: [PATCH 10/12] nic interface check to avoid dot in short host name --- perl-xCAT/xCAT/Schema.pm | 4 ++-- xCAT-server/lib/xcat/plugins/hosts.pm | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index f4f9965cc..c38db16d2 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1551,14 +1551,14 @@ passed as argument rather than by table value', If multiple ip addresses are associated with each NIC: !|,!|,..., 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', + 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) and minus sign (-). 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 associated 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', + 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) and minus sign (-). 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/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index f2a8f3327..0ef05ace2 100755 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -165,7 +165,7 @@ sub build_line $longname = "$node.$domain"; } - # if shortname contains a dot then we have a bad syntax for name + # if shortname contains a dot then we have a bad syntax for name if ($shortname =~ /\./) { my $rsp; push @{ $rsp->{data} }, "Invalid short node name \'$shortname\'. The short node name may not contain a dot. The short node name is considered to be anything preceeding the network domain name in the fully qualified node name \'$longname\'.\n"; @@ -729,9 +729,28 @@ sub donics for (my $i = 0 ; $i < $nicindex{$nic} ; $i++) { if (!$nich->{$nic}->{nicsufx}->[$i] && !$nich->{$nic}->{nicprfx}->[$i]) { + if ($nic =~ /\./) { + my $rsp; + push @{ $rsp->{data} }, "$node: since \'$nic\' contains dot, nics.nichostnamesuffixes should be configured without dot for \'$nic\' interface."; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; + } # then we have no suffix at all for this # so set a default $nich->{$nic}->{nicsufx}->[$i] = "-$nic"; + + } elsif ($nich->{$nic}->{nicsufx}->[$i] && $nich->{$nic}->{nicsufx}->[$i] =~ /\./) { + my $rsp; + push @{ $rsp->{data} }, "$node: the value \'$nich->{$nic}->{nicsufx}->[$i]\' of nics.nichostnamesuffixes should not contain dot."; + xCAT::MsgUtils->message("E", $rsp, $callback); + delete $nich->{$nic}->{nicsufx}->[$i]; + next; + } elsif ($nich->{$nic}->{nicprfx}->[$i] && $nich->{$nic}->{nicprfx}->[$i] =~ /\./) { + my $rsp; + push @{ $rsp->{data} }, "$node: the value \'$nich->{$nic}->{nicprfx}->[$i]\' of nics.nichostnameprefixes should not contain dot."; + xCAT::MsgUtils->message("E", $rsp, $callback); + delete $nich->{$nic}->{nicprfx}->[$i]; + next; } } } From be81e218c649de3e499abfd22dbed70da049f26d Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 19 Sep 2017 04:51:48 -0400 Subject: [PATCH 11/12] Fix issue 3951, rm all bmc nodes when discovered --- xCAT-server/lib/xcat/plugins/nodediscover.pm | 14 ++++++++++---- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 16 ++++++++-------- xCAT-server/lib/xcat/plugins/switch.pm | 16 ++++++++-------- xCAT-server/lib/xcat/plugins/typemtms.pm | 18 +++++++++--------- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index b6b78383a..fcb4e9db5 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -454,10 +454,16 @@ sub process_request { } } } else { - - # Only BMC that doesn't support in-band configuration need to run rspconfig out-of-band, such as S822L running in OPAL model - xCAT::MsgUtils->message("S", "No bmcinband specified, need to configure BMC out-of-band"); - xCAT::Utils->cleanup_for_powerLE_hardware_discovery($request, $doreq); + if (defined($request->{bmc_node}) and defined($request->{bmc_node}->[0])) { + my $bmc_node = $request->{bmc_node}->[0]; + if ($bmc_node =~ /\,/) { + xCAT::MsgUtils->message("W", "Multiple BMC nodes matched with no bmcinband specified, please remove manually"); + } else { + # Only BMC that doesn't support in-band configuration need to run rspconfig out-of-band, such as S822L running in OPAL model + xCAT::MsgUtils->message("S", "No bmcinband specified, need to configure BMC out-of-band"); + xCAT::Utils->cleanup_for_powerLE_hardware_discovery($request, $doreq); + } + } } diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 128164279..413382266 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -131,25 +131,25 @@ sub findme { } } my $bmc_node = undef; + my @bmc_nodes = (); if ($request->{'mtm'}->[0] and $request->{'serial'}->[0]) { my $mtms = $request->{'mtm'}->[0] . "*" . $request->{'serial'}->[0]; my $tmp_nodes = $::XCATVPDHASH{$mtms}; foreach (@$tmp_nodes) { if ($::XCATMPHASH{$_}) { - $bmc_node = $_; + push @bmc_nodes, $_; } } } - unless ($bmc_node) { - if ($request->{'bmcmac'}->[0]) { - my $bmcmac = lc($request->{'bmcmac'}->[0]); - $bmcmac =~ s/\://g; - my $tmp_node = "node-$bmcmac"; - $bmc_node = $tmp_node if ($::XCATMPHASH{$tmp_node}); - } + if ($request->{'bmcmac'}->[0]) { + my $bmcmac = lc($request->{'bmcmac'}->[0]); + $bmcmac =~ s/\://g; + my $tmp_node = "node-$bmcmac"; + push @bmc_nodes, $tmp_node if ($::XCATMPHASH{$tmp_node}); } + $bmc_node = join(",", @bmc_nodes); if ($node) { my $skiphostip; my $skipbmcip; diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 523932036..024070b67 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -336,25 +336,25 @@ sub process_request { } } my $bmc_node = undef; + my @bmc_nodes = (); if ($req->{'mtm'}->[0] and $req->{'serial'}->[0]) { my $mtms = $req->{'mtm'}->[0] . "*" . $req->{'serial'}->[0]; my $tmp_nodes = $::XCATVPDHASH{$mtms}; foreach (@$tmp_nodes) { if ($::XCATMPHASH{$_}) { - $bmc_node = $_; + push @bmc_nodes, $_; } } } - unless ($bmc_node) { - if ($req->{'bmcmac'}->[0]) { - my $bmcmac = lc($req->{'bmcmac'}->[0]); - $bmcmac =~ s/\://g; - my $tmp_node = "node-$bmcmac"; - $bmc_node = $tmp_node if ($::XCATMPHASH{$tmp_node}); - } + if ($req->{'bmcmac'}->[0]) { + my $bmcmac = lc($req->{'bmcmac'}->[0]); + $bmcmac =~ s/\://g; + my $tmp_node = "node-$bmcmac"; + push @bmc_nodes, $tmp_node if ($::XCATMPHASH{$tmp_node}); } + $bmc_node = join(",", @bmc_nodes); if ($node) { xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Found node: $node"); diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm index b6bcb9817..d8bbc5e54 100644 --- a/xCAT-server/lib/xcat/plugins/typemtms.pm +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -26,24 +26,24 @@ sub findme { my $mtms = $request->{'mtm'}->[0] . "*" . $request->{'serial'}->[0]; my $tmp_nodes = $::XCATVPDHASH{$mtms}; my @nodes = (); - my $bmc_node; + my @bmc_nodes = (); + my $bmc_node = undef; foreach (@$tmp_nodes) { if ($::XCATMPHASH{$_}) { - $bmc_node = $_; + push @bmc_nodes, $_; } else { push @nodes, $_; } } - unless ($bmc_node) { - if ($request->{'bmcmac'}->[0]) { - my $bmcmac = lc($request->{'bmcmac'}->[0]); - $bmcmac =~ s/\://g; - my $tmp_node = "node-$bmcmac"; - $bmc_node = $tmp_node if ($::XCATMPHASH{$tmp_node}); - } + if ($request->{'bmcmac'}->[0]) { + my $bmcmac = lc($request->{'bmcmac'}->[0]); + $bmcmac =~ s/\://g; + my $tmp_node = "node-$bmcmac"; + push @bmc_nodes, $tmp_node if ($::XCATMPHASH{$tmp_node}); } + $bmc_node = join(",", @bmc_nodes); my $nodenum = $#nodes; if ($nodenum < 0) { xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Warning: Could not find any node for $mtms using mtms-based discovery"); From c7ea492e6bfebb49ce1c58c56336b38ab853ab65 Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 19 Sep 2017 05:21:07 -0400 Subject: [PATCH 12/12] polished --- xCAT-server/lib/xcat/plugins/hosts.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 0ef05ace2..945509f36 100755 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -731,7 +731,7 @@ sub donics if ($nic =~ /\./) { my $rsp; - push @{ $rsp->{data} }, "$node: since \'$nic\' contains dot, nics.nichostnamesuffixes should be configured without dot for \'$nic\' interface."; + push @{ $rsp->{data} }, "$node: since \'$nic\' contains dot, nics.nichostnamesuffixes.$nic should be configured without dot for \'$nic\' interface."; xCAT::MsgUtils->message("E", $rsp, $callback); next; } @@ -741,13 +741,13 @@ sub donics } elsif ($nich->{$nic}->{nicsufx}->[$i] && $nich->{$nic}->{nicsufx}->[$i] =~ /\./) { my $rsp; - push @{ $rsp->{data} }, "$node: the value \'$nich->{$nic}->{nicsufx}->[$i]\' of nics.nichostnamesuffixes should not contain dot."; + push @{ $rsp->{data} }, "$node: the value \'$nich->{$nic}->{nicsufx}->[$i]\' of nics.nichostnamesuffixes.$nic should not contain dot."; xCAT::MsgUtils->message("E", $rsp, $callback); delete $nich->{$nic}->{nicsufx}->[$i]; next; } elsif ($nich->{$nic}->{nicprfx}->[$i] && $nich->{$nic}->{nicprfx}->[$i] =~ /\./) { my $rsp; - push @{ $rsp->{data} }, "$node: the value \'$nich->{$nic}->{nicprfx}->[$i]\' of nics.nichostnameprefixes should not contain dot."; + push @{ $rsp->{data} }, "$node: the value \'$nich->{$nic}->{nicprfx}->[$i]\' of nics.nichostnameprefixes.$nic should not contain dot."; xCAT::MsgUtils->message("E", $rsp, $callback); delete $nich->{$nic}->{nicprfx}->[$i]; next;