From 79fc3de99857647772f5834e72ef151a346c3f8c Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 20 Feb 2018 16:19:31 -0500 Subject: [PATCH 1/2] Build xCAT-openbmc-py with the makerpm script, it is identical to the makerpm-python. --- buildcore.sh | 4 ++-- makerpm-python | 38 -------------------------------------- 2 files changed, 2 insertions(+), 40 deletions(-) delete mode 100755 makerpm-python diff --git a/buildcore.sh b/buildcore.sh index bab8ce3b0..1b41b4b1c 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -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 diff --git a/makerpm-python b/makerpm-python deleted file mode 100755 index 8718e7ae5..000000000 --- a/makerpm-python +++ /dev/null @@ -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 - From f19c936638c72ecc98cc51ca6eaa228379652691 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 20 Feb 2018 16:20:13 -0500 Subject: [PATCH 2/2] Change some code in the python framework so that it's easier to debug issues in configuration when moving to python for OpenBMC --- xCAT-openbmc-py/lib/python/agent/xcatagent/base.py | 4 ++-- xCAT-server/lib/perl/xCAT/OPENBMC.pm | 10 +++++----- xCAT-server/lib/xcat/plugins/openbmc2.pm | 13 ++++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/base.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/base.py index bf58ef628..d75bd7f00 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/base.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/base.py @@ -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) diff --git a/xCAT-server/lib/perl/xCAT/OPENBMC.pm b/xCAT-server/lib/perl/xCAT/OPENBMC.pm index 783a9e30e..3fc6fc1aa 100644 --- a/xCAT-server/lib/perl/xCAT/OPENBMC.pm +++ b/xCAT-server/lib/perl/xCAT/OPENBMC.pm @@ -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); } } diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index efd38e9e0..439c99dc6 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -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);