2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 09:13:08 +00:00

Merge pull request #4836 from whowutwut/openbmc_python_requirements

Build xCAT-openbmc-py, improve message when debugging missing dependencies in the python agent
This commit is contained in:
Mark Gurevich 2018-02-21 09:24:39 -05:00 committed by GitHub
commit 41c86021be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 52 deletions

View File

@ -70,7 +70,7 @@ if [ -z "$UP" ]; then
fi
# These are the rpms that should be built for each kind of xcat build
ALLBUILD="perl-xCAT xCAT-client xCAT-server xCAT-test xCAT-buildkit xCAT xCATsn xCAT-genesis-scripts xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe xCAT-csm"
ALLBUILD="perl-xCAT xCAT-client xCAT-server xCAT-test xCAT-buildkit xCAT xCATsn xCAT-genesis-scripts xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe xCAT-csm xCAT-openbmc-py"
ZVMBUILD="perl-xCAT xCAT-server xCAT-UI"
ZVMLINK="xCAT-client xCAT xCATsn"
# xCAT and xCATsn have PCM specific configuration - conserver-xcat, syslinux-xcat
@ -323,7 +323,7 @@ if [ "$OSNAME" = "AIX" ]; then
fi
# Build the rest of the noarch rpms
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-buildkit xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe xCAT-csm; do
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-buildkit xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe xCAT-csm xCAT-openbmc-py; do
if [[ " $EMBEDBUILD " != *\ $rpmname\ * ]]; then continue; fi
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi # do not build xCAT-buildkit on aix
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-SoftLayer" ]; then continue; fi # do not build xCAT-softlayer on aix

View File

@ -1,38 +0,0 @@
#!/bin/bash
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
function makepythonrpm {
RPMNAME="$1"
SPEC_FILE="$RPMNAME/$RPMNAME.spec"
RPMROOT=`rpmbuild --eval '%_topdir' ${SPEC_FILE}`
mkdir -p $RPMROOT/SOURCES
tar --exclude .svn -czvf $RPMROOT/SOURCES/$RPMNAME-${VER}.tar.gz $RPMNAME
rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm
echo "Building $RPMROOT/RPMS/noarch/$RPMNAME-$VER-snap*.noarch.rpm $EMBEDTXT..."
rpmbuild --quiet -ta $RPMROOT/SOURCES/$RPMNAME-${VER}.tar.gz --define "version $VER" $REL "$EASE"
if [ $? -eq 0 ]; then
exit 0
else
exit 1
fi
}
# Main code....
OSNAME=$(uname)
VER=`cat Version`
REL="--define"
EASE='usedate 1'
rpmbuild --version > /dev/null
if [ $? -gt 0 ]; then
echo "Error: rpmbuild does not appear to be installed or working."
exit 2
fi
if [ -n "$1" -a "$1" = "xCAT-openbmc-py" ]; then
makepythonrpm $1
else
echo 'Usage: makepythonrpm xCAT-openbmc-py'
exit 1
fi

View File

@ -14,8 +14,8 @@ class BaseManager(object):
module_name = 'xcatagent.%s' % name
try:
__import__(module_name)
except ImportError:
return None
except ImportError as err:
raise ImportError(err)
class_name = MODULE_MAP[name]
return utils.class_func(module_name, class_name)

View File

@ -70,19 +70,19 @@ sub acquire_lock {
}
sub start_python_agent {
if (! -e $PYTHON_AGENT_FILE) {
xCAT::MsgUtils->message("S", "'$PYTHON_AGENT_FILE' does not exist");
xCAT::MsgUtils->message("S", "start_python_agent() Error: '$PYTHON_AGENT_FILE' does not exist");
return undef;
}
if (!defined(acquire_lock())) {
xCAT::MsgUtils->message("S", "Error: Faild to require lock");
xCAT::MsgUtils->message("S", "start_python_agent() Error: Failed to acquire lock");
return undef;
}
my $fd;
open($fd, '>', $AGENT_SOCK_PATH) && close($fd);
my $pid = fork;
if (!defined $pid) {
xCAT::MsgUtils->message("S", "Error: Unable to fork process");
xCAT::MsgUtils->message("S", "start_python_agent() Error: Unable to fork process");
return undef;
}
$SIG{CHLD} = 'DEFAULT';
@ -93,7 +93,7 @@ sub start_python_agent {
open(STDERR, '>>&', \*STDOUT) or die("open: $!");
my $ret = exec ($PYTHON_AGENT_FILE);
if (!defined($ret)) {
xCAT::MsgUtils->message("S", "Error: Failed to start python agent");
xCAT::MsgUtils->message("S", "start_python_agent() Error: Failed to start the xCAT Python agent.");
exit(1);
}
}
@ -194,7 +194,7 @@ sub wait_agent {
my ($pid, $callback) = @_;
waitpid($pid, 0);
if ($? >> 8 != 0) {
xCAT::MsgUtils->message("E", { data => ["python agent exited unexpectedly"] }, $callback);
xCAT::MsgUtils->message("E", { data => ["python agent exited unexpectedly. See $PYTHON_LOG_PATH for more details."] }, $callback);
}
}

View File

@ -127,6 +127,14 @@ sub preprocess_request {
sub process_request {
my $request = shift;
$callback = shift;
# If we can't start the python agent, exit immediately
my $pid = xCAT::OPENBMC::start_python_agent();
if (!defined($pid)) {
xCAT::MsgUtils->message("E", { data => ["Failed to start the xCAT Python agent. Check /var/log/xcat/cluster.log for more information."] }, $callback);
return;
}
my $noderange = $request->{node};
my $check = parse_node_info($noderange);
if (&refactor_args($request)) {
@ -135,11 +143,6 @@ sub process_request {
}
$callback->({ errorcode => [$check] }) if ($check);
return unless(%node_info);
my $pid = xCAT::OPENBMC::start_python_agent();
if (!defined($pid)) {
xCAT::MsgUtils->message("E", { data => ["Failed to start python agent"] }, $callback);
return;
}
xCAT::OPENBMC::submit_agent_request($pid, $request, \%node_info, $callback);
xCAT::OPENBMC::wait_agent($pid, $callback);