2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-20 21:20:36 +00:00

Add some logs for bmcdiscover (#5163)

* Add some logs for bmcdiscover
This commit is contained in:
xuweibj
2018-05-04 15:43:51 +08:00
committed by Bin Xu
parent 9dff3bb734
commit a9825f3260

View File

@ -34,6 +34,7 @@ use HTTP::Cookies;
use HTTP::Response;
use JSON;
my $log_label = "bmcdiscover:";
my $nmap_path;
my %ipmac = ();
@ -595,6 +596,7 @@ sub scan_process {
$bcmd = join(" ", $nmap_path, " -sn -n $range");
}
xCAT::MsgUtils->trace(0, "I", "$log_label Try to scan live IPs by command $bcmd ...");
$ip_info_list = xCAT::Utils->runcmd("$bcmd", -1);
if ($::RUNCMD_RC != 0) {
my $rsp = {};
@ -617,7 +619,7 @@ sub scan_process {
my $live_mac = split_comma_delim_str($mac_list);
my %pipe_map;
if (scalar(@{$live_ip}) > 0) {
xCAT::MsgUtils->trace(0, "I", "$log_label Scaned live IPs " . scalar(@{$live_ip}) . " with mac " . scalar(@{$live_mac}));
foreach (@{$live_ip}) {
my $new_mac = lc(shift @{$live_mac});
$new_mac =~ s/\://g;
@ -696,7 +698,11 @@ sub scan_process {
my $is_openbmc = 0;
foreach my $mc_cmd (@mc_cmds) {
$mc_info = xCAT::Utils->runcmd($mc_cmd, -1);
if ($::RUNCMD_RC != 0) {
next;
}
if ($mc_info =~ /Manufacturer ID\s*:\s*(\d+)\s*Manufacturer Name.+\s*Product ID\s*:\s*(\d+)/) {
xCAT::MsgUtils->trace(0, "D", "$log_label Found ${$live_ip}[$i] Manufacturer ID: $1 Product ID: $2");
if ($1 eq $::P9_WITHERSPOON_MFG_ID and $2 eq $::P9_WITHERSPOON_PRODUCT_ID) {
bmcdiscovery_openbmc(${$live_ip}[$i], $opz, $opw, $request_command,$parent_fd);
$is_openbmc = 1;
@ -1044,6 +1050,9 @@ sub bmcdiscovery_ipmi {
$bmcpassword = "-P $bmc_pass";
}
my $log_info = "$ip: Detected ipmi, attempting to obtain system information...";
xCAT::MsgUtils->trace(0, "D", "$log_label $log_info");
my $mtms_node = "";
my $mac_node = "";
@ -1160,7 +1169,10 @@ sub bmcdiscovery_openbmc{
my $mac_node = "";
store_fd({data=>1}, $fd);
print "$ip: Detected openbmc, attempting to obtain system information...\n";
my $log_info = "$ip: Detected openbmc, attempting to obtain system information...";
print "$log_info\n";
xCAT::MsgUtils->trace(0, "D", "$log_label $log_info");
my $http_protocol="https";
my $openbmc_project_url = "xyz/openbmc_project";
my $login_endpoint = "login";
@ -1244,8 +1256,14 @@ sub bmcdiscovery_openbmc{
}
$node_data .= ",$::opt_SN,$::opt_SN";
} else {
if ($login_response->status_line =~ /401 Unauthorized/) {
xCAT::MsgUtils->message("W", { data => ["Invalid username or password for $ip"] }, $::CALLBACK);
my $login_status;
eval { $login_status = $login_response->status_line };
if ($@) {
xCAT::MsgUtils->message("W", { data => ["Login failed for $ip and no status received from response"] }, $::CALLBACK);
return;
}
if ($login_status =~ /401 Unauthorized/) {
xCAT::MsgUtils->message("W", { data => ["Invalid username or password for $ip"] }, $::CALLBACK);
} else {
xCAT::MsgUtils->message("W", { data => ["Received response " . $login_response->status_line . " for $ip"] }, $::CALLBACK);
}