mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-09-07 02:38:15 +00:00
Merge pull request #4893 from xcat2/master
Merge master to 2.13 for 2.13.11 release(2)
This commit is contained in:
@@ -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**.
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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']))
|
||||
|
||||
|
@@ -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. ' \
|
||||
|
@@ -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)
|
||||
|
@@ -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,63 +195,32 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
@@ -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 = {};
|
||||
|
@@ -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};
|
||||
|
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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:
|
||||
|
@@ -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:
|
||||
|
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
|
@@ -17,6 +17,7 @@ conf_file_bak="/etc/resolv.conf.bak"
|
||||
# get values set when the myxcatpost_<node> 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,15 @@ 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
|
||||
grep -q $ns $conf_file || \
|
||||
echo "nameserver ${ns/<xcatmaster>/$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
|
||||
|
Reference in New Issue
Block a user