2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-05-16 11:24:16 +00:00

Merge pull request #5077 from xcat2/master

Merge master to 2.14 for regression test
This commit is contained in:
zet809
2018-04-10 17:38:52 +08:00
committed by GitHub
18 changed files with 174 additions and 40 deletions
@@ -75,7 +75,7 @@ The REST API client needs to download the xCAT certificate CA from the xCAT http
When accessing the REST API, the certificate CA must be specified and the FQDN of the https server must be used. For example: ::
curl -X GET --cacert /root/ca-cert.pem 'https://<FQDN of xCAT MN>/xcatws/nodes?userName=root& userPW=cluster'
curl -X GET --cacert /root/ca-cert.pem 'https://<FQDN of xCAT MN>/xcatws/nodes?userName=root&userPW=<root-pw>'
Extend the Timeout of Web Server
================================
@@ -83,10 +83,10 @@ Extend the Timeout of Web Server
Some operations like 'create osimage' (copycds) need a long time (longer than 3 minutes sometimes) to complete. It would fail with a ``timeout error`` (504 Gateway Time-out) if the timeout setting in the web server is not extended: ::
For [RHEL]
sed -i 's/^Timeout.*/Timeout 600/' /etc/httpd/conf/httpd.conf
service htttd restart
Edit "/etc/httpd/conf/httpd.conf" and change existing or add new entry: "Timeout 600"
service httpd restart
For [SLES]
echo "Timeout 600" >> /etc/apache2/httpd.conf
Edit "/etc/apache2/httpd.conf" and change existing or add new entry: "Timeout 600"
service apache2 restart
Set Up an Account for Web Service Access
@@ -114,16 +114,27 @@ Use non-root Account
Create new user and setup the password and policy rules. ::
useradd wsuser
passwd wsuser # set the password
tabch key=xcat,username=wsuser passwd.password=cluster
mkdef -t policy 6 name=wsuser rule=allow
# create a user
useradd -u <wsuid> <wsuser>
# set the password
passwd <wsuser>
# add password to passwd table
tabch key=xcat,username=<wsuser> passwd.password=<wspw>
# add user to policy table
mkdef -t policy 6 name=<wsuser> rule=allow
``Note:`` in the tabch command above you can put the salted password (from /etc/shadow) in the xCAT passwd table instead of the clear text password, if you prefer.
Identical user with the same name and uid need to be created on each compute node. ::
# create a user
useradd -u <wsuid> <wsuser>
# set the password
passwd <wsuser>
Create the SSL certificate under that user's home directory so that user can be authenticated to xCAT. This is done by running the following command on the Management node as root: ::
/opt/xcat/share/xcat/scripts/setup-local-client.sh <username>
/opt/xcat/share/xcat/scripts/setup-local-client.sh <wsuser>
When running this command you'll see SSL certificates created. Enter "y" where prompted and take the defaults.
@@ -133,11 +144,13 @@ To enable the POST method of resources like nodeshell, nodecopy, updating and fi
Run a test request to see if everything is working: ::
curl -X GET --cacert /root/ca-cert.pem 'https://<xcat-mn-host>/xcatws/nodes?userName=<user>&userPW=<password>'
curl -X GET --cacert /root/ca-cert.pem 'https://<xcat-mn-host>/xcatws/nodes?userName=<wsuser>&userPW=<wspw>'
or if you did not set up the certificate: ::
curl -X GET -k 'https://<xcat-mn-host>/xcatws/nodes?userName=<user>&userPW=<password>'
curl -X GET -k 'https://<xcat-mn-host>/xcatws/nodes?userName=<wsuser>&userPW=<wspw>'
You should see some output that includes your list of nodes.
If errors returned, check `/var/log/httpd/ssl_error_log` on xCAT MN.
@@ -54,6 +54,7 @@ class ParallelNodesCommand(BaseCommand):
"""
self.inventory = inventory
self.callback = callback
self.cwd = kwargs.get('cwd')
self.debugmode = kwargs.get('debugmode')
self.verbose = kwargs.get('verbose')
@@ -98,7 +98,7 @@ def mask_int2str(mask_int):
def get_full_path(cwd, directory):
if not os.path.isabs(directory):
directory = '%s/%s' % (cwd, directory)
directory = os.path.join(cwd, directory)
return directory
class Messager(object):
@@ -301,9 +301,10 @@ rmdir \"/tmp/$userid\" \n")
def _set_hostname(self, hostname, **kw):
node = kw['node']
if hostname == '*':
if kw['nodeinfo']['bmc'] == kw['nodeinfo']['bmcip']:
self.callback.info("%s: set BMC ip as BMC Hostname" % node)
hostname = kw['nodeinfo']['bmc']
if kw['nodeinfo']['bmc'] != kw['nodeinfo']['bmcip']:
hostname = kw['nodeinfo']['bmc']
else:
return self.callback.error("Invalid OpenBMC Hostname %s, can't set to OpenBMC" % kw['nodeinfo']['bmc'], node)
self._set_apis_values("hostname", hostname, **kw)
self._get_netinfo(hostname=True, ntpserver=False, **kw)
return
@@ -383,7 +384,15 @@ rmdir \"/tmp/$userid\" \n")
try:
obmc.login()
obmc.set_apis_values(key, value)
except (SelfServerException, SelfClientException) as e:
except SelfServerException as e:
return self.callback.error(e.message, node)
except SelfClientException:
if e.code == 404:
return self.callback.error('404 Not Found - Requested endpoint does not exist or may \
indicate function is not supported on this OpenBMC firmware.', node)
if e.code == 403:
return self.callback.error('403 Forbidden - Requested endpoint does not exist or may \
indicate function is not yet supported by OpenBMC firmware.', node)
return self.callback.error(e.message, node)
self.callback.info("%s: BMC Setting %s..." % (node, openbmc.RSPCONFIG_APIS[key]['display_name']))
@@ -396,7 +405,15 @@ rmdir \"/tmp/$userid\" \n")
obmc.login()
value = obmc.get_apis_values(key)
except (SelfServerException, SelfClientException) as e:
except SelfServerException as e:
return self.callback.error(e.message, node)
except SelfClientException:
if e.code == 404:
return self.callback.error('404 Not Found - Requested endpoint does not exist or may \
indicate function is not supported on this OpenBMC firmware.', node)
if e.code == 403:
return self.callback.error('403 Forbidden - Requested endpoint does not exist or may \
indicate function is not yet supported by OpenBMC firmware.', node)
return self.callback.error(e.message, node)
if isinstance(value, dict):
@@ -34,7 +34,7 @@ class OpenBMCInventoryTask(ParallelNodesCommand):
if 'version=' in line:
version = line.split('=')[-1].strip()
if 'purpose=' in line:
purpose = line.split('=')[-1].strip().split('.')[-1]
purpose = line.split('=')[-1].strip()
if version and purpose:
break
@@ -190,6 +190,9 @@ class OpenBMCManager(base.BaseManager):
try:
opts = docopt(rflash_usage, argv=args)
self.verbose = opts.pop('--verbose')
except DocoptExit as e:
self.messager.error("Failed to parse args by docopt: %s" % e)
return
except Exception as e:
self.messager.error("Failed to parse arguments for rflash: %s" % args)
return
+2 -2
View File
@@ -2423,7 +2423,7 @@ sub deal_with_response {
my $log_id = (split ('/', $cur_url))[5];
$error = "Invalid ID=$log_id provided to be resolved. [$::RESPONSE_FORBIDDEN]";
} else{
$error = "$::RESPONSE_FORBIDDEN - Requested endpoint does not exists and may indicate function is not yet supported by OpenBMC firmware.";
$error = "$::RESPONSE_FORBIDDEN - Requested endpoint does not exist or may indicate function is not yet supported by OpenBMC firmware.";
}
# Handle 404
} elsif ($response->status_line eq $::RESPONSE_NOT_FOUND) {
@@ -2434,7 +2434,7 @@ sub deal_with_response {
$error = "Invalid ID provided to delete. Use the -l option to view valid firmware IDs.";
} elsif (($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_QUERY_RESPONSE") ||
($node_info{$node}{cur_status} eq "RSPCONFIG_API_CONFIG_ATTR_RESPONSE")) {
$error = "$::RESPONSE_NOT_FOUND - Requested endpoint does not exists and may indicate function is not supported on this OpenBMC firmware.";
$error = "$::RESPONSE_NOT_FOUND - Requested endpoint does not exist or may indicate function is not supported on this OpenBMC firmware.";
} else {
$error = "[" . $response->code . "] " . $response_info->{'data'}->{'description'};
}
+17
View File
@@ -508,6 +508,23 @@ sub refactor_args {
unshift @$extrargs, "list";
}
}
if ($command eq "rflash") {
my @new_args = ('') x 4;
foreach my $tmp (@$extrargs) {
if ($tmp =~ /^-/) {
if ($tmp !~ /^-V$|^--verbose$/) {
$new_args[0] = $tmp;
} elsif ($tmp =~ /^--no-host-reboot$/) {
$new_args[2] = $tmp;
} else {
$new_args[3] = $tmp;
}
} else {
$new_args[1] = $tmp;
}
}
@$extrargs = grep(/.+/, @new_args);
}
return 0;
}
+1
View File
@@ -356,6 +356,7 @@ sub runpgsqlcmd
if ($? > 0) # error
{
$rc = $? >> 8;
$cmd = "PGPASSWORD=xxxxxx $psql -d $dbname -h $hostname -U $admin -f $file ";
xCAT::MsgUtils->message("SE",
"The command $cmd had errors. Return=$rc");
}
+5 -1
View File
@@ -409,7 +409,7 @@ sub do_installm_service {
}
}
$conn_peer_addr = $conn->peerhost();
xCAT::MsgUtils->trace(0, "I", "xcatd: received a connection request from $conn_peer_addr");
xCAT::MsgUtils->trace(0, "I", "xcatd: install monitor received a connection request from $conn_peer_addr");
my $client_name;
my $client_aliases;
@@ -590,11 +590,15 @@ sub do_installm_service {
`/usr/bin/cat $myfile | /usr/bin/sed "/BASECUST_REMOVAL/d">/tmp/$text.nimtmp`;
`/usr/bin/mv /tmp/$text.nimtmp $myfile`;
close($conn);
} elsif ($text =~ /installmonitor/) {
xCAT::MsgUtils->trace(0, "I", "xcatd: handle installmonitor requesting from $text...");
close($conn);
} else {
sleep 0.01;
chomp $text;
xCAT::MsgUtils->trace(0, "E", "xcatd: install monitor does not support \'$text\', the connection request from $conn_peer_addr will be ignored.");
close($conn); #close it to avoid the DDOS attack
alarm(2);
next;
}
xCAT::MsgUtils->trace(0, "I", "xcatd: finish a connection request for $node from $conn_peer_addr");
+1 -2
View File
@@ -53,10 +53,9 @@ cmd:xdsh $$CN "rm -rf /tmp/go-xcat.log"
cmd:migration_version=`echo $$MIGRATION2_VERSION |cut -d "." -f -2`; xdsh $$CN "cd /; ./go-xcat -x $migration_version -y install"
check:rc==0
cmd:xdsh $$CN "cat /tmp/go-xcat.log"
cmd:xdsh $$CN "source /etc/profile.d/xcat.sh;lsxcatd -v"
cmd:xdsh $$CN "source /etc/profile.d/xcat.sh;lsxcatd -v" |tee /tmp/version
check:rc==0
cmd:migration_version=`echo $$MIGRATION2_VERSION |cut -d "." -f -2`;cd /;if grep Ubuntu /etc/*release;then cd / ; wget http://xcat.org/files/xcat/repos/apt/$migration_version/xcat-core/buildinfo;else cd / ; wget http://xcat.org/files/xcat/repos/yum/$migration_version/xcat-core/buildinfo; fi
cmd:xdsh $$CN "lsxcatd -v" |tee /tmp/version
cmd:if [ -e /buildinfo ]; then xcatversion=`grep VERSION /buildinfo |awk -F'=' '{print $2}'`;grep $xcatversion /tmp/version; fi
check:rc==0
cmd:migration_version=`echo $$MIGRATION2_VERSION |cut -d "." -f -2`;grep $migration_version /tmp/version
@@ -116,7 +116,7 @@ cmd:xdsh $$SN "service httpd status"
check:rc==0
cmd:xdsh $$SN "service systemd status"
#check:rc==0
cmd:xdsh $$SN "cat /var/log/xcat/xcat.log"
cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-netboot-service|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.org ]; then rm -rf $rootimgdir; mv $rootimgdir.org $rootimgdir; fi
check:rc==0
cmd:xdsh $$SN "cat /var/log/xcat/xcat.log"
@@ -90,7 +90,7 @@ check:output=~/install on /install
cmd:xdsh $$SN "mount"
check:rc==0
check:output=~/tftpboot on /tftpboot
cmd:xdsh $$SN "cat /var/log/xcat/xcat.log"
cmd:if [[ "__GETNODEATTR($$SN,arch)__" =~ "x86_64" ]]; then if [[ "__GETNODEATTR($$SN,os)__" =~ "sles" ]];then xdsh $$SN "zypper -n install perl-Sys-Virt"; elif [[ "__GETNODEATTR($$SN,os)__" =~ "rh" ]];then xdsh $$SN "yum install -y perl-Sys-Virt";fi;fi
check:rc==0
cmd:makentp -a
+1 -1
View File
@@ -33,7 +33,7 @@ cmd:reventlog $$CN 10 -s 1
check:output=~The -s option is not supported for OpenBMC
check:rc!=0
cmd:reventlog $$CN -s all
check:output=~The -s option is not supported for OpenBMC
check:output=~The -s option is not supported for OpenBMC|Only one option is supported at the same time for reventlog
check:rc!=0
cmd:reventlog $$CN -s
check:output=~Error: Unsupported command
@@ -448,22 +448,19 @@ check:rc != 0
cmd:mkdir -p /tmp/bogus123
check:rc == 0
cmd:rflash $$CN /tmp/bogus123 -d
check:output =~Error: No BMC tar file found
check:output =~Error: No Host tar file found
check:output =~Error: No BMC tar file found|Can't open directory
check:output!~Attempting to
check:rc != 0
cmd:touch /tmp/bogus123/obmc-phosphor-image-witherspoon.ubi.mtd.tar
check:rc == 0
cmd:rflash $$CN -d /tmp/bogus123
check:output =~Error: No BMC tar file found
check:output =~Error: No Host tar file found
check:output =~Error: No BMC tar file found|Can't open directory
check:output!~Attempting to
check:rc != 0
cmd:touch /tmp/bogus123/witherspoon.pnor.squashfs.tar
check:rc == 0
cmd:rflash $$CN -d /tmp/bogus123
check:output =~Error: No BMC tar file found
check:output =~Error: No Host tar file found
check:output =~Error: No BMC tar file found|Can't open directory
check:output!~Attempting to
check:rc != 0
cmd:rm -rf /tmp/bogus123
+5 -6
View File
@@ -127,7 +127,7 @@ start:rspconfig_set_vlan
description:rspconfig change openbmc gateway
Attribute: $$CN-The operation object of rspconfig command
cmd:rspconfig $$CN vlan=0
check:output=~Error: Invalid parameter for option vlan
check:output=~Error: Invalid parameter for option vlan|Error: VLAN must be configured with IP, netmask and gateway
check:rc!=0
cmd:rspconfig $$CN vlan=111
check:output=~Error: VLAN must be configured with IP, netmask and gateway
@@ -258,6 +258,7 @@ check:rc == 0
cmd:rspconfig $$CN hostname=*
check:rc == 0
check:output =~ Invalid OpenBMC Hostname
cmd:ssh __GETNODEATTR(f6u03,bmc)__ "hostname"
end
@@ -342,17 +343,15 @@ cmd:rspconfig $$CN sshcfg
check:rc == 0
cmd:ssh __GETNODEATTR($$CN,bmc)__ "hostname" | tee /tmp/rspconfig_set_hostname/working_hostname
check:rc == 0
cmd:cat /tmp/rspconfig_set_hostname/working_hostname
check:rc == 0
cmd:a=$(cat /tmp/rspconfig_set_hostname/working_hostname); rspconfig $$CN hostname=test_$a |tee /tmp/rspconfig_set_hostname/rspconfig_output
check:rc == 0
cmd:grep -i 'BMC hostname' /tmp/rspconfig_set_hostname/rspconfig_output|awk -F':' '{print $3}' |sed s/\\s//g > /tmp/rspconfig_set_hostname/rspconfig_get_hostname
cmd:grep -i '$$CN: BMC hostname:' /tmp/rspconfig_set_hostname/rspconfig_output|awk -F':' '{print $3}' |sed s/\\s//g |tee /tmp/rspconfig_set_hostname/rspconfig_get_hostname
check:rc == 0
cmd:ssh __GETNODEATTR($$CN,bmc)__ "hostname" | tee /tmp/rspconfig_set_hostname/new_working_hostname
check:rc == 0
cmd:diff /tmp/rspconfig_set_hostname/rspconfig_get_hostname /tmp/rspconfig_set_hostname/new_working_hostname
cmd:diff -y /tmp/rspconfig_set_hostname/rspconfig_get_hostname /tmp/rspconfig_set_hostname/new_working_hostname
check:rc == 0
cmd:diff /tmp/rspconfig_set_hostname/new_working_hostname /tmp/rspconfig_set_hostname/working_hostname
cmd:diff -y /tmp/rspconfig_set_hostname/new_working_hostname /tmp/rspconfig_set_hostname/working_hostname
check:rc != 0
cmd:a=test_$(cat /tmp/rspconfig_set_hostname/working_hostname);b=$(cat /tmp/rspconfig_set_hostname/new_working_hostname);echo "a=$a b=$b";if [ "$a" = "$b" ];then exit 0;else exit 1; fi
check:rc == 0
+85
View File
@@ -0,0 +1,85 @@
#!/bin/bash
if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then
str_dir_name=`dirname $0`
. $str_dir_name/xcatlib.sh
fi
#---------------------------------------------------------------------------
#=head1 enablecapi
#=head2 enable CAPI and tunnel Atomics for compute nodes
# at least MOFED 4.3.1 has to be installed and only support on ConnectX5
#
# updatenode <node> enablecapi
#
#---------------------------------------------------------------------------
function logerr {
echo "$@"
logger -t xcat -p local4.err $@
}
#check if mlnx ofed commands are installed
COMMANDS="ofed_info mst mlxconfig"
for CMD in ${COMMANDS}; do
RC=`command -v ${CMD} >> /dev/nul 2>&1; echo $?`
if [[ ${RC} != 0 ]]; then
ERRMSG="Command: ${CMD} is not found, unable to run the scripts"
logerr $ERRMSG
exit 1
fi
done
#mofed version at least 4.3-1
version=`/usr/bin/ofed_info -n`
majorversion=`echo $version | cut -d- -f1`
minorversion=`echo $version | cut -d- -f2`
if (( $(echo "$majorversion < 4.3" |bc -l) )); then
ERRMSG="Current MOFED version is $version and needs to be at least 4.3-1"
logerr $ERRMSG
exit 1
fi
if (( $(echo "$majorversion == 4.3" |bc -l) )); then
minor=`echo $minorversion | cut -d. -f1`
if (( $(echo "$minor < 1") )); then
ERRMSG="Current MOFED version is $version and needs to be at least 4.3-1"
logerr $ERRMSG
exit 1
fi
fi
service mst restart >/dev/null 2>&1
if [ "$?" != "0" ] ;then
ERRMSG "[Error] failed to start mst."
logerr $ERRMSG
exit 1
fi
reboot_flag=0
for x in `ls /dev/mst/mt*`
do
mlxconfig -y -d $x q | grep 'ConnectX5' >/dev/null 2>&1
if [ $? == 0 ]; then
mlxconfig -y -d $x set ADVANCED_PCI_SETTINGS=true >/dev/null 2>&1
mlxconfig -y -d $x set IBM_CAPI_EN=true >/dev/null 2>&1
mlxconfig -y -d $x set IBM_TUNNELED_ATOMIC_EN=true >/dev/null 2>&1
mlxconfig -y -d $x set IBM_AS_NOTIFY_EN=true >/dev/null 2>&1
echo "Apply new Configuration for $x:"
mlxconfig -y -d $x q | grep 'IBM'
reboot_flag=1
fi
done
if [[ $reboot_flag == 0 ]]; then
echo "Didn't find ConnectX5 Devices, will not apply the new configuration"
else
echo "******************************************************"
echo " New configuration applied"
echo " Please reboot system to load new configurations"
echo "******************************************************"
fi
exit 0
-2
View File
@@ -56,8 +56,6 @@ then
#delete all occurance of the attribute and then add xCAT settings
sed -i '/X11Forwarding /'d /etc/ssh/sshd_config
echo "X11Forwarding yes" >>/etc/ssh/sshd_config
sed -i '/KeyRegenerationInterval /'d /etc/ssh/sshd_config
echo "KeyRegenerationInterval 0" >>/etc/ssh/sshd_config
sed -i '/MaxStartups /'d /etc/ssh/sshd_config
echo "MaxStartups 1024" >>/etc/ssh/sshd_config