From e2467dbf38db9dc9c7617055872dd7d703a4e22e Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Mon, 18 Dec 2017 11:44:01 -0800 Subject: [PATCH 1/8] use all nameservers defined in site.nameservers --- xCAT/postscripts/mkresolvconf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/mkresolvconf b/xCAT/postscripts/mkresolvconf index 8b4b58d69..65276b101 100755 --- a/xCAT/postscripts/mkresolvconf +++ b/xCAT/postscripts/mkresolvconf @@ -17,6 +17,7 @@ conf_file_bak="/etc/resolv.conf.bak" # get values set when the myxcatpost_ script was run master=$MASTER_IP # this is the ip for the nodes xcatmaster attribute domain=$DOMAIN # this is the domain name used in this cluster +nameservers=$NAMESERVERS # nameservers defined in the site table node=$NODE if [ -n "$master" ] && [ -n "$domain" ]; then @@ -24,7 +25,14 @@ if [ -n "$master" ] && [ -n "$domain" ]; then #logger -t xcat "Created /etc/resolv.conf file on $node." cp $conf_file $conf_file_bak > /dev/null 2>&1 echo "search $domain" >$conf_file - echo "nameserver $master" >>$conf_file + if [[ "$nameservers" != "" ]]; then + for ns in ${nameservers//,/ }; do + echo "nameserver ${ns//$master}" >>$conf_file + done + else + echo "nameserver $master" >>$conf_file + fi + else logger -t xcat -p local4.err "Could not create resolv.conf on $node." exit 1 From d743b26b290a8bcd09f173c8fc6935773bf8b5aa Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Mon, 18 Dec 2017 17:15:01 -0800 Subject: [PATCH 2/8] mkresolvconf: avoid duplicate nameservers --- xCAT/postscripts/mkresolvconf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/mkresolvconf b/xCAT/postscripts/mkresolvconf index 65276b101..39cf9c06a 100755 --- a/xCAT/postscripts/mkresolvconf +++ b/xCAT/postscripts/mkresolvconf @@ -27,7 +27,8 @@ if [ -n "$master" ] && [ -n "$domain" ]; then echo "search $domain" >$conf_file if [[ "$nameservers" != "" ]]; then for ns in ${nameservers//,/ }; do - echo "nameserver ${ns//$master}" >>$conf_file + grep -q $ns $conf_file || \ + echo "nameserver ${ns//$master}" >>$conf_file done else echo "nameserver $master" >>$conf_file From 40118f0c8f3f00641bcd2e98aa0b53a67f536ce2 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Mon, 5 Mar 2018 12:09:01 -0500 Subject: [PATCH 3/8] Improve the error message when python dependencies are not met --- xCAT-openbmc-py/lib/python/agent/xcatagent/server.py | 2 +- xCAT-server/lib/perl/xCAT/OPENBMC.pm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py index ab236a5a7..ac55601a1 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py @@ -106,7 +106,7 @@ class Server(object): self.server.stop() os._exit(0) except ImportError: - messager.error("xCAT mgt=openbmc is using a Python based framework and there are some dependencies that are not met.") + messager.error("OpenBMC management is using a Python framework and some dependency libraries could not be imported.") print(traceback.format_exc(), file=sys.stderr) self.server.stop() os._exit(1) diff --git a/xCAT-server/lib/perl/xCAT/OPENBMC.pm b/xCAT-server/lib/perl/xCAT/OPENBMC.pm index 8984a7a10..b481625d7 100644 --- a/xCAT-server/lib/perl/xCAT/OPENBMC.pm +++ b/xCAT-server/lib/perl/xCAT/OPENBMC.pm @@ -137,7 +137,7 @@ sub submit_agent_request { $retry++; } if (!defined($sock)) { - xCAT::MsgUtils->message("E", { data => ["Failed to connect to the agent"] }, $callback); + xCAT::MsgUtils->message("E", { data => ["OpenBMC management is using a Python framework. An error has occured when trying to create socket $AGENT_SOCK_PATH."] }, $callback); kill('TERM', $pid); return; } @@ -195,7 +195,7 @@ sub wait_agent { my ($pid, $callback) = @_; waitpid($pid, 0); if ($? >> 8 != 0) { - xCAT::MsgUtils->message("E", { data => ["python agent exited unexpectedly. See $PYTHON_LOG_PATH for more details."] }, $callback); + xCAT::MsgUtils->message("E", { data => ["Agent exited unexpectedly. See $PYTHON_LOG_PATH for details."] }, $callback); } } From 05b6f489accfae799330233c8227c793da1438aa Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 5 Mar 2018 11:30:01 -0500 Subject: [PATCH 4/8] OpenBMC commands default to Python --- xCAT-server/lib/perl/xCAT/OPENBMC.pm | 83 ++++++++---------------- xCAT-server/lib/xcat/plugins/openbmc.pm | 2 +- xCAT-server/lib/xcat/plugins/openbmc2.pm | 2 +- 3 files changed, 30 insertions(+), 57 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/OPENBMC.pm b/xCAT-server/lib/perl/xCAT/OPENBMC.pm index 8984a7a10..a8e662b69 100644 --- a/xCAT-server/lib/perl/xCAT/OPENBMC.pm +++ b/xCAT-server/lib/perl/xCAT/OPENBMC.pm @@ -199,59 +199,28 @@ sub wait_agent { } } -sub is_openbmc_python { - my $environment = shift; - $environment = shift if (($environment) && ($environment =~ /OPENBMC/)); - # If XCAT_OPENBMC_PYTHON is YES, - # will return "ALL" and caller will run openbmc2.pm. - # If XCAT_OPENBMC_PYTHON is not set or is set to NO, return "NO" and caller - # will run openbmc.pm - # If XCAT_OPENBMC_PYTHON is a list of commands, return that list and caller - # will run openbmc2.pm if the command is on the list, caller will run - # openbmc.pm if command is not on the list - if (ref($environment) eq 'ARRAY' and ref($environment->[0]->{XCAT_OPENBMC_PYTHON}) eq 'ARRAY') { - $::OPENBMC_PYTHON = $environment->[0]->{XCAT_OPENBMC_PYTHON}->[0]; - } elsif (ref($environment) eq 'ARRAY') { - $::OPENBMC_PYTHON = $environment->[0]->{XCAT_OPENBMC_PYTHON}; - } else { - $::OPENBMC_PYTHON = $environment->{XCAT_OPENBMC_PYTHON}; - } - if (defined($::OPENBMC_PYTHON)) { - if ($::OPENBMC_PYTHON eq "YES") { - return "ALL"; - } - elsif ($::OPENBMC_PYTHON eq "NO") { - return "NO"; - } - else { - return $::OPENBMC_PYTHON; - } - } - - return "NO"; -} - #-------------------------------------------------------------------------------- -=head3 is_support_in_perl - check if specified command is included in site attribute openbmcperl +=head3 run_cmd_in_perl + Check if specified command should run in perl The policy is: Get value from `openbmcperl`, `XCAT_OPENBMC_DEVEL`, agent.py: - 1. If agent.py not exist: ==>Go Perl - 2. If `openbmcperl` not set or not include a command: - if `XCAT_OPENBMC_DEVEL` set to `NO`: ==> Go Perl - else if set to `YES` or not set: ==> Go Python - 3. If `openbmcperl` set and include a command - if `XCAT_OPENBMC_DEVEL` set to `YES`: == >Go Python - else ==> Go Perl + + 1. If agent.py does not exist: ==> 1: Go Perl + 2. If `openbmcperl` not set or doesn't contain command: ==> 0: Go Python + 3. If `openbmcperl` lists the command OR set to "ALL" ==> 1: Go Perl + 4. If command is one of unsupported commands AND + a. XCAT_OPENBMC_DEVEL = YES ==> 0: Go Python + b. XCAT_OPENBMC_DEVEL = NO or not set ==> 1: Go Perl =cut #-------------------------------------------------------------------------------- -sub is_support_in_perl { +sub run_cmd_in_perl { my ($class, $command, $env) = @_; if (! -e $PYTHON_AGENT_FILE) { - return (1, ''); + return (1, ''); # Go Perl: agent file is not there } + my @entries = xCAT::TableUtils->get_site_attribute("openbmcperl"); my $site_entry = $entries[0]; my $support_obmc = undef; @@ -262,22 +231,26 @@ sub is_support_in_perl { } else { $support_obmc = $env->{XCAT_OPENBMC_DEVEL}; } - if ($support_obmc and $support_obmc ne 'YES' and $support_obmc ne 'NO') { - return (-1, "Value $support_obmc is invalid for XCAT_OPENBMC_DEVEL, only support 'YES' and 'NO'"); + if ($support_obmc and uc($support_obmc) ne 'YES' and uc($support_obmc) ne 'NO') { + return (-1, "Invalid value $support_obmc for XCAT_OPENBMC_DEVEL, only 'YES' and 'NO' are supported."); } - if ($site_entry and $site_entry =~ $command) { - if ($support_obmc and $support_obmc eq 'YES') { - return (0, ''); + if ($site_entry and ($site_entry =~ $command or uc($site_entry) eq "ALL")) { + return (1, ''); # Go Perl: command listed in "openbmcperl" or "ALL" + } + + # List of commands currently not supported in Python + my @unsupported_in_python_commands = ('rflash', 'rspconfig', 'reventlog'); + + if ($command ~~ @unsupported_in_python_commands) { + # Command currently not supported in Python + if ($support_obmc and uc($support_obmc) eq 'YES') { + return (0, ''); # Go Python: unsuppored command, but XCAT_OPENBMC_DEVEL=YES overrides } else { - return (1, ''); - } - } else { - if ($support_obmc and $support_obmc eq 'NO') { - return (1, ''); - } else { - return (0, ''); + return (1, ''); # Go Perl: unsuppored command } } + + return (0, ''); # Go Python: default } 1; diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 3d61835ad..5d2b67187 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -758,7 +758,7 @@ sub preprocess_request { $callback = shift; my $command = $request->{command}->[0]; - my ($rc, $msg) = xCAT::OPENBMC->is_support_in_perl($command, $request->{environment}); + my ($rc, $msg) = xCAT::OPENBMC->run_cmd_in_perl($command, $request->{environment}); if ($rc == 0) { $request = {}; return;} if ($rc < 0) { $request = {}; diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index 0e6364b48..e5b038531 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -62,7 +62,7 @@ sub preprocess_request { $callback = shift; my $command = $request->{command}->[0]; - my ($rc, $msg) = xCAT::OPENBMC->is_support_in_perl($command, $request->{environment}); + my ($rc, $msg) = xCAT::OPENBMC->run_cmd_in_perl($command, $request->{environment}); if ($rc != 0) { $request = {}; return;} my $noderange = $request->{node}; From 40380568796a6dbae5e8f307e4a5536b8f400eda Mon Sep 17 00:00:00 2001 From: cxhong Date: Mon, 5 Mar 2018 22:25:38 -0500 Subject: [PATCH 5/8] Add more print statement for config switches scripts (#4872) * Add more print statement for config switches scripts * modified from reviews * more modify from review --- .../switch_based_switch_discovery.rst | 10 +++--- .../lib/xcat/plugins/switchdiscover.pm | 14 ++++---- xCAT-server/share/xcat/scripts/configBNT | 33 +++++++++++++------ xCAT-server/share/xcat/scripts/configMellanox | 29 +++++++++------- xCAT-server/share/xcat/scripts/configonie | 15 ++++++--- 5 files changed, 64 insertions(+), 37 deletions(-) diff --git a/docs/source/advanced/networks/switchdiscover/switch_based_switch_discovery.rst b/docs/source/advanced/networks/switchdiscover/switch_based_switch_discovery.rst index 356132d7f..2f207d0ff 100644 --- a/docs/source/advanced/networks/switchdiscover/switch_based_switch_discovery.rst +++ b/docs/source/advanced/networks/switchdiscover/switch_based_switch_discovery.rst @@ -105,7 +105,7 @@ if **--setup** flag is specified, the command will perform following steps: snmppassword=xcatadminpassw0rd@snmp snmpusername=xcatadmin snmpversion=3 - status=hostname_configed + status=hostname_configured statustime=08-31-2016 15:35:49 supportedarchs=ppc64 switch=switch-10-5-23-1 @@ -155,13 +155,13 @@ These two config files are located in the **/opt/xcat/share/xcat/scripts** direc Switch Status ~~~~~~~~~~~~~ -During the switch-based switch discovery process, there are four states displayed. User may only see **switch_configed** status on node definition if discovery process successfully finished. +During the switch-based switch discovery process, there are four states displayed. User may only see **switch_configured** status on node definition if discovery process successfully finished. **Matched** --- Discovered switch is matched to predefine switch, **otherinterfaces** attribute is updated to dhcp IP address, and mac address, **switch type** and **usercomment** also updated with vendor information for the predefined switch. -**ip_configed** --- switch is set up to static IP address based on predefine switch IP address. If failure to set up IP address, the status will stay as **Matched**. +**ip_configured** --- switch is set up to static IP address based on predefine switch IP address. If failure to set up IP address, the status will stay as **Matched**. -**hostname_configed** -- switch host name is changed based on predefine switch hostname. If failure to change hostname on the switch, the status will stay as **ip_configed**. +**hostname_configured** -- switch host name is changed based on predefine switch hostname. If failure to change hostname on the switch, the status will stay as **ip_configured**. -**switch_configed** -- snmpv3 is setup for the switches. This should be finial status after running ``switchdiscover --setup`` command. If failure to setup snmpv3, the status will stay as **hostname_configed**. +**switch_configured** -- snmpv3 is setup for the switches. This should be finial status after running ``switchdiscover --setup`` command. If failure to setup snmpv3, the status will stay as **hostname_configured**. diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index 512356939..07b88b26a 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -1491,20 +1491,20 @@ sub switchsetup { if (-r -x $config_script) { my $switches = join(",",@{${nodes_to_config}->{$mytype}}); if ($mytype eq "onie") { - send_msg($request, 0, "Call to config $switches\n"); + send_msg($request, 0, "Calling $config_script to configure $mytype switches $switches..."); my $out = `$config_script --switches $switches --all`; - send_msg($request, 0, "output = $out\n"); + send_msg($request, 0, "$out"); } else { - send_msg($request, 0, "call to config $mytype switches $switches\n"); + send_msg($request, 0, "Calling $config_script to configure $mytype switches $switches..."); if ($mytype =~ /Mellanox/) { - send_msg($request, 0, "NOTE: If command takes too long for Mellanox IB switch, please CTRL C out of the command\n"); - send_msg($request, 0, "then run $config_script --switches $switches --all\n"); + send_msg($request, 0, "NOTE: If command takes too long for Mellanox IB switch, open another window and ping the switches being configured, once they are complete, ctrl-c out of this command"); + send_msg($request, 0, "then run $config_script --switches $switches --all again"); } my $out = `$config_script --switches $switches --all`; - send_msg($request, 0, "output = $out\n"); + send_msg($request, 0, "$out"); } } else { - send_msg($request, 0, "the switch type $mytype is not support yet\n"); + send_msg($request, 0, "the switch type $mytype is not support yet"); } } diff --git a/xCAT-server/share/xcat/scripts/configBNT b/xCAT-server/share/xcat/scripts/configBNT index c58c1c1f9..328acd16d 100755 --- a/xCAT-server/share/xcat/scripts/configBNT +++ b/xCAT-server/share/xcat/scripts/configBNT @@ -162,7 +162,7 @@ sub config_ip { } foreach my $switch (@nodes) { - print "change $switch to static ip address\n"; + print "change $switch to static IP address\n"; #makesure host is in the /etc/hosts $cmd = "makehosts $switch"; @@ -171,7 +171,7 @@ sub config_ip { my $dip= $nodehash->{$switch}->[0]->{otherinterfaces}; my $mac= $machash->{$switch}->[0]->{mac}; if (!$dip) { - print "ERROR: Add otherinterfaces attribute for discover ip: chdef $switch otherinterfaces=x.x.x.x\n"; + print "ERROR: Add otherinterfaces attribute for discover IP: chdef $switch otherinterfaces=x.x.x.x\n"; next; } @@ -186,7 +186,7 @@ sub config_ip { # don't need to set if ip addresses are same if ($dip eq $static_ip) { - print "static ip $static_ip and discovery ip $dip is same, will not process command for $switch\n"; + print "static IP $static_ip and discovery IP $dip is same, will not process command for $switch\n"; $cmd = "chdef $switch otherinterfaces="; $rc= xCAT::Utils->runcmd($cmd, 0); next; @@ -220,6 +220,7 @@ sub config_ip { } } + print "Changing IP address of $dswitch to $static_ip...\n"; # For RackSwitch G8124 if ($mac =~ /fc\:cf\:62/i) { $cmd="xdsh $dswitch -t 10 --devicetype EthSwitch::BNT 'enable;configure terminal;show interface ip;interface ip-mgmt enable;interface ip-mgmt address $static_ip $mask;exit' "; @@ -246,7 +247,7 @@ sub config_ip { } print "retry $retry_failed\n"; if ($retry_failed) { - print "Failed to set up static ip address: $static_ip for $switch\n"; + print "Failed to set up static IP address: $static_ip for $switch\n"; push (@discover_switches, $dswitch); next; } @@ -257,8 +258,9 @@ sub config_ip { if (@config_switches) { #update switch status my $csw = join(",",@config_switches); - $cmd = "chdef $csw status=ip_configed otherinterfaces="; + $cmd = "chdef $csw status=ip_configured otherinterfaces="; $rc= xCAT::Utils->runcmd($cmd, 0); + print "$csw: IP address configured\n"; } if (@discover_switches) { my $dsw = join(",",@discover_switches); @@ -292,14 +294,16 @@ sub config_hostname { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","Failed to setup hostname for $switch"); + print "$switch: Failed to setup hostname\n"; next; } + print "$switch: Hostname changed to $switch\n"; push (@config_switches, $switch); } if (@config_switches) { #update switch status my $csw = join(",",@config_switches); - $cmd = "chdef $csw status=hostname_configed" ; + $cmd = "chdef $csw status=hostname_configured" ; $rc= xCAT::Utils->runcmd($cmd, 0); } } @@ -485,8 +489,9 @@ sub config_snmp { if (@config_switches) { #update switch status my $csw = join(",",@config_switches); - $cmd = "chdef $csw status=switch_configed snmpversion=3 snmpauth=sha snmpprivacy=authNoPriv snmpusername=$snmp_user snmppassword=$snmp_passwd"; + $cmd = "chdef $csw status=switch_configured snmpversion=3 snmpauth=sha snmpprivacy=authNoPriv snmpusername=$snmp_user snmppassword=$snmp_passwd"; $rc= xCAT::Utils->runcmd($cmd, 0); + print "$csw: SNMP configured\n"; } } @@ -567,7 +572,12 @@ sub config_vlan { $vlan = $::VLAN; print "Tagging VLAN=$vlan for $switches port $port\n"; #create vlan, tagged vlan - $cmd = `xdsh $switches --devicetype EthSwitch::BNT "enable;configure terminal;vlan $vlan;exit;interface port $port;switchport mode trunk;switchport trunk allowed vlan $vlan;write memory;exit;exit"`; + $cmd = "xdsh $switches --devicetype EthSwitch::BNT 'enable;configure terminal;vlan $vlan;exit;interface port $port;switchport mode trunk;switchport trunk allowed vlan $vlan;write memory;exit;exit' "; + $rc= xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message("E","Failed to setup VLAN number"); + print "$switches: Failed to setup VLAN\n"; + } } @@ -597,7 +607,10 @@ sub config_desc { if ($::VERBOSE) { print "Executing cmd: \n==> $final_cmd\n"; } - `$final_cmd` + $rc= xCAT::Utils->runcmd($final_cmd, 0); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message("E","Failed to set a description on the port: $port"); + } } #--------------------------------------------------------- @@ -618,7 +631,7 @@ sub usage configBNT --switches switchnames --snmp [--user snmp_user] [--password snmp_password] [--group snmp_group] configBNT --switches switchnames --port port --vlan vlan - To set the ip address, hostname and config snmp: + To set the IP address, hostname and config snmp: configBNT --switches switchnames --all To set the description for a port on the switch: diff --git a/xCAT-server/share/xcat/scripts/configMellanox b/xCAT-server/share/xcat/scripts/configMellanox index 545ba47e2..6a085abf6 100755 --- a/xCAT-server/share/xcat/scripts/configMellanox +++ b/xCAT-server/share/xcat/scripts/configMellanox @@ -150,7 +150,7 @@ sub config_ip { # Validate if this IP is reachable my $p = Net::Ping->new(); if (!$p->ping($dip)) { - print "$dip is not reachable, will not change ip address\n"; + print "$dip is not reachable, will not change IP address\n"; #clean up discovery switch deifnition if any my $ip_str = $dip; $ip_str =~ s/\./\-/g; @@ -168,7 +168,7 @@ sub config_ip { # don't need to set if ip addresses are same if ($dip eq $static_ip) { - print "static ip $static_ip and discovery ip $dip is same, will not process command for $switch\n"; + print "static IP $static_ip and discovery IP $dip is same, will not process command for $switch\n"; next; } @@ -219,23 +219,24 @@ sub config_ip { } } + print "Sending xdsh command to change IP address...\n"; $cmd="xdsh $dswitch -t 10 -l admin --devicetype IBSwitch::Mellanox 'enable;configure terminal;no interface mgmt0 dhcp;interface mgmt0 ip address $static_ip $mask;configuration write;exit;exit' "; $rc= xCAT::Utils->runcmd($cmd, 0); if (!$p->ping($static_ip)) { - print "$switch: Failed to change ip address to $static_ip\n"; + print "$switch: Failed to change IP address to $static_ip\n"; next; } push (@discover_switches, $dswitch); push (@config_switches, $switch); - print "$switch: Changing IP address to static IP $static_ip\n"; + print "$switch: IP address changed to $static_ip\n"; } if (@config_switches) { # update switch status my $csw = join(",",@config_switches); - $cmd = "chdef $csw status=ip_configed otherinterfaces="; + $cmd = "chdef $csw status=ip_configured otherinterfaces="; $rc= xCAT::Utils->runcmd($cmd, 0); $cmd = "makehosts $csw"; $rc= xCAT::Utils->runcmd($cmd, 0); @@ -279,6 +280,7 @@ sub config_hostname { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","Failed to setup hostname for $switch"); + print "$switch: Failed to setup hostname\n"; next; } push (@config_switches, $switch); @@ -287,7 +289,7 @@ sub config_hostname { if (@config_switches) { # update switch status my $csw = join(",",@config_switches); - $cmd = "chdef $csw status=hostname_configed" ; + $cmd = "chdef $csw status=hostname_configured" ; $rc= xCAT::Utils->runcmd($cmd, 0); } } @@ -349,8 +351,10 @@ sub config_snmp { $cmd = $cmd . "configuration write\;exit\;"; my $final_cmd = $cmd_prefix . " \"" . $cmd . "\""; - - `$final_cmd` + my $rc= xCAT::Utils->runcmd($final_cmd, 0); + if ($::RUNCMD_RC != 0) { + print "Failed to configure SNMP"; + } } } @@ -382,7 +386,7 @@ sub run_rspconfig { if (@config_switches) { # update switch status my $csw = join(",",@config_switches); - $cmd = "chdef $csw status=switch_configed" ; + $cmd = "chdef $csw status=switch_configured" ; $rc= xCAT::Utils->runcmd($cmd, 0); } @@ -482,7 +486,10 @@ sub config_vlan { $cmd = $cmd . "exit\;exit\;exit\;"; my $final_cmd = $cmd_prefix . " \"" . $cmd . "\""; - `$final_cmd` + my $rc= xCAT::Utils->runcmd($final_cmd, 0); + if ($::RUNCMD_RC != 0) { + print "Failed to config VLAN"; + } } } } @@ -505,7 +512,7 @@ sub usage configMellanox --switches switchnames --name configMellanox --switches switchnames --snmp - To set the ip address, hostname, config snmp and run rspconfig command: + To set the IP address, hostname, config snmp and run rspconfig command: configMellanox --switches switchnames --all To run rspconfig command: diff --git a/xCAT-server/share/xcat/scripts/configonie b/xCAT-server/share/xcat/scripts/configonie index 0e8bab746..b47aa0957 100755 --- a/xCAT-server/share/xcat/scripts/configonie +++ b/xCAT-server/share/xcat/scripts/configonie @@ -158,7 +158,7 @@ sub config_ssh { my ($exp, $errstr) = cumulus_connect($ssh_ip, $userid, $password, $timeout); if (!defined $exp) { - print ("connect failed $errstr\n"); + print ("Failed to connect to $ssh_ip, $errstr\n"); next; } @@ -198,6 +198,7 @@ sub config_ssh { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","Failed to run updatenode, please check the switch"); + print "Failed to run $cmd\n"; } $cmd = "chdef $csw status=configured"; $rc= xCAT::Utils->runcmd($cmd, 0); @@ -283,6 +284,7 @@ sub install_license { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","Failed to xscp $license_file to $switch"); + print "$switch: Failed to run $cmd\n"; next; } @@ -290,6 +292,7 @@ sub install_license { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","Failed to $cmd to $switch"); + print "$switch: Failed to run $cmd\n"; next; } #restart switchd and reload interface @@ -317,6 +320,7 @@ sub config_snmp { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","xdsh command to $switch failed"); + print "$switch: Failed to run $cmd\n"; next; } @@ -346,9 +350,10 @@ sub config_snmp { $rc= xCAT::Utils->runcmd($dshcmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","Failed to update snmpd.conf for $switch"); + print "$switch: Failed to update snmpd.conf\n"; next; } - print "Add username=$username, password=$password, privacy=$privacy, auth=$auth to snmp service for $switch \n"; + print "$switch: snmp service is configured\n"; } } @@ -400,12 +405,13 @@ sub config_ntp { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","xdsh command to $switch failed"); + print "$switch: Failed to run $cmd\n"; next; } $cmd = "xdsh $switch 'echo $timezone >/etc/timezone;dpkg-reconfigure --frontend noninteractive tzdata' "; $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - print "Failed to update ntp timezone\n"; + print "$switch: Failed to update ntp timezone\n"; xCAT::MsgUtils->message("E","Failed to update ntp timezone for $switch"); } #use ntpserver from network table if available @@ -433,6 +439,7 @@ sub config_ntp { $rc= xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message("E","Failed to update ntp for $switch"); + print "$switch: Failed to configure ntp service\n"; next; } push (@config_switches, $switch); @@ -445,7 +452,7 @@ sub config_ntp { my $csw = join(",",@config_switches); $cmd = "chdef $csw status=ntp_configured"; $rc= xCAT::Utils->runcmd($cmd, 0); - print "$csw: ntp configured\n"; + print "$csw: NTP service is configured\n"; } From ec0927d208b459c29bd2c8e02161d9bfbe37bb97 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 6 Mar 2018 01:32:39 -0500 Subject: [PATCH 6/8] modify error print of power in python --- .../agent/hwctl/executor/openbmc_power.py | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py index 567d6b825..024f455cf 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py @@ -55,14 +55,11 @@ class OpenBMCPowerTask(ParallelNodesCommand): obmc.login() states = obmc.list_power_states() state = self._determine_state(states) - result = '%s: %s' % (node, openbmc.RPOWER_STATES.get(state, state)) + self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES.get(state, state))) - except SelfServerException as e: - result = '%s: %s' % (node, e.message) - except SelfClientException as e: - result = '%s: %s' % (node, e.message) + except (SelfServerException, SelfClientException) as e: + self.callback.error(e.message, node) - self.callback.info(result) return state def get_bmcstate(self, **kw): @@ -86,13 +83,12 @@ class OpenBMCPowerTask(ParallelNodesCommand): if bmc_state != 'Ready': bmc_state = bmc_not_ready - result = '%s: %s' % (node, openbmc.RPOWER_STATES.get(bmc_state, bmc_state)) + self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES.get(bmc_state, bmc_state))) except SelfServerException, SelfClientException: # There is no response when BMC is not ready - result = '%s: %s' % (node, openbmc.RPOWER_STATES[bmc_not_ready]) + self.callback.error(openbmc.RPOWER_STATES[bmc_not_ready], node) - self.callback.info(result) return bmc_state def set_state(self, state, **kw): @@ -105,14 +101,11 @@ class OpenBMCPowerTask(ParallelNodesCommand): ret = obmc.set_power_state(state) new_status = POWER_STATE_DB.get(state, '') - result = '%s: %s' % (node, state) + self.callback.info('%s: %s' % (node, state)) if new_status: self.callback.update_node_attributes('status', node, new_status) except (SelfServerException, SelfClientException) as e: - result = '%s: %s' % (node, e.message) - - self.callback.info(result) - + self.callback.error(e.message, node) def reboot(self, optype='boot', **kw): @@ -127,7 +120,7 @@ class OpenBMCPowerTask(ParallelNodesCommand): new_status ='' if optype == 'reset' and status in ['Off', 'chassison']: status = openbmc.RPOWER_STATES['Off'] - result = '%s: %s' % (node, status) + self.callback.info('%s: %s' % (node, status)) else: if status not in ['Off', 'off']: obmc.set_power_state('off') @@ -153,13 +146,10 @@ class OpenBMCPowerTask(ParallelNodesCommand): ret = obmc.set_power_state('on') self.callback.update_node_attributes('status', node, POWER_STATE_DB['on']) - result = '%s: %s' % (node, 'reset') + self.callback.info('%s: %s' % (node, 'reset')) except (SelfServerException, SelfClientException) as e: - result = '%s: %s' % (node, e.message) - - self.callback.info(result) - + self.callback.error(e.message, node) def reboot_bmc(self, optype='warm', **kw): @@ -170,13 +160,12 @@ class OpenBMCPowerTask(ParallelNodesCommand): try: obmc.login() except (SelfServerException, SelfClientException) as e: - result = '%s: %s' % (node, e.message) + self.callback.error(e.message, node) else: try: obmc.reboot_bmc(optype) except (SelfServerException, SelfClientException) as e: - result = '%s: %s' % (node, e.message) + self.callback.error(e.message, node) else: - result = '%s: %s' % (node, openbmc.RPOWER_STATES['bmcreboot']) - self.callback.info(result) + self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES['bmcreboot'])) From 804b132605248c803e69ef0571b305d0015e2cce Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Tue, 6 Mar 2018 16:13:02 +0800 Subject: [PATCH 7/8] clear cache for IP change case in node discovery(#4890) (#4891) --- perl-xCAT/xCAT/NetworkUtils.pm | 20 ++++++++++++++++++++ xCAT-server/lib/xcat/plugins/aaadiscovery.pm | 3 +++ 2 files changed, 23 insertions(+) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index cb01ca93e..e3871e3f4 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -388,6 +388,26 @@ sub getipaddr #------------------------------------------------------------------------------- +=head3 clearcache + Workaround: Clear the IP address cache in case that the long running process + (discovery/install monitor) could work as normal when the node's IP address + is changed. + Globals: + cache: %::hostiphash + Error: + none + Example: + xCAT::NetworkUtils->clearcache(); +=cut + +#------------------------------------------------------------------------------- +sub clearcache +{ + undef %::hostiphash; +} + +#------------------------------------------------------------------------------- + =head3 linklocaladdr Only for IPv6. Takes a mac address, calculate the IPv6 link local address diff --git a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm index e52123d80..55f44162e 100644 --- a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm @@ -8,6 +8,7 @@ BEGIN } use lib "$::XCATROOT/lib/perl"; use xCAT::DiscoveryUtils; +use xCAT::NetworkUtils; sub handled_commands { return { @@ -51,6 +52,8 @@ sub process_request { xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($mac) Got a discovery request, attempting to discover the node..."); $req->{discoverymethod}->[0] = 'undef'; $req->{_xcat_clientmac}->[0] = $mac; + #Workaround (#4890) for IP changed cases. + xCAT::NetworkUtils->clearcache(); xCAT::DiscoveryUtils->update_discovery_data($req); return; } From 3502b9a5b7f12cc4be80bade2e2c8feec614d24a Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 6 Mar 2018 03:57:58 -0500 Subject: [PATCH 8/8] tag for openbmc perl --- xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py | 2 +- xCAT-server/lib/xcat/plugins/openbmc.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py index 8b1dc1605..bddeec94a 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py @@ -305,7 +305,7 @@ class OpenBMCRest(object): self._log_request(method, url, httpheaders, data=data, cmd=cmd) try: - response = self.session.request(method, url, httpheaders, data=data) + response = self.session.request(method, url, httpheaders, data=data, timeout=timeout) return self.handle_response(response, cmd=cmd) except SelfServerException as e: e.message = 'Error: BMC did not respond. ' \ diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 5d2b67187..af5983180 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -703,7 +703,7 @@ my %allerrornodes = (); my $xcatdebugmode = 0; -my $flag_debug = "[openbmc_debug]"; +my $flag_debug = "[openbmc_debug_perl]"; my %login_pid_node; # used in process_request, record login fork pid map