Compare commits

..

4 Commits

652 changed files with 14467 additions and 46578 deletions

View File

@ -1 +1 @@
2.10
2.9

View File

@ -1,88 +0,0 @@
#!/bin/bash
###########
#
# This script call make<package>deb and create the deb packages
# for xCAT
#
# Author: Leonardo Tonetto <tonetto@linux.vnet.ibm.com>
# Revisor: Adalberto Medeiros <adalbas@linux.vnet.ibm.com>
# Revisor2: Arif Ali <aali@ocf.co.uk>
#
# Input:
#
# $1 is the build type/location
# $2 is the string added to the debian/changelog of each package
#
############
##############
# Get input
##############
PKG_LOCATION=$1 # local | snap | alpha
if [ -z $PKG_LOCATION ]; then
PKG_LOCATION="local"
fi
BUILD_STRING=$2
if [ -z $BUILD_STRING ]; then
BUILD_STRING="Personal Build"
fi
XCAT_VERSION=`cat Version`
TRUNK_REVISION=`svnversion | cut -d ":" -f1`
CUR_DATE=`date +%Y%m%d`
VERSION="${XCAT_VERSION}-${PKG_LOCATION}${CUR_DATE}"
function makedeb {
SRC_ROOT=$1
PKG_LOCATION=$2
BUILD_STRING=$3
VERSION=$4
#
# Make DEBs
#
# build perl-xCAT - deps are libsoap-lite-perl, libdigest-sha1-perl, libdbi-perl
#
find $SRC_ROOT -maxdepth 2 -name debian -type d | while read DEBIAN_DIR
do
DIR=`echo ${DEBIAN_DIR} | sed -e 's/[/]debian$//'`
cd ${DIR}
dch -v $VERSION -b -c debian/changelog "$BUILD_STRING"
dpkg-buildpackage
cd -
RC=$?
if [ ${RC} -gt 0 ]
then
echo "Warning: ${DEBIAN_DIR} failed exit code ${RC}"
fi
done
#
# Clean up
#
# Eliminate unnecessary directories and debian/files made by dpkg-buildpackage
find $SRC_ROOT -maxdepth 3 -type d -name "xcat-*" | grep debian | xargs rm -rf
find $SRC_ROOT -maxdepth 3 -type f -name "files" | grep debian | xargs rm -f
}
# build all debian packages
packages="xCAT-client xCAT-nbroot xCAT-nbroot2 perl-xCAT xCAT-server xCAT-UI xCAT xCATsn xCAT-test xCAT-IBMhpc xCAT-rmc xCAT-vlan xCAT-confluent"
for file in `echo $packages`
do
makedeb $file $PKG_LOCATION "$BUILD_STRING" $VERSION
done
if [ -d debs ]; then
rm -rf debs
fi
mkdir debs
mv xcat* debs/
mv perl-xcat* debs/
echo $VERSION > latest_version
exit 0

View File

@ -27,7 +27,6 @@
# release this build, use PROMOTE=1 without PREGA
# BUILDALL=1 - build all rpms, whether they changed or not. Should be used for snap builds that are in prep for a release.
# UP=0 or UP=1 - override the default upload behavior
# LOG=<filename> - provide an LOG file option to redirect some output into log file
#
# For the dependency packages 1. please run the build-debs-all in xcat-dep svn first( there is usage detail in that script)
# 2. run ./build-ubunturepo -d
@ -54,7 +53,7 @@ for i in $*; do
done
# Supported distributions
dists="saucy trusty utopic"
dists="maverick natty oneiric precise saucy"
c_flag= # xcat-core (trunk-delvel) path
d_flag= # xcat-dep (trunk) path
@ -87,7 +86,7 @@ if [ "$c_flag" -a "$d_flag" ];then
exit 2
fi
uploader="ligc"
uploader="bp-sawyers"
# Find where this script is located to set some build variables
old_pwd=`pwd`
cd `dirname $0`
@ -95,7 +94,8 @@ curdir=`pwd`
#define the dep source code path, core build target path and dep build target path
local_core_repo_path="$curdir/../../xcat-core"
local_dep_repo_path="$curdir/../../xcat-dep/xcat-dep"
xcat_dep_path="$curdir/../../../xcat-dep/src/xcat-dep"
local_dep_repo_path="$curdir/../../../xcat-dep/xcat-dep"
#define the url used for creating the source list file
#define the upload dir used for uploading packages
@ -112,18 +112,13 @@ fi
export HOME=/root
WGET_CMD="wget"
if [ ! -z ${LOG} ]; then
WGET_CMD="wget -o ${LOG}"
fi
#sync the gpg key to the build machine local
gsa_url=http://pokgsa.ibm.com/projects/x/xcat/build/linux
mkdir -p $HOME/.gnupg
for key_name in pubring.gpg secring.gpg trustdb.gpg; do
if [ ! -f $HOME/.gnupg/$key_name ] || [ `wc -c $HOME/.gnupg/$key_name|cut -f 1 -d' '` == 0 ]; then
rm -f $HOME/.gnupg/$key_name
${WGET_CMD} -P $HOME/.gnupg $gsa_url/keys/$key_name
wget -P $HOME/.gnupg $gsa_url/keys/$key_name
chmod 600 $HOME/.gnupg/$key_name
fi
done
@ -199,40 +194,27 @@ then
if [ ! -d ../../$package_dir_name ];then
mkdir -p "../../$package_dir_name"
fi
packages="xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT xCATsn xCAT-test xCAT-buildkit xCAT-vlan xCAT-confluent"
target_archs=(amd64 ppc64el)
packages="xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT-UI xCAT xCATsn xCAT-test xCAT-OpenStack xCAT-OpenStack-baremetal"
for file in `echo $packages`
do
file_low=`echo $file | tr '[A-Z]' '[a-z]'`
if [ "$file" = "xCAT" -o "$file" = "xCAT-genesis-scripts" ]; then
target_archs="amd64 ppc64el"
else
target_archs="all"
fi
for target_arch in `echo $target_archs`
do
if grep -q $file $update_log || [ "$BUILDALL" == 1 -o "$file" = "perl-xCAT" ]; then
rm -f ../../$package_dir_name/${file_low}_*.$target_arch.deb
#genesis scripts package, don't remove genesis amd64 files
#rm -f ../../$package_dir_name/${file_low}-amd64_*.deb
cd $file
dch -v $pkg_version -b -c debian/changelog $build_string
if [ "$target_arch" = "all" ]; then
dpkg-buildpackage -uc -us
else
dpkg-buildpackage -uc -us -a$target_arch
fi
rc=$?
if [ $rc -gt 0 ]; then
echo "Error: $file build package failed exit code $rc"
exit $rc
fi
cd -
find $file -maxdepth 3 -type d -name "${file_low}*" | grep debian | xargs rm -rf
find $file -maxdepth 3 -type f -name "files" | grep debian | xargs rm -rf
mv ${file_low}* ../../$package_dir_name/
if grep -q $file $update_log || [ "$BUILDALL" == 1 -o "$file" = "perl-xCAT" ]; then
rm -f ../../$package_dir_name/${file_low}_*.deb
#only for genesis package
rm -f ../../$package_dir_name/${file_low}-amd64_*.deb
cd $file
dch -v $pkg_version -b -c debian/changelog $build_string
dpkg-buildpackage -uc -us
rc=$?
if [ $rc -gt 0 ]; then
echo "Error: $file build package failed exit code $rc"
fi
done
cd -
find $file -maxdepth 3 -type d -name "${file_low}*" | grep debian | xargs rm -rf
find $file -maxdepth 3 -type f -name "files" | grep debian | xargs rm -rf
mv ${file_low}* ../../$package_dir_name/
fi
done
find ../../$package_dir_name/* ! -name *.deb | xargs rm -f
@ -268,16 +250,11 @@ then
mkdir conf
for dist in $dists; do
if [ "$dist" = "trusty" ] || [ "$dist" = "utopic" ]; then
tmp_out_arch="amd64 ppc64el"
else
tmp_out_arch="amd64"
fi
cat << __EOF__ >> conf/distributions
Origin: xCAT internal repository
Label: xcat-core bazaar repository
Codename: $dist
Architectures: $tmp_out_arch
Architectures: amd64
Components: main
Description: Repository automatically genereted conf
SignWith: yes
@ -292,29 +269,17 @@ basedir .
__EOF__
#import the deb packages into the repo
amd_files=`ls ../$package_dir_name/*.deb | grep -v "ppc64el"`
all_files=`ls ../$package_dir_name/*.deb`
for dist in $dists; do
if [ "$dist" = "trusty" ] || [ "$dist" = "utopic" ]; then
deb_files=$all_files
else
deb_files=$amd_files
fi
for file in $deb_files; do
for file in `ls ../$package_dir_name/*.deb`; do
reprepro -b ./ includedeb $dist $file;
done
done
#create the mklocalrepo script
cat << '__EOF__' > mklocalrepo.sh
. /etc/lsb-release
cd `dirname $0`
host_arch=`uname -m`
if [ "$host_arch" != "ppc64le" ];then
host_arch="amd64"
else
host_arch="ppc64el"
fi
echo deb [arch=$host_arch] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
__EOF__
chmod 775 mklocalrepo.sh
@ -388,16 +353,11 @@ then
#create the conf/distributions file
for dist in $dists; do
if [ "$dist" = "trusty" ] || [ "$dist" = "utopic" ]; then
tmp_out_arch="amd64 ppc64el"
else
tmp_out_arch="amd64"
fi
cat << __EOF__ >> conf/distributions
Origin: xCAT internal repository
Label: xcat-dep bazaar repository
Codename: $dist
Architectures: $tmp_out_arch
Architectures: amd64
Components: main
Description: Repository automatically genereted conf
SignWith: yes
@ -411,16 +371,8 @@ ask-passphrase
basedir .
__EOF__
#import the deb packages into the repo
amd_files=`ls ../debs/*.deb | grep -v "ppc64el"`
all_files=`ls ../debs/*.deb`
for dist in $dists; do
if [ "$dist" = "trusty" ] || [ "$dist" = "utopic" ]; then
deb_files=$all_files
else
deb_files=$amd_files
fi
for file in $deb_files; do
for file in `ls ../debs/*.deb`; do
reprepro -b ./ includedeb $dist $file;
done
done
@ -428,13 +380,7 @@ __EOF__
cat << '__EOF__' > mklocalrepo.sh
. /etc/lsb-release
cd `dirname $0`
host_arch=`uname -m`
if [ "$host_arch" != "ppc64le" ];then
host_arch="amd64"
else
host_arch="ppc64el"
fi
echo deb [arch=$host_arch] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
__EOF__
chmod 775 mklocalrepo.sh
@ -450,7 +396,7 @@ __EOF__
chmod -R g+w xcat-dep
#create the tar ball
dep_tar_name=xcat-dep-ubuntu-snap`date +%Y%m%d`.tar.bz
dep_tar_name=xcat-dep-ubuntu.tar.bz
tar -hjcf $dep_tar_name xcat-dep
chgrp root $dep_tar_name
chmod g+w $dep_tar_name

View File

@ -12,45 +12,40 @@
# at https://sourceforge.net/account/ssh
# - On Linux: make sure createrepo is installed on the build machine
# - On AIX: Install openssl and openssh installp pkgs and run updtvpkg. Install from http://www.perzl.org/aix/ :
# apr, apr-util, bash, bzip2, db4, expat, gdbm, gettext, glib2, gmp, info, libidn, neon, openssl (won't
# conflict with the installp version - but i don't think you need this), pcre, perl-DBD-SQLite, perl-DBI,
# popt, python, readline, rsynce, sqlite, subversion, unixODBC, zlib.
# Install wget from http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html
# apr, apr-util, bash, bzip2, db4, expat, gdbm, gettext, glib2, gmp, info, libidn, neon, openssl (won't
# conflict with the installp version - but i don't think you need this), pcre, perl-DBD-SQLite, perl-DBI,
# popt, python, readline, rsynce, sqlite, subversion, unixODBC, zlib. Install wget from http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html
# - Run this script from the local svn repository you just created. It will create the other
# directories that are needed.
# Usage: buildcore.sh [attr=value attr=value ...]
# Before running buildcore.sh, you must change the local git repo to the branch you want built, using: git checkout <branch>
# PROMOTE=1 - if the attribute "PROMOTE" is specified, means an official dot release. This does not actually build
# xcat, just uploads the most recent snap build to https://sourceforge.net/projects/xcat/files/xcat/ .
# If not specified, a snap build is assumed, which uploads to https://sourceforge.net/projects/xcat/files/yum/
# or https://sourceforge.net/projects/xcat/files/aix/.
# PREGA=1 - use this option with PROMOTE=1 on a branch that already has a released dot release, but this build is
# a GA candidate build, not to be released yet. This will result in the tarball being uploaded to
# https://sourceforge.net/projects/xcat/files/yum/ or https://sourceforge.net/projects/xcat/files/aix/
# (but the tarball file name will be like a released tarball, not a snap build). When you are ready to
# release this build, use PROMOTE=1 without PREGA
# BUILDALL=1 - build all rpms, whether they changed or not. Should be used for snap builds that are in prep for a release.
# UP=0 or UP=1 - override the default upload behavior
# SVNUP=<filename> - control which rpms get built by specifying a coresvnup file
# GITUP=<filename> - control which rpms get built by specifying a coregitup file
# EMBED=<embedded-environment> - the environment for which a minimal version of xcat should be built, e.g. zvm or flex
# VERBOSE=1 - to see lots of verbose output
# LOG=<filename> - provide an LOG file option to redirect some output into log file
# Before running buildcore.sh, you must change the local git repo to the branch you want built, using: git checkout <branch>
# PROMOTE=1 - if the attribute "PROMOTE" is specified, means an official dot release. This does not
# actually build xcat, just uploads the most recent snap build to https://sourceforge.net/projects/xcat/files/xcat/ .
# If not specified, a snap build is assumed, which uploads to https://sourceforge.net/projects/xcat/files/yum/
# or https://sourceforge.net/projects/xcat/files/aix/.
# PREGA=1 - use this option with PROMOTE=1 on a branch that already has a released dot release, but this build is
# a GA candidate build, not to be released yet. This will result in the tarball being uploaded to
# https://sourceforge.net/projects/xcat/files/yum/ or https://sourceforge.net/projects/xcat/files/aix/
# (but the tarball file name will be like a released tarball, not a snap build). When you are ready to
# release this build, use PROMOTE=1 without PREGA
# BUILDALL=1 - build all rpms, whether they changed or not. Should be used for snap builds that are in prep for a release.
# UP=0 or UP=1 - override the default upload behavior
# SVNUP=<filename> - control which rpms get built by specifying a coresvnup file
# GITUP=<filename> - control which rpms get built by specifying a coregitup file
# EMBED=<embedded-environment> - the environment for which a minimal version of xcat should be built, e.g. zvm or flex
# VERBOSE=1 - to see lots of verbose output
# you can change this if you need to
UPLOADUSER=litingt
UPLOADUSER=bp-sawyers
FRS=/home/frs/project/x/xc/xcat
# 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"
ALLBUILD="perl-xCAT xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-buildkit xCAT xCATsn xCAT-genesis-scripts xCAT-OpenStack xCAT-SoftLayer xCAT-OpenStack-baremetal"
ZVMBUILD="perl-xCAT xCAT-server xCAT-UI"
ZVMLINK="xCAT-client xCAT xCATsn"
# xCAT and xCATsn have PCM specific configuration - conserver-xcat, syslinux-xcat
# xCAT-server has PCM specific configuration - RESTAPI(perl-JSON)
# xCAT-client has PCM specific configuration - getxcatdocs(perl-JSON)
PCMBUILD="xCAT xCAT-server xCAT-client xCATsn"
PCMLINK="perl-xCAT xCAT-buildkit xCAT-genesis-scripts-x86_64 xCAT-genesis-scripts-ppc64 xCAT-vlan"
PCMBUILD="xCAT"
PCMLINK="perl-xCAT xCAT-client xCAT-server xCAT-buildkit xCAT-genesis-scripts-x86_64"
# Note: for FSM, the FlexCAT rpm is built separately from gsa/git
FSMBUILD="perl-xCAT xCAT-client xCAT-server"
FSMLINK=""
@ -86,19 +81,21 @@ if [ "$OSNAME" != "AIX" ]; then
echo "Can't get lock /var/lock/xcatbld-$REL.lock. Someone else must be doing a build right now. Exiting...."
exit 1
fi
# This is so rpm and gpg will know home, even in sudo
export HOME=/root
export HOME=/root # This is so rpm and gpg will know home, even in sudo
fi
# for the git case, query the current branch and set REL (changing master to devel if necessary)
function setbranch {
#git checkout $BRANCH
#REL=`git rev-parse --abbrev-ref HEAD`
REL=`git name-rev --name-only HEAD`
if [ "$REL" = "master" ]; then
REL="devel"
fi
}
if [ "$REL" = "xcat-core" ]; then # using git
if [ "$REL" = "xcat-core" ]; then # using git
GIT=1
setbranch # this changes the REL variable
fi
@ -130,7 +127,7 @@ fi
XCATCORE="xcat-core" # core-snap is a sym link to xcat-core
if [ "$GIT" = "1" ]; then # using git - need to include REL in the path where we put the built rpms
if [ "$GIT" = "1" ]; then # using git - need to include REL in the path where we put the built rpms
DESTDIR=../../$REL$EMBEDDIR/$XCATCORE
else
DESTDIR=../..$EMBEDDIR/$XCATCORE
@ -183,8 +180,7 @@ fi
# If they have not given us a premade update file, do an svn update or git pull and capture the results
SOMETHINGCHANGED=0
if [ "$GIT" = "1" ]; then
# using git
if [ "$GIT" = "1" ]; then # using git
if [ -z "$GITUP" ]; then
GITUP=../coregitup
echo "git pull > $GITUP"
@ -198,8 +194,7 @@ if [ "$GIT" = "1" ]; then
if ! $GREP 'Already up-to-date' $GITUP; then
SOMETHINGCHANGED=1
fi
else
# using svn
else # using svn
GIT=0
if [ -z "$SVNUP" ]; then
SVNUP=../coresvnup
@ -242,19 +237,16 @@ 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; do
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-buildkit xCAT-SoftLayer; do
#if [ "$EMBED" = "zvm" -a "$rpmname" != "xCAT-server" -a "$rpmname" != "xCAT-UI" ]; then continue; fi # for zvm embedded env only need to build server and UI
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
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-vlan" ]; then continue; fi # do not build xCAT-vlan on aix
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-confluent" ]; then continue; fi # do not build xCAT-confluent on aix
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi # do not build xCAT-buildkit on aix
if $GREP $rpmname $GITUP || [ "$BUILDALL" == 1 ]; then
UPLOAD=1
maker $rpmname
fi
if [ "$OSNAME" = "AIX" ]; then
if [ "$rpmname" = "xCAT-client" -o "$rpmname" = "xCAT-server" ]; then
# we do not automatically install the rest of the rpms on AIX
if [ "$rpmname" = "xCAT-client" -o "$rpmname" = "xCAT-server" ]; then # we do not automatically install the rest of the rpms on AIX
echo "rpm -Uvh $rpmname-$SHORTSHORTVER*rpm" >> $DESTDIR/instxcat
fi
fi
@ -269,8 +261,6 @@ if [ "$OSNAME" != "AIX" ]; then
ORIGFAILEDRPMS="$FAILEDRPMS"
./makerpm xCAT-genesis-scripts x86_64 "$EMBED"
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS xCAT-genesis-scripts-x86_64"; fi
./makerpm xCAT-genesis-scripts ppc64 "$EMBED"
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS xCAT-genesis-scripts-ppc64"; fi
if [ "$FAILEDRPMS" = "$ORIGFAILEDRPMS" ]; then # all succeeded
rm -f $DESTDIR/xCAT-genesis-scripts*rpm
rm -f $SRCDIR/xCAT-genesis-scripts*rpm
@ -282,7 +272,8 @@ if [ "$OSNAME" != "AIX" ]; then
fi
# Build the xCAT and xCATsn rpms for all platforms
for rpmname in xCAT xCATsn; do
for rpmname in xCAT xCATsn xCAT-OpenStack xCAT-OpenStack-baremetal; do
#if [ "$EMBED" = "zvm" ]; then break; fi
if [[ " $EMBEDBUILD " != *\ $rpmname\ * ]]; then continue; fi
if [ $SOMETHINGCHANGED == 1 -o "$BUILDALL" == 1 ]; then # used to be: if $GREP -E "^[UAD] +$rpmname/" $GITUP; then
UPLOAD=1
@ -292,7 +283,7 @@ for rpmname in xCAT xCATsn; do
./makerpm $rpmname "$EMBED"
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname"; fi
else
for arch in x86_64 ppc64 ppc64le s390x; do
for arch in x86_64 ppc64 s390x; do
if [ "$rpmname" = "xCAT-OpenStack" -a "$arch" != "x86_64" ] || [ "$rpmname" = "xCAT-OpenStack-baremetal" -a "$arch" != "x86_64" ] ; then continue; fi # only bld openstack for x86_64 for now
./makerpm $rpmname $arch "$EMBED"
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname-$arch"; fi
@ -344,10 +335,6 @@ fi
#else we will continue
# Prepare the RPMs for pkging and upload
WGET_CMD="wget"
if [ ! -z ${LOG} ]; then
WGET_CMD="wget -o ${LOG}"
fi
# get gpg keys in place
if [ "$OSNAME" != "AIX" ]; then
@ -355,7 +342,7 @@ if [ "$OSNAME" != "AIX" ]; then
for i in pubring.gpg secring.gpg trustdb.gpg; do
if [ ! -f $HOME/.gnupg/$i ] || [ `wc -c $HOME/.gnupg/$i|cut -f 1 -d' '` == 0 ]; then
rm -f $HOME/.gnupg/$i
${WGET_CMD} -P $HOME/.gnupg $GSA/keys/$i
wget -P $HOME/.gnupg $GSA/keys/$i
chmod 600 $HOME/.gnupg/$i
fi
done
@ -365,7 +352,7 @@ if [ "$OSNAME" != "AIX" ]; then
echo '%_signature gpg' >> $MACROS
fi
if ! $GREP '%_gpg_name' $MACROS 2>/dev/null; then
echo '%_gpg_name xCAT Security Key' >> $MACROS
echo '%_gpg_name Jarrod Johnson' >> $MACROS
fi
echo "Signing RPMs..."
build-utils/rpmsign.exp `find $DESTDIR -type f -name '*.rpm'` | grep -v -E '(already contains identical signature|was already signed|rpm --quiet --resign|WARNING: standard input reopened)'
@ -377,10 +364,10 @@ if [ "$OSNAME" != "AIX" ]; then
gpg -a --detach-sign $DESTDIR/repodata/repomd.xml
gpg -a --detach-sign $SRCDIR/repodata/repomd.xml
if [ ! -f $DESTDIR/repodata/repomd.xml.key ]; then
${WGET_CMD} -q -P $DESTDIR/repodata $GSA/keys/repomd.xml.key
wget -P $DESTDIR/repodata $GSA/keys/repomd.xml.key
fi
if [ ! -f $SRCDIR/repodata/repomd.xml.key ]; then
${WGET_CMD} -P $SRCDIR/repodata $GSA/keys/repomd.xml.key
wget -P $SRCDIR/repodata $GSA/keys/repomd.xml.key
fi
fi
@ -428,18 +415,7 @@ EOF
#!/bin/sh
cd `dirname $0`
REPOFILE=`basename xCAT-*.repo`
if [[ $REPOFILE == "xCAT-*.repo" ]]; then
echo "ERROR: For xcat-dep, please execute $0 in the correct <os>/<arch> subdirectory"
exit 1
fi
#
# default to RHEL yum, if doesn't exist try Zypper
#
DIRECTORY="/etc/yum.repos.d"
if [[ ! -d ${DIRECTORY} ]]; then
DIRECTORY="/etc/zypp/repos.d"
fi
sed -e 's|baseurl=.*|baseurl=file://'"`pwd`"'|' $REPOFILE | sed -e 's|gpgkey=.*|gpgkey=file://'"`pwd`"'/repodata/repomd.xml.key|' > ${DIRECTORY}/$REPOFILE
sed -e 's|baseurl=.*|baseurl=file://'"`pwd`"'|' $REPOFILE | sed -e 's|gpgkey=.*|gpgkey=file://'"`pwd`"'/repodata/repomd.xml.key|' > /etc/yum.repos.d/$REPOFILE
cd -
EOF2
chmod 775 mklocalrepo.sh
@ -519,9 +495,8 @@ if [ "$OSNAME" != "AIX" -a "$REL" = "devel" -a "$PROMOTE" != 1 -a -z "$EMBED" ];
rpm2cpio ../$XCATCORE/perl-xCAT-*.$NOARCH.rpm | cpio -id '*.html'
rpm2cpio ../$XCATCORE/xCAT-test-*.$NOARCH.rpm | cpio -id '*.html'
rpm2cpio ../$XCATCORE/xCAT-buildkit-*.$NOARCH.rpm | cpio -id '*.html'
#rpm2cpio ../$XCATCORE/xCAT-OpenStack-*.x86_64.rpm | cpio -id '*.html'
rpm2cpio ../$XCATCORE/xCAT-OpenStack-*.x86_64.rpm | cpio -id '*.html'
rpm2cpio ../$XCATCORE/xCAT-SoftLayer-*.$NOARCH.rpm | cpio -id '*.html'
rpm2cpio ../$XCATCORE/xCAT-vlan-*.$NOARCH.rpm | cpio -id '*.html'
i=0
while [ $((i+=1)) -le 5 ] && ! rsync $verboseflag -r opt/xcat/share/doc/man1 opt/xcat/share/doc/man3 opt/xcat/share/doc/man5 opt/xcat/share/doc/man7 opt/xcat/share/doc/man8 $UPLOADUSER,xcat@web.sourceforge.net:htdocs/
do : ; done

View File

@ -19,7 +19,7 @@
# VERBOSE=1 - to see lots of verbose output
# you can change this if you need to
UPLOADUSER=litingt
UPLOADUSER=bp-sawyers
FRS=/home/frs/project/x/xc/xcat
OSNAME=$(uname)
@ -92,7 +92,7 @@ if [ "$OSNAME" != "AIX" ]; then
echo '%_signature gpg' >> $MACROS
fi
if ! $GREP -q '%_gpg_name' $MACROS 2>/dev/null; then
echo '%_gpg_name xCAT Security Key' >> $MACROS
echo '%_gpg_name Jarrod Johnson' >> $MACROS
fi
# Sign the rpms that are not already signed. The "standard input reopened" warnings are normal.

View File

@ -8,29 +8,10 @@
OSNAME=$(uname)
NAMEALL=$(uname -a)
for i in $*; do
# upper case the variable name
varstring=`echo "$i"|cut -d '=' -f 1|tr '[a-z]' '[A-Z]'`=`echo "$i"|cut -d '=' -f 2`
export $varstring
done
if [ -z "$CURDIR" ]; then
echo "get current directory!"
CURDIR=$(pwd)
fi
echo "CURDIR is $CURDIR"
echo "OSNAME is $OSNAME!"
echo "NAMEALL is $NAMEALL"
grep -i 'SUSE' /etc/issue
if [ $? -eq 0 ]; then
echo "This is a SUSE system!"
OS="SUSE";
fi
ls $CURDIR/makerpm
ls /code/xcat-core
if [ $? -gt 0 ]; then
echo "Error:no repo exist, exit 1."
@ -44,9 +25,10 @@ if ! flock -n 8; then
exit 1
fi
#delete old package if there is
rm -rf $CURDIR/build/
cd $CURDIR
#used only for hard code, will change later
cd /code/xcat-core
rm -rf build/
echo "==============================================="
echo $NAMEALL | egrep "Ubuntu"
@ -61,9 +43,9 @@ echo "This is an Ubuntu system"
short_ver=`cat Version|cut -d. -f 1,2`
pkg_version="${short_ver}-${pkg_type}${cur_date}"
mkdir -p $CURDIR/build
mkdir -p /code/xcat-core/build
for rpmname in xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT xCATsn xCAT-test xCAT-vlan; do
for rpmname in xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT xCATsn xCAT-test; do
rpmname_low=`echo $rpmname | tr '[A-Z]' '[a-z]'`
echo "============================================"
echo "$rpmname_low"
@ -75,88 +57,49 @@ echo "This is an Ubuntu system"
echo "Error: $rpmname build package failed exit code $rc"
fi
cd -
mv ${rpmname_low}* $CURDIR/build
mv ${rpmname_low}* /code/xcat-core/build
done
#delete all files except .deb file
find $CURDIR/build/* ! -name *.deb | xargs rm -f
find /code/xcat-core/build/* ! -name *.deb | xargs rm -f
else
#This is not an Ubuntu system
echo "This is an $OSNAME system"
if [ "$OS" = "SUSE" ]; then
rm -rf /usr/src/packages/RPMS/noarch/*
rm -rf /usr/src/packages/RPMS/x86_64/*
rm -rf /usr/src/packages/RPMS/ppc64/*
else
rm -rf /root/rpmbuild/RPMS/noarch/*
rm -rf /root/rpmbuild/RPMS/x86_64/*
rm -rf /root/rpmbuild/RPMS/ppc64/*
fi
mkdir -p $CURDIR/build/
#always build perl-xCAT
$CURDIR/makerpm perl-xCAT
rm -rf /root/rpmbuild/RPMS/noarch/*
rm -rf /root/rpmbuild/RPMS/x86_64/*
rm -rf /root/rpmbuild/RPMS/ppc64/*
mkdir build/
# Build the rest of the noarch rpms
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-test xCAT-buildkit xCAT-vlan; do
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-test xCAT-buildkit; do
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi
$CURDIR/makerpm $rpmname
./makerpm $rpmname
done
#build xCAT-genesis-scripts if it is x86_64 platform
ARCH=$(uname -p)
if [ "$ARCH" = "x86_64" ]; then
$CURDIR/makerpm xCAT-genesis-scripts x86_64
else
$CURDIR/makerpm xCAT-genesis-scripts ppc64
if [ "$ARCH" = "x64_64" ]; then
./makerpm xCAT-genesis-scripts x86_64
fi
# Build the xCAT and xCATsn rpms for all platforms
for rpmname in xCAT xCATsn; do
if [ "$OSNAME" = "AIX" ]; then
$CURDIR/makerpm $rpmname
./makerpm $rpmname
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname"; fi
else
for arch in x86_64 ppc64 s390x; do
$CURDIR/makerpm $rpmname $arch
./makerpm $rpmname $arch
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname-$arch"; fi
done
fi
done
if [ "$OS" = "SUSE" ]; then
cp /usr/src/packages/RPMS/noarch/* $CURDIR/build/
cp /usr/src/packages/RPMS/x86_64/* $CURDIR/build/
cp /usr/src/packages/RPMS/ppc64/* $CURDIR/build/
else
cp /root/rpmbuild/RPMS/noarch/* $CURDIR/build/
cp /root/rpmbuild/RPMS/x86_64/* $CURDIR/build/
cp /root/rpmbuild/RPMS/ppc64/* $CURDIR/build/
fi
#begin to create repo for redhat platform
grep -i 'Red' /etc/*release*;
if [ "$OSNAME" != "AIX" -a $? -eq 0 ]; then
cat >$CURDIR/build/xCAT-core.repo << EOF
[xcat-2-core]
name=xCAT 2 Core packages
baseurl=file://$CURDIR/build
enabled=1
gpgcheck=0
EOF
cp $CURDIR/build/xCAT-core.repo /etc/yum.repos.d/
createrepo $CURDIR/build
else
rm -f /etc/zypp/repos.d/xCAT-core.repo
zypper ar file://$CURDIR/build xCAT-core
fi
cp /root/rpmbuild/RPMS/noarch/* build/
cp /root/rpmbuild/RPMS/x86_64/* build/
cp /root/rpmbuild/RPMS/ppc64/* build/
fi

34
makerpm
View File

@ -23,18 +23,6 @@ function makenoarch {
RC=$?
else # linux
echo "Building $RPMROOT/RPMS/noarch/$RPMNAME-$VER-snap*.noarch.rpm $EMBEDTXT..."
# TODO: should fix this up, this is a hack for the new build machine
if [ $RPMNAME = "xCAT-UI" ]; then
# Only if the old compiler.jar file does not exist.....
if [ ! -e /xcat2/build/tools/compiler.jar ]; then
# look for the dynamic location of the compiler.jar file
DIRNAME=`dirname $(readlink -f $0)`
COMPILER_JAR=`echo "${DIRNAME%%linux_rpm/*}tools/compiler.jar"`
if [ -f $COMPILER_JAR ]; then
sed -i "s#/xcat2/build/tools/compiler.jar#${COMPILER_JAR}#g" xCAT-UI/xCAT-UI.spec
fi
fi
fi
tar --exclude .svn -czf $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz $RPMNAME
rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm
rpmbuild $QUIET -ta $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz
@ -97,7 +85,6 @@ function makexcat {
cd `dirname $0`/$RPMNAME
tar --exclude .svn -czf $RPMROOT/SOURCES/license.tar.gz LICENSE.html
cp xcat.conf $RPMROOT/SOURCES
cp xcat.conf.apach24 $RPMROOT/SOURCES
cp xCATSN $RPMROOT/SOURCES
cd - >/dev/null
elif [ "$RPMNAME" = "xCAT-buildkit" ]; then
@ -118,23 +105,7 @@ function makexcat {
fi
}
# make ironic rpm for ironic baremetal driver
function makeironic {
RPMNAME="$1"
ARCH="$2"
cd `dirname $0`/$RPMNAME
cp -rf ironic_baremetal /tmp/
cd /tmp/ironic_baremetal
git init
git add *
git commit -a -m "generate rpm"
python setup.py bdist_rpm
rm -rf $RPMROOT/RPMS/$ARCH/
mkdir -p $RPMROOT/RPMS/$ARCH/
cp -rf dist/*.rpm $RPMROOT/RPMS/$ARCH/
rm -rf /tmp/ironic_baremetal
}
# Make the xCAT-nbroot-core rpm
function makenbroot {
@ -234,6 +205,7 @@ else # linux
fi
fi
if [ "$1" = "xCAT" -o "$1" = "xCATsn" -o "$1" = "xCAT-buildkit" -o "$1" = "xCAT-OpenStack" ]; then
exportEmbed $3
makexcat $1 $2
@ -246,8 +218,6 @@ elif [ "$1" = "xCAT-genesis-builder" ]; then
elif [ "$1" = "xCAT-genesis-scripts" ]; then
exportEmbed $3
makegenesisscripts $1 $2
elif [ "$1" = "xCAT-OpenStack-ironic" ]; then
makeironic $1 $2
else # must be one of the noarch rpms
exportEmbed $2
makenoarch $1

View File

@ -266,7 +266,7 @@ See http://www.perl.com/doc/manual/html/pod/perlre.html for information on perl
As of xCAT 2.8.1, you can use a modified version of the regular expression support described in the previous section. You do not need to enter the node information (1st part of the expression), it will be derived from the input nodename. You only need to supply the 2nd part of the expression to determine the value to give the attribute. For examples, see
https://sourceforge.net/p/xcat/wiki/Listing_and_Modifying_the_Database/#easy-regular-expressions
https://sourceforge.net/apps/mediawiki/xcat/index.php?title=Listing_and_Modifying_the_Database#Easy_Regular_expressions
=head1 OBJECT DEFINITIONS

View File

@ -48,7 +48,7 @@ binary-arch: build install
chmod 644 `pwd`/debian/perl-xcat/opt/xcat/share/doc/man5/*
chmod 644 `pwd`/debian/perl-xcat/opt/xcat/share/man/man7/*
chmod 644 `pwd`/debian/perl-xcat/opt/xcat/share/doc/man7/*
./modifyUtils `cat ../Version` `git log -n 1 | head -n 1 | cut -f 2 -d ' '`
./modifyUtils `cat ../Version` `svn info | grep Revision | cut -d" " -f 2`
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate

View File

@ -1,21 +1,20 @@
#!/bin/sh
# Put the version, svn revision #, and build date into the Version function in Version.pm
if [ -z "$2" ]
if [ -z "$1" ]
then
echo "modifyUtils: Error: must specify the xCAT version as an argument" >&2
exit
fi
VER=$1
GITREF="git commit $2, "
BUILDDATE=`date`
#echo ". '(built $BUILDDATE)'"
if [ "$(uname)" = "AIX" ]
then
sed -e s/"#XCATVERSIONSUBHERE"/". '$VER'"/ -e s/"#XCATSVNBUILDSUBHERE"/". ' (${GITREF}built $BUILDDATE)'"/ xCAT/Version.pm >xCAT/Version.pm.new
sed -e s/"#XCATVERSIONSUBHERE"/". '$VER'"/ -e s/"#XCATSVNBUILDSUBHERE"/". ' (built $BUILDDATE)'"/ xCAT/Version.pm >xCAT/Version.pm.new
mv xCAT/Version.pm.new xCAT/Version.pm
else
if [ -f "/etc/debian_version" ];then
@ -23,5 +22,5 @@ else
else
FILENAME="xCAT/Version.pm"
fi
sed -i -e s/"#XCATVERSIONSUBHERE"/". '$VER'"/ -e s/"#XCATSVNBUILDSUBHERE"/". ' (${GITREF}built $BUILDDATE)'"/ $FILENAME
sed -i -e s/"#XCATVERSIONSUBHERE"/". '$VER'"/ -e s/"#XCATSVNBUILDSUBHERE"/". ' (built $BUILDDATE)'"/ $FILENAME
fi

View File

@ -23,8 +23,6 @@ Provides: perl-xCAT = %{epoch}:%{version}
Provides perl xCAT libraries for core functionality. Required for all xCAT installations.
Includes xCAT::Table, xCAT::NodeRange, among others.
%define gitinfo %(git log -n 1 | head -n 1 | cut -f 2 -d ' ')
%define zvm %(if [ "$zvm" = "1" ];then echo 1; else echo 0; fi)
%define fsm %(if [ "$fsm" = "1" ];then echo 1; else echo 0; fi)
@ -38,7 +36,7 @@ Includes xCAT::Table, xCAT::NodeRange, among others.
%if %fsm
%else
# Modify the Version() function in xCAT/Utils.pm to automatically have the correct version
./modifyUtils %{version} %{gitinfo}
./modifyUtils %{version}
# Build the pod version of the man pages for each DB table. It puts them in the man5 and man7 subdirs.
# Then convert the pods to man pages and html pages.

View File

@ -500,7 +500,6 @@ sub setCFMPkglistFile {
Arguments:
$imagename - the specified linuximage name
@curospkgs - the currently selected OS packages list
$mode - using Fuzzy Matching or Exact Matching to check packages
Returns:
0 - update successfully
1 - update failed
@ -510,22 +509,13 @@ sub setCFMPkglistFile {
none
Example:
my $ret = CAT::CFMUtils->updateCFMPkglistFile($imagename, @cur_selected_pkgs);
my $ret = CAT::CFMUtils->updateCFMPkglistFile($imagename, @cur_selected_pkgs, 1);
=cut
#-----------------------------------------------------------------------------
sub updateCFMPkglistFile {
my ($class, $img, $ospkgs, $mode) = @_;
if(defined($mode)){
# Exact Matching
$mode = 1;
}else {
# Fuzzy Matching
$mode = 0;
}
my ($class, $img, $ospkgs) = @_;
my @cur_selected = @$ospkgs;
my $cfmpkglist = "/install/osimages/$img/pkglist.cfm";
@ -559,14 +549,6 @@ sub updateCFMPkglistFile {
my @selected = @$selected_ref;
@basepkgs = xCAT::CFMUtils->arrayops("U", \@basepkgs, \@selected);
}
# Fuzzy Matching
if (not $mode){
my ($ref1, $ref2, $ref3) = xCAT::CFMUtils->updateSelectedPkgs(\@pre_selected, \@pre_removed, \@cur_selected);
@pre_selected = @$ref1;
@pre_removed = @$ref2;
@cur_selected = @$ref3;
}
# get diff between previous and current selected OS packages lists
my @diff = xCAT::CFMUtils->getPkgsDiff(\@pre_selected, \@cur_selected);
@ -679,48 +661,6 @@ sub getPreOSpkgsList {
return (\@selected, \@removed);
}
#-----------------------------------------------------------------------------
=head3 getPreBaseOSpkgsList
Get previously selected and removed base OS packages lists from pkglist file. Packages named with "example.xxx" should be the base name "example"
Arguments:
$ospkglist - the path for ospkglist file
Returns:
refs for selected and removed OS packages arrays
Globals:
none
Error:
none
Example:
my $pre_selected_ref = xCAT::CFMUtils->getPreOSpkgsList($ospkglist);
=cut
#-----------------------------------------------------------------------------
sub getPreBaseOSpkgsList {
my ($class, $pkglist) = @_;
my ($pre_selected_ref, $pre_removed_ref) = xCAT::CFMUtils->getPreOSpkgsList($pkglist);
my %pre_selected_hash = ();
foreach (@$pre_selected_ref) {
my @names = split(/\./, $_);
my $basename = $names[0];
if ($_ =~ /^$basename\.([^\.]+)$/) {
$pre_selected_hash{$basename} = 1;
}else {
$pre_selected_hash{$_} = 1;
}
}
my @pre_selected = keys %pre_selected_hash;
return \@pre_selected;
}
#-----------------------------------------------------------------------------
=head3 getPkgsDiff
@ -879,66 +819,3 @@ sub arrayops {
#return (\@union, \@intersection, \@difference);
}
#-----------------------------------------------------------------------------
=head3 updateSelectedPkgs
Update previous selected, previous removed and current selected packages based on fuzzy matching rules. Packages named with "example.i686" should be same with package "example"
Arguments:
\@pre_selected - reference to previous selected packages
\@pre_removed - reference to previous removed packages
\@cur_selected - reference to current selected packages
Returns:
new previous selected, previous removed, current selected packages
Globals:
none
Error:
none
Example:
my ($ref1, $ref2, $ref3) = xCAT::CFMUtils->arrayops(\@pre_selected, \@pre_removed, \@cur_selected);
=cut
#-----------------------------------------------------------------------------
sub updateSelectedPkgs() {
my ($class, $pre_selected_ref, $pre_removed_ref, $cur_selected_ref) = @_;
my %pre_selected_hash = map{$_ => 1} @$pre_selected_ref;
my %pre_removed_hash = map{$_ => 1} @$pre_removed_ref;
my %cur_selected_hash = map{$_ => 1} @$cur_selected_ref;
my %new_pre_selected_hash = %pre_selected_hash;
my %new_pre_removed_hash = %pre_removed_hash;
my %new_cur_selected_hash = %cur_selected_hash;
foreach (keys %cur_selected_hash) {
my $father = $_;
my $flag = 0;
foreach (keys %pre_selected_hash) {
my $child = $_;
if ($child =~ /^$father\.([^\.]+)$/) {
$new_cur_selected_hash{$child} = 1;
$flag = 1;
}
}
if ($flag and not exists $pre_selected_hash{$father}){
delete $new_cur_selected_hash{$father} if exists $new_cur_selected_hash{$father};
}
foreach (keys %pre_removed_hash) {
my $child = $_;
if ($child =~ /^$father\.([^\.]+)$/) {
delete $new_pre_removed_hash{$child} if exists $new_pre_removed_hash{$child};
}
}
}
my @new_cur_selected = keys %new_cur_selected_hash;
my @new_pre_selected = keys %new_pre_selected_hash;
my @new_pre_removed = keys %new_pre_removed_hash;
return (\@new_pre_selected, \@new_pre_removed, \@new_cur_selected);
}

View File

@ -1,462 +0,0 @@
#! /usr/bin/env perl
# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html
# This package offers subroutines to access CIM server
package xCAT::CIMUtils;
use strict;
use warnings;
use HTTP::Headers;
use HTTP::Request;
use LWP::UserAgent;
use XML::LibXML;
use Data::Dumper;
=head1 HTTP_PARAMS
A hash which includes all the parameters for accessing HTTP server. The valid parameter:
ip: The IP address of the HTTP server
user: The user to access HTTP server.
password: The password for the user.
method: The http method. (GET, PUT, POST, DELETE). Default is GET
protocol: The protocol which will be used to access HTTP server. (http/https). Default is https
format: The format of payload. Default is xml
payload: The payload of http
Example:
my %http_params = ( ip => '192.168.1.1',
port => '5989',
user => 'HMC',
password => 'admin',
method => 'POST',
protocol => 'https');
=cut
=head1 enum_instance ()
Description:
Enumerate CIM instances.
Arguments:
http_params: A reference to HTTP_PARAMS
cim_params: The CIM parameters
classname - a mandatory param to specify the class that enumerate will target to.
Return:
1 - A hash reference. The valid key includes:
rc - The return code. 0 - success. > 0 - fail.
cim_rc - The return code from CIM server.
msg - Output message.
2 - Array of instances, each instance is a hash contains lots of properties.
3 - The name path of instance
=cut
sub enum_instance
{
my $http_params = shift;
unless (ref($http_params)) {
$http_params = shift;
}
my $cim_params = shift;
# This is a mandatory parameter
unless ($cim_params->{classname}) {
return ({rc => 1, msg => "Missed the classname"});
}
unless ($cim_params->{namespace}) {
$cim_params->{namespace} = "ibmsd";
}
# prepare the CIM payload
my $tmpnode;
# create a new doc
my $doc = XML::LibXML->createDocument('1.0','UTF-8');
# create and add the root element
my $root = $doc->createElement("CIM");
$root->setAttribute("CIMVERSION", "2.0");
$root->setAttribute("DTDVERSION", "2.0");
$doc->setDocumentElement($root);
# create and add the MESSAGE element
my $message = $doc->createElement("MESSAGE");
$message->setAttribute("ID", "1000");
$message->setAttribute("PROTOCOLVERSION", "1.0");
$root->addChild($message);
# add a SIMPLE REQUEST
my $simple_request = $doc->createElement("SIMPLEREQ");
$message->addChild($simple_request);
# add an IMETHOD CALL
my $imethod_call = $doc->createElement("IMETHODCALL");
$imethod_call->setAttribute("NAME", "EnumerateInstances");
$simple_request->addChild($imethod_call);
# add the local name space path
my $localnamespacepath = $doc->createElement("LOCALNAMESPACEPATH");
$tmpnode = $doc->createElement("NAMESPACE");
$tmpnode->setAttribute("NAME", "root");
$localnamespacepath->addChild($tmpnode);
$tmpnode = $doc->createElement("NAMESPACE");
$tmpnode->setAttribute("NAME", $cim_params->{namespace});
$localnamespacepath->addChild($tmpnode);
$imethod_call->addChild($localnamespacepath);
# add the target class name
my $param_classname = $doc->createElement("IPARAMVALUE");
$param_classname->setAttribute("NAME", "ClassName");
$imethod_call->addChild($param_classname);
my $classname = $doc->createElement("CLASSNAME");
$classname->setAttribute("NAME", $cim_params->{classname});
$param_classname->addChild($classname);
# add several common parameters
$imethod_call->appendWellBalancedChunk('<IPARAMVALUE NAME="DeepInheritance"><VALUE>TRUE</VALUE></IPARAMVALUE><IPARAMVALUE NAME="LocalOnly"><VALUE>FALSE</VALUE></IPARAMVALUE><IPARAMVALUE NAME="IncludeQualifiers"><VALUE>FALSE</VALUE></IPARAMVALUE><IPARAMVALUE NAME="IncludeClassOrigin"><VALUE>TRUE</VALUE></IPARAMVALUE>');
my $payload = $doc->toString();
# generate http request
my $ret = gen_http_request($http_params, $payload);
if ($ret->{rc}) {
return $ret;
}
# send request to http server
$ret = send_http_request($http_params, $ret->{request});
if ($ret->{rc}) {
return $ret;
}
# parse the http response
my $ret_value;
my $parser = XML::LibXML->new();
my $resp_doc = $parser->parse_string($ret->{payload});
# check the error message from CIM
my $error_node = $resp_doc->getElementsByTagName("ERROR");
if ($error_node) {
my $msg = $error_node->[0]->getAttribute("DESCRIPTION");
my $errorcode = $error_node->[0]->getAttribute("CODE");
return ({rc => 1, cim_rc => $errorcode, msg => $error_node->[0]->getAttribute("DESCRIPTION")." [cim return code: $errorcode]"});
}
# get the name path of the instance, which is used to set property
my @namepath = $resp_doc->getElementsByTagName("INSTANCENAME");
my $namepath_string;
if (@namepath) {
$namepath_string = $namepath[0]->toString();
}
# get all the instance elements
my @instances = $resp_doc->getElementsByTagName("VALUE.NAMEDINSTANCE");
foreach my $instance (@instances) {
# get all the property element for each instance
my @properties = $instance->getElementsByTagName("PROPERTY");
if (my @property_arrays = $instance->getElementsByTagName("PROPERTY.ARRAY")) {
push @properties, @property_arrays;
}
my $ins_value;
foreach my $property (@properties) {
# get name, vlaue and type for each property. (only the one which has value)
if (my $pname = $property->getAttribute("NAME")) {
if (my $pvalue = $property->getAttribute("TYPE")) {
$ins_value->{property}->{$pname}->{type} = $pvalue;
}
if ($property->getElementsByTagName("VALUE.ARRAY")) {
my @nodelist = $property->getElementsByTagName("VALUE");
my @value_array = ();
foreach my $n (@nodelist) {
push @value_array, $n->textContent;
}
$ins_value->{property}->{$pname}->{value} = join(',',@value_array);
} elsif (my $node = $property->getElementsByTagName("VALUE")) {
$ins_value->{property}->{$pname}->{value} = $node->[0]->textContent;
}
}
}
push @{$ret_value}, $ins_value;
}
return ({rc =>0}, $ret_value, $namepath_string);
}
=head1 set_property ()
Description:
Set the property for an instance.
Arguments:
http_params: A reference to HTTP_PARAMS
cim_params: The CIM parameters
namepath - a mandatory param to specify the path of the instance.
It should be returned from 'enum_instance' subroutine.
Return:
1 - A hash reference. The valid key includes:
rc - The return code. 0 - success. > 0 - fail.
cim_rc - The return code from CIM server.
msg - Output message.
=cut
sub set_property
{
my $http_params = shift;
unless (ref($http_params)) {
$http_params = shift;
}
my $cim_params = shift;
# This is a mandatory parameter
unless ($cim_params->{namepath}) {
return ({rc => 1, msg => "Missed the name path for the instance"});
}
unless ($cim_params->{namespace}) {
$cim_params->{namespace} = "ibmsd";
}
# prepare the CIM payload
my $tmpnode;
# create a new doc
my $doc = XML::LibXML->createDocument('1.0','UTF-8');
# create and add the root element
my $root = $doc->createElement("CIM");
$root->setAttribute("CIMVERSION", "2.0");
$root->setAttribute("DTDVERSION", "2.0");
$doc->setDocumentElement($root);
# create and add the MESSAGE element
my $message = $doc->createElement("MESSAGE");
$message->setAttribute("ID", "1000");
$message->setAttribute("PROTOCOLVERSION", "1.0");
$root->addChild($message);
# add a SIMPLE REQUEST
my $simple_request = $doc->createElement("SIMPLEREQ");
$message->addChild($simple_request);
# add an IMETHOD CALL
my $imethod_call = $doc->createElement("IMETHODCALL");
$imethod_call->setAttribute("NAME", "SetProperty");
$simple_request->addChild($imethod_call);
# add the local name space path
my $localnamespacepath = $doc->createElement("LOCALNAMESPACEPATH");
$tmpnode = $doc->createElement("NAMESPACE");
$tmpnode->setAttribute("NAME", "root");
$localnamespacepath->addChild($tmpnode);
$tmpnode = $doc->createElement("NAMESPACE");
$tmpnode->setAttribute("NAME", $cim_params->{namespace});
$localnamespacepath->addChild($tmpnode);
$imethod_call->addChild($localnamespacepath);
# add the target property name
my $param_propertyname = $doc->createElement("IPARAMVALUE");
$param_propertyname->setAttribute("NAME", "PropertyName");
$imethod_call->addChild($param_propertyname);
$tmpnode = $doc->createElement("VALUE");
$tmpnode->appendTextNode($cim_params->{propertyname});
$param_propertyname->addChild($tmpnode);
# add the target property value
my $param_newvaluename = $doc->createElement("IPARAMVALUE");
$param_newvaluename->setAttribute("NAME", "NewValue");
$imethod_call->addChild($param_newvaluename);
$tmpnode = $doc->createElement("VALUE");
$tmpnode->appendTextNode($cim_params->{propertyvalue});
$param_newvaluename->addChild($tmpnode);
# add parameters of instance name path
my $param_namepath = $doc->createElement("IPARAMVALUE");
$param_namepath->setAttribute("NAME", "InstanceName");
$param_namepath->appendWellBalancedChunk($cim_params->{namepath});
$imethod_call->addChild($param_namepath);
my $payload = $doc->toString();
# generate http request
my $ret = gen_http_request($http_params, $payload);
if ($ret->{rc}) {
return $ret;
}
# send request to http server
$ret = send_http_request($http_params, $ret->{request});
if ($ret->{rc}) {
return $ret;
}
# parse the http response
my $ret_value;
my $parser = XML::LibXML->new();
my $resp_doc = $parser->parse_string($ret->{payload});
# check the error message from CIM
my $error_node = $resp_doc->getElementsByTagName("ERROR");
if ($error_node) {
my $msg = $error_node->[0]->getAttribute("DESCRIPTION");
my $errorcode = $error_node->[0]->getAttribute("CODE");
return ({rc => 1, cim_rc => $errorcode, msg => $error_node->[0]->getAttribute("DESCRIPTION")." [cim return code: $errorcode]"});
}
# if no http and cim error, the setting was succeeded
return ($ret);
}
=head1 gen_http_request ()
Description:
Generate a http request.
Arguments:
http_params: A reference to HTTP_PARAMS
payload: The payload for the http request. It can be null if the payload has been set in http_params.
Return:
A hash reference. The valid key includes:
rc - The return code. 0 - success. > 0 - fail.
msg - Output message
request - The generated HTTP::Request object
=cut
sub gen_http_request
{
my $http_params = shift;
my $http_payload = shift;
# check the mandatory parameters
unless (defined ($http_params->{ip}) && defined ($http_params->{port}) && defined($http_params->{user}) && defined($http_params->{password})) {
return ({rc => 1, msg => "Missed the mandatory parameters: ip, port, user or password"});
}
# set the default value for parameters
unless (defined ($http_params->{protocol})) {
$http_params->{protocol} = 'https';
}
unless (defined ($http_params->{format})) {
$http_params->{format} = 'xml';
}
unless (defined ($http_params->{method})) {
$http_params->{method} = 'GET';
}
my $payload = '';
if (defined ($http_params->{payload})) {
$payload = $http_params->{payload};
}
if (defined ($http_payload)) {
unless (ref($http_payload)) { #Todo: support payloasd to be a hash
$payload = $http_payload;
}
}
# create the http head
my $header = HTTP::Headers->new('content-type' => "application/$http_params->{format}",
'Accept' => "application/$http_params->{format}",
'User-Agent' => "xCAT/2",
'Host' => "$http_params->{ip}:$http_params->{port}");
# set the user & password
$header->authorization_basic($http_params->{user}, $http_params->{password});
# set the length of payload
my $plen = length($payload);
$header->push_header('Content-Length' => $plen);
# create the URL
my $url = "$http_params->{protocol}://$http_params->{ip}:$http_params->{port}";
my $request = HTTP::Request->new($http_params->{method}, $url, $header, $payload);
# set the http version
$request->protocol('HTTP/1.1');
return ({rc => 0, request => $request});
}
=head1 send_http_request ()
Description:
Send http request to http server and waiting for the response.
Arguments:
http_params: A reference to HTTP_PARAMS
http_request: A HTTP::Request object
Return:
A hash reference. The valid key includes:
rc - The return code. 0 - success. > 0 - fail.
http_rc - The return code of http. 200, 400 ...
msg - Output message
payload - The http response from http server
=cut
sub send_http_request
{
my $http_params = shift;
my $http_request = shift;
# Load the library LWP::Protocol::https for https support
if ($http_params->{protocol} eq 'https') {
eval { require LWP::Protocol::https};
if ($@) {
return ({rc => 1, msg => "Failed to load perl library LWP::Protocol::https"});
}
}
# create a new HTTP User Agent Object
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0, SSL_verify_mode => 0});
if ($http_params->{timeout}) {
$ua->timeout($http_params->{timeout});
} else {
$ua->timeout(10); # the default timeout is 10s
}
if (defined($http_params->{verbose}) && defined ($http_params->{callback})) {
$http_params->{callback}({data => ["\n========CIM Request Start========", $http_request->as_string(), "=======CIM Request End======="]});
}
# send request and receive the response
my $response = $ua->request($http_request);
if (defined($http_params->{verbose}) && defined ($http_params->{callback}) && defined ($response->{_content})) {
$http_params->{callback}({data => ["\n========CIM Response Start========", $response->{_content}, "=======CIM Response End======="]});
}
# check the http response
if (defined ($response) && defined ($response->{_rc}) && defined ($response->{_msg})) {
if ($response->{_rc} eq "200" && $response->{_msg} eq "OK") {
return ({rc => 0, http_rc => $response->{_rc}, msg => "$response->{_msg} [http return code: $response->{_rc}]", payload => $response->{_content}});
}
}
return ({rc => 1, http_rc => $response->{_rc}, msg => $response->{_msg}});
}
1;

View File

@ -29,7 +29,7 @@ if ($inet6support) {
if ($^O =~ /^linux/i) {
# Is IPv6 enabled on the MN or xcat client node at all?
my $ipv6enabled = `ip addr 2> /dev/null | grep inet6`;
my $ipv6enabled = `ip addr | grep inet6`;
if (!$ipv6enabled) {
$inet6support = 0;
}
@ -237,10 +237,6 @@ if (ref($request) eq 'HASH') { # the request is an array, not pure XML
}
}
my $client;
my %sslargs;
if (defined($ENV{'XCATSSLVER'})) {
$sslargs{SSL_version} = $ENV{'XCATSSLVER'};
}
if (-r $keyfile and -r $certfile and -r $cafile) {
$client = IO::Socket::SSL->start_SSL($pclient,
SSL_key_file => $keyfile,
@ -249,7 +245,6 @@ if (ref($request) eq 'HASH') { # the request is an array, not pure XML
SSL_verify_mode => SSL_VERIFY_PEER,
SSL_use_cert => 1,
Timeout => 0,
%sslargs,
);
} else {
$client = IO::Socket::SSL->start_SSL($pclient,

View File

@ -598,7 +598,7 @@ sub _execute_dsh
}
else
{
# HERE: This is where the output shows up
# LKV: This is where the output shows up
#print STDOUT @{$output_buffers{$user_target}};
#print STDERR @{$error_buffers{$user_target}};
chomp(@{$output_buffers{$user_target}});
@ -1020,7 +1020,6 @@ sub fork_fanout_dsh
}
}
# save the original exports, we are going to add the unique node name below
my $firstpass=0;
while (@$targets_waiting
&& (keys(%$targets_active) < $$options{'fanout'}))
{
@ -1047,7 +1046,6 @@ sub fork_fanout_dsh
}
if ($$options{'environment'})
{
if ($firstpass ==0) { # do the servicenode stuff only once
# if we are on a servicenode need to get the environment file
# from the SNsyncfiledir, not local
if (xCAT::Utils->isServiceNode()) {
@ -1070,10 +1068,8 @@ sub fork_fanout_dsh
$rsp->{error}->[0] = "File $$options{'environment'} does not exist";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
}
$firstpass=1;
}
# build the xdsh command
push @dsh_command,
# build the xdsh command
push @dsh_command,
"$exportnode$$options{'pre-command'} . $$options{'environment'} ; $$options{'command'}$$options{'post-command'}";
}
@ -3997,7 +3993,8 @@ sub parse_and_run_dsh
{
$options{'user'} = $ENV{'DSH_TO_USERID'};
}
if ((!(defined($nodes))) && (!(defined($options{'rootimg'}))))
if ((!(defined(@$nodes))) && (!(defined($options{'rootimg'}))))
{ # no nodes and not -i option, error
my $rsp = ();
$rsp->{error}->[0] = "Unless using -i option, noderange is required.";
@ -4036,7 +4033,7 @@ sub parse_and_run_dsh
{ # from sinv, discard this name
undef @$nodes;
}
if (@$nodes[0])
if (defined(@$nodes))
{
my $rsp = {};
$rsp->{error}->[0] =
@ -4407,16 +4404,8 @@ sub parse_and_run_dcp
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1);
return;
}
if (@$nodes[0])
{
my $rsp = {};
$rsp->{error}->[0] =
"Input noderange:@$nodes and any other xdsh flags or environment variables are not valid with -i flag.";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1);
return;
}
}
if ((!(defined($nodes))) && (!(defined($options{'rootimg'}))))
if ((!(defined(@$nodes))) && (!(defined($options{'rootimg'}))))
{ # no nodes and not -i option, error
my $rsp = {};
$rsp->{error}->[0] = "Unless using -i option, noderange is required.";
@ -4513,7 +4502,7 @@ sub parse_and_run_dcp
#
# build list of nodes
my @nodelist;
if (@$nodes[0])
if (defined(@$nodes))
{ # there are nodes
@nodelist = @$nodes;
$options{'nodes'} = join(',', @nodelist);
@ -4983,8 +4972,7 @@ sub parse_rsync_input_file_on_MN
$::process_line = 0;
my $destfileisdir;
my $clause=0;
my $addmergescript =0;
my $addappendscript =0;
open(INPUTFILE, "< $input_file") || die "File $input_file does not exist\n";
while (my $line = <INPUTFILE>)
{
@ -5025,16 +5013,12 @@ sub parse_rsync_input_file_on_MN
# this triggers the running of the appendscript
$::appendscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
}
# add the append script to the sync
if ($addappendscript == 0) { # only add once
my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
my $appendscriptline = "$appscript -> $appscript";
$syncappendscript=1; # syncing the xdcpappend.sh script
&build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript);
$addappendscript=1;
}
} # end APPEND clause
my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
my $appendscriptline = "$appscript -> $appscript";
$syncappendscript=1; # syncing the xdcpappend.sh script
&build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript);
}
if ($clause =~ /MERGE:/) {
# location of the base merge script
# for MERGE we have to sync the mergescript and the
@ -5046,16 +5030,12 @@ sub parse_rsync_input_file_on_MN
# this triggers the running of the mergescript
$::mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
}
# add the merge script to the sync
if ($addmergescript == 0) { # only add once
my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
my $mergescriptline = "$mergescript -> $mergescript";
$syncmergescript=1; # syncing the xdcpmerge.sh script
&build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript);
$addmergescript=1;
}
} # end MERGE clause
my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
my $mergescriptline = "$mergescript -> $mergescript";
$syncmergescript=1; # syncing the xdcpmerge.sh script
&build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript);
}
}
} else { # not processing EXECUTE, EXECUTEALWAYS or APPEND
@ -5219,7 +5199,6 @@ sub build_append_rsync
push @::appendlines,$line;
}
my $src_file = $1; # append file left of arror
my $orig_src_file = $1; # append file left of arror
# it will be sync'd to $nodesyncfiledir/$append_file
my $dest_file = $nodesyncfiledir;
$dest_file .= $src_file;
@ -5248,7 +5227,7 @@ sub build_append_rsync
# to pick up files from /var/xcat/syncfiles...
if ($onServiceNode == 1) {
my $newsrcfile = $syncdir; # add SN syndir on front
$newsrcfile .= $orig_src_file;
$newsrcfile .= $src_file;
$src_file=$newsrcfile;
}
# destination file name
@ -5331,8 +5310,7 @@ sub build_merge_rsync
if ($syncmergescript == 0) { # don't add the xdcpmerge.sh line
push @::mergelines,$line;
}
my $src_file = $1; # merge file left of arrow
my $orig_src_file = $1;
my $src_file = $1; # merge file left of arror
# it will be sync'd to $nodesyncfiledir/$merge_file
my $dest_file = $nodesyncfiledir;
$dest_file .= $src_file;
@ -5361,7 +5339,7 @@ sub build_merge_rsync
# to pick up files from /var/xcat/syncfiles...
if ($onServiceNode == 1) {
my $newsrcfile = $syncdir; # add SN syndir on front
$newsrcfile .= $orig_src_file;
$newsrcfile .= $src_file;
$src_file=$newsrcfile;
}
# destination file name
@ -6051,11 +6029,11 @@ sub run_always_rsync_postscripts
# if on the service node need to add the $syncdir directory
# to the path
if (xCAT::Utils->isServiceNode()) {
my $tmps=$syncdir . $ps;
push @args, $tmps;
} else{
push @args, $ps;
my $tmpp=$syncdir . $ps;
$ps=$tmpp;
}
push @args, $ps;
push (@nodes, @{$$dshparms{'postscripts'}{$ps}});
$out=xCAT::Utils->runxcmd( { command => ['xdsh'],

View File

@ -253,6 +253,64 @@ use strict;
#---------------------------------------------------------------------------
=head3
ifconfig_inet
Builds a list of all IP Addresses bound to the local host and
stores them in a global list
Arguments:
None
Returns:
None
Globals:
@local_inet
Error:
None
Example:
xCAT::DSHCore->ifconfig_inet;
Comments:
Internal routine only
=cut
#---------------------------------------------------------------------------
sub ifconfig_inet
{
my @local_inet = ();
if ($^O eq 'aix')
{
my @ip_address = ();
my @output = `/usr/sbin/ifconfig -a`;
foreach my $line (@output)
{
($line =~ /inet ((\d{1,3}?\.){3}(\d){1,3})\s/o)
&& (push @local_inet, $1);
}
}
elsif ($^O eq 'linux')
{
my @ip_address = ();
my @output = `/sbin/ifconfig -a`;
foreach my $line (@output)
{
($line =~ /inet addr:((\d{1,3}?\.){3}(\d){1,3})\s/o)
&& (push @local_inet, $1);
}
}
}
#---------------------------------------------------------------------------

View File

@ -407,7 +407,7 @@ sub lshwconn_parse_args
}
if (scalar(@error_type_nodes)) {
my $tmp_nodelist = join ',', @error_type_nodes;
my $link = (scalar(@error_type_nodes) eq '1')? 'is':'are';
my $link = (scalar(@error_type_nodes) == '1')? 'is':'are';
return( ["Node type of node(s) $tmp_nodelist $link not supported for this command in FSPAPI.\n"]);
}
#$nodetypetab->close();

View File

@ -517,14 +517,12 @@ sub getmacs {
$data.= "\n$_\n";
push @$value, "\n$_\n";
} elsif ( /^ent\s+/ || /^hfi-ent\s+/ ) {
#my @fields = split /\s+/, $_;
#my $mac = $fields[2];
#$mac = format_mac( $mac );
#$fields[2] = $mac;
#$data .= join(" ",@fields)."\n";
#push @$value, join(" ",@fields)."\n";
$data .= "$_\n";
push @$value, "$_\n";
my @fields = split /\s+/, $_;
my $mac = $fields[2];
$mac = format_mac( $mac );
$fields[2] = $mac;
$data .= join(" ",@fields)."\n";
push @$value, join(" ",@fields)."\n";
}
}
push @$res,[$node,$data,0];

View File

@ -264,7 +264,7 @@ sub temp {
# No frame commands for IVM
#################################
if ( $hwtype eq "ivm" ) {
push @result, [$name,"$prefix Not available (No BPA)",0];
push @result, [$name,"$prefix Not available (No BPA)",1];
next;
}
#################################
@ -272,14 +272,14 @@ sub temp {
#################################
if ( @$d[4] !~ /^(fsp|lpar|cec)$/ ) {
my $text = "$prefix Only available for CEC/LPAR";
push @result, [$name,$text,0];
push @result, [$name,$text,1];
next;
}
#################################
# Error - No frame
#################################
if ( $mtms eq "0" ) {
push @result, [$name,"$prefix Not available (No BPA)",0];
push @result, [$name,"$prefix Not available (No BPA)",1];
next;
}
#################################
@ -352,7 +352,7 @@ sub rackenv {
#################################
if ( @$d[4] !~ /^(bpa|frame)$/ ) {
my $text = "$prefix Only available for BPA/Frame";
push @result, [$name,$text,0];
push @result, [$name,$text,1];
next;
}

View File

@ -16,7 +16,7 @@ use xCAT::Usage;
use xCAT::NodeRange;
use xCAT::FSPUtils;
use xCAT::VMCommon;
use Data::Dumper;
#use Data::Dumper;
use xCAT::MsgUtils qw(verbose_message);
##############################################
# Globals
@ -48,26 +48,15 @@ sub parse_args {
##########################################################################
# Parse the chvm command line for options and operands
##########################################################################
my @query_array = ();
my %param_list_map = (
'vmcpus' => 'part_get_lpar_processing',
'vmmemory' => 'part_get_lpar_memory',
'add_physlots' => 'part_get_all_io_bus_info',
'del_physlots' => 'part_get_all_io_bus_info',
'add_vmnics' => 'part_get_all_vio_info',
'add_vmstorage' => 'part_get_all_vio_info',
'del_vadapter' => 'part_get_all_vio_info'
);
sub chvm_parse_extra_options {
my $args = shift;
my $opt = shift;
# Partition used attributes #
my @support_ops = qw(vmcpus vmmemory add_physlots vmothersetting add_vmstorage add_vmnics del_vadapter del_physlots);
my @support_ops = qw(vmcpus vmmemory vmphyslots vmothersetting vmstorage vmnics del_vadapter);
if (ref($args) ne 'ARRAY') {
return "$args";
}
my %tmp_hash = ();
foreach (@$args) {
my ($cmd, $value) = split (/\=/, $_);
if (!defined($value)) {
@ -86,33 +75,17 @@ sub chvm_parse_extra_options {
# return "'$value' invalid";
# }
} elsif (grep(/^$cmd$/, @support_ops)) {
if (exists($param_list_map{$cmd})) {
$tmp_hash{$param_list_map{$cmd}} = 1;
}
if (exists($opt->{p775})) {
return "'$cmd' doesn't work for Power 775 machines.";
} elsif ($cmd eq "del_vadapter") {
if ($value !~ /^\d+$/) {
return "Invalid param '$value', only one slot id can be specified";
}
} elsif ($cmd eq "del_physlots") {
my @tmp_array = split ",",$value;
foreach (@tmp_array) {
unless (/(0x\w{8})/) {
return "'$_' is invalid";
}
}
} elsif ($cmd eq "vmothersetting") {
if ($value =~ /hugepage:\s*(\d+)/i) {
$opt->{huge_page} = $1;
$tmp_hash{'get_huge_page'} = 1;
}
if ($value =~ /bsr:\s*(\d+)/i) {
$opt->{bsr} = $1;
$tmp_hash{'get_cec_bsr'} = 1;
}
next;
} elsif ($cmd eq "add_vmstorage") {
} elsif ($cmd eq "vmstorage") {
if (exists($opt->{vios})) {
if ($value !~ /\d+/) {
return "'$value' is invalid, must be numbers";
@ -141,13 +114,13 @@ sub chvm_parse_extra_options {
} elsif ($cmd eq "vmmemory") {
if ($value =~ /^([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)$/i) {
my ($mmin, $mcur, $mmax);
if ($2 eq "G" or $2 eq '') {
if ($2 == "G" or $2 == '') {
$mmin = $1 * 1024;
}
if ($4 eq "G" or $4 eq '') {
if ($4 == "G" or $4 == '') {
$mcur = $3 * 1024;
}
if ($6 eq "G" or $6 eq '') {
if ($6 == "G" or $6 == '') {
$mmax = $5 * 1024;
}
unless ($mmin <= $mcur and $mcur <= $mmax) {
@ -156,7 +129,7 @@ sub chvm_parse_extra_options {
} else {
return "'$value' is invalid";
}
} elsif ($cmd eq "add_physlots") {
} elsif ($cmd eq "vmphyslots") {
my @tmp_array = split ",",$value;
foreach (@tmp_array) {
unless (/(0x\w{8})/) {
@ -170,7 +143,7 @@ sub chvm_parse_extra_options {
return "'$_' is invalid";
}
}
} elsif ($cmd eq "add_vmnics") {
} elsif ($cmd eq "vmnics") {
my @tmp_array = split ",", $value;
foreach (@tmp_array) {
unless (/^vlan\d+$/i) {
@ -184,7 +157,6 @@ sub chvm_parse_extra_options {
}
$opt->{$cmd} = $value;
}
@query_array = keys(%tmp_hash);
return undef;
}
@ -206,9 +178,8 @@ sub chvm_parse_args {
# Process command-line arguments
#############################################
if ( !defined( $args )) {
#$request->{method} = $cmd;
#return( \%opt );
return ( usage() );
$request->{method} = $cmd;
return( \%opt );
}
#############################################
# Checks case in GetOptions, allows opts
@ -423,7 +394,7 @@ sub chvm_parse_args {
my $check_chvm_arg = chvm_parse_extra_options(\@ARGV, \%opt);
if (defined($check_chvm_arg)) {
return (usage("Invalid argument: $check_chvm_arg"));
} elsif (($opt{lparname}) && ($opt{lparname} ne '*') && (scalar(@{$request->{node}}) > '1')){
} elsif (($opt{lparname} ne '*') && (scalar(@{$request->{node}}) > '1')){
return(usage( "Invalid argument: must specify '*' for more than one node" ));
}
if ((exists($opt{lparname}) ||exists($opt{huge_page})) &&
@ -616,6 +587,7 @@ sub mkvm_parse_args {
if ( (!exists( $opt{i} ) || !exists( $opt{r} )) ) {
return(usage());
}
}
$opt{target} = \@{$request->{node}};
my $ppctab = xCAT::Table->new( 'ppc');
unless($ppctab) {
@ -640,11 +612,9 @@ sub mkvm_parse_args {
return(usage("For Power 775, please make sure the noderange are in one CEC "));
}
}
#if (exists($opt{p775})) {
if (exists($opt{p775})) {
$request->{node} = [$other_p];
$request->{noderange} = $other_p;
#}
}
####################################
# No operands - add command name
@ -749,7 +719,7 @@ sub lsvm_parse_args {
$Getopt::Long::ignorecase = 0;
Getopt::Long::Configure( "bundling" );
if ( !GetOptions( \%opt, qw(V|verbose l|long p775 updatedb) )) {
if ( !GetOptions( \%opt, qw(V|verbose l|long p775) )) {
return( usage() );
}
if (exists($opt{l}) && !exists($opt{p775})) {
@ -788,12 +758,11 @@ sub modify {
return op_extra_cmds ($request, $hash) if ($request->{opt}->{lparname} || $request->{opt}->{huge_page});
return ([["Error", "Miss argument\n".$usage_string, 1]]);
}
sub do_op_extra_cmds {
my $request = shift;
my $hash = shift;
my @values = ();
my %lpar_hash = ();
while (my ($mtms, $h) = each(%$hash)) {
my $memhash;
while (my($name, $d) = each(%$h)) {
@ -803,27 +772,14 @@ sub do_op_extra_cmds {
if ($op eq "lparname") {
$action = "set_lpar_name";
} elsif ($op eq "huge_page") {
my @td = @$d;
@td[0] = 0;
my $tmphash = &query_cec_info_actions($request, $name, \@td, 1, ["get_huge_page"]);
if ($tmphash->{huge_page_avail}) {
if ($param > $tmphash->{huge_page_avail}) {
push @values, [$name, "No enough huge pages, only $tmphash->{huge_page_avail} pages available", 0];
$param = $tmphash->{huge_page_avail};
}
$param = "1/$param/$param";
} else {
push @values, [$name, "No huge page available to configure", 0];
next;
}
$action = "set_huge_page";
} elsif ($op eq "vmcpus") {
$action = "part_set_lpar_pending_proc";
} elsif ($op eq "add_physlots" or $op eq "del_physlots") {
} elsif ($op eq "vmphyslots") {
$action = "set_io_slot_owner_uber";
} elsif ($op eq "del_vadapter") {
$action = "part_clear_vslot_config";
} elsif ($op eq "add_vmnics") {
} elsif ($op eq "vmnics") {
my @vlans = split /,/,$param;
foreach (@vlans) {
if (/vlan(\d+)/i) {
@ -842,7 +798,7 @@ sub do_op_extra_cmds {
}
}
next;
} elsif ($op eq "add_vmstorage") {
} elsif ($op eq "vmstorage") {
foreach my $v_info (@$param) {
if ($v_info =~ /(\d+),([\w_-]*):(\d+)/) {
my $vios = &find_lpar_id($request, @$d[3], $2);
@ -864,28 +820,24 @@ sub do_op_extra_cmds {
my @td = @$d;
@td[0] = 0;
$memhash = &query_cec_info_actions($request, $name, \@td, 1, ["part_get_hyp_process_and_mem"]);
unless (scalar keys(%$memhash)) {
push @values, [$mtms, "Can not get hypervisor information", 1];
next;
}
if (!exists($memhash->{run})) {
if ($param =~ /(\d+)([G|M]?)\/(\d+)([G|M]?)\/(\d+)([G|M]?)/i) {
my $memsize = $memhash->{mem_region_size};
my $min = $1;
if ($2 eq "G" or $2 eq '') {
if ($2 == "G" or $2 == '') {
$min = $min * 1024;
}
$min = int($min/$memsize);
$min = $min/$memsize;
my $cur = $3;
if ($4 eq "G" or $4 eq '') {
if ($4 == "G" or $4 == '') {
$cur = $cur * 1024;
}
$cur = int($cur/$memsize);
$cur = $cur/$memsize;
my $max = $5;
if ($6 eq "G" or $6 eq '') {
if ($6 == "G" or $6 == '') {
$max = $max * 1024;
}
$max = int($max/$memsize);
$max = $max/$memsize;
$request->{opt}->{$op} ="$min/$cur/$max";
$param = $request->{opt}->{$op};
} else {
@ -897,11 +849,7 @@ sub do_op_extra_cmds {
$memhash->{lpar_used_regions} = 0;
my $ret = &deal_with_avail_mem($request, $name, $d, $memhash);
if (ref($ret) eq "ARRAY") {
if (@$ret[2]) {
return ([[@$ret]]);
} else {
push @values, $ret;
}
return ([[@$ret]]);
}
$param = $memhash->{memory};
$action = "part_set_lpar_pending_mem";
@ -915,32 +863,15 @@ sub do_op_extra_cmds {
}
my $tmp_value = ($param eq '*') ? $name : $param;
xCAT::MsgUtils->verbose_message($request, "$request->{command} $action for node:$name, parm:$tmp_value.");
my @tmpd = @$d;
if ($op eq "del_physlots") {
@tmpd[0] = "-1";
}
my $value = xCAT::FSPUtils::fsp_api_action($request, $name, \@tmpd, $action, 0, $tmp_value);
my $value = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $tmp_value);
if (@$value[1] && ((@$value[1] =~ /Error/i) && (@$value[2] ne '0'))) {
return ([[$name, @$value[1], '1']]) ;
} else {
push @values, [$name, "Success", '0'];
}
}
if (@query_array) {
my $rethash = query_cec_info_actions($request, $name, $d, 1, \@query_array);
unless (scalar keys(%$rethash)) {
push @values, [$mtms, "Can not get hypervisor information", 1];
next;
}
# need to add update db here
$lpar_hash{$name} = $rethash;
$lpar_hash{$name}->{parent} = @$d[3];
}
}
}
if (%lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@values;
}
sub check_node_info {
@ -1183,7 +1114,7 @@ sub get_cec_lpar_name {
my @value = split(/\n/, $lpar_info);
foreach my $v (@value) {
if($v =~ /lparname:\s*([^\,]*),\s*lparid:\s*([\d]+),/) {
if($2 eq $lparid) {
if($2 == $lparid) {
return $1;
}
}
@ -1707,7 +1638,7 @@ sub xCATdB {
$profile,
$parent );
return( xCAT::PPCdb::add_ppc( $hwtype, [$values],'','',"FSP" ));
return( xCAT::PPCdb::add_ppc( $hwtype, [$values] ));
}
return undef;
}
@ -1721,7 +1652,6 @@ my @partition_query_actions = qw(part_get_partition_cap part_get_hyp_process_and
sub parse_part_get_info {
my $hash = shift;
my $data = shift;
my $lparid = shift;
my @array = split /\n/, $data;
foreach my $line (@array) {
chomp($line);
@ -1738,16 +1668,13 @@ sub parse_part_get_info {
$hash->{process_units_avail} = $2;
} elsif ($line =~ /Authority Lpar id:(\w+)/i) {
$hash->{service_lparid} = $1;
} elsif ($line =~ /(\d+),(\d+),[^,]*,(\w+),\w*\(([\w| |-|_|\/]*)\)/) {
} elsif ($line =~ /(\d+),(\d+),[^,]*,(\w+),\w*\(([\w| |-|_]*)\)/) {
$hash->{bus}->{$3}->{cur_lparid} = $1;
$hash->{bus}->{$3}->{bus_slot} = $2;
$hash->{bus}->{$3}->{des} = $4;
if ($lparid and $lparid eq $1) {
push @{$hash->{lpar_phy_bus}}, $3;
}
} elsif ($line =~ /Phy drc_index:(\w+), Port group: (\w+), Phy port id: (\w+)/) {
$hash->{phy_drc_group_port}->{$1}->{$2}->{$3} = '1';
#} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) {
} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) {
if (($2 == -1) && ($4 == 255)) {
$hash->{logic_drc_phydrc}->{$3}->{$5} = $1;
#$hash->{logic_drc_phydrc}->{$5}->{$1} = [$2,$3,$4];
@ -1760,49 +1687,12 @@ sub parse_part_get_info {
$hash->{lpar0_used_mem} = $2;
$hash->{phy_min_mem_req} = $3;
#print "===>lpar0_used_mem:$hash->{lpar0_used_mem}.\n";
} elsif ($line =~ /Curr Memory (Min|Req|Max):\s*([\d]*)[^\(]*\((\d+)\s*regions\)/) {
if ($1 eq 'Min') {
$hash->{lpar_mem_min} = $2
} elsif ($1 eq 'Max') {
$hash->{lpar_mem_max} = $2;
} else {
$hash->{lpar_mem_req} = $2;
$hash->{lpar_used_regions} = $3;
}
} elsif ($line =~ /Curr Processor (Min|Req|Max):\s*(\d+)/) {
if ($1 eq 'Min') {
$hash->{lpar_cpu_min} = $2;
} elsif ($1 eq 'Max') {
$hash->{lpar_cpu_max} = $2;
} else {
$hash->{lpar_cpu_req} = $2;
}
} elsif ($line =~ /\s*lpar_id=(\d+),type=vSCSI,slot=(\d+),attr=(\d+).*remote_lpar_id=0x(\w+),remote_slot_num=0x(\w+)/) {
if ($3 eq '0') {
my $lparid = hex($4);
my $slotid = hex($5);
push @{$hash->{lpar_vmstorage_client}}, "$lparid:$slotid";
} else {
if (exists($hash->{lpar_vmstorage_server})) {
$hash->{lpar_vmstorage_server}++;
} else {
$hash->{lpar_vmstorage_server} = 1;
}
}
} elsif ($line =~ /\s*lpar_id=(\d+),type=(vEth),slot=(\d+).*port_vlan_id=(\d+),mac_addr=(\w+)/) {
push @{$hash->{lpar_vmnics}}, "vlan$4";
} elsif ($line =~ /Curr Memory Req:[^\(]*\((\d+)\s*regions\)/) {
$hash->{lpar_used_regions} = $1;
} elsif ($line =~ /Available huge page memory\(in pages\):\s*(\d+)/) {
$hash->{huge_page_avail} = $1;
} elsif ($line =~ /Available BSR array:\s*(\d+)/) {
$hash->{cec_bsr_avail} = $1;
} elsif ($line =~ /^\d+\/(\d+)\/\d+$/) {
if ($1 ne 0) {
push @{$hash->{lpar_othersetting}}, "hugepage:$1";
}
} elsif ($line =~ /^(\d+)\.$/) {
if ($1 ne 0) {
push @{$hash->{lpar_othersetting}}, "bsr:$1";
}
}
}
}
@ -1813,7 +1703,6 @@ sub query_cec_info_actions {
my $td = shift;
my $usage = shift;
my $action_array = shift;
my $lpar_hash = shift;
my $lparid = @$td[0];
my $data;
my @array = ();
@ -1828,16 +1717,12 @@ sub query_cec_info_actions {
chomp(@$values[1]);
#if ($action eq "part_get_partition_cap" and (@$values[1] =~ /Error:/i or @$values[2] ne 0)) {
if (@$values[1] =~ /Error:/i or @$values[2] ne 0) {
next; #return ([[@$values]]);
return ([[@$values]]);
}
if (@$values[1] =~ /^$/) {
next;
}
if ($usage eq 1 or $usage eq 2) {
&parse_part_get_info(\%hash, @$values[1], $lparid);
}
if ($usage eq 0 or $usage eq 2) {
if ($usage eq 0) {
if ($lparid) {
if ($action eq "lpar_lhea_mac") {
my @output = split /\n/,@$values[1];
@ -1892,72 +1777,18 @@ sub query_cec_info_actions {
}
#$data .= "@$values[1]\n\n";
push @array, [$name, @$values[1], @$values[2]];
}
}
if ($usage eq 0 or $usage eq 2) {
#return $data;
if ($usage eq 2) {
%$lpar_hash = %hash;
} else {
&parse_part_get_info(\%hash, @$values[1]);
}
}
if ($usage eq 0) {
#return $data;
return \@array;
} else {
return \%hash;
}
}
sub update_vm_db {
my $request = shift;
my $lpar_hash = shift;
my $vm_hd = xCAT::Table->new('vm');
my %name_id_map = ();
my $commit = 0;
foreach (keys (%$lpar_hash)) {
my %db_update = ();
my $node_hash = $lpar_hash->{$_};
if (exists($node_hash->{lpar_cpu_min})) {
$db_update{cpus} = "$node_hash->{lpar_cpu_min}/$node_hash->{lpar_cpu_req}/$node_hash->{lpar_cpu_max}";
}
if (exists($node_hash->{lpar_mem_min})) {
$db_update{memory} = "$node_hash->{lpar_mem_min}/$node_hash->{lpar_mem_req}/$node_hash->{lpar_mem_max}";
}
if (exists($node_hash->{lpar_vmstorage_server})) {
$db_update{storage} = $node_hash->{lpar_vmstorage_server};
} elsif (exists($node_hash->{lpar_vmstorage_client})) {
my @tmp_array = ();
foreach (@{$node_hash->{lpar_vmstorage_client}}) {
if (/(\d+):(\d+)/) {
if (exists($name_id_map{$1})) {
push @tmp_array, "$name_id_map{$1}:$2";
} else {
my $vios_name = &find_lpar_name($request, $node_hash->{parent}, $1);
if (defined($vios_name)) {
$name_id_map{$1} = $vios_name;
push @tmp_array, "$vios_name:$2";
}
}
}
}
$db_update{storage} = join(",",@tmp_array);
}
if (exists($node_hash->{lpar_vmnics})) {
$db_update{nics} = join(",",@{$node_hash->{lpar_vmnics}});
}
if (exists($node_hash->{lpar_phy_bus})) {
$db_update{physlots} = join(",",@{$node_hash->{lpar_phy_bus}});
}
if (exists($node_hash->{lpar_othersetting})) {
$db_update{othersettings} = join(",",@{$node_hash->{lpar_othersetting}});
}
if (%db_update) {
$vm_hd->setNodeAttribs($_,\%db_update);
$commit = 1;
}
}
if ($commit) {
$vm_hd->commit;
}
}
#my @partition_query_actions = qw(part_get_partition_cap part_get_num_of_lpar_slots part_get_hyp_config_process_and_mem part_get_hyp_avail_process_and_mem part_get_service_authority_lpar_id part_get_shared_processing_resource part_get_all_vio_info lpar_lhea_mac part_get_all_io_bus_info part_get_lpar_processing part_get_lpar_memory get_huge_page get_cec_bsr);
sub query_cec_info {
my $request = shift;
@ -1965,48 +1796,25 @@ sub query_cec_info {
my $args = $request->{opt};
my @td = ();
my @result = ();
my $usage = 0;
my %lpar_hash = ();
#print Dumper($request);
#print Dumper($hash);
while (my ($mtms,$h) = each(%$hash) ) {
while (my ($name, $d) = each (%$h)) {
my %tmp_hash = ();
@td = @$d;
if (@$d[0] == 0 && @$d[4] !~ /lpar|vios/) {
last;
}
#my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","lpar_lhea_mac","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]);
if ($args->{updatedb}) {
$usage = 2;
}
my $rethash = query_cec_info_actions($request, $name, $d, $usage, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"], \%tmp_hash);
my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"]);
#push @result, [$name, $rethash, 0];
#push @result, @$rethash;
if (scalar (@$rethash)) {
push @result, @$rethash;
} else {
push @result, [$name, "No information got", -1];
last;
}
$lpar_hash{$name} = \%tmp_hash;
$lpar_hash{$name}->{parent} = @$d[3];
push @result, @$rethash;
}
if (@td[0] == 0) {
my $rethash = query_cec_info_actions($request, @td[3],\@td, $usage);
if (scalar (@$rethash)) {
push @result, @$rethash;
} else {
push @result, [@td[3], "No information got", -1];
last;
}
my $rethash = query_cec_info_actions($request, @td[3],\@td, 0);
#push @result, [@td[3], $rethash, 0];
#push @result, @$rethash;
push @result, @$rethash;
}
}
if ($args->{updatedb} and %lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@result;
}
@ -2101,12 +1909,9 @@ sub deal_with_avail_mem {
my $cur_mem_in_G = $lparhash->{hyp_avail_mem} * $lparhash->{mem_region_size} * 1.0 / 1024;
return([$name, "Parse reserverd regions failed, no enough memory, available:$cur_mem_in_G GB.", 1]);
}
if (($cur_avail > 0) and ($cur > $cur_avail)) {
my $cur_avail_in_G = $cur_avail * $lparhash->{mem_region_size} * 1.0 / 1024;
$lparhash->{memory} = "$min/$cur_avail/$max";
unless ($lparhash->{full_par}) {
return([$name, "Available memory is less than required, allocate $cur_avail_in_G GB.", 0]);
}
if ($cur > $cur_avail) {
my $new_cur = $cur_avail;
$lparhash->{memory} = "$min/$new_cur/$max";
}
} else {
return ([$name, "Failed to get hypervisor reserved memory regions.", 1]);
@ -2126,25 +1931,11 @@ sub find_lpar_id {
return undef;
}
sub find_lpar_name {
my $request = shift;
my $parent = shift;
my $id = shift;
my %mapping = %{$request->{ppc}->{$parent}->{mapping}};
foreach (keys %mapping) {
if ($mapping{$_} eq $id) {
return $_;
}
}
return undef;
}
sub create_lpar {
my $request = shift;
my $name = shift;
my $d = shift;
my $lparhash = shift;
my @ret = ();
my $values;
if (exists($request->{opt}->{vios})) {
$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_def_state", 0, 0x03);
@ -2157,7 +1948,7 @@ sub create_lpar {
$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_lpar_name", 0, $name);
if (@$values[2] ne 0) {
&set_lpar_undefined($request, $name, $d);
return ([[$name, @$values[1], @$values[0]]]);
return ([$name, @$values[1], @$values[0]]);
}
xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_shared_pool_util_auth");
xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_group_id");
@ -2168,7 +1959,7 @@ sub create_lpar {
#$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_io_slot_owner", 0, join(",",@phy_io_array));
if (@$values[2] ne 0) {
&set_lpar_undefined($request, $name, $d);
return ([[$name, @$values[1], @$values[2]]]);
return ([$name, @$values[1], @$values[2]]);
}
}
if (exists($lparhash->{nics})) {
@ -2184,7 +1975,7 @@ sub create_lpar {
$values = xCAT::FSPUtils::fsp_api_action($request,$name, $d, "part_set_veth_slot_config",0,"0,$vlanid,$mac");
if (@$values[2] ne 0) {
&set_lpar_undefined($request, $name, $d);
return ([[$name, @$values[1], @$values[2]]]);
return ([$name, @$values[1], @$values[2]]);
}
}
}
@ -2194,7 +1985,7 @@ sub create_lpar {
$values = xCAT::FSPUtils::fsp_api_action($request,$name, $d, "part_set_vscsi_slot_config",0,$v_info);
if (@$values[2] ne 0) {
&set_lpar_undefined($request, $name, $d);
return ([[$name, @$values[1], @$values[2]]]);
return ([$name, @$values[1], @$values[2]]);
}
}
}
@ -2225,23 +2016,19 @@ sub create_lpar {
$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_pending_proc", 0, $lparhash->{cpus});
if (@$values[2] ne 0) {
&set_lpar_undefined($request, $name, $d);
return ([[$name, @$values[1], @$values[2]]]);
return ([$name, @$values[1], @$values[2]]);
}
$values = &deal_with_avail_mem($request, $name, $d,$lparhash);
if (ref($values) eq "ARRAY") {
if (@$values[2]) {
&set_lpar_undefined($request, $name, $d);
return ([[@$values]]);
} else {
push @ret, $values;
}
&set_lpar_undefined($request, $name, $d);
return ([@$values]);
}
#print "======>memory:$lparhash->{memory}.\n";
$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_pending_mem", 0, $lparhash->{memory});
if (@$values[2] ne 0) {
&set_lpar_undefined($request, $name, $d);
return ([[$name, @$values[1], @$values[2]]]);
return ([$name, @$values[1], @$values[2]]);
}
xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_comp_modes");
@ -2256,11 +2043,9 @@ sub create_lpar {
$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_def_state", 0, 0x02);
}
if (@$values[2] ne 0) {
return ([[$name, @$values[1], @$values[2]]]);
return ([$name, @$values[1], @$values[2]]);
}
push @ret, [$name, "Done", 0];
#return ([$name, "Done", 0]);
return \@ret;
return ([$name, "Done", 0]);
}
sub mkspeclpar {
@ -2269,13 +2054,12 @@ sub mkspeclpar {
my $opt = $request->{opt};
my $values;
my @result = ();
my %lpar_hash = ();
my $vmtab = xCAT::Table->new( 'vm');
unless($vmtab) {
return([["Error","Cannot open vm table", 1]]);
}
while (my ($mtms, $h) = each (%$hash)) {
my $memhash = undef;
my $memhash;
my @nodes = keys(%$h);
my $ent = $vmtab->getNodesAttribs(\@nodes, ['cpus', 'memory','physlots', 'othersettings', 'storage', 'nics']);
while (my ($name, $d) = each (%$h)) {
@ -2283,18 +2067,12 @@ sub mkspeclpar {
push @result, [$name, "Node must be LPAR", 1];
last;
}
#if (!exists($memhash->{run}))
#{
if (!exists($memhash->{run})) {
my @td = @$d;
@td[0] = 0;
$memhash = &query_cec_info_actions($request, $name, \@td, 1, ["part_get_hyp_process_and_mem","lpar_lhea_mac","part_get_all_io_bus_info"]);
unless (scalar keys(%$memhash)) {
push @result, [$mtms, "Can not get hypervisor information", 1];
last;
}
#$memhash->{run} = 1;
#}
$memhash->{run} = 1;
}
my $tmp_ent = $ent->{$name}->[0];
if (exists($opt->{vmcpus})) {
$tmp_ent->{cpus} = $opt->{vmcpus};
@ -2329,40 +2107,28 @@ sub mkspeclpar {
if ($tmp_ent->{cpus} =~ /^(\d+)\/(\d+)\/(\d+)$/) {
unless ($1 <= $2 and $2 <= $3) {
return([[$name, "Parameter for 'vmcpus' is invalid", 1]]);
} elsif ($memhash->{process_units_avail} eq '0') {
push @result, [$name, "No process available", 1];
next;
} elsif ($2 > $memhash->{process_units_avail}) {
my $cur = $memhash->{process_units_avail};
my $min = $1 > $cur ? $cur : $1;
$tmp_ent->{cpus} = "$min/$cur/$3";
push @result, [$name, "Available processor is less than required, allocate $cur processors.", 0];
}
} else {
return([[$name, "Parameter for 'vmcpus' is invalid", 1]]);
}
if ($tmp_ent->{memory} =~ /^([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)$/i) {
if ($memhash->{hyp_avail_mem} eq '0') {
push @result, [$name, "No memory available", 1];
next;
}
my ($mmin, $mcur, $mmax);
if ($2 eq "G" or $2 eq '') {
if ($2 == "G" or $2 == '') {
$mmin = $1 * 1024;
}
if ($4 eq "G" or $4 eq '') {
if ($4 == "G" or $4 == '') {
$mcur = $3 * 1024;
}
if ($6 eq "G" or $6 eq '') {
if ($6 == "G" or $6 == '') {
$mmax = $5 * 1024;
}
unless ($mmin <= $mcur and $mcur <= $mmax) {
return([[$name, "Parameter for 'vmmemory' is invalid", 1]]);
}
my $memsize = $memhash->{mem_region_size};
$mmin = int(($mmin + $memsize - 1) / $memsize);
$mcur = int(($mcur + $memsize - 1) / $memsize);
$mmax = int(($mmax + $memsize - 1) / $memsize);
$mmin = ($mmin + $memsize) / $memsize;
$mcur = ($mcur + $memsize) / $memsize;
$mmax = ($mmax + $memsize) / $memsize;
$tmp_ent->{memory} = "$mmin/$mcur/$mmax";
$tmp_ent->{mem_region_size} = $memsize;
} else {
@ -2412,27 +2178,21 @@ sub mkspeclpar {
$tmp_ent->{storage} = \@array;
}
} else {
if (exists($tmp_ent->{storage})) {
my @tmp_array = split ",",$tmp_ent->{storage};
my $storage_array = undef;
foreach (@tmp_array) {
if (/([\w_-]*):(\d+)/) {
my $vios = &find_lpar_id($request, @$d[3], $1);
my $r_slotid = $2;
if (defined($vios)) {
push @$storage_array, "0,$vios,$r_slotid";
} else {
return ([[$name, "Cannot find lparid for Server lpar:$1"]]);
}
} else {
return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]);
if (exists($tmp_ent->{storage}) and $tmp_ent->{storage} !~ /^[\w_-]*:\d+$/) {
return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]);
} elsif (exists($tmp_ent->{storage})) {
if ($tmp_ent->{storage} =~ /([\w_-]*):(\d+)/) {
my $vios = &find_lpar_id($request, @$d[3], $1);
my $r_slotid = $2;
if (!defined($vios)) {
return ([[$name, "Cannot find lparid for Server lpar:$1"]]);
}
$tmp_ent->{storage} = ["0,$vios,$r_slotid"];
}
$tmp_ent->{storage} = $storage_array;
}
}
$tmp_ent->{hyp_config_mem} = $memhash->{hyp_config_mem};
$tmp_ent->{hyp_avail_mem} = $memhash->{hyp_avail_mem};
if (exists($tmp_ent->{othersettings})) {
@ -2452,23 +2212,11 @@ sub mkspeclpar {
$tmp_ent->{phy_hea} = $memhash->{phy_drc_group_port};
$tmp_ent->{logic_drc_phydrc} = $memhash->{logic_drc_phydrc};
$values = &create_lpar($request, $name, $d, $tmp_ent);
push @result, @$values;
#need to add update db here
my $rethash = query_cec_info_actions($request, $name, $d, 1, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]);
unless (scalar keys(%$rethash)) {
push @result, [$mtms, "Can not get hypervisor information", 1];
next;
}
$lpar_hash{$name} = $rethash;
$lpar_hash{$name}->{parent} = @$d[3];
push @result, $values;
$name = undef;
$d = undef;
}
}
if (%lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@result;
}
@ -2488,9 +2236,8 @@ sub mkfulllpar {
my @td = @$d;
@td[0] = 0;
$rethash = query_cec_info_actions($request, $name, \@td, 1);
unless (scalar keys(%$rethash)) {
push @result, [$mtms, "Can not get hypervisor information", 1];
next;
if (ref($rethash) ne 'HASH') {
return ([[$mtms, "Cann't get hypervisor info hash", 1]]);
}
$rethash->{run} = 1;
#print Dumper($rethash);
@ -2500,17 +2247,15 @@ sub mkfulllpar {
$lpar_param{memory} = "1/".$rethash->{hyp_avail_mem}."/".$rethash->{hyp_config_mem};
$lpar_param{hyp_config_mem} = $rethash->{hyp_config_mem};
$lpar_param{hyp_avail_mem} = $rethash->{hyp_avail_mem};
$lpar_param{mem_region_size} = $rethash->{mem_region_size};
my @phy_io_array = keys(%{$rethash->{bus}});
$lpar_param{physlots} = join(",", @phy_io_array);
$lpar_param{huge_page} = "1/".$rethash->{huge_page_avail}."/".$rethash->{huge_page_avail};
$lpar_param{bsr_num} = $rethash->{cec_bsr_avail};
$lpar_param{phy_hea} = $rethash->{phy_drc_group_port};
$lpar_param{logic_drc_phydrc} = $rethash->{logic_drc_phydrc};
$lpar_param{full_par} = 1;
$values = &create_lpar($request, $name, $d, \%lpar_param);
$rethash->{logic_drc_phydrc} = $lpar_param{logic_drc_phydrc};
push @result, @$values;
push @result, $values;
$name = undef;
$d = undef;
}

28
perl-xCAT/xCAT/InstUtils.pm Executable file → Normal file
View File

@ -217,23 +217,14 @@ sub is_me
#my ($b1, $b2, $b3, $b4) = split /\./, $nameIP;
# get all the possible IPs for the node I'm running on
# this is a common subroutine for both AIX and Linux,
# AIX does not have ip command
my $ipcmd;
if ( -f "/sbin/ip" )
{
$ipcmd = "ip addr | grep 'inet'";
}
else
{
$ipcmd = "ifconfig -a | grep 'inet'";
}
my $result = xCAT::Utils->runcmd($ipcmd, -1, 1);
my $ifcmd = "ifconfig -a | grep 'inet'";
my $result = xCAT::Utils->runcmd($ifcmd, -1, 1);
if ($::RUNCMD_RC != 0)
{
my $str="Error running ipcmd";
xCAT::MsgUtils->message("S", $str);
$::VERBOSE = $verb;
my $rsp;
# push @{$rsp->{data}}, "Could not run $ifcmd.\n";
# xCAT::MsgUtils->message("E", $rsp, $callback);
$::VERBOSE = $verb;
return 0;
}
@ -241,6 +232,7 @@ sub is_me
{
my ($inet, $myIP, $str) = split(" ", $int);
chomp $myIP;
$myIP =~ s/addr://;
$myIP =~ s/\/.*//; # ipv6 address 4000::99/64
$myIP =~ s/\%.*//; # ipv6 address ::1%1/128
@ -1031,7 +1023,7 @@ sub dolitesetup
$nrange = join(',',@nodel);
}
@flist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $nrange", -1);
my @flist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $nrange", -1);
if (scalar(@flist) > 0) {
foreach my $l (@flist) {
my ($j1, $j2, $file) = split /\s+/, $l;
@ -1143,8 +1135,8 @@ sub dolitesetup
if (!$file) {
next;
}
}
# ex. .../inst_root/foo/bar/ or .../inst_root/etc/lppcfg
my $instrootfile = $instrootloc . $file;

82
perl-xCAT/xCAT/LparNetbootExp.pm Executable file → Normal file
View File

@ -629,8 +629,7 @@ sub get_adap_prop {
$cmd[0] = "\" supported-network-types\" " . $phandle . " get-package-property\r";
$msg[0] = "Status: rc and all supported network types now on stack\n";
#$pattern[0] = "(.*)3 >(.*)";
#$pattern[0] = "3 >";
$pattern[0] = "ok";
$pattern[0] = "3 >";
$newstate[0] = 1;
# state 1, return code and string on stack
@ -638,8 +637,7 @@ sub get_adap_prop {
$cmd[1] = ".\r";
$msg[1] = "Status: All supported network types now on stack\n";
#$pattern[1] = "(.*)2 >(.*)";
#$pattern[1] = "2 >";
$pattern[1] = "ok";
$pattern[1] = "2 >";
$newstate[1] = 2;
# state 2, data ready to decode
@ -693,16 +691,6 @@ sub get_adap_prop {
$timeout,
[ qr/$pattern[$state]/i,
sub {
if ($state eq 1) {
if ($rconsole->before() =~ /-\d+/) {
nc_msg($verbose, "Status: Error getting adapter property for phandle=$phandle.\n");
$state = 7;
$rconsole->clear_accum();
$rc = 1;
return 1;
}
}
nc_msg($verbose, $msg[$state]);
$state = $newstate[$state];
$rconsole->clear_accum();
@ -890,15 +878,6 @@ sub get_mac_addr {
$timeout,
[qr/$pattern[$state]/=>
sub {
if ($state eq 1) {
if ($rconsole->before() =~ /-\d+/) {
nc_msg($verbose, "Status: Error getting MAC address for phandle=$phandle.\n");
$rconsole->clear_accum();
$state = 4;
$rc = 1;
return undef;
}
}
nc_msg($verbose, $msg[$state]);
$state = $newstate[$state];
$rconsole->clear_accum();
@ -1040,8 +1019,7 @@ sub get_mac_addr {
$cmd[0] = "\" ibm,loc-code\" $phandle get-package-property\r";
$msg[0] = "Status: return code and loc-code now on stack\n";
#$pattern[0] = "(.*)3 >(.*)";
#$pattern[0] = "3 >";
$pattern[0] = "ok";
$pattern[0] = "3 >";
$newstate[0] = 1;
# cmd(1) is a dot (.). This is a stack manipulation command that removes one
@ -1074,16 +1052,6 @@ sub get_mac_addr {
$timeout,
[qr/$pattern[$state]/=>
sub {
if ($state eq 1) {
if ($rconsole->before() =~ /-\d+/) {
nc_msg($verbose, "Status: Error getting adapter location for phandle=$phandle.");
$rconsole->clear_accum();
$state = 3;
$rc = 1;
return undef;
}
}
nc_msg($verbose, $msg[$state]);
$rconsole->clear_accum();
$state = $newstate[$state];
@ -1157,19 +1125,10 @@ sub get_mac_addr {
return undef if ($rc eq 1);
}
# Did we find one or more adapters?
my @loc_array = split /\n/,$result[3];
my $found = 0;
$loc_code = '';
foreach my $line ( @loc_array ) {
if ($line =~ /(\w*):(.*):([\w|\.|-]*):/) {
$loc_code .= $3;
$found = 1;
}
}
if ($found) {
$loc_code =~ s/\.$//;
return $loc_code;
} else {
if ($result[3] =~ /(\w*):(.*):(\w*\.\w*\.\w*):/) {
$loc_code = $3;
}else {
return undef;
}
}
@ -1281,12 +1240,6 @@ sub ping_server{
$msg[3] = "Status: ping return code now on stack\n";
$newstate[3] = 4;
# get the timeout for ping test
my $to4pt;
if ( $ENV{TIMEOUT4PINGTEST} =~ /^\d+$/ ) {
$to4pt = ",$ENV{TIMEOUT4PINGTEST}";
}
#IPv6
if ( $server_ip =~ /:/ ) {
#::1, calculate link local address
@ -1296,9 +1249,9 @@ sub ping_server{
} else {
$linklocal_ip = $client_ip;
}
$cmd[3] = "ping $full_path_name:ipv6,$server_ip,$linklocal_ip,$gateway_ip$to4pt\r";
$cmd[3] = "ping $full_path_name:ipv6,$server_ip,$linklocal_ip,$gateway_ip\r";
} else {
$cmd[3] = "ping $full_path_name:$server_ip,$client_ip,$gateway_ip$to4pt\r";
$cmd[3] = "ping $full_path_name:$server_ip,$client_ip,$gateway_ip\r";
}
$pattern[3] = ".*ping(.*)ok(.*)0 >(.*)";
@ -2675,7 +2628,7 @@ sub lparnetbootexp
sub {
$rc = 2;
$rconsole->clear_accum();
nc_msg(1, "Please make sure rcons $node works.\n");
nc_msg($verbose, "Please make sure rcons $node works.\n");
}
],
);
@ -3047,21 +3000,6 @@ sub lparnetbootexp
$device_type = "physical";
}
if (defined($mac_address)) {
my @newmacs = ();
my @allmacs = split /\|/,$mac_address;
if ( !xCAT::Utils->isAIX() ) {
foreach my $mac_a ( @allmacs ) {
$mac_a = lc($mac_a);
$mac_a =~ s/(\w{2})/$1:/g;
$mac_a =~ s/:$//;
push @newmacs, $mac_a;
}
$mac_address = join("|",@newmacs);
}
}
if($colon) {
nc_msg($verbose, "$adap_type[$i]\:$loc_code\:$mac_address\:$full_path_name_array[$i]\:$ping_result\:$device_type\:\:\:\:\n");
$outputarrayindex++;

View File

@ -138,9 +138,8 @@ This program module file, supports the xcat messaging and logging
N - Node informational goes to STDOUT
S - Message will be logged to syslog ( severe error)
Note S can be combined with other flags for example
SE logs message to syslog and is sent to STDERR.
SA logs message to syslog and to the auditlog DB table. (only xcatd)
A logs message auditlog DB table only. (only for xcatd)
SE logs message to syslog and is sent to STDERR.
SA logs message to syslog and to the auditlog DB table
V - verbose. This flag is not valid, the calling routine
should check for verbose mode before calling the message
@ -176,7 +175,7 @@ This program module file, supports the xcat messaging and logging
# Message to Syslog
xCAT::MsgUtils->message('S', "Host $host not responding\n");
# Message to Syslog and auditlog table (only used by xcatd)
# Message to Syslog and auditlog table
# see tabdump -d auditlog
my $rsp = {};
$rsp->{syslogdata}->[0] = "$host not responding\n"; # for syslog
@ -190,18 +189,6 @@ This program module file, supports the xcat messaging and logging
$rsp->{status} -> [0] = $status;
xCAT::MsgUtils->message('SA', $rsp);
# Message to only auditlog table (only used by xcatd)
# see tabdump -d auditlog
my $rsp = {};
$rsp->{userid} ->[0] = $user;
$rsp->{clientname} -> [0] = $client;
$rsp->{clienttype} -> [0] = $clienttype;
$rsp->{command} -> [0] = $command;
$rsp->{noderange} -> [0] = $noderange;
$rsp->{args} -> [0] = $arguments;
$rsp->{status} -> [0] = $status;
xCAT::MsgUtils->message('A', $rsp);
# Message to Log and Syslog
xCAT::MsgUtils->message('LS', "Host $host not responding\n");
@ -210,44 +197,44 @@ This program module file, supports the xcat messaging and logging
Use with callback
# Message to callback
my $rsp = {};
my $rsp = {};
$rsp->{data}->[0] = "Job did not run. \n";
xCAT::MsgUtils->message("D", $rsp, $::CALLBACK);
my $rsp = {};
my $rsp = {};
$rsp->{error}->[0] = "No hosts in node list\n";
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
my $rsp = {};
$rsp->{node}->[0]->{name}->[0] ="mynode";
$rsp->{node}->[0]->{data}->[0] ="mydata";
xCAT::MsgUtils->message("N", $rsp, $callback);
my $rsp = {};
$rsp->{node}->[0]->{name}->[0] ="mynode";
$rsp->{node}->[0]->{data}->[0] ="mydata";
xCAT::MsgUtils->message("N", $rsp, $callback);
my $rsp = {};
my $rsp = {};
$rsp->{info}->[0] = "No hosts in node list\n";
xCAT::MsgUtils->message("I", $rsp, $::CALLBACK);
my $rsp = {};
my $rsp = {};
$rsp->{sinfo}->[0] = "No hosts in node list\n";
xCAT::MsgUtils->message("IS", $rsp, $::CALLBACK);
my $rsp = {};
my $rsp = {};
$rsp->{warning}->[0] = "No hosts in node list\n";
xCAT::MsgUtils->message("W", $rsp, $::CALLBACK);
my $rsp = {};
my $rsp = {};
$rsp->{error}->[0] = "Host not responding\n";
xCAT::MsgUtils->message("S", $rsp, $::CALLBACK);
# Message to Syslog and callback
my $rsp = {};
my $rsp = {};
$rsp->{error}->[0] = "Host not responding\n";
xCAT::MsgUtils->message("SE", $rsp, $::CALLBACK);
# Message to Syslog and callback
my $rsp = {};
my $rsp = {};
$rsp->{info}->[0] = "Host not responding\n";
xCAT::MsgUtils->message("SI", $rsp, $::CALLBACK);
@ -287,19 +274,17 @@ sub message
my $call_back = shift; # optional
my $exitcode = shift; # optional
# should be I,IS, D, E, S, SA,A ,LS, W , L,N
# should be I,IS, D, E, S, SA ,LS, W , L,N
# or S(I, D, E, S, W, L,N)
#
# if SA option need to split syslog messages from auditlog entry
# if new SA option need to split syslog messages from auditlog entry
#
my $newrsp;
if (($sev eq 'SA') || ($sev eq 'A'))
{ # if SA ( syslog and auditlog) or A ( only auditlog)then need to pull first entry from $rsp
# for syslog, to preserve old interface
if ($sev eq 'SA')
{ # if SA then need to pull first entry from $rsp
# for syslog, to preserve old interface
$newrsp = $rsp;
if ($sev eq 'SA'){ # syslog and auditlog
$rsp = $newrsp->{syslogdata}->[0];
}
}
my $stdouterrf = \*STDOUT;
my $stdouterrd = '';
@ -464,10 +449,11 @@ sub message
}
}
# is syslog option requested
# is syslog requested
if ($sev =~ /S/)
{
# If they want this msg to also go to syslog, do that now
eval {
openlog("xCAT", "nofatal,pid", "local4");
@ -488,7 +474,7 @@ sub message
# if write to auditlog table requested, if not on service node
if (xCAT::Utils->isMN()){
if (($sev eq 'SA') || ($sev eq 'A'))
if ($sev eq 'SA')
{
require xCAT::Table;
my $auditlogentry;

View File

@ -19,7 +19,6 @@ use File::Path;
use Math::BigInt;
use Socket;
use xCAT::GlobalDef;
#use Data::Dumper;
use strict;
use warnings "all";
my $socket6support = eval { require Socket6 };
@ -69,14 +68,14 @@ This program module file, is a set of network utilities used by xCAT commands.
#-------------------------------------------------------------------------------
sub getNodeDomains()
{
my $class = shift;
my $class = shift;
my $nodes = shift;
my @nodelist = @$nodes;
my %nodedomains;
# Get the network info for each node
my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist);
my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist);
# get the site domain value
my @domains = xCAT::TableUtils->get_site_attribute("domain");
@ -85,13 +84,12 @@ sub getNodeDomains()
# for each node - set hash value to network domain or default
# to site domain
foreach my $node (@nodelist) {
unless (defined($node)) {next;}
if (defined($nethash{$node}) && $nethash{$node}{domain}) {
$nodedomains{$node} = $nethash{$node}{domain};
} else {
$nodedomains{$node} = $sitedomain;
}
}
if ($nethash{$node}{domain}) {
$nodedomains{$node} = $nethash{$node}{domain};
} else {
$nodedomains{$node} = $sitedomain;
}
}
return \%nodedomains;
}
@ -644,11 +642,16 @@ sub get_nic_ip
{
my $nic;
my %iphash;
my $cmd = "ifconfig -a";
my $result = `$cmd`;
my $mode = "MULTICAST";
my $payingattention=0;
my $interface;
my $keepcurrentiface;
#############################################
# Error running command
#############################################
if ( !$result ) {
return undef;
}
if (xCAT::Utils->isAIX()) {
##############################################################
@ -660,14 +663,6 @@ sub get_nic_ip
# en1: ...
#
##############################################################
my $cmd = "ifconfig -a";
my $result = `$cmd`;
#############################################
# Error running command
#############################################
if ( !$result ) {
return undef;
}
my @adapter = split /(\w+\d+):\s+flags=/, $result;
foreach ( @adapter ) {
if ($_ =~ /^(en\d)/) {
@ -687,39 +682,37 @@ sub get_nic_ip
}
}
}
else { # linux
my @ipoutput = `ip addr`;
#############################################
# Error running command
#############################################
if ( !@ipoutput ) {
return undef;
}
foreach my $line (@ipoutput) {
if ($line =~ /^\d/) { # new interface, new context..
if ($interface and not $keepcurrentiface) {
#don't bother reporting unusable nics
delete $iphash{$interface};
else {
##############################################################
# Should look like this for Linux:
# eth0 Link encap:Ethernet HWaddr 00:02:55:7B:06:30
# inet addr:9.114.154.193 Bcast:9.114.154.223
# inet6 addr: fe80::202:55ff:fe7b:630/64 Scope:Link
# UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
# RX packets:1280982 errors:0 dropped:0 overruns:0 frame:0
# TX packets:3535776 errors:0 dropped:0 overruns:0 carrier:0
# collisions:0 txqueuelen:1000
# RX bytes:343489371 (327.5 MiB) TX bytes:870969610 (830.6 MiB)
# Base address:0x2600 Memory:fbfe0000-fc0000080
#
# eth1 ...
#
##############################################################
my @adapter= split /\n{2,}/, $result;
foreach ( @adapter ) {
if ( !($_ =~ /LOOPBACK / ) and
$_ =~ /UP / and
$_ =~ /$mode / ) {
my @ip = split /\n/;
for my $ent ( @ip ) {
if ($ent =~ /^(eth\d|ib\d|hf\d)\s+/) {
$nic = $1;
}
if ( $ent =~ /^\s*inet addr:\s*(\d+\.\d+\.\d+\.\d+)/ ) {
$iphash{$nic} = $1;
next;
}
}
$keepcurrentiface=0;
if ( !($line =~ /LOOPBACK/ ) and
$line =~ /UP( |,|>)/ and
$line =~ /$mode/ ) {
$payingattention=1;
$line =~ /^([^:]*): ([^:]*):/;
$interface=$2;
} else {
$payingattention=0;
next;
}
}
unless ($payingattention) { next; }
if ($line =~ /inet/) {
$keepcurrentiface=1;
}
if ( $line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) {
$iphash{$interface} = $1;
}
}
}
@ -1098,8 +1091,7 @@ sub my_if_netmap
Error:
none
Example:
my $ip = xCAT::NetworkUtils->my_ip_facing($peerip)
my @ip = xCAT::NetworkUtils->my_ip_facing($peerip) # return multiple
xCAT::NetworkUtils->my_ip_facing
Comments:
none
=cut
@ -1117,8 +1109,6 @@ sub my_ip_facing
unless ($peernumber) { return undef; }
my $noden = unpack("N", inet_aton($peer));
my @nets = split /\n/, `/sbin/ip addr`;
my @ips;
foreach (@nets)
{
my @elems = split /\s+/;
@ -1131,19 +1121,10 @@ sub my_ip_facing
my $curn = unpack("N", inet_aton($curnet));
if (($noden & $curmask) == ($curn & $curmask))
{
push @ips, $curnet;
return $curnet;
}
}
if (@ips) {
if (wantarray) {
return @ips;
} else {
return $ips[0];
}
} else {
return undef;
}
return undef;
}
#-------------------------------------------------------------------------------
@ -1614,124 +1595,56 @@ sub thishostisnot
=cut
#-----------------------------------------------------------------------------
#sub gethost_ips1
#{
# my ($class) = @_;
# my $cmd;
# my @ipaddress;
# $cmd = "ifconfig" . " -a";
# $cmd = $cmd . "| grep \"inet\"";
# my @result = xCAT::Utils->runcmd($cmd, 0);
# if ($::RUNCMD_RC != 0)
# {
# xCAT::MsgUtils->message("S", "Error from $cmd\n");
# exit $::RUNCMD_RC;
# }
# foreach my $addr (@result)
# {
# my @ip;
# if (xCAT::Utils->isLinux())
# {
# if ($addr =~ /inet6/)
# {
# #TODO, Linux ipv6
# }
# else
# {
# my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
# #@ip = split(":", $addr1);
# #push @ipaddress, $ip[1];
# $addr1 =~ s/.*://;
# push @ipaddress, $addr1;
# }
# }
# else
# { #AIX
# if ($addr =~ /inet6/)
# {
# $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
# my $v6ip = $1;
# my $v6mask = $2;
# if ($v6ip)
# {
# push @ipaddress, $v6ip;
# }
# }
# else
# {
# my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
# split(" ", $addr);
# push @ipaddress, $addr1;
# }
#
# }
# }
# my @names = @ipaddress;
# foreach my $ipaddr (@names)
# {
# my $hostname = xCAT::NetworkUtils->gethostname($ipaddr);
# if ($hostname)
# {
# my @shorthost = split(/\./, $hostname);
# push @ipaddress, $shorthost[0];
# }
# }
#
# return @ipaddress;
#}
sub gethost_ips
{
my ($class) = @_;
my $cmd;
my @ipaddress;
if (xCAT::Utils->isLinux())
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet\"";
my @result = xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
$cmd="ip -4 --oneline addr show |awk -F ' ' '{print \$4}'|awk -F '/' '{print \$1}'";
my @result =xCAT::Utils->runcmd($cmd);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
push @ipaddress, @result;
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
else
{ #AIX
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet\"";
my @result = xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
foreach my $addr (@result)
{
if ($addr =~ /inet6/)
{
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
my $v6ip = $1;
my $v6mask = $2;
if ($v6ip)
{
push @ipaddress, $v6ip;
}
}
else
{
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
push @ipaddress, $addr1;
}
foreach my $addr (@result)
{
my @ip;
if (xCAT::Utils->isLinux())
{
if ($addr =~ /inet6/)
{
#TODO, Linux ipv6
}
else
{
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
@ip = split(":", $addr1);
push @ipaddress, $ip[1];
}
}
else
{ #AIX
if ($addr =~ /inet6/)
{
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
my $v6ip = $1;
my $v6mask = $2;
if ($v6ip)
{
push @ipaddress, $v6ip;
}
}
else
{
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
push @ipaddress, $addr1;
}
}
}
}
my @names = @ipaddress;
foreach my $ipaddr (@names)
{
@ -1742,9 +1655,9 @@ sub gethost_ips
push @ipaddress, $shorthost[0];
}
}
return @ipaddress;
}
#-------------------------------------------------------------------------------
=head3 get_subnet_aix
@ -1920,6 +1833,102 @@ sub validate_ip
}
return([0]);
}
#-------------------------------------------------------------------------------
=head3 getFacingIP
Gets the ip address of the adapter of the localhost that is facing the
the given node.
Assume it is the same as my_ip_facing...
Arguments:
The name of the node that is facing the localhost.
Returns:
The ip address of the adapter that faces the node.
=cut
#-------------------------------------------------------------------------------
sub getFacingIP
{
my ($class, $node) = @_;
my $ip;
my $cmd;
my @ipaddress;
my $nodeip = inet_ntoa(inet_aton($node));
unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/)
{
return 0; #Not supporting IPv6 here IPV6TODO
}
$cmd = "ifconfig" . " -a";
$cmd = $cmd . "| grep \"inet \"";
my @result = xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
xCAT::MsgUtils->message("S", "Error from $cmd\n");
exit $::RUNCMD_RC;
}
# split node address
my ($n1, $n2, $n3, $n4) = split('\.', $nodeip);
foreach my $addr (@result)
{
my $ip;
my $mask;
if (xCAT::Utils->isLinux())
{
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
if ((!$addr1) || (!$Mask)) { next; }
my @ips = split(":", $addr1);
my @masks = split(":", $Mask);
$ip = $ips[1];
$mask = $masks[1];
}
else
{ #AIX
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
split(" ", $addr);
if ((!$addr1) && (!$mask1)) { next; }
$ip = $addr1;
$mask1 =~ s/0x//;
$mask =
`printf "%d.%d.%d.%d" \$(echo "$mask1" | sed 's/../0x& /g')`;
}
if ($ip && $mask)
{
# split interface IP
my ($h1, $h2, $h3, $h4) = split('\.', $ip);
# split mask
my ($m1, $m2, $m3, $m4) = split('\.', $mask);
# AND this interface IP with the netmask of the network
my $a1 = ((int $h1) & (int $m1));
my $a2 = ((int $h2) & (int $m2));
my $a3 = ((int $h3) & (int $m3));
my $a4 = ((int $h4) & (int $m4));
# AND node IP with the netmask of the network
my $b1 = ((int $n1) & (int $m1));
my $b2 = ((int $n2) & (int $m2));
my $b3 = ((int $n3) & (int $m3));
my $b4 = ((int $n4) & (int $m4));
if (($b1 == $a1) && ($b2 == $a2) && ($b3 == $a3) && ($b4 == $a4))
{
return $ip;
}
}
}
xCAT::MsgUtils->message("S", "Cannot find master for the node $node\n");
return 0;
}
#-------------------------------------------------------------------------------
=head3 isIpaddr
@ -1972,65 +1981,6 @@ sub isIpaddr
}
}
#-------------------------------------------------------------------------------
=head3 getNodeNameservers
Description:
Get nameservers of specified nodes.
The priority: noderes.nameservers > networks.nameservers > site.nameservers
Arguments:
node: node name list
Returns:
Return a hash ref, of the $nameservers{$node}
undef - Failed to get the nameservers
Globals:
none
Error:
none
Example:
my $nameservers = xCAT::NetworkUtils::getNodeNameservers(\@node);
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub getNodeNameservers{
my $nodes=shift;
if( $nodes =~ /xCAT::NetworkUtils/)
{
$nodes=shift;
}
my @nodelist = @$nodes;
my %nodenameservers;
my $nrtab = xCAT::Table->new('noderes',-create=>0);
my %nrhash = %{$nrtab->getNodesAttribs(\@nodelist,['nameservers'])};
my $nettab = xCAT::Table->new("networks");
my %nethash = xCAT::DBobjUtils->getNetwkInfo( \@nodelist );
my @nameservers = xCAT::TableUtils->get_site_attribute("nameservers");
my $sitenameservers=$nameservers[0];
foreach my $node (@nodelist){
if ($nrhash{$node} and $nrhash{$node}->[0] and $nrhash{$node}->[0]->{nameservers})
{
$nodenameservers{$node}=$nrhash{$node}->[0]->{nameservers};
}elsif($nethash{$node}{nameservers})
{
$nodenameservers{$node}=$nethash{$node}{nameservers};
}elsif($sitenameservers)
{
$nodenameservers{$node}=$sitenameservers;
}
}
return \%nodenameservers;
}
#-------------------------------------------------------------------------------
=head3 getNodeNetworkCfg
@ -2057,31 +2007,19 @@ sub getNodeNameservers{
sub getNodeNetworkCfg
{
my $node = shift;
if( $node =~ /xCAT::NetworkUtils/)
{
$node =shift;
}
my $nets = xCAT::NetworkUtils::my_nets();
my $ip = xCAT::NetworkUtils->getipaddr($node);
my $mask = undef;
my $gateway = undef;
my $nettab = xCAT::Table->new("networks");
if ($nettab) {
my @nets = $nettab->getAllAttribs('net','mask','gateway');
foreach my $net (@nets) {
if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) {
$gateway=$net->{'gateway'};
$mask=$net->{'mask'};
}
}
for my $net (keys %$nets)
{
my $netname;
($netname,$mask) = split /\//, $net;
last if ( xCAT::NetworkUtils::isInSameSubnet( $netname, $ip, $mask, 1));
}
return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask,0,0));
return ($ip, $node, undef, xCAT::NetworkUtils::formatNetmask($mask,1,0));
}
#-------------------------------------------------------------------------------
=head3 get_hdwr_ip
@ -2155,13 +2093,7 @@ sub pingNodeStatus {
foreach (@mon_nodes) {
$deadnodes{$_}=1;
}
# get additional options from site table
my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions");
my $more_options = $nmap_options[0];
#call namp
open (NMAP, "nmap -PE --system-dns --send-ip -sP $more_options ". $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
open (NMAP, "nmap -PE --system-dns --send-ip -sP ". $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
my $node;
while (<NMAP>) {
if (/Host (.*) \(.*\) appears to be up/) {
@ -2263,7 +2195,6 @@ sub isValidHostname
return 0;
}
#-------------------------------------------------------------------------------
=head3 isValidFQDN
@ -2428,105 +2359,6 @@ sub get_all_nicips{
}
}
#-------------------------------------------------------------------------------
=head3 gen_net_boot_params
Description:
This subroutine is used to generate all possible kernel parameters for network boot (rh/sles/ubuntu + diskfull/diskless)
The supported network boot parameters:
ksdevice - Specify network device for Anaconda. For rh6 and earlier. Format: 'ksdevice={$mac|$nicname}'
BOOTIF - Specify network device for Anaconda. The boot device which set by pxe. xCAT also set it if the bootload is not pxe. Format 'BOOTIF={$mac}'
ifname - Specify a interfacename<->mac pair, it will set the interfacename to the interface which has the <mac>. Format 'ifname=$ifname:$mac'
# This will only be generated when linuximage.nodebootif is set.
bootdev - Specify the boot device. Mostly it's used with <ip> parameter and when there are multiple <ip> params. Format 'bootdev={$mac|$ifname}
ip - Specify the network configuration for an interface. Format: 'ip=dhcp', 'ip=$ifname:dhcp'
netdevice - Specify network device for Linuxrc (Suse bootloader). Format: 'netdevice={$mac|$nicname}'
netdev - Specify the interfacename which is used by xCAT diskless boot script to select the network interface. Format: 'netdev=$nicname'
Reference:
Redhat anaconda doc: https://github.com/rhinstaller/anaconda/blob/master/docs/boot-options.txt
Suse Linuxrc do: https://en.opensuse.org/SDB:Linuxrc
Arguments:
$installnic <- node.installnic
$primarynic <- node.primarynic
$macmac <- node.mac
$nodebootif <- linuximage.nodebootif
Returns:
$net_params - The key will be the parameter name, the value for the key will be the parameter value.
Valid Parameter Name:
ksdevice
netdev
netdevice
ip
ifname
BOOTIF
And following two keys also will be returned for reference
mac
nicname
Example:
my $netparams = xCAT::NetworkUtils->gen_net_boot_params($installnic, $primmarynic, $macmac, $nodebootif);
=cut
#-------------------------------------------------------------------------------
sub gen_net_boot_params
{
my $class = shift;
my $installnic = shift;
my $primarynic = shift;
my $macmac = shift;
my $nodebootif = shift;
my $net_params;
# arbitrary use primarynic if installnic is not set
unless ($installnic) {
$installnic = $primarynic;
}
# just use the installnic to generate the nic related kernel parameters
my $mac;
my $nicname;
if ((! defined ($installnic)) || ($installnic eq "") || ($installnic =~ /^mac$/i)) {
$mac = $macmac;
$net_params->{mac} = $mac;
} elsif ($installnic =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/) {
$mac = $installnic;
$net_params->{mac} = $mac;
$net_params->{setmac} = $mac;
} else {
$mac = $macmac;
$nicname = $installnic;
$net_params->{nicname} = $nicname;
$net_params->{mac} = $mac;
}
if ($nicname) {
$net_params->{ksdevice} = "ksdevice=$nicname";
$net_params->{ip} = "ip=$nicname:dhcp";
$net_params->{netdev} = "netdev=$nicname";
$net_params->{netdevice} = "netdevice=$nicname";
$net_params->{ifname} = "ifname=$nicname:$mac";
} elsif ($mac) {
$net_params->{ksdevice} = "ksdevice=$mac";
$net_params->{BOOTIF} = "BOOTIF=$mac";
$net_params->{bootdev} = "bootdev=$mac";
$net_params->{ip} = "ip=dhcp";
if ($nodebootif) {
$net_params->{ifname} = "ifname=$nodebootif:$mac";
}
$net_params->{netdevice} = "netdevice=$mac";
}
return $net_params;
}
1;

View File

@ -196,7 +196,6 @@ sub expandatom {
$nodelist->_set_use_cache(1);
@allnodeset = $nodelist->getAllAttribs('node','groups');
%allnodehash = map { $_->{node} => 1 } @allnodeset;
$nodelist->_set_use_cache(0); #The {_use_cache} for nodelist table object must be turn off, otherwise it will keep open and affect the Table.pm subroutines like getNodesAttribs when it tries to access nodelist table to get status column.
}
my $verify = (scalar(@_) >= 1 ? shift : 1);
my %options = @_; # additional options

View File

@ -311,6 +311,9 @@ sub notify {
my ($modname, $path, $suffix) = fileparse($_, ".pm");
# print "modname=$modname, path=$path, suffix=$suffix\n";
if ($suffix =~ /.pm/) { #it is a perl module
my $pid;
if ($pid=xCAT::Utils->xfork()) { }
elsif (defined($pid)) {
my $fname;
if (($path eq "") || ($path eq ".\/")) {
#default path is /opt/xcat/lib/perl/xCAT_monitoring/ if there is no path specified
@ -325,7 +328,8 @@ sub notify {
else {
${"xCAT_monitoring::".$modname."::"}{processTableChanges}->($action, $tablename, $old_data, $new_data);
}
return 0;
exit 0;
}
}
else { #it is a command
my $pid;

View File

@ -21,6 +21,7 @@ sub parse_args {
my %opt = ();
my $cmd = $request->{command};
my $args = $request->{arg};
my @VERSION = qw( 2.1 );
#############################################
# Responds with usage statement
@ -59,8 +60,7 @@ sub parse_args {
# Option -v for version
####################################
if ( exists( $opt{v} )) {
my $version = xCAT::Utils->Version();
return ([$version]);
return( \@VERSION );
}
if ( exists( $opt{s} ) ){
@ -350,27 +350,6 @@ sub do_rnetboot {
last;
}
}
# Set the boot mode to norm from 'of' (open firmware)
# NOW, only necessary for IVM
my $hwtype = @$exp[2];
if ($hwtype eq "ivm") {
my $server = @$exp[3];
# creat connection first
my @newexp = xCAT::PPCcli::connect( $request, $hwtype, $server );
if (ref($newexp[0]) eq "Expect" ) {
my $cfg = "lpar_id=@$d[0],boot_mode=norm";
# change the boot mode to 'norm'
xCAT::PPCcli::chsyscfg(\@newexp, "prof", $d, $cfg);
xCAT::PPCcli::disconnect(\@newexp);
} else {
my $rsp;
$rsp->{data} = ["Failed to set the boot mode to normal. For rnetboot command, you have to rpower off and then on the node after finishing the OS deployment."];
xCAT::MsgUtils->message("E", $rsp, $request->{callback});
}
}
return $result;
}

View File

@ -436,9 +436,9 @@ sub sshcfg {
#####################################
# userid@host not found in key file
#####################################
#if ( $sshkey !~ /\s+(\S+\@\S+$)/ ) {
# return( [[$server,"Cannot find userid\@host in '$fname'",RC_ERROR]] );
#}
if ( $sshkey !~ /\s+(\S+\@\S+$)/ ) {
return( [[$server,"Cannot find userid\@host in '$fname'",RC_ERROR]] );
}
my $logon = $1;
#####################################

View File

@ -156,7 +156,7 @@ sub connect {
# Shell prompt regexp based on HW Type
##################################################
my %prompt = (
hmc => "~>\\s*\$",
hmc => "~> \$",
ivm => "\\\$ \$"
);
##################################################

View File

@ -339,7 +339,7 @@ sub lshwconn_parse_args
}
if (scalar(@error_type_nodes)) {
my $tmp_nodelist = join ',', @error_type_nodes;
my $link = (scalar(@error_type_nodes) eq '1')? 'is':'are';
my $link = (scalar(@error_type_nodes) == '1')? 'is':'are';
return( ["Node type of node(s) $tmp_nodelist $link not supported for this command.\n"]);
}
$request->{nodetype} = $nodetype;

View File

@ -75,7 +75,6 @@ sub add_ppc {
my $values = shift;
my $not_overwrite = shift;
my $otherinterfaces = shift;
my $callfile = shift;
my @tabs = qw(ppc vpd nodehm nodelist nodetype hosts mac);
my %db = ();
###################################
@ -120,12 +119,7 @@ sub add_ppc {
# Specify CEC and Frame's mgt as fsp and bpa
if ( $type =~ /^cec$/) {
if ( $callfile eq "PPC" ) {
$mgt = "hmc";
}
if ( $callfile eq "FSP" ) {
$mgt = "fsp";
}
$mgt = "fsp";
}
if ( $type =~ /^frame$/) {
$mgt = "bpa";
@ -326,7 +320,7 @@ sub update_lpar {
}
}
if (defined($write)) {
&add_ppc($hwtype, \@write_list,'','',"FSP");
&add_ppc($hwtype, \@write_list);
return ([@update_list,@write_list]);
} else {
foreach ( @tabs ) {

View File

@ -14,7 +14,7 @@ use xCAT::Usage;
use xCAT::NodeRange;
use xCAT::DBobjUtils;
use xCAT::FSPUtils;
use xCAT::TableUtils;
use xCAT::TableUtils qw(get_site_Master);
%::QUERY_ATTRS = (
'savingstatus' => 1,
'dsavingstatus' => 1,
@ -223,6 +223,7 @@ sub renergy {
my ($node, $attrs) = %$nodehash;
my $cec_name = @$attrs[2];
my $hw_type = @$attrs[4];
if (!$cec_name) {
return ([[$node, "ERROR: Cannot find the cec name, check the attributes: vpd.serial, vpd.mtm.", 1]]);
@ -294,43 +295,43 @@ sub renergy {
foreach (@hcps_ip) {
$deadnodes{$_}=1;
}
# get additional options from site table
my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions");
my $more_options = $nmap_options[0];
open (NMAP, "nmap -PE --system-dns --send-ip -sP $more_options ". join(' ',@hcps_ip) . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
my $node;
open (NMAP, "nmap -PE --system-dns --send-ip -sP ". join(' ',@hcps_ip) . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
my $node1;
my $msg1;
while (<NMAP>) {
#print "$_\n";
if (/Host (.*) \((.*)\) appears to be up/) {
$node=$2;
unless ($deadnodes{$node}) {
$node1=$2;
unless ($deadnodes{$node1}) {
foreach (keys %deadnodes) {
if ($node =~ /^$_\./) {
$node = $_;
if ($node1 =~ /^$_\./) {
$node1 = $_;
last;
}
}
}
delete $deadnodes{$node};
delete $deadnodes{$node1};
if ($verbose) {
push @return_msg, [$node, $_, 0];
}
push(@pingable_hcp, $node);
} elsif (/Nmap scan report for ([^ ]*)/) {
$node=$1;
push(@pingable_hcp, $node1);
} elsif (/Nmap scan report for ([^ ]*) \((.*)\)/) {
$node1=$2;
$msg1=$_;
} elsif (/Host is up./) {
unless ($deadnodes{$node}) {
unless ($deadnodes{$node1}) {
foreach (keys %deadnodes) {
if ($node =~ /^$_\./) {
$node = $_;
if ($node1 =~ /^$_\./) {
$node1 = $_;
last;
}
}
}
delete $deadnodes{$node};
push(@pingable_hcp, $node);
delete $deadnodes{$node1};
if ($verbose) {
push @return_msg, [$node, "$msg1$_", 0];
}
push(@pingable_hcp, $node1);
}
}
} else {

View File

@ -144,16 +144,12 @@ sub connect {
##################################
# Set options
##################################
#my $hosttab = xCAT::Table->new( 'hosts' );
#if ( $hosttab) {
# my $hostshash = $hosttab->getNodeAttribs( $server, [qw(ip otherinterfaces)]);
# if ( $hostshash ) {
# $server = $hostshash->{ip};
# }
#}
$server = xCAT::NetworkUtils::getNodeIPaddress( $server );
unless ($server) {
return( "Unable to get IP address for $server" );
my $hosttab = xCAT::Table->new( 'hosts' );
if ( $hosttab) {
my $hostshash = $hosttab->getNodeAttribs( $server, [qw(ip otherinterfaces)]);
if ( $hostshash ) {
$server = $hostshash->{ip};
}
}
# my $serverip = inet_ntoa(inet_aton($server));
my $url = "https://$server/cgi-bin/cgi?form=2";

View File

@ -347,7 +347,7 @@ sub bus {
#################################
# Output header
#################################
push @result, [$name,"I/O Bus Information", 0];
push @result, [$name,"I/O Bus Information"];
#################################
# Output error
@ -532,7 +532,7 @@ sub config {
#################################
# Output header
#################################
push @result, [$name,"Machine Configuration Info", 0];
push @result, [$name,"Machine Configuration Info"];
my $i;
foreach ( @prefix ) {

View File

@ -555,9 +555,6 @@ sub getmacs {
} else {
$type = "virtualio";
}
if ($mac_addr) {
$mac_addr = format_mac($mac_addr);
}
my %att = ();
$att{'MAC_Address'} = ($mac_addr) ? $mac_addr : "N/A";
@ -630,9 +627,9 @@ sub getmacs {
}
foreach ( @$value ) {
if ( /^#\s?Type/ ) {
$data.= "\n$_\n";
$data.= "\n$_\n";
} else {
$data.= "$_\n";
$data.= format_mac( $_ );
}
}
@ -759,7 +756,7 @@ sub getmacs {
if ( /^#\s?Type/ ) {
$data.= "\n$_\n";
} elsif ( /^ent\s+/ or /^hfi-ent\s+/ ) {
$data.= "$_\n";
$data.= format_mac( $_ );
}
}
#####################################
@ -804,8 +801,10 @@ sub cal_mac {
##########################################################################
sub format_mac {
my $mac = shift;
my $data = shift;
$data =~ /^(\S+\s+\S+\s+)(\S+)(\s+.*)$/;
my $mac = $2;
#####################################
# Get adapter mac
#####################################
@ -814,10 +813,6 @@ sub format_mac {
if ( !xCAT::Utils->isAIX() ) {
foreach my $mac_a ( @macs ) {
if (&checkmac($mac_a)) {
push @newmacs, $mac_a;
next;
}
#################################
# Delineate MAC with colons
#################################
@ -826,30 +821,14 @@ sub format_mac {
$mac_a =~ s/:$//;
push @newmacs, $mac_a;
}
$mac = join("|",@newmacs);
my $newmac = join("|",@newmacs);
$data =~ s/$mac/$newmac/;
}
return( "$mac\n" );
return( "$data\n" );
}
##########################################################################
# checkmac format
##########################################################################
sub checkmac {
my $mac = shift;
if ( !xCAT::Utils->isAIX()) {
if ($mac =~ /\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}/) {
return 1;
} else {
return 0;
}
} else {
return 1;
}
}
##########################################################################
# Write first valid adapter MAC to database
@ -868,9 +847,6 @@ sub writemac {
# Find first valid adapter
#####################################
foreach ( @$data ) {
unless (&checkmac($_)) {
next;
}
if ( /^ent\s+/ or /^hfi-ent\s+/ ) {
$value = $_;
#####################################
@ -893,9 +869,6 @@ sub writemac {
#####################################
if ( $pingret ne "successful" ) {
foreach ( @$data ) {
unless (&checkmac($_)) {
next;
}
if ( /^ent\s+/ or /^hfi-ent\s+/ ) {
$value = $_;
$ping_test = 0;
@ -917,7 +890,7 @@ sub writemac {
#####################################
# Get adapter mac
#####################################
#$value = format_mac( $value );
$value = format_mac( $value );
@fields = split /\s+/, $value;
$mac = $fields[2];

View File

@ -411,7 +411,7 @@ sub format_output {
# Strip errors for results
#######################################
my @val = grep( !/^#.*: ERROR /, @$values );
xCAT::PPCdb::add_ppc( $hwtype, \@val ,'','',"PPC");
xCAT::PPCdb::add_ppc( $hwtype, \@val );
}
###########################################

View File

@ -203,7 +203,7 @@ sub voltage {
# Voltages available in frame
#################################
if ( @$d[4] ne "bpa" ) {
push @result, [$name,"$text Only available for BPA",0];
push @result, [$name,"$text Only available for BPA",1];
next;
}
my $volt = enumerate_volt( $exp, $d );
@ -256,7 +256,7 @@ sub temp {
# No frame commands for IVM
#################################
if ( $hwtype eq "ivm" ) {
push @result, [$name,"$prefix Not available (No BPA)",0];
push @result, [$name,"$prefix Not available (No BPA)",1];
next;
}
#################################
@ -264,14 +264,14 @@ sub temp {
#################################
if ( @$d[4] !~ /^(fsp|cec|lpar)$/ ) {
my $text = "$prefix Only available for CEC/LPAR";
push @result, [$name,$text,0];
push @result, [$name,$text,1];
next;
}
#################################
# Error - No frame
#################################
if ( $mtms eq "0" ) {
push @result, [$name,"$prefix Not available (No BPA)",0];
push @result, [$name,"$prefix Not available (No BPA)",1];
next;
}
#################################

View File

@ -1913,7 +1913,7 @@ sub xCATdB {
$profile,
$parent );
return( xCAT::PPCdb::add_ppc( $hwtype, [$values],'','',"PPC" ));
return( xCAT::PPCdb::add_ppc( $hwtype, [$values] ));
}
return undef;
}

View File

@ -277,7 +277,7 @@ sub get_nodes_nic_attrs{
my $nodes = shift;
my $nicstab = xCAT::Table->new( 'nics');
my $entry = $nicstab->getNodesAttribs($nodes, ['nictypes', 'nichostnamesuffixes', 'nichostnameprefixes', 'niccustomscripts', 'nicnetworks', 'nicips', 'nicextraparams']);
my $entry = $nicstab->getNodesAttribs($nodes, ['nictypes', 'nichostnamesuffixes', 'nichostnameprefixes', 'niccustomscripts', 'nicnetworks', 'nicips']);
my %nicsattrs;
my @nicattrslist;
@ -361,19 +361,6 @@ sub get_nodes_nic_attrs{
$nicsattrs{$node}{$nicattrs[0]}{'ip'} = $nicattrs[1];
}
}
if($entry->{$node}->[0]->{'nicextraparams'}){
@nicattrslist = split(",", $entry->{$node}->[0]->{'nicextraparams'});
foreach (@nicattrslist){
my @nicattrs;
if ($_ =~ /!/) {
@nicattrs = split("!", $_);
} else {
@nicattrs = split(":", $_);
}
$nicsattrs{$node}{$nicattrs[0]}{'extraparams'} = $nicattrs[1];
}
}
}
return \%nicsattrs;
@ -666,39 +653,6 @@ sub get_all_cecs
}
}
#-------------------------------------------------------------------------------
=head3 get_all_lparids
Description : Get all LPAR ids in system.
Arguments : ref of all cecs
Returns : ref for LPAR ids hash.
Example :
my $arrayref = xCAT::ProfiledNodeUtils->get_all_lparids(\%allcecs);
=cut
#-------------------------------------------------------------------------------
sub get_all_lparids
{
my $class= shift;
my $cecsref = shift;
my %allcecs = %$cecsref;
my %lparids;
my $ppctab = xCAT::Table->new('ppc');
foreach my $cec (keys %allcecs) {
my @ids = $ppctab->getAllAttribsWhere("hcp = '$cec'", 'id');
foreach (@ids) {
if ( $_->{'id'} ){
$lparids{$cec}{$_->{'id'}} = 0;
}
}
}
$ppctab->close();
return \%lparids;
}
#-------------------------------------------------------------------------------
=head3 is_discover_started
@ -736,7 +690,6 @@ sub get_nodes_profiles
{
my $class = shift;
my $nodelistref = shift;
my $groupnamemode = shift;
my %profile_dict;
my $nodelisttab = xCAT::Table->new('nodelist');
@ -756,12 +709,8 @@ sub get_nodes_profiles
if ( $idx == 2 ){
# The group string will like @NetworkProfile_<profile name>
# So, index should +3, 2 for '__', 1 for _.
if ($groupnamemode) {
$profile_dict{$_}{$profile} = $group;
} else{
my $append_index = length($profile) + 3;
$profile_dict{$_}{$profile} = substr $group, $append_index;
}
my $append_index = length($profile) + 3;
$profile_dict{$_}{$profile} = substr $group, $append_index;
last;
}
}
@ -772,33 +721,6 @@ sub get_nodes_profiles
#-------------------------------------------------------------------------------
=head3 get_imageprofile_prov_method
Description : Get A node's provisioning method from its imageprofile attribute.
Arguments : $imgprofilename - imageprofile name
Returns : node's provisioning method: install, netboot...etc
=cut
#-------------------------------------------------------------------------------
sub get_imageprofile_prov_method
{
# For imageprofile, we can get node's provisioning method through:
# nodetype table: node (imageprofile name), provmethod (osimage name)
# osimage table: imagename (osimage name), provmethod (node deploy method: install, netboot...)
my $class = shift;
my $imgprofilename = shift;
my $nodetypestab = xCAT::Table->new('nodetype');
my $entry = ($nodetypestab->getAllAttribsWhere("node = '$imgprofilename'", 'ALL' ))[0];
return $entry->{'provmethod'};
#my $osimgtab = xCAT::Table->new('osimage');
#my $osimgentry = ($osimgtab->getAllAttribsWhere("imagename = '$osimgname'", 'ALL' ))[0];
#return $osimgentry->{'provmethod'};
}
#-------------------------------------------------------------------------------
=head3 get_imageprofile_prov_osvers
Description : Get A node's provisioning os version and profile from its imageprofile attribute.
Arguments : $imgprofilename - imageprofile name
@ -818,6 +740,34 @@ sub get_imageprofile_prov_osvers
return ($osversion, $profile);
}
#-------------------------------------------------------------------------------
=head3 get_imageprofile_prov_method
Description : Get A node's provisioning method from its imageprofile attribute.
Arguments : $imgprofilename - imageprofile name
Returns : node's provisioning method: install, netboot...etc
=cut
#-------------------------------------------------------------------------------
sub get_imageprofile_prov_method
{
# For imageprofile, we can get node's provisioning method through:
# nodetype table: node (imageprofile name), provmethod (osimage name)
# osimage table: imagename (osimage name), provmethod (node deploy method: install, netboot...)
my $class = shift;
my $imgprofilename = shift;
my $nodetypestab = xCAT::Table->new('nodetype');
my $entry = ($nodetypestab->getAllAttribsWhere("node = '$imgprofilename'", 'ALL' ))[0];
my $osimgname = $entry->{'provmethod'};
#my $osimgtab = xCAT::Table->new('osimage');
#my $osimgentry = ($osimgtab->getAllAttribsWhere("imagename = '$osimgname'", 'ALL' ))[0];
#return $osimgentry->{'provmethod'};
}
#-------------------------------------------------------------------------------
=head3 check_profile_consistent
@ -851,20 +801,16 @@ sub check_profile_consistent{
}
}
# Profile consistent keys, arch=>netboot, mgt=>nictype
my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => 'yaboot',
'fsp' => 'FSP', 'ipmi' => 'BMC');
# Get Imageprofile arch
my $nodetypetab = xCAT::Table->new('nodetype');
my $nodetypeentry = $nodetypetab->getNodeAttribs($imageprofile, ['os','arch']);
my $os = $nodetypeentry->{'os'};
my $nodetypeentry = $nodetypetab->getNodeAttribs($imageprofile, ['arch']);
my $arch = $nodetypeentry->{'arch'};
$nodetypetab->close();
# Get Imageprofile pkgdir
my $osdistroname = $os . "-" . $arch;
my $osdistrotab = xCAT::Table->new('osdistro');
my $osdistroentry = ($osdistrotab->getAllAttribsWhere("osdistroname = '$osdistroname'", 'ALL' ))[0];
my $pkgdir = $osdistroentry->{'dirpaths'};
$osdistrotab->close();
# Get networkprofile netboot and installnic
my $noderestab = xCAT::Table->new('noderes');
my $noderesentry = $noderestab->getNodeAttribs($networkprofile, ['netboot', 'installnic']);
@ -896,33 +842,16 @@ sub check_profile_consistent{
my $nodetype = undef;
$nodetype = $ntentry->{'nodetype'} if ($ntentry->{'nodetype'});
$ppctab->close();
# Checking whether netboot initrd image for Ubuntu ppc64
# This image should be downloaded from internet
if ($arch =~ /ppc64/i and $os =~ /ubuntu/i and !(-e "$pkgdir/install/netboot/initrd.gz")){
return 0, "The netboot initrd is not found in $pkgdir/install/netboot, please download it firstly.";
}
# Check if exists provision network
if (not ($installnic and exists $netprofile_nicshash{$installnic}{"network"})){
return 0, "Provisioning network not defined for network profile."
}
# Remove check mechanism about arch and netboot attribute
# Attribute 'neboot' will be generated based on arch, management method, os
# Profile consistent keys, arch=>netboot, mgt=>nictype
#my $ppc_netboot = 'yaboot';
#if( $os =~ /rhels7/ ){
# $ppc_netboot = 'grub2';
#}
#my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => $ppc_netboot,
# 'ppc64el' => $ppc_netboot,
# 'fsp' => 'FSP', 'ipmi' => 'BMC');
# Check if imageprofile is consistent with networkprofile
#if ($profile_dict{$arch} ne $netboot) {
# return 0, "Imageprofile's arch is not consistent with networkprofile's netboot."
#}
if ($profile_dict{$arch} ne $netboot) {
return 0, "Imageprofile's arch is not consistent with networkprofile's netboot."
}
# Check if networkprofile is consistent with hardwareprofile
if (not $hardwareprofile) { # Not define hardwareprofile
@ -932,29 +861,24 @@ sub check_profile_consistent{
return 0, "$nictype networkprofile must use with hardwareprofile.";
}
}
my %mgt_dict = ('fsp' => 'FSP', 'ipmi' => 'BMC', 'kvm' => '');
if ($mgt eq 'vm') {
return 1, "";
# For nodetype is lpar node, not need to check the nictype as it is not required for lpar node
if (not $nictype and $mgt and $nodetype ne 'lpar' ) {
# define hardwareprofile, not define fsp or bmc networkprofile, and the node type is not lpar
return 0, "$profile_dict{$mgt} hardwareprofile must use with $profile_dict{$mgt} networkprofile.";
}
if ($nodetype eq 'lpar') {
if ($nictype) {
# Can not associate FSP/BMC network if the node type is lpar
return 0, "The node with hardware type $nodetype can not use with $nictype networkprofile.";
}
return 1, ""
if ($profile_dict{$mgt} ne $nictype and $nodetype ne 'lpar') {
# Networkprofile's nictype is not consistent with hadrwareprofile's mgt, and the node type is not lpar
return 0, "Networkprofile's nictype is not consistent with hardwareprofile's mgt.";
}
if ($mgt and $mgt_dict{$mgt} ne $nictype) {
my $errmsg = "$mgt hardwareprofile must use with $mgt_dict{$mgt} networkprofile.";
if ( $mgt eq 'kvm' ) {
$errmsg = "$mgt hardwareprofile must use with non-BMC and non-FSP networkprofile."
}
return 0, $errmsg;
if ($nodetype eq 'lpar' and $nictype eq 'FSP')
{
# can not associate FSP network if the node type is lpar
return 0, "The node with hardware type $nodetype can not use with $nictype networkprofile.";
}
return 1, "";
}
@ -996,72 +920,6 @@ sub is_fsp_node
#-------------------------------------------------------------------------------
=head3 is_kvm_node
Description : Judge whether nodes are KVM nodes.
Arguments : $hardwareprofile - hardwareprofile name
Returns : 1 - KVM nodes
0 - Not KVM nodes
=cut
#-------------------------------------------------------------------------------
sub is_kvm_node
{
my $class = shift;
my $hardwareprofile = shift;
if (not $hardwareprofile) {
return 0;
}
#Get hardwareprofile mgt
my $nodehmtab = xCAT::Table->new('nodehm');
my $mgtentry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']);
my $mgt = undef;
$mgt = $mgtentry->{'mgt'} if ($mgtentry->{'mgt'});
$nodehmtab->close();
if ($mgt eq 'kvm') {
return 1;
}
return 0;
}
#-------------------------------------------------------------------------------
=head3 is_kvm_hypv_node
Description : Judge whether nodes are KVM nodes.
Arguments : $imageprofile - imageprofile name
Returns : 1 - KVM hypervisor nodes
0 - Not KVM hypervisor nodes
=cut
#-------------------------------------------------------------------------------
sub is_kvm_hypv_node
{
my $class = shift;
my $imageprofile = shift;
# Get provmethod
my $provmethod = xCAT::ProfiledNodeUtils->get_imageprofile_prov_method($imageprofile);
unless ($provmethod ){
return 0;
}
my $osimage_tab = xCAT::Table->new('osimage');
my $osimage_tab_entry = $osimage_tab->getAttribs({'imagename'=> $provmethod},('osdistroname'));
my $osdistroname = $osimage_tab_entry->{'osdistroname'};
$osimage_tab->close();
if ($osdistroname and $osdistroname =~ /^pkvm/ ) {
return 1;
}
return 0;
}
#-------------------------------------------------------------------------------
=head3 get_nodes_cmm
Description : Get the CMM of nodelist
Arguments : $nodelist - the ref of node list array
@ -1282,270 +1140,3 @@ sub check_nicips{
return (0, \%nics_hash, "");
}
#-------------------------------------------------------------------------------
=head3 gen_chain_for_profiles
Description: Generate a chain string based on Network/Hardware/Image profiles.
Arguments: $profiles_hash: The reference for profiles hash.
For example:
$profiles_hash = { 'HardwareProfile' => 'IBM_NeXtScale_M4',
'ImageProfile' => 'rhels6.5-x86_64-stateful-compute',
'NetworkProfile' => 'default_network_profile',
}
$hw_reconfig: the flag shows whether we need re-configure all hardware
relative settings or not: like runcmds, runimg...etc
Returns: ($retcode, $chain)
$retcode = 1. Generate chain failed, $chain stands for error message.
$retcode = 0. Generate chain OK. $chain stands for the chain string.
=cut
#-------------------------------------------------------------------------------
sub gen_chain_for_profiles{
my $class = shift;
my $profiles_hashref = shift;
my $hw_reconfig = shift;
my $final_chain = "";
if (! $profiles_hashref){
return (1, "Missing parameter for gen_chain_for_profiles.");
}
# A node must have at least imageprofile and network profile.
unless (defined $profiles_hashref->{'ImageProfile'}){
return (1, "No imageprofile specified in profiles hash.");
}
unless (defined $profiles_hashref->{'NetworkProfile'}){
return (1, "No networkprofile specified in profiles hash.");
}
my $hwprofile = $profiles_hashref->{'HardwareProfile'};
my $imgprofile = $profiles_hashref->{'ImageProfile'};
my $netprofile = $profiles_hashref->{'NetworkProfile'};
# Get node's provisioning method
my $provmethod = xCAT::ProfiledNodeUtils->get_imageprofile_prov_method($imgprofile);
unless ($provmethod ){
return (1, "Can not get provisioning method for image profile $imgprofile");
}
my $netprofileattr = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$netprofile])->{$netprofile};
unless ($netprofileattr){
return (1, "Can not get attributes for network profile $netprofile");
}
# Get node's netboot attribute
my ($retcode, $retval) = xCAT::ProfiledNodeUtils->get_netboot_attr($imgprofile, $hwprofile);
if (not $retcode) {
return (1, $retval);
}
my $netboot = $retval;
$final_chain = 'osimage='.$provmethod.":--noupdateinitrd";
# get the chain attribute from hardwareprofile and insert it to node.
if (defined $hwprofile and $hwprofile and $hw_reconfig){
my $chaintab = xCAT::Table->new('chain');
my $chain = $chaintab->getNodeAttribs($hwprofile, ['chain']);
if (exists $chain->{'chain'}) {
my $hw_chain = $chain->{'chain'};
$final_chain = $hw_chain.',osimage='.$provmethod.":--noupdateinitrd";
}
}
#run bmcsetups.
#PowerNV nodes can't use 'runcmd=bmcsetup' to set BMC.
if ((exists $netprofileattr->{"bmc"}) and $hw_reconfig and $netboot ne 'petitboot'){
if (index($final_chain, "runcmd=bmcsetup") == -1){
$final_chain = 'runcmd=bmcsetup,'.$final_chain.':reboot4deploy';
}
else{
$final_chain = $final_chain.':reboot4deploy';
}
}
return (0, $final_chain);
}
#-------------------------------------------------------------------------------
=head3 get_all_vmhosts
Description : Get all vm hosts/hypervisor from DB.
Arguments : N/A
Returns : ref for vm hosts/hypervisor hash.
Example :
my $hashref = xCAT::ProfiledNodeUtils->get_all_vmhosts();
=cut
#-------------------------------------------------------------------------------
sub get_all_vmhosts
{
my %vmhostshash;
my $nodelisttab = xCAT::Table->new('nodelist');
# groups like '__Hypervisor_pkvm' means this node is Power KVM hypervisor
my @vmhosts = $nodelisttab->getAllAttribsWhere("groups like '%__Hypervisor_kvm%'", 'node');
foreach (@vmhosts) {
if($_->{'node'}) {
$vmhostshash{$_->{'node'}} = 1;
}
}
$nodelisttab->close();
# Return the ref accordingly
return \%vmhostshash;
}
#-------------------------------------------------------------------------------
=head3 get_netboot_attr
Description : Get netboot attribute for node
Arguments : $imageprofile - image profile name, mandatory. e.g. "__ImageProfile_rhels7.0-x86_64-stateful-mgmtnode"
$hardwareprofile - harware profile name, optional. e.g. "__HardwareProfile_IBM_System_x_M4"
Returns : (returncode, netboot)
returncode=0 - can not get netboot value,netboot is the error message
returncode=1 - can get netboot value,netboot is the right value
=cut
#-------------------------------------------------------------------------------
sub get_netboot_attr{
my $class = shift;
my $imageprofile = shift;
my $hardwareprofile = shift;
my $netboot;
my @nodegrps = xCAT::TableUtils->list_all_node_groups();
unless(grep{ $_ eq $imageprofile} @nodegrps)
{
return 0, "Image profile not defined in DB."
}
$imageprofile =~ s/^__ImageProfile_//;
if ($hardwareprofile){
unless(grep{ $_ eq $hardwareprofile} @nodegrps)
{
return 0, "Hardware profile not defined in DB."
}
}
else
{
$hardwareprofile = '*';
}
# Get os name, os major version, osarch
my $osimage_tab = xCAT::Table->new('osimage');
my $osimage_tab_entry = $osimage_tab->getAttribs({'imagename'=> $imageprofile},('osdistroname'));
my $osdistroname = $osimage_tab_entry->{'osdistroname'};
$osimage_tab->close();
my $osdistro_tab = xCAT::Table->new('osdistro');
my $osdistro_tab_entry = $osdistro_tab->getAttribs({'osdistroname'=> $osdistroname},('basename', 'majorversion', 'arch'));
my $os_name = $osdistro_tab_entry->{'basename'};
my $os_major_version = $osdistro_tab_entry->{'majorversion'};
my $os_arch = $osdistro_tab_entry->{'arch'};
$osdistro_tab->close;
# Treate os name rhel,centos,rhelhpc same as rhels
if ($os_name eq 'centos' || $os_name eq 'rhelhpc' || $os_name eq 'rhel')
{
$os_name = 'rhels';
}
# Treate arch ppc64el same as ppc64le,x86 same as x86_64
if ($os_arch eq 'ppc64el')
{
$os_arch = 'ppc64le';
}elsif ($os_arch eq 'x86')
{
$os_arch = 'x86_64';
}
# Identify whether this node is PowerKVM or PowerNV if os arch is ppc64le
# If hardware profile is defined
my $mgt = '*';
if ($os_arch eq 'ppc64le' and $hardwareprofile ne '*') {
my $nodehmtab = xCAT::Table->new('nodehm');
my $nodehmtab_entry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']);
if (defined $nodehmtab_entry->{'mgt'}) {
$mgt = $nodehmtab_entry->{'mgt'};
}
}
# Rule for netboot attribute.If update the rule,just update %netboot_dict and @condition_array
# It's sequence sensitive: os arch -> os name -> os major version -> hardware profile
# Priority | Arch | OS Name | OS Major Version | Management method | Noderes.netboot |
# 1 | x86_64/x86 | * | * | * | xnba |
# 2 | ppc64 | rhels | 7 | * | grub2 |
# 2 | ppc64 | pkvm | * | * | petitboot |
# 3 | | * | * | * | yaboot |
# 4 | ppc64le/el | * | * | * | grub2
# 4 | ppc64le/el | * | * | ipmi | petitboot
# arch osname version hardware netboot
my %netboot_dict = ( 'x86_64' => 'xnba',
'ppc64' => {
'rhels' => {
'7' => 'grub2',
'*' => 'yaboot',
},
'pkvm' => 'petitboot',
'*' => 'yaboot',
},
'ppc64le' => {
'*' => {
'*' => {
'*' => 'grub2',
'ipmi' => 'petitboot',
},
},
},
);
my $condition_array_ref = [$os_arch, $os_name, $os_major_version, $mgt];
$netboot = cal_netboot(\%netboot_dict, $condition_array_ref);
if($netboot eq '0')
{
return 0, "Can not get the netboot attribute";
}
else
{
return 1, $netboot;
}
}
#-------------------------------------------------------------------------------
=head3 cal_netboot
Description : Calculate netboot attribute by conditions recursively, internal use.
Arguments : $netboot_dict_ref
$condition_array_ref
Returns : netboot
returncode=0 - can not get netboot value
=cut
#-------------------------------------------------------------------------------
sub cal_netboot{
my $netboot_dict_ref = shift;
my $condition_array_ref = shift;
my $condition_array_len = scalar @$condition_array_ref;
if( $condition_array_len == 0 ){
return 0;
}
my $condition = shift @$condition_array_ref;
if( (exists($netboot_dict_ref->{$condition})) || (exists($netboot_dict_ref->{'*'})) )
{
if(!exists($netboot_dict_ref->{$condition}))
{
$condition = '*';
}
if(ref($netboot_dict_ref->{$condition}) eq 'HASH')
{
if($condition_array_len > 1)
{
return cal_netboot($netboot_dict_ref->{$condition}, $condition_array_ref);
}
else
{
return 0;
}
}
else
{
return $netboot_dict_ref->{$condition};
}
}
else
{
return 0;
}
}

View File

@ -810,10 +810,6 @@ sub senddeviceskeys
# add to the command
$setupcmd .=$key;
$setupcmd .="\"";
# Special case for vios
if ($ENV{DEVICETYPE} eq 'vios') {
$setupcmd = "\"echo $key | tee -a ~/.ssh/authorized_keys2\"";
}
# For each input device
my @nodelist=split(/,/,$nodes);
foreach my $node (@nodelist) {

View File

@ -116,9 +116,6 @@ sub dodiscover {
send_message($args{reqcallback}, 0, "The rarge is too large and may be time consuming. Broadcast is recommended.");
}
}
#no need to check site.nmapoptions because it specifilly
# uses T5 for certain performance requirement.
`/usr/bin/nmap $range -sn -PE -n --send-ip -T5 `;
my $nmapres = `/usr/bin/nmap $range -PE -p 427 -n --send-ip -T5 `;
foreach my $line (split(/\n\n/,$nmapres)) {
@ -290,7 +287,7 @@ sub dodiscover {
if ($rethash{$peername}) {
next; #got a dupe, discard
}
my $result = process_slp_packet(packet=>$slpkg,sockaddr=>$pkg,'socket'=>$args{'socket'}, peername=>$peername, callback=>$args{reqcallback});
my $result = process_slp_packet(packet=>$slpkg,sockaddr=>$pkg,'socket'=>$args{'socket'});
if ($result) {
if ($peername =~ /\./) { #ipv4
$peername =~ s/::ffff://;
@ -374,10 +371,9 @@ sub process_slp_packet {
if ($parsedpacket->{FunctionId} == 2) {#Service Reply
parse_service_reply($parsedpacket->{payload},$parsedpacket);
unless (ref $parsedpacket->{service_urls} and scalar @{$parsedpacket->{service_urls}}) { return undef; }
if ($parsedpacket->{attributes} && get_mac_for_addr($args{peername})) {
#service reply had ext. Stop here if has gotten attributes and got mac.
#continue the unicast request for service attributes if cannot find mac for peernode
return $parsedpacket; #don't bother sending attrrequest, already got it in first packet
if ($parsedpacket->{attributes}) { #service reply had ext
return $parsedpacket; #don't bother sending attrrequest, already got it in first packet
}
my $srvtype = $xid_to_srvtype_map{$parsedpacket->{Xid}};
my $packet = generate_attribute_request(%args,SrvType=>$srvtype);

View File

@ -650,8 +650,7 @@ sub decode_spd {
8 => "DDR2 SDRAM",
9 => "DDR2 SDRAM FB-DIMM",
10 => "DDR2 SDRAM FB-DIMM PROBE",
11 => "DDR3 SDRAM",
12 => "DDR4 SDRAM",
11 => "DDR3 SDRAM"
);
my %modtypes = (
@ -669,35 +668,33 @@ sub decode_spd {
1333 => 10600,
1600 => 12800,
1867 => 14900,
2132 => 17000,
2133 => 17000,
2134 => 17000,
);
my %ddrmodcap = (
my %ddr3modcap = (
0 => 256,
1 => 512,
2 => 1024,
3 => 2048,
4 => 4096,
5 => 8192,
6 => 16384,
7 => 32768,
6 => 16384
);
my %ddrdevwidth = (
my %ddr3devwidth = (
0 => 4,
1 => 8,
2 => 16,
3 => 32
);
my %ddrranks = (
my %ddr3ranks = (
0 => 1,
1 => 2,
2 => 3,
3 => 4
);
my %ddrbuswidth = (
my %ddr3buswidth = (
0 => 8,
1 => 16,
2 => 32,
@ -731,10 +728,10 @@ sub decode_spd {
$rethash->{product}->{name} .= " ECC";
}
$rethash->{product}->{name}.=" ".$modtypes{$spd[3]&0x0f};
my $sdramcap=$ddrmodcap{$spd[4]&0xf};
my $buswidth=$ddrbuswidth{$spd[8]&0b111};
my $sdramwidth=$ddrdevwidth{$spd[7]&0b111};
my $ranks = $ddrranks{($spd[7]&0b111000)>>3};
my $sdramcap=$ddr3modcap{$spd[4]&0xf};
my $buswidth=$ddr3buswidth{$spd[8]&0b111};
my $sdramwidth=$ddr3devwidth{$spd[7]&0b111};
my $ranks = $ddr3ranks{($spd[7]&0b111000)>>3};
my $capacity = $sdramcap/8*$buswidth/$sdramwidth*$ranks;
@ -772,61 +769,6 @@ sub decode_spd {
# $rawspd .= sprintf("%02X ",$_);
#}
#push @{$rethash->{product}->{extra}},$rawspd;
} elsif ($spd[2] == 12) { #DDR4 spec applies
# spd[125] spd[18] spd[18is sdram min cycle time .. spd125 is fine offset for min time
# mtb and ftb are fixed in ddr4 spd spec.. mtb is always 0.125 ns and ftb is always 0.001 ns
my $speed;
my $clock;
if ($spd[17] == 0) {
my $fineoffset = $spd[125];
if ($fineoffset & 0b10000000) {
#negative value, twos complement
$fineoffset = 0-(($fineoffset ^ 0xff) + 1);
}
$clock = int(2/((0.125*$spd[18] + $fineoffset*0.001)*0.001));
$speed = $speedfromclock{$clock};
unless ($speed) { $speed = "UNKNOWN"; }
} else { # this would mean a different MTB and FTB than spec indicated..
$clock = "UNKNOWN";
$speed = "UNKNOWN";
}
$rethash->{product}->{name}="PC4-".$speed." ($clock MT/s)";
if ($spd[13]&0b11000 == 0b1000) {
$rethash->{product}->{name} .= " ECC";
}
$rethash->{product}->{name}.=" ".$modtypes{$spd[3]&0x0f};
my $sdramcap=$ddrmodcap{$spd[4]&0xf};
my $buswidth=$ddrbuswidth{$spd[13]&0b111};
my $sdramwidth=$ddrdevwidth{$spd[12]&0b111};
my $ranks = $ddrranks{($spd[12]&0b111000)>>3};
my $capacity = $sdramcap/8*$buswidth/$sdramwidth*$ranks;
if ($capacity < 1024) {
$capacity = $capacity."MB";
} else {
$capacity = ($capacity/1024)."GB";
}
$rethash->{product}->{name} = $capacity." ".$rethash->{product}->{name};
$rethash->{product}->{manufacturer} = decode_manufacturer($spd[320],$spd[321]);
$rethash->{product}->{buildlocation} = sprintf("%02x",$spd[322]);
if ($spd[120] != 0 or $spd[121] != 0) {
$rethash->{product}->{builddate} = sprintf("Week %x of 20%02x",$spd[323],$spd[324]);
}
foreach (@spd[329..348]) {
if ($_ > 126 or $_ < 32) {
$rethash->{product}->{model}="Malformed SPD";
}
}
unless ($rethash->{product}->{model}) {
$rethash->{product}->{model}=pack("C*",@spd[329..348]);
}
#my $rawspd="SPD Dump: ";
#foreach (@spd) {
# $rawspd .= sprintf("%02X ",$_);
#}
#push @{$rethash->{product}->{extra}},$rawspd;
} else {
$rethash->{product}->{model}="Unrecognized SPD";
}

View File

@ -326,7 +326,7 @@ bootparams => {
'kernel' => 'The kernel that network boot actions should currently acquire and use. Note this could be a chained boot loader such as memdisk or a non-linux boot loader',
'initrd' => 'The initial ramdisk image that network boot actions should use (could be a DOS floppy or hard drive image if using memdisk as kernel)',
'kcmdline' => 'Arguments to be passed to the kernel',
'addkcmdline' => 'User specified one or more parameters to be passed to the kernel. For the kernel options need to be persistent after installation, specify them with prefix "R::"',
'addkcmdline' => 'User specified one or more parameters to be passed to the kernel',
'dhcpstatements' => 'xCAT manipulated custom dhcp statements (not intended for user manipulation)',
'adddhcpstatements' => 'Custom dhcp statements for administrator use (not implemneted yet)',
comments => 'Any user-written notes.',
@ -393,46 +393,7 @@ ipmi => {
descriptions => {
node => 'The node name or group name.',
bmc => 'The hostname of the BMC adapater.',
bmcport => ' In systems with selectable shared/dedicated ethernet ports,
this parameter can be used to specify the preferred port. 0
means use the shared port, 1 means dedicated, blank is to not
assign.
The following special cases exist for IBM System x servers:
For x3755 M3 systems, 0 means use the dedicated port, 1 means
shared, blank is to not assign.
For certain systems which have a mezzaine or ML2 adapter, there is a second
value to include:
For x3750 M4 (Model 8722):
0 2 1st 1Gbps interface for LOM
0 0 1st 10Gbps interface for LOM
0 3 2nd 1Gbps interface for LOM
0 1 2nd 10Gbps interface for LOM
For x3750 M4 (Model 8752), x3850/3950 X6, dx360 M4, x3550 M4, and x3650 M4:
0 Shared (1st onboard interface)
1 Dedicated
2 0 First interface on ML2 or mezzanine adapter
2 1 Second interface on ML2 or mezzanine adapter
2 2 Third interface on ML2 or mezzanine adapter
2 3 Fourth interface on ML2 or mezzanine adapter',
bmcport => 'In systems with selectable shared/dedicated ethernet ports, this parameter can be used to specify the preferred port. 0 means use the shared port, 1 means dedicated, blank is to not assign',
taggedvlan => 'Have bmcsetup place the BMC on the specified vlan tag on a shared netwirk interface. Some network devices may be incompatible with this option',
bmcid => 'Unique identified data used by discovery processes to distinguish known BMCs from unrecognized BMCs',
username => 'The BMC userid. If not specified, the key=ipmi row in the passwd table is used as the default.',
@ -542,7 +503,7 @@ networks => {
netname => 'Name used to identify this network definition.',
net => 'The network address.',
mask => 'The network mask.',
mgtifname => 'The interface name of the management/service node facing this network. !remote!<nicname> indicates a non-local network on a specific nic for relay DHCP.',
mgtifname => 'The interface name of the management/service node facing this network. !remote! indicates a non-local network for relay DHCP.',
gateway => 'The network gateway. It can be set to an ip address or the keyword <xcatmaster>, the keyword <xcatmaster> indicates the cluster-facing ip address configured on this management node or service node. Leaving this field blank means that there is no gateway for this network.',
dhcpserver => 'The DHCP server that is servicing this network. Required to be explicitly set for pooled service node operation.',
tftpserver => 'The TFTP server that is servicing this network. If not set, the DHCP server is assumed.',
@ -643,14 +604,14 @@ noderes => {
descriptions => {
node => 'The node name or group name.',
servicenode => 'A comma separated list of node names (as known by the management node) that provides most services for this node. The first service node on the list that is accessible will be used. The 2nd node on the list is generally considered to be the backup service node for this node when running commands like snmove.',
netboot => 'The type of network booting to use for this node. Valid values: pxe or xnba for x86* architecture, yaboot for POWER architecture, grub2-tftp and grub2-http for RHEL7 on Power and all the os deployment on Power LE. Notice: yaboot is not supported from rhels7 on Power,use grub2-tftp or grub2-http instead, the difference between the 2 is the file transfer protocol(i.e, http or tftp)',
netboot => 'The type of network booting to use for this node. Valid values: pxe or xnba for x86* architecture, yaboot for POWER architecture, grub2 for RHEL7 on Power. Notice: yaboot is not supported from rhels7 on Power,use grub2 instead',
tftpserver => 'The TFTP server for this node (as known by this node). If not set, it defaults to networks.tftpserver.',
tftpdir => 'The directory that roots this nodes contents from a tftp and related perspective. Used for NAS offload by using different mountpoints.',
nfsserver => 'The NFS or HTTP server for this node (as known by this node).',
monserver => 'The monitoring aggregation point for this node. The format is "x,y" where x is the ip address as known by the management node and y is the ip address as known by the node.',
nfsdir => 'The path that should be mounted from the NFS server.',
installnic => 'The network adapter on the node that will be used for OS deployment, the installnic can be set to the network adapter name or the mac address or the keyword "mac" which means that the network interface specified by the mac address in the mac table will be used. If not set, primarynic will be used. If primarynic is not set too, the keyword "mac" will be used as default.',
primarynic => 'This attribute will be deprecated. All the used network interface will be determined by installnic. The network adapter on the node that will be used for xCAT management, the primarynic can be set to the network adapter name or the mac address or the keyword "mac" which means that the network interface specified by the mac address in the mac table will be used. Default is eth0.',
installnic => 'The network adapter on the node that will be used for OS deployment, the installnic can be set to the network adapter name or the mac address or the keyword "mac" which means that the network interface specified by the mac address in the mac table will be used. If not set, primarynic will be used.',
primarynic => 'The network adapter on the node that will be used for xCAT management, the primarynic can be set to the network adapter name or the mac address or the keyword "mac" which means that the network interface specified by the mac address in the mac table will be used. Default is eth0.',
discoverynics => 'If specified, force discovery to occur on specific network adapters only, regardless of detected connectivity. Syntax can be simply "eth2,eth3" to restrict discovery to whatever happens to come up as eth2 and eth3, or by driver name such as "bnx2:0,bnx2:1" to specify the first two adapters managed by the bnx2 driver',
cmdinterface => 'Not currently used.',
xcatmaster => 'The hostname of the xCAT service node (as known by this node). This acts as the default value for nfsserver and tftpserver, if they are not set. If xcatmaster is not set, the node will use whoever responds to its boot request as its master. For the directed bootp case for POWER, it will use the management node if xcatmaster is not set.',
@ -728,7 +689,7 @@ osimage => {
description => 'OS Image Description',
provmethod => 'The provisioning method for node deployment. The valid values are install, netboot,statelite,boottarget,dualboot,sysclone. If boottarget is set, you must set linuximage.boottarget to the name of the boottarget definition. It is not used by AIX.',
rootfstype => 'The filesystem type for the rootfs is used when the provmethod is statelite. The valid values are nfs or ramdisk. The default value is nfs',
osdistroname => 'The name of the OS distro definition. This attribute can be used to specify which OS distro to use, instead of using the osname,osvers,and osarch attributes. For *kit commands, the attribute will be used to read the osdistro table for the osname, osvers, and osarch attributes. If defined, the osname, osvers, and osarch attributes defined in the osimage table will be ignored.',
osdistroname => 'The name of the OS distro definition. This attribute can be used to specify which OS distro to use, instead of using the osname,osvers,and osarch attributes.',
osupdatename => 'A comma-separated list of OS distro updates to apply to this osimage.',
cfmdir => 'CFM directory name for PCM. Set to /install/osimages/<osimage name>/cfmdir by PCM. ',
profile => 'The node usage category. For example compute, service.',
@ -752,16 +713,16 @@ linuximage => {
table_desc => 'Information about a Linux operating system image that can be used to deploy cluster nodes.',
descriptions => {
imagename => 'The name of this xCAT OS image definition.',
template => 'The fully qualified name of the template file that will be used to create the OS installer configuration file for stateful installations (e.g. kickstart for RedHat, autoyast for SLES).',
template => 'The fully qualified name of the template file that is used to create the kick start file for diskful installation.',
boottarget => 'The name of the boottarget definition. When this attribute is set, xCAT will use the kernel, initrd and kernel params defined in the boottarget definition instead of the default.',
addkcmdline=> 'User specified arguments to be passed to the kernel. The user arguments are appended to xCAT.s default kernel arguments. For the kernel options need to be persistent after installation, specify them with prefix "R::". This attribute is ignored if linuximage.boottarget is set.',
addkcmdline=> 'User specified arguments to be passed to the kernel. The user arguments are appended to xCAT.s default kernel arguments. This attribute is ignored if linuximage.boottarget is set.',
pkglist => 'The fully qualified name of the file that stores the distro packages list that will be included in the image. Make sure that if the pkgs in the pkglist have dependency pkgs, the dependency pkgs should be found in one of the pkgdir',
pkgdir => 'The name of the directory where the distro packages are stored. It could be set multiple paths.The multiple paths must be seperated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other.',
otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set multiple paths.The multiple paths must be seperated by ",".',
otherpkgdir => 'The base directory where the non-distro packages are stored. Only 1 local directory supported at present.',
pkgdir => 'The name of the directory where the distro packages are stored. It could be set multiple paths.The multiple paths must be seperated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. ',
otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image.',
otherpkgdir => 'The base directory where the non-distro packages are stored.',
exlist => 'The fully qualified name of the file that stores the file names and directory names that will be excluded from the image during packimage command. It is used for diskless image only.',
postinstall => 'The fully qualified name of the script file that will be run at the end of the genimage command. It could be set multiple paths.The multiple paths must be seperated by ",". It is used for diskless image only.',
rootimgdir => 'The directory name where the image is stored. It is generally used for diskless image. it also can be used in sysclone environment to specify where the image captured from golden client is stored. in sysclone environment, rootimgdir is generally assigned to some default value by xcat, but you can specify your own store directory. just one thing need to be noticed, wherever you save the image, the name of last level directory must be the name of image. for example, if your image name is testimage and you want to save this image under home directoy, rootimgdir should be assigned to value /home/testimage/',
postinstall => 'The fully qualified name of the script file that will be run at the end of the genimage command. It is used for diskless image only.',
rootimgdir => 'The directory name where the image is stored. It is used for diskless image only.',
kerneldir => 'The directory name where the 3rd-party kernel is stored. It is used for diskless image only.',
nodebootif => 'The network interface the stateless/statelite node will boot over (e.g. eth0)',
otherifce => 'Other network interfaces (e.g. eth1) in the image that should be configured via DHCP',
@ -771,7 +732,7 @@ linuximage => {
permission => 'The mount permission of /.statelite directory is used, its default value is 755',
dump => qq{The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs://<nfs_server_ip>/<kdump_path>". If you want to use the node's "xcatmaster" (its SN or MN), <nfs_server_ip> can be left blank. For example, "nfs:///<kdump_path>" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN.},
crashkernelsize => 'the size that assigned to the kdump kernel. If the kernel size is not set, 256M will be the default value.',
partitionfile => 'The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "<partition file absolute path>" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES). "s:<partitioning script absolute path>" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify "<partition file absolute path>"; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.',
partitionfile => 'The path of the configuration file which is used to part the disk for the node. For stateful: two types of value can be set for this attribute. One is "<partition file absolute path>", the content of the partition file must use the corresponding format with the OS type. The other one is "s:<partition file absolute path>", the content of the partition file should be a shell script which must write the partition definition into /tmp/partitionfile on the node. For statelite: the valid value is <partition file absolute path>, refer to the statelite doc for the xCAT defined format of the configuration file.',
driverupdatesrc => 'The source of the drivers which need to be loaded during the boot. Two types of driver update source are supported: Driver update disk and Driver rpm package. The value for this attribute should be comma separated sources. Each source should be the format tab:full_path_of_srouce_file. The tab keyword can be: dud (for Driver update disk) and rpm (for driver rpm). If missing the tab, the rpm format is the default. e.g. dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
@ -786,7 +747,7 @@ winimage => {
imagename => 'The name of this xCAT OS image definition.',
template => 'The fully qualified name of the template file that is used to create the windows unattend.xml file for diskful installation.',
installto => 'The disk and partition that the Windows will be deployed to. The valid format is <disk>:<partition>. If not set, default value is 0:1 for bios boot mode(legacy) and 0:3 for uefi boot mode; If setting to 1, it means 1:1 for bios boot and 1:3 for uefi boot',
partitionfile => 'The path of partition configuration file. Since the partition configuration for bios boot mode and uefi boot mode are different, this configuration file can include both configurations if you need to support both bios and uefi mode. Either way, you must specify the boot mode in the configuration. Example of partition configuration file: [BIOS]xxxxxxx[UEFI]yyyyyyy. To simplify the setting, you also can set installto in partitionfile with section like [INSTALLTO]0:1',
partitionfile => 'The path of partition configuration file. Since the partition configuration for bios boot mode and uefi boot mode are different, this configuration file should include two parts if customer wants to support both bios and uefi mode. If customer just wants to support one of the modes, specify one of them anyway. Example of partition configuration file: [BIOS]xxxxxxx[UEFI]yyyyyyy. To simplify the setting, you also can set installto in partitionfile with section likes [INSTALLTO]0:1',
winpepath => 'The path of winpe which will be used to boot this image. If the real path is /tftpboot/winboot/winpe1/, the value for winpepath should be set to winboot/winpe1',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
@ -924,11 +885,8 @@ site => {
" -----------------\n".
"DATABASE ATTRIBUTES\n".
" -----------------\n".
" auditnosyslog: If set to 1, then commands will only be written to the auditlog table.\n".
" This attribute set to 1 and auditskipcmds=ALL means no logging of commands.\n".
" Default is to write to both the auditlog table and syslog.\n".
" auditskipcmds: List of commands and/or client types that will not be\n".
" written to the auditlog table and syslog. See auditnosyslog.\n".
" written to the auditlog table.\n".
" 'ALL' means all cmds will be skipped. If attribute is null, all\n".
" commands will be written.\n".
" clienttype:web would skip all commands from the web client\n".
@ -946,7 +904,6 @@ site => {
" nodestatus: If set to 'n', the nodelist.status column will not be updated during\n".
" the node deployment, node discovery and power operations. The default is to update.\n\n".
" skiptables: Comma separated list of tables to be skipped by dumpxCATdb\n\n".
" skipvalidatelog: If set to 1, then getcredentials and getpostscripts calls will not be logged in syslog.\n\n".
" -------------\n".
"DHCP ATTRIBUTES\n".
" -------------\n".
@ -964,11 +921,6 @@ site => {
" '0' value means include all the nodes in the subnet.\n\n".
" pruneservices: Whether to enable service pruning when noderm is run (i.e.\n".
" removing DHCP entries when noderm is executed)\n\n".
" managedaddressmode: The mode of networking configuration during node provision.\n".
" If set to 'static', the network configuration will be configured \n".
" in static mode based on the node and network definition on MN.\n".
" If set to 'dhcp', the network will be configured with dhcp protocol.\n".
" The default is 'dhcp'.\n\n".
" ------------\n".
"DNS ATTRIBUTES\n".
" ------------\n".
@ -989,22 +941,6 @@ site => {
" \"<xcatmaster>\" to mean the DNS server for each node should be the\n".
" node that is managing it (either its service node or the management\n".
" node).\n\n".
" externaldns: To specify that external dns is used. If externaldns is set to any value\n".
" then, makedns command will not start the local nameserver on xCAT MN. \n".
" Default is to start the local nameserver.\n\n".
" dnsupdaters: The value are \',\' separated string which will be added to the zone config\n".
" section. This is an interface for user to add configuration entries to\n".
" the zone sections in named.conf.\n\n".
" dnsinterfaces: The network interfaces DNS server should listen on. If it is the same\n".
" for all nodes, use a simple comma-separated list of NICs. To\n".
" specify different NICs for different nodes:\n".
" xcatmn|eth1,eth2;service|bond0.\n".
" In this example xcatmn is the name of the xCAT MN, and DNS there\n".
" should listen on eth1 and eth2. On all of the nodes in group\n".
" 'service' DNS should listen on the bond0 nic.\n".
" NOTE: if using this attribute to block certain interfaces, make sure\n".
" the ip maps to your hostname of xCAT MN is not blocked since xCAT needs to\n".
" use this ip to communicate with the local NDS server on MN.\n\n".
" -------------------------\n".
"HARDWARE CONTROL ATTRIBUTES\n".
" -------------------------\n".
@ -1132,13 +1068,6 @@ site => {
" httpport: The port number that the booting/installing nodes should contact the\n".
" http server on the MN/SN on. It is your responsibility to configure\n".
" the http server to listen on that port - xCAT will not do that.\n\n".
" nmapoptions: Additional options for the nmap command. nmap is used in pping, \n".
" nodestat, xdsh -v and updatenode commands. Sometimes additional \n".
" performance tuning may be needed for nmap due to network traffic.\n".
" For example, if the network response time is too slow, nmap may not\n".
" give stable output. You can increase the timeout value by specifying \n".
" '--min-rtt-timeout 1s'. xCAT will append the options defined here to \n".
" the nmap command.\n\n".
" ntpservers: A comma delimited list of NTP servers for the cluster - often the\n".
" xCAT management node.\n\n".
" svloglocal: if set to 1, syslog on the service node will not get forwarded to the\n".
@ -1167,10 +1096,6 @@ site => {
" will not interfere.\n\n".
" vmwarereconfigonpower: When set to no, the VMWare plugin will make no effort to\n".
" push vm.cpus/vm.memory updates from xCAT to VMWare.\n\n".
" persistkvmguests: Keep the kvm definition on the kvm hypervisor when you power off\n".
" the kvm guest node. This is useful for you to manually change the \n".
" kvm xml definition file in virsh for debugging. Set anything means\n".
" enable.\n\n".
" --------------------\n".
"XCAT DAEMON ATTRIBUTES\n".
" --------------------\n".
@ -1181,9 +1106,9 @@ site => {
" locking out admin interactive use. This value works with the\n".
" xcatmaxconnections and xcatmaxbatch attributes. Is not supported on AIX.\n".
" If the value is no, nodes sleep for a random time before contacting\n".
" xcatd, and retry. The default is no.\n".
" xcatd, and retry. On a new install of xcat, this value will be set to yes.\n".
" See the following document for details:\n".
" Hints_and_Tips_for_Large_Scale_Clusters\n\n".
" https://sourceforge.net/apps/mediawiki/xcat/index.php?title=Hints_and_Tips_for_Large_Scale_Clusters\n\n".
" xcatmaxconnections: Number of concurrent xCAT protocol requests before requests\n".
" begin queueing. This applies to both client command requests\n".
" and node requests, e.g. to get postscripts. Default is 64.\n\n".
@ -1420,7 +1345,7 @@ firmware => {
},
nics => {
cols => [qw(node nicips nichostnamesuffixes nichostnameprefixes nictypes niccustomscripts nicnetworks nicaliases nicextraparams comments disable)],
cols => [qw(node nicips nichostnamesuffixes nichostnameprefixes nictypes niccustomscripts nicnetworks nicaliases comments disable)],
keys => [qw(node)],
tablespace =>'XCATTBS16K',
table_desc => 'Stores NIC details.',
@ -1457,12 +1382,6 @@ nics => {
Format: eth0!<alias list>,eth1!<alias1 list>|<alias2 list>
For multiple aliases per nic use a space-separated list.
For example: eth0!moe larry curly,eth1!tom|jerry',
nicextraparams => 'Comma-separated list of extra parameters that will be used for each NIC configuration.
If only one ip address is associated with each NIC:
<nic1>!<param1=value1 param2=value2>,<nic2>!<param3=value3>, for example, eth0!MTU=1500,ib0!MTU=65520 CONNECTED_MODE=yes.
If multiple ip addresses are associated with each NIC:
<nic1>!<param1=value1 param2=value2>|<param3=value3>,<nic2>!<param4=value4 param5=value5>|<param6=value6>, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes.
The xCAT object definition commands support to use nicextraparams.<nicname> as the sub attributes.',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
@ -1584,7 +1503,7 @@ discoverydata => {
method => 'The method which handled the discovery request. The method could be one of: switch, blade, profile, sequential.',
discoverytime => 'The last time that xCAT received the discovery message.',
arch => 'The architecture of the discovered node. e.g. x86_64.',
cpucount => 'The number of cores multiply by threads core supported for the discovered node. e.g. 192.',
cpucount => 'The cpu number of the discovered node. e.g. 32.',
cputype => 'The cpu type of the discovered node. e.g. Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz',
memory => 'The memory size of the discovered node. e.g. 198460852',
mtm => 'The machine type model of the discovered node. e.g. 786310X',
@ -1649,18 +1568,7 @@ hwinv => {
disable => "Set to 'yes' or '1' to comment out this row.",
},
},
token => {
cols => [qw(tokenid username expire comments disable)],
keys => [qw(tokenid)],
table_desc => 'The token of users for authentication.',
descriptions => {
tokenid => 'It is a UUID as an unified identify for the user.',
username => 'The user name.',
expire => 'The expire time for this token.',
comments => 'Any user-provided notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
},
); # end of tabspec definition
@ -2389,11 +2297,7 @@ my @nodeattrs = (
tabentry => 'nics.nicaliases',
access_tabentry => 'nics.node=attr:node',
},
{attr_name => 'nicextraparams',
tabentry => 'nics.nicextraparams',
access_tabentry => 'nics.node=attr:node',
},
#######################
######################
# prodkey table #
######################
{attr_name => 'productkey',
@ -3644,10 +3548,6 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs);
tabentry => 'kit.kitdeployparams',
access_tabentry => 'kit.kitname=attr:kitname',
},
{attr_name => 'kitdir',
tabentry => 'kit.kitdir',
access_tabentry => 'kit.kitname=attr:kitname',
},
);
#############################
@ -3664,8 +3564,8 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs);
tabentry => 'kitrepo.kitname',
access_tabentry => 'kitrepo.kitreponame=attr:kitreponame',
},
{attr_name => 'osbasename',
tabentry => 'kitrepo.osbasename',
{attr_name => 'osname',
tabentry => 'kitrepo.osname',
access_tabentry => 'kitrepo.kitreponame=attr:kitreponame',
},
{attr_name => 'osmajorversion',
@ -3710,7 +3610,7 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs);
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',
},
{attr_name => 'kitreponame',
tabentry => 'kitcomponent.kitreponame',
tabentry => 'kitcomponent.kitrepoid',
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',
},
{attr_name => 'basename',
@ -3733,10 +3633,6 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs);
tabentry => 'kitcomponent.kitpkgdeps',
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',
},
{attr_name => 'prerequisite',
tabentry => 'kitcomponent.prerequisite',
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',
},
{attr_name => 'driverpacks',
tabentry => 'kitcomponent.driverpacks',
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',
@ -3749,10 +3645,6 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs);
tabentry => 'kitcomponent.postbootscripts',
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',
},
{attr_name => 'genimage_postinstall',
tabentry => 'kitcomponent.genimage_postinstall',
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',
},
{attr_name => 'exlist',
tabentry => 'kitcomponent.exlist',
access_tabentry => 'kitcomponent.kitcompname=attr:kitcompname',

View File

@ -10,8 +10,12 @@ BEGIN
# if AIX - make sure we include perl 5.8.2 in INC path.
# Needed to find perl dependencies shipped in deps tarball.
if ($^O =~ /^aix/i) {
unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2));
}
use lib "/usr/opt/perl5/lib/5.8.2/aix-thread-multi";
use lib "/usr/opt/perl5/lib/5.8.2";
use lib "/usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi";
use lib "/usr/opt/perl5/lib/site_perl/5.8.2";
}
use lib "$::XCATROOT/lib/perl";
use strict;
#-----------------------------------------------------------------------------
@ -185,13 +189,6 @@ sub isServiceReq
if (!exists($servicehash->{'tftpserver'})) {
$servicehash->{'tftpserver'} = 1;
}
# On Ubuntu management node, we disabled the isc-dhcp-server in upstart,
# through file /etc/init/isc-dhcp-server.override, see bug 4399
# however, this causes a new problem, bug 4515
# the fix is to start dhcp server when starting xcatd
if (!exists($servicehash->{'dhcpserver'}) && xCAT::Utils->osver() =~ /ubuntu.*/i) {
$servicehash->{'dhcpserver'} = 1;
}
}
$servicenodetab->close;

View File

@ -179,10 +179,6 @@ sub init_dbworker {
#setup signal in NotifHandler so that the cache can be updated
xCAT::NotifHandler::setup($$, 0);
# NOTE: There's a bug that sometimes the %SIG is cleaned up by accident, but we cannot figure out when and why
# this happens. The temporary fix is to backup the %SIG and recover it when necessary.
my %SIGbakup = %SIG;
while (not $exitdbthread) {
eval {
my @ready_socks = $clientset->can_read;
@ -195,7 +191,6 @@ sub init_dbworker {
} else {
eval {
handle_dbc_conn($currcon,$clientset);
unless (%SIG && defined ($SIG{USR1})) { %SIG = %SIGbakup; }
};
if ($@) {
my $err=$@;
@ -220,9 +215,6 @@ sub init_dbworker {
exit(0);
}
}
# sleep a while to make sure the client process has done
sleep 1.5;
close($dbworkersocket);
unlink($dbsockpath);
exit 0;
@ -3842,7 +3834,7 @@ sub writeAllEntries
}
my $filename = shift;
my $fh;
my $rc = 0;
my $rc;
# open the file for write
unless (open($fh," > $filename")) {
my $msg="Unable to open $filename for write \n.";

14
perl-xCAT/xCAT/TableUtils.pm Executable file → Normal file
View File

@ -10,8 +10,11 @@ BEGIN
# if AIX - make sure we include perl 5.8.2 in INC path.
# Needed to find perl dependencies shipped in deps tarball.
if ($^O =~ /^aix/i) {
unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2));
}
use lib "/usr/opt/perl5/lib/5.8.2/aix-thread-multi";
use lib "/usr/opt/perl5/lib/5.8.2";
use lib "/usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi";
use lib "/usr/opt/perl5/lib/site_perl/5.8.2";
}
use lib "$::XCATROOT/lib/perl";
use strict;
@ -426,6 +429,7 @@ rmdir \"/tmp/$to_userid\" \n";
# Need to check if nodes are in a zone.
my @zones;
my $tab = xCAT::Table->new("zone");
my @zones;
if ($tab)
{
# if we have zones, need to send the zone keys to each node in the zone
@ -619,7 +623,7 @@ sub sendkeysTOzones
my ($class, $ref_nodes,$expecttimeout) = @_;
my @nodes=$ref_nodes;
my $n_str = $nodes[0];
@nodes= split(",", $n_str);
my @nodes= split(",", $n_str);
my $rsp = ();
my $cmd;
my $roothome = xCAT::Utils->getHomeDir("root");
@ -1174,9 +1178,7 @@ sub getAppStatus
my ($class, $nodes_ref, $application) = @_;
my @nodes = @$nodes_ref;
# FIXME: why autocommit matters for a read-only subroutine getNodesAttribs?
# but could not get the appstatus without the autocommit=0
my $nltab = xCAT::Table->new('nodelist', -autocommit => 0);
my $nltab = xCAT::Table->new('nodelist');
my $nodeappstat = $nltab->getNodesAttribs(\@nodes,['appstatus']);
my $ret_nodeappstat;

View File

@ -18,9 +18,8 @@ use xCAT::Utils;
my %usage = (
"rnetboot" =>
"Usage: rnetboot <noderange> [-s net|hd] [-F] [-f] [-V|--verbose] [-m table.colum==expectedstatus] [-m table.colum==expectedstatus...] [-r <retrycount>] [-t <timeout>]
rnetboot [-h|--help|-v|--version]
zVM specific:
rnetboot <noderange> [ipl= address]",
rnetboot <noderange> [ipl= address]
rnetboot [-h|--help|-v|--version]",
"rpower" =>
"Usage: rpower <noderange> [--nodeps] [on|onstandby|off|suspend|reset|stat|state|boot] [-V|--verbose] [-m table.colum==expectedstatus][-m table.colum==expectedstatus...] [-r <retrycount>] [-t <timeout>]
rpower [-h|--help|-v|--version]
@ -28,12 +27,10 @@ my %usage = (
rpower <noderange> [boot] [ -c <path to iso> ]
PPC (with IVM or HMC) specific:
rpower <noderange> [--nodeps] [of] [-V|--verbose]
CEC (with HMC) specific:
rpower <noderange> [on|off|reset|boot|onstandby]
LPAR(with HMC) specific:
rpower <noderange> [on|off|reset|stat|state|boot|of|sms|softoff]
PPC (HMC) specific:
rpower <noderange> [onstandby] [-V|--verbose]
CEC(using Direct FSP Management) specific:
rpower <noderange> [on|onstandby|off|stat|state|resetsp]
rpower <noderange> [on|onstandby|off|stat|state|lowpower|resetsp]
Frame(using Direct FSP Management) specific:
rpower <noderange> [stat|state|rackstandby|exit_rackstandby|resetsp]
LPAR(using Direct FSP Management) specific:
@ -134,7 +131,7 @@ my %usage = (
textid=<*>|
frame=<*>|
ntp=<[ntp],[ip],[frequency],[v3]>
FSP/CEC (using ASM Interface) Specific:
FSP/BPA Common:
rspconfig <noderange> [autopower|iocap|decfg|memdecfg|procdecfg|time|date|spdump|sysdump|network|hostname]
rspconfig <noderange> autopower=<enable|disable>|
iocap=<enable|disable>|
@ -225,7 +222,7 @@ my %usage = (
lsvm <noderange> [-a|--all]
PPC (using Direct FSP Management) specific:
lsvm <noderange> [-l|--long] --p775
lsvm <noderange>
lsvm <noderange>
zVM specific:
lsvm noderange
lsvm noderange --getnetworknames
@ -244,10 +241,8 @@ my %usage = (
chvm <noderange> --p775 -i <id> [-m <memory_interleaving>] -r <partition_rule>
chvm <noderange> [lparname=<*|name>]
chvm <noderange> [vmcpus=min/req/max] [vmmemory=min/req/max]
[vmothersetting=hugepage:N,bsr:N]
[add_physlots=drc_index1,drc_index2...]
[add_vmnics=vlan1,vlan2] [add_vmstorage=<N|viosnode:slotid>] [--vios]
chvm <noderange> [del_physlots=drc_index1,drc_index2...]
[vmphyslots=drc_index1,drc_index2...] [vmothersetting=hugepage:N,bsr:N]
[vmnics=vlan1,vlan2] [vmstorage=<N|viosnode:slotid>] [--vios]
chvm <noderange> [del_vadapter=slotid]
VMware specific:
chvm <noderange> [-a size][-d disk][-p disk][--resize disk=size][--cpus count][--mem memory]
@ -333,16 +328,12 @@ my %usage = (
renergy [-v | --version]
Power 6 server specific :
renergy noderange [-V] { all | { [savingstatus] [cappingstatus] [cappingmaxmin] [cappingvalue] [cappingsoftmin] [averageAC] [averageDC] [ambienttemp] [exhausttemp] [CPUspeed] } }
renergy noderange [-V] { {savingstatus}={on | off} | {cappingstatus}={on | off} | {cappingwatt}=watt | {cappingperc}=percentage }
renergy noderange [-V] { all | { [savingstatus] [cappingstatus] [cappingmaxmin] [cappingvalue] [cappingsoftmin] [averageAC] [averageDC] [ambienttemp] [exhausttemp] [CPUspeed] } }
renergy noderange [-V] { {savingstatus}={on | off} | {cappingstatus}={on | off} | {cappingwatt}=watt | {cappingperc}=percentage }
Power 7 server specific :
renergy noderange [-V] { all | { [savingstatus] [dsavingstatus] [cappingstatus] [cappingmaxmin] [cappingvalue] [cappingsoftmin] [averageAC] [averageDC] [ambienttemp] [exhausttemp] [CPUspeed] [syssbpower] [sysIPLtime] [fsavingstatus] [ffoMin] [ffoVmin] [ffoTurbo] [ffoNorm] [ffovalue] } }
renergy noderange [-V] { {savingstatus}={on | off} | {dsavingstatus}={on-norm | on-maxp | off} | {fsavingstatus}={on | off} | {ffovalue}=MHZ | {cappingstatus}={on | off} | {cappingwatt}=watt | {cappingperc}=percentage }
Power 8 server specific :
renergy noderange [-V] { all | [savingstatus] [dsavingstatus] [averageAC] [averageAChistory] [averageDC] [averageDChistory] [ambienttemp] [ambienttemphistory] [exhausttemp] [exhausttemphistory] [fanspeed] [fanspeedhistory] [CPUspeed] [CPUspeedhistory] [syssbpower] [sysIPLtime] [fsavingstatus] [ffoMin] [ffoVmin] [ffoTurbo] [ffoNorm] [ffovalue]}
renergy noderange [-V] { savingstatus={on | off} | dsavingstatus={on-norm | on-maxp | off} | fsavingstatus={on | off} | ffovalue=MHZ }
renergy noderange [-V] { all | { [savingstatus] [dsavingstatus] [cappingstatus] [cappingmaxmin] [cappingvalue] [cappingsoftmin] [averageAC] [averageDC] [ambienttemp] [exhausttemp] [CPUspeed] [syssbpower] [sysIPLtime] [fsavingstatus] [ffoMin] [ffoVmin] [ffoTurbo] [ffoNorm] [ffovalue] } }
renergy noderange [-V] { {savingstatus}={on | off} | {dsavingstatus}={on-norm | on-maxp | off} | {fsavingstatus}={on | off} | {ffovalue}=MHZ | {cappingstatus}={on | off} | {cappingwatt}=watt | {cappingperc}=percentage }
BladeCenter specific :
For Management Modules:

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,6 @@ require Exporter;
"1341569670.539525" => "centos6.3",#x86
"1362445555.957609" => "centos6.4",#x86_64
"1385726732.061157" => "centos6.5",#x86_64
"1404489053.504589" => "centos7.0",
"1176234647.982657" => "centos5",
"1156364963.862322" => "centos4.4",
"1178480581.024704" => "centos4.5",
@ -30,7 +29,6 @@ require Exporter;
"1272326751.405938" => "centos5.5",
"1330913492.861127" => "centos5.8",#x86_64
"1357930415.252042" => "centos5.9",#x86_64
"1381776971.473332" => "centos5.10",#x86_64
"1195488871.805863" => "centos4.6",
"1195487524.127458" => "centos4.6",
"1301444731.448392" => "centos5.6",
@ -67,21 +65,11 @@ require Exporter;
"1359576196.686790" => "rhels6.4", #ppc64
"1384196515.415715" => "rhels6.5", #x86_64
"1384198011.520581" => "rhels6.5", #ppc64
"1411733344.627228" => "rhels6.6", #x86_64
"1411733344.616389" => "rhels6.6", #ppc64
"1399449226.171922" => "rhels7", #x86_64
"1399449226.155578" => "rhels7", #ppc64
"1424360759.989976" => "rhels7.1", #x86_64
"1424360759.878519" => "rhels7.1", #ppc64
"1424361409.280138" => "rhels7.1", #ppc64le
"1285193176.593806" => "rhelhpc6", #x86_64
"1305067719.718814" => "rhelhpc6.1",#x86_64
"1321545261.599847" => "rhelhpc6.2",#x86_64
"1339640148.070971" => "rhelhpc6.3",#x86_64
"1359576195.413831" => "rhelhpc6.4",#x86_64, RHEL ComputeNode
"1384196516.465862" => "rhelhpc6.5",#x86_64, RHEL ComputeNode
"1411733344.599861" => "rhelhpc6.6",#x86_64, RHEL ComputeNode
"1399449226.140088" => "rhelhpc7.0",#x86_64, RHEL ComputeNode
"1194015916.783841" => "fedora8",
"1194015385.299901" => "fedora8",
"1210112435.291709" => "fedora9",
@ -100,12 +88,9 @@ require Exporter;
"1194512327.501046" => "rhas4.6",
"1241464993.830723" => "rhas4.8", #x86-64
"1273608367.051780" => "SL5.5", #x86_64 DVD ISO
"1299104542.844706" => "SL6", #x86_64 DVD ISO
"1390839789.062069" => "SL6.5", #x86_64 DVD ISO Install
"1394111947.452332" => "pkvm2.1", # ppc64, PowerKVM
"1413749127.352649" => "pkvm2.1.1", # ppc64, PowerKVM
"1273608367.051780" => "SL5.5", #x86_64 DVD ISO
"1299104542.844706" => "SL6", #x86_64 DVD ISO
"1394111947.452332" => "pkvm2.1", # ppc64
);
my %numdiscs = (
"1156364963.862322" => 4,

File diff suppressed because it is too large Load Diff

View File

@ -614,6 +614,8 @@ sub punch2Reader {
my $out;
if ( $os =~ m/sles10/i ) {
$out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo /sbin/vmur punch $options -u $userId -r $srcFile -N $tgtFile"`;
} elsif ( $os =~ m/sles11/i ) {
$out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo /usr/sbin/vmur punch $options -u $userId -r $srcFile -N $tgtFile"`;
} elsif ( $os =~ m/rhel/i ) {
$out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo /usr/sbin/vmur punch $options -u $userId -r $srcFile -N $tgtFile"`;
} else {

View File

@ -2393,7 +2393,7 @@ sub getFreeRepoSpace {
if ($master eq $ip) {
# If the master IP and node IP match, then it is the management node
my $out = `$sudo /bin/df -h /install | sed 1d`;
# causing problems on other platforms $out =~ s/\h+/ /g;$out =~ s/\h+/ /g;
$out =~ s/\h+/ /g;
my @results = split(' ', $out);
return ($results[3]);
}

View File

@ -1,10 +0,0 @@
# AIX Bundle file for compiler runtime packages
I:xlC.aix61
I:xlC.rte
I:xlfrte
I:xlfrte.aix61
I:xlfrte.msg.en_US
I:xlsmp.aix61.rte
I:xlsmp.msg.en_US.rte
I:xlsmp.rte

View File

@ -41,8 +41,8 @@ if [ $OS != "AIX" ]; then
mkdir -p /tmp/gpfs_updates
rm -f -R /tmp/gpfs_updates/*
cd /tmp/gpfs_updates
# wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=3 ftp://$MASTER/$UPDATES_DIR/*.rpm 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=4 --reject "index.html*" --no-parent http://$MASTER$INSTALL_DIR/$UPDATES_DIR/ 2> /tmp/wget.log
# wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=3 ftp://$SITEMASTER/$UPDATES_DIR/*.rpm 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=4 --reject "index.html*" --no-parent http://$SITEMASTER$INSTALL_DIR/$UPDATES_DIR/ 2> /tmp/wget.log
if [ -n "`ls *.rpm 2> /dev/null`" ] ; then
rpm -Uvh *.rpm
fi
@ -103,7 +103,7 @@ else # assume Linux
fi
if [ ! -e $gpfsprofile.sh ]; then
echo 'export PATH=$PATH:/usr/lpp/mmfs/bin' > $gpfsprofile.sh
echo 'setenv PATH ${PATH}:/usr/lpp/mmfs/bin' > $gpfsprofile.csh
echo 'setenv PATH $PATH:/usr/lpp/mmfs/bin' > $gpfsprofile.csh
# Turn off LANG support since we did not install other msg catalogs
echo 'export LC_CTYPE=POSIX' >> $gpfsprofile.sh
echo 'setenv LC_CTYPE POSIX' >> $gpfsprofile.csh

View File

@ -62,8 +62,7 @@ else
file=$1
fi
#ifconfig -a | grep 'inet ' | awk ' { print $2 } ' | grep -v 127.0.0.1 |
ip -4 -oneline addr show 2>/dev/null |grep inet | sed -ne "s/.*inet //p"|awk -F ' ' '{print $1}'|awk -F '/' '{print $1}'|
ifconfig -a | grep 'inet ' | awk ' { print $2 } ' | grep -v 127.0.0.1 |
while read my_address ; do
##print "checking $my_address"
grep -q " ${my_address}$" $file

View File

@ -1,88 +1,38 @@
Eclipse Public License - v 1.0
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: xcat-openstack-baremetal
Source: <url://example.com>
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: <special license>
<Put the license of the package here indented by 1 space>
<This follows the format of Description: lines in control file>
.
<Including paragraphs>
1. DEFINITIONS
# If you want to use GPL v2 or later for the /debian/* files use
# the following clauses, or change it to suit. Delete these two lines
Files: debian/*
Copyright: 2014 root <root@unknown>
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
"Contribution" means:
a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
b) in the case of each subsequent Contributor:
i) changes to the Program, and
ii) additions to the Program;
where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
"Contributor" means any person or entity that distributes the Program.
"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
"Program" means the Contributions distributed in accordance with this Agreement.
"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
2. GRANT OF RIGHTS
a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
3. REQUIREMENTS
A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
a) it complies with the terms and conditions of this Agreement; and
b) its license agreement:
i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
When the Program is made available in source code form:
a) it must be made available under this Agreement; and
b) a copy of this Agreement must be included with each copy of the Program.
Contributors may not remove or alter any copyright notices contained within the Program.
Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
4. COMMERCIAL DISTRIBUTION
Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
5. NO WARRANTY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
6. DISCLAIMER OF LIABILITY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. GENERAL
If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
# Please avoid to pick license terms that are more restrictive than the
# packaged work, as it may make Debian's contributions unacceptable upstream.

View File

@ -0,0 +1,2 @@
xcat-openstack-baremetal_2.8.4-1_all.deb admin extra
xcat-openstack-baremetal_2.8.4-1_all.deb admin extra

View File

@ -0,0 +1,201 @@
dh_installdirs
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb
dh_installdirs
dh_install
dh_link
dh_installman
dh_compress
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dh_builddeb

View File

@ -67,13 +67,11 @@ sub opsaddbmnode {
my $help;
my $version;
my $verbose;
my $host;
if(!GetOptions(
'h|help' => \$help,
'v|version' => \$version,
'V|verbose' => \$verbose,
's=s' => \$host,
))
{
@ -245,18 +243,7 @@ sub opsaddbmnode {
$disk = 1;
}
if ($verbose) {
my $rsp;
push @{$rsp->{data}}, "Attributes gathered from the xCAT database:";
push @{$rsp->{data}}, " bmc=$bmc";
push @{$rsp->{data}}, " bmc_user=$bmc_user";
push @{$rsp->{data}}, " bmc_password=$bmc_password";
push @{$rsp->{data}}, " mac=$mac";
push @{$rsp->{data}}, " cpu=$cpu";
push @{$rsp->{data}}, " memory=$memory";
push @{$rsp->{data}}, " disk=$disk";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
#print "$bmc, $bmc_user, $bmc_password, $mac, $cpu, $memory, $disk\n";
#call OpenStack command to add the node into the OpenStack as
#a baremetal node.
@ -276,14 +263,7 @@ sub opsaddbmnode {
}
$cmd_tmp .= " $host $cpu $memory $disk $mac";
my $cmd = qq~$cmd_tmp~;
if ($verbose) {
my $rsp;
push @{$rsp->{data}}, "The command to run on $host:";
push @{$rsp->{data}}, " $cmd";
push @{$rsp->{data}}, " ";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $cmd = qq~source \~/openrc;$cmd_tmp~;
#print "cmd=$cmd\n";
my $output =
xCAT::InstUtils->xcmd($callback, $doreq, "xdsh", [$host], $cmd, 0);
@ -291,17 +271,8 @@ sub opsaddbmnode {
my $rsp;
push @{$rsp->{data}}, "OpenStack creating baremetal node $node:";
push @{$rsp->{data}}, "$output";
push @{$rsp->{data}}, "The command was: $cmd";
xCAT::MsgUtils->message("E", $rsp, $callback);
} else {
if (($verbose) && ($output)) {
my $rsp;
push @{$rsp->{data}}, "$output";
push @{$rsp->{data}}, " ";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
}
}
}
@ -325,7 +296,6 @@ sub opsaddimage {
my $help;
my $version;
my $verbose;
#my $cloud;
my $ops_img_names;
my $controller;
@ -333,7 +303,6 @@ sub opsaddimage {
if(!GetOptions(
'h|help' => \$help,
'v|version' => \$version,
'V|verbose' => \$verbose,
'c=s' => \$controller,
'n=s' => \$ops_img_names,
))
@ -422,46 +391,16 @@ sub opsaddimage {
}
my $cmd_tmp = "glance image-create --name $new_name --public --disk-format qcow2 --container-format bare --property xcat_image_name=\'$image\' < /tmp/$image.qcow2";
my $cmd = qq~touch /tmp/$image.qcow2;$cmd_tmp~;
if ($verbose) {
my $rsp;
push @{$rsp->{data}}, "The command to run on $controller:";
push @{$rsp->{data}}, " $cmd";
push @{$rsp->{data}}, " ";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $cmd = qq~touch /tmp/$image.qcow2;source \~/openrc;$cmd_tmp;rm /tmp/$image.qcow2~;
#print "cmd=$cmd\ncontroller=$controller\n";
my $output =
xCAT::InstUtils->xcmd($callback, $doreq, "xdsh", [$controller], $cmd, 0);
if ($::RUNCMD_RC != 0) {
my $rsp;
push @{$rsp->{data}}, "OpenStack creating image $new_name:";
push @{$rsp->{data}}, "$output";
push @{$rsp->{data}}, "The command was: $cmd";
xCAT::MsgUtils->message("E", $rsp, $callback);
} else {
if (($verbose) && ($output)) {
my $rsp;
push @{$rsp->{data}}, "$output";
push @{$rsp->{data}}, " ";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
}
my $cmd1 = qq~rm /tmp/$image.qcow2~;
if ($verbose) {
my $rsp;
push @{$rsp->{data}}, "The command to run on $controller:";
push @{$rsp->{data}}, " $cmd1";
push @{$rsp->{data}}, " ";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $output1 =
xCAT::InstUtils->xcmd($callback, $doreq, "xdsh", [$controller], $cmd1, 0);
if (($verbose) && ($output1)) {
my $rsp;
push @{$rsp->{data}}, "$output1";
push @{$rsp->{data}}, " ";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
}
}
@ -906,7 +845,7 @@ sub opsaddbmnode_usage {
$rsp->{data}->[0]= "Usage: opsaddbmnode -h";
$rsp->{data}->[1]= " opsaddbmnode -v";
$rsp->{data}->[2]= " opsaddbmnode <noderange> -s <service_host> [-V]";
$rsp->{data}->[2]= " opsaddbmnode <noderange> -s <service_host>";
$cb->($rsp);
}
@ -924,7 +863,7 @@ sub opsaddimage_usage {
$rsp->{data}->[0]= "Usage: opsaddimage -h";
$rsp->{data}->[1]= " opsaddimage -v";
$rsp->{data}->[2]= " opsaddimage <image1,image2...> [-n <new_name1,new_name2...> -c <controller> [-V]";
$rsp->{data}->[2]= " opsaddimage <image1,image2...> [-n <new_name1,new_name2...> -c <controller>";
$cb->($rsp);
}

View File

@ -4,7 +4,7 @@ B<opsaddbmnode> - It adds xCAT baremetal nodes to an OpenStack cloud.
=head1 SYNOPSIS
B<opsaddbmnode> I<noderange> B<-s> I<service_host> [B<-V>|B<--verbose>]
B<opsaddbmnode> I<noderange> B<-s> I<service_host>
B<opsaddbmnode> [B<-h>|B<--help>]
@ -59,8 +59,6 @@ I<noderage> is a comma separated node or node group names.
=item B<-v|--version> The Command Version.
=item B<-V|--verbose> Verbose output.
=back
=head1 RETURN VALUE

View File

@ -4,7 +4,7 @@ B<opsaddimage> - It adds or removes nodes for the vlan.
=head1 SYNOPSIS
B<opsaddimage> I<image1,image2,...> B<-n> I<new_name1,new_name2,...> [B<-c> I<controller>] [B<-V>|B<--verbose>]
B<opsaddimage> I<image1,image2,...> B<-n> I<new_name1,new_name2,...> [B<-c> I<controller>]
B<opsaddimage> [B<-h>|B<--help>]
@ -35,8 +35,6 @@ I<image1,image1...> a comma separated xCAT images names.
=item B<-v|--version> The Command Version.
=item B<-V|--verbose> Verbose output.
=back
=head1 RETURN VALUE

View File

@ -100,8 +100,8 @@ change_host_name()
if [ "$str_os_type" = "sles" ];then
echo "Persistently changing the hostname not implemented yet."
#debian ubuntu and rh7
elif [ -f "/etc/hostname" ];then
#debian ubuntu
elif [ "$str_os_type" = "debian" ];then
conf_file="/etc/hostname"
echo "$str_hostname" > $conf_file
else

View File

@ -36,8 +36,8 @@ change_host_name()
if [ "$str_os_type" = "sles" ];then
echo "Persistently changing the hostname not implemented yet."
#debian ubuntu and rh7
elif [ -f "/etc/hostname" ];then
#debian ubuntu
elif [ "$str_os_type" = "debian" ];then
conf_file="/etc/hostname"
echo "$str_hostname" > $conf_file
else

View File

@ -71,7 +71,7 @@ sub createDummyPods {
my $cmd = "grep -r -E 'L<.+\\([57]\\)\\|.+\\.[57]>' " . $poddir;
#print "Running cmd: ", $cmd, "\n";
my @lines = `$cmd`;
if ($?) { print "Did not find any section 5 man page, creating dummy pods...\n"; print join('', @lines); }
if ($?) { print "Error running: $cmd\n"; print join('', @lines); }
#my @lines;
#system($cmd);
my @dummyPods;

View File

@ -1,6 +0,0 @@
include AUTHORS
include ChangeLog
exclude .gitignore
exclude .gitreview
global-exclude *.pyc

View File

@ -1,44 +0,0 @@
xCAT Driver for ironic x86/64 machine
==================================
xCAT is a Extreme Cluster/Cloud Administration Toolkit. We can use xcat
to do :
1 hardward discoveery
2 remote hardware control
3 remote sonsole
4 hardware inventory
5 firmware flashing
Ironic is a project in Openstack, it will replace the nova-baremetal in juno release. Ironic's design is very flexable, we can add driver to extend function
without change any code in Openstack. Ironic xCAT driver takes the advantage of xcat and openstack, we can use it to deploy the baremetal machine very easily.
Before using this driver, we must setup the openstack environment at least for two nodes( ironic conductor and neutron network node can't setup on the same node)
Ironic conductor and the baremetal node( waiting for deploy) must in the same vlan
Add the follows in the ironic egg-info entry_points.txt file (ironic.drivers section)
pxe_xcat = ironic.drivers.xcat:XCATBaremetalDriver
When the openstack with ironic is ready, just execute command in the ironic_xcat directory as follows:
$ python setup.py install
Restart the ironic-conductor process
Initialize the xcat environment according to http://sourceforge.net/p/xcat/wiki/XCAT_iDataPlex_Cluster_Quick_Start/
Using xCAT baremetal driver need config site table and run copycds to generate image. The node definition is not requirement.
Ironic use neutron as the network service.
Check the openvswitch config on the network node ,make sure brbm bridge connect to the baremetal node.
==================================================================================
Some Example to use the xCAT baremetal driver.
$touch /tmp/rhelhpc6.5-x86_64-install-compute.qcow2;glance image-create --name rhelhpc6.5-x86_64-install-compute --public --disk-format qcow2 --container-format bare --property xcat_image_name='rhels6.4-x86_64-install-compute' < /tmp/rhelhpc6.5-x86_64-install-compute.qcow2
--name rhelhpc6.5-x86_64-install-compute is the image name in xcat. You can use lsdef -t osimage on the ironic-conductor node which xcat is installed.
$ ironic node-create --driver pxe_xcat -i ipmi_address=xxx.xxx.xxx.xxx -i ipmi_username=userid -i ipmi_password=password -i xcat_node=x3550m4n02 -i xcatmaster=10.1.0.241 -i netboot=xnba -i ipmi_terminal_port=0 -p memory_mb=2048 -p cpus=8
$ ironic port-create --address ff:ff:ff:ff:ff:ff --node_uuid <ironic node uuid>
$ nova boot --flavor baremetal --image <image-id> testing --nic net-id=<internal network id>

View File

@ -1,25 +0,0 @@
"""xCAT baremtal exceptions.
"""
from oslo.config import cfg
import six
from ironic.openstack.common.gettextutils import _
from ironic.openstack.common import log as logging
from ironic.common.exception import IronicException
LOG = logging.getLogger(__name__)
class xCATCmdFailure(IronicException):
message = _("xcat call failed: %(cmd)s %(node)s %(args)s.")
class xCATDeploymentFailure(IronicException):
message = _("xCAT node deployment failed for node %(node)s:%(error)s")
class GetNetworkFixedIPFailure(IronicException):
message = _("get fixed ip failed for mac %(mac_address)s")
class GetNetworkIdFailure(IronicException):
message = _("get node network in failed for mac %(mac_address)s")
class FailedToGetInfoOnPort(IronicException):
message = _("Show info on port: %(port_id)s failed.")

View File

@ -1,41 +0,0 @@
"""
Get the network from neutron
This is a xcat patch for the ironic/common/neutron.py
"""
from neutronclient.common import exceptions as neutron_client_exc
from ironic.common import exception
from ironic.openstack.common import log as logging
from ironic.common import neutron
from ironic.drivers.modules import xcat_exception
LOG = logging.getLogger(__name__)
def get_vif_port_info(task, port_id):
""" Get detail port info from neutron with a given port id """
api = neutron.NeutronAPI(task.context)
try:
port_info = api.client.show_port(port_id)
except neutron_client_exc.NeutronClientException:
LOG.exception(_("Failed to get port info %s."), port_id)
raise exception.FailedToGetInfoOnPort(port_id=port_id)
return port_info
def get_ports_info_from_neutron(task):
""" Get neutron port info from neutron about this task """
vifs = neutron.get_node_vif_ids(task)
if not vifs:
LOG.warning(_("No VIFs found for node %(node)s when attempting to "
"update Neutron DHCP BOOT options."),
{'node': task.node.uuid})
return
failures = []
vif_ports_info = {}
for port_id, port_vif in vifs.iteritems():
try:
vif_ports_info[port_id] = get_vif_port_info(task,port_vif)
except xcat_exception.FailedToGetInfoOnPort(port_id=port_vif):
failures.append(port_vif)
return vif_ports_info

View File

@ -1,462 +0,0 @@
"""
pxe procedure for the xcat baremetal driver
use xcat to config dhcp and tftp
"""
import os
import time
import paramiko
import datetime
from oslo.config import cfg
from ironic.common import exception
from ironic.common import image_service as service
from ironic.common import keystone
from ironic.common import states
from ironic.common import utils
from ironic.conductor import task_manager
from ironic.conductor import utils as manager_utils
from ironic.drivers import base
from ironic.drivers import utils as driver_utils
from ironic.openstack.common import log as logging
from ironic.openstack.common import strutils
from ironic.drivers.modules import xcat_neutron
from ironic.drivers.modules import xcat_util
from ironic.openstack.common import loopingcall
from nova.openstack.common import timeutils
from ironic.openstack.common import lockutils
from ironic.drivers.modules import xcat_exception
pxe_opts = [
cfg.StrOpt('pxe_append_params',
default='nofb nomodeset vga=normal',
help='Additional append parameters for baremetal PXE boot.'),
cfg.StrOpt('default_ephemeral_format',
default='ext4',
help='Default file system format for ephemeral partition, '
'if one is created.'),
]
xcat_opts = [
cfg.StrOpt('network_node_ip',
default='127.0.0.1',
help='IP address of neutron network node'),
cfg.StrOpt('ssh_user',
default='root',
help='Username of neutron network node.'),
cfg.StrOpt('ssh_password',
default='cluster',
help='Password of neutron network node'),
cfg.IntOpt('ssh_port',
default=22,
help='ssh connection port for the neutron '),
cfg.StrOpt('host_filepath',
default='/etc/hosts',
help='host file of server'),
cfg.IntOpt('deploy_timeout',
default=3600,
help='max depolyment time(seconds) for the xcat driver'),
cfg.IntOpt('deploy_checking_interval',
default=30,
help='interval time(seconds) to check the xcat deploy state'),
]
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF.register_opts(pxe_opts, group='pxe')
CONF.register_opts(xcat_opts, group='xcat')
CONF.import_opt('use_ipv6', 'ironic.netconf')
REQUIRED_PROPERTIES = {
'pxe_deploy_kernel': _("UUID (from Glance) of the deployment kernel. "
"Required."),
'pxe_deploy_ramdisk': _("UUID (from Glance) of the ramdisk that is "
"mounted at boot time. Required."),
}
COMMON_PROPERTIES = REQUIRED_PROPERTIES
EM_SEMAPHORE = 'xcat_pxe'
def _check_for_missing_params(info_dict, param_prefix=''):
missing_info = []
for label, value in info_dict.items():
if not value:
missing_info.append(param_prefix + label)
if missing_info:
raise exception.InvalidParameterValue(_(
"Can not validate PXE bootloader. The following parameters "
"were not passed to ironic: %s") % missing_info)
def _parse_driver_info(node):
"""Gets the driver specific Node deployment info.
This method validates whether the 'driver_info' property of the
supplied node contains the required information for this driver to
deploy images to the node.
:param node: a single Node.
:returns: A dict with the driver_info values.
"""
info = node.driver_info
d_info = {}
d_info['xcat_node'] = info.get('xcat_node')
return d_info
def _parse_instance_info(node):
"""Gets the instance specific Node deployment info.
This method validates whether the 'instance_info' property of the
supplied node contains the required information for this driver to
deploy images to the node.
:param node: a single Node.
:returns: A dict with the instance_info values.
"""
info = node.instance_info
i_info = {}
i_info['image_source'] = info.get('image_source')
i_info['root_gb'] = info.get('root_gb')
i_info['image_file'] = i_info['image_source']
_check_for_missing_params(i_info)
# Internal use only
i_info['deploy_key'] = info.get('deploy_key')
i_info['swap_mb'] = info.get('swap_mb', 0)
i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0)
i_info['ephemeral_format'] = info.get('ephemeral_format')
err_msg_invalid = _("Can not validate PXE bootloader. Invalid parameter "
"%(param)s. Reason: %(reason)s")
for param in ('root_gb', 'swap_mb', 'ephemeral_gb'):
try:
int(i_info[param])
except ValueError:
reason = _("'%s' is not an integer value.") % i_info[param]
raise exception.InvalidParameterValue(err_msg_invalid %
{'param': param, 'reason': reason})
if i_info['ephemeral_gb'] and not i_info['ephemeral_format']:
i_info['ephemeral_format'] = CONF.pxe.default_ephemeral_format
preserve_ephemeral = info.get('preserve_ephemeral', False)
try:
i_info['preserve_ephemeral'] = strutils.bool_from_string(
preserve_ephemeral, strict=True)
except ValueError as e:
raise exception.InvalidParameterValue(err_msg_invalid %
{'param': 'preserve_ephemeral', 'reason': e})
return i_info
def _parse_deploy_info(node):
"""Gets the instance and driver specific Node deployment info.
This method validates whether the 'instance_info' and 'driver_info'
property of the supplied node contains the required information for
this driver to deploy images to the node.
:param node: a single Node.
:returns: A dict with the instance_info and driver_info values.
"""
info = {}
info.update(_parse_instance_info(node))
info.update(_parse_driver_info(node))
return info
def _validate_glance_image(ctx, deploy_info):
"""Validate the image in Glance.
Check if the image exist in Glance and if it contains the
'kernel_id' and 'ramdisk_id' properties.
:raises: InvalidParameterValue.
"""
image_id = deploy_info['image_source']
if not image_id:
raise exception.ImageNotFound
class PXEDeploy(base.DeployInterface):
"""PXE Deploy Interface: just a stub until the real driver is ported."""
def get_properties(self):
return COMMON_PROPERTIES
def validate(self, task):
"""Validate the deployment information for the task's node.
:param task: a TaskManager instance containing the node to act on.
:raises: InvalidParameterValue.
"""
node = task.node
if not driver_utils.get_node_mac_addresses(task):
raise exception.InvalidParameterValue(_("Node %s does not have "
"any port associated with it.") % node.uuid)
d_info = _parse_deploy_info(node)
# Try to get the URL of the Ironic API
try:
# TODO(lucasagomes): Validate the format of the URL
CONF.conductor.api_url or keystone.get_service_url()
except (exception.CatalogFailure,
exception.CatalogNotFound,
exception.CatalogUnauthorized):
raise exception.InvalidParameterValue(_(
"Couldn't get the URL of the Ironic API service from the "
"configuration file or keystone catalog."))
_validate_glance_image(task.context, d_info)
@task_manager.require_exclusive_lock
def deploy(self, task):
"""Start deployment of the task's node'.
Config host file and xcat dhcp, generate image info for xcat
and issues a reboot request to the power driver.
This causes the node to boot into the deployment ramdisk and triggers
the next phase of PXE-based deployment via
VendorPassthru._continue_deploy().
:param task: a TaskManager instance containing the node to act on.
:returns: deploy state DEPLOYDONE.
"""
d_info = _parse_deploy_info(task.node)
if not task.node.instance_info.get('fixed_ip_address') or not task.node.instance_info.get('image_name'):
raise exception.InvalidParameterValue
self._config_host_file(d_info,task.node.instance_info.get('fixed_ip_address'))
self._make_dhcp()
self._nodeset_osimage(d_info,task.node.instance_info.get('image_name'))
manager_utils.node_set_boot_device(task, 'pxe', persistent=True)
manager_utils.node_power_action(task, states.REBOOT)
try:
self._wait_for_node_deploy(task)
except xcat_exception.xCATDeploymentFailure:
LOG.info(_("xcat deployment failed"))
return states.ERROR
return states.DEPLOYDONE
@task_manager.require_exclusive_lock
def tear_down(self, task):
"""Tear down a previous deployment on the task's node.
Power off the node. All actual clean-up is done in the clean_up()
method which should be called separately.
:param task: a TaskManager instance containing the node to act on.
:returns: deploy state DELETED.
"""
manager_utils.node_power_action(task, states.POWER_OFF)
return states.DELETED
def prepare(self, task):
"""Prepare the deployment environment for this task's node.
Get the image info from glance, config the mac for the xcat
use ssh and iptables to disable dhcp on network node
:param task: a TaskManager instance containing the node to act on.
"""
# TODO(deva): optimize this if rerun on existing files
d_info = _parse_deploy_info(task.node)
i_info = task.node.instance_info
image_id = d_info['image_source']
try:
glance_service = service.Service(version=1, context=task.context)
image_name = glance_service.show(image_id)['name']
i_info['image_name'] = image_name
except (exception.GlanceConnectionFailed,
exception.ImageNotAuthorized,
exception.Invalid):
LOG.warning(_("Failed to connect to Glance to get the properties "
"of the image %s") % image_id)
node_mac_addresses = driver_utils.get_node_mac_addresses(task)
vif_ports_info = xcat_neutron.get_ports_info_from_neutron(task)
try:
network_info = self._get_deploy_network_info(vif_ports_info, node_mac_addresses)
except (xcat_exception.GetNetworkFixedIPFailure,xcat_exception.GetNetworkIdFailure):
LOG.error(_("Failed to get network info"))
return
if not network_info:
LOG.error(_("Failed to get network info"))
return
fixed_ip_address = network_info['fixed_ip_address']
deploy_mac_address = network_info['mac_address']
network_id = network_info['network_id']
i_info['fixed_ip_address'] = fixed_ip_address
i_info['network_id'] = network_id
i_info['deploy_mac_address'] = deploy_mac_address
# use iptables to drop the dhcp mac of baremetal machine
self._ssh_append_dhcp_rule(CONF.xcat.network_node_ip,CONF.xcat.ssh_port,CONF.xcat.ssh_user,
CONF.xcat.ssh_password,network_id,deploy_mac_address)
self._chdef_node_mac_address(d_info,deploy_mac_address)
def clean_up(self, task):
"""Clean up the deployment environment for the task's node.
Unlinks TFTP and instance images and triggers image cache cleanup.
Removes the TFTP configuration files for this node. As a precaution,
this method also ensures the keystone auth token file was removed.
:param task: a TaskManager instance containing the node to act on.
"""
pass
def take_over(self, task):
pass
def _get_deploy_network_info(self, vif_ports_info, valid_node_mac_addrsses):
"""Get network info from mac address of ironic node.
:param vif_ports_info: info collection from neutron ports
:param valid_node_mac_addrsses: mac address from ironic node
:raises: GetNetworkFixedIpFailure if search the fixed ip from mac address failure
:raises: GetNetworkIdFailure if search the network id from mac address failure
"""
network_info = {}
for port_info in vif_ports_info.values():
if(port_info['port']['mac_address'] in valid_node_mac_addrsses ):
network_info['fixed_ip_address'] = port_info['port']['fixed_ips'][0]['ip_address']
if not network_info['fixed_ip_address']:
raise xcat_exception.GetNetworkFixedIPFailure(mac_address=port_info['port']['mac_address'])
network_info['mac_address'] = port_info['port']['mac_address']
network_info['network_id'] = port_info['port']['network_id']
if not network_info['network_id']:
raise xcat_exception.GetNetworkIdFailure(mac_address=port_info['port']['mac_address'])
network_info['port_id'] = port_info['port']['id']
return network_info
return network_info
def _chdef_node_mac_address(self, driver_info, deploy_mac):
""" run chdef command to set mac address"""
cmd = 'chdef'
args = 'mac='+ deploy_mac
try:
out_err = xcat_util.exec_xcatcmd(driver_info, cmd, args)
LOG.info(_("xcat chdef cmd exetute output: %(out_err)s") % {'out_err':out_err})
except xcat_exception.xCATCmdFailure as e:
LOG.warning(_("xcat chdef failed for node %(xcat_node)s with "
"error: %(error)s.")
% {'xcat_node': driver_info['xcat_node'], 'error': e})
raise exception.IPMIFailure(cmd=cmd)
@lockutils.synchronized(EM_SEMAPHORE, 'xcat-hosts-')
def _config_host_file(self, driver_info, deploy_ip):
""" append node and ip infomation to host file"""
with open(CONF.xcat.host_filepath,"r+") as f:
lines = []
for line in f:
temp = line.split('#')
if temp[0].strip():
host_name = xcat_util._tsplit(temp[0].strip(),(' ','\t'))[1]
if driver_info['xcat_node'] not in host_name:
lines.append(line)
# append a new line to host file
line = "%s\t%s\n" %(deploy_ip,driver_info['xcat_node'])
lines.append(line)
f.seek(0)
f.truncate()
for line in lines:
f.write(line)
def _nodeset_osimage(self, driver_info, image_name):
"""run nodeset command to config the image for the xcat node
:param driver_info: xcat node deploy info
:param image_name: image for the xcat deployment
"""
cmd = 'nodeset'
args = 'osimage='+ image_name
try:
xcat_util.exec_xcatcmd(driver_info, cmd, args)
except xcat_exception.xCATCmdFailure as e:
LOG.warning(_("xcat nodeset failed for node %(xcat_node)s with "
"error: %(error)s.")
% {'xcat_node': driver_info['xcat_node'], 'error': e})
def _make_dhcp(self):
"""run makedhcp command to setup dhcp environment for the xcat node"""
cmd = ['makedhcp',
'-n'
]
try:
out, err = utils.execute(*cmd)
LOG.info(_(" excute cmd: %(cmd)s \n output: %(out)s \n. Error: %(err)s \n"),
{'cmd':cmd,'out': out, 'err': err})
except Exception as e:
LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
{'cmd': cmd, 'exception': e})
# makedhcp -a
cmd = ['makedhcp',
'-a'
]
try:
out, err = utils.execute(*cmd)
LOG.info(_(" excute cmd: %(cmd)s \n output: %(out)s \n. Error: %(err)s \n"),
{'cmd':cmd,'out': out, 'err': err})
except Exception as e:
LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
{'cmd': cmd, 'exception': e})
def _ssh_append_dhcp_rule(self,ip,port,username,password,network_id,mac_address):
""" drop the dhcp package in network node to avoid of confilct of dhcp """
netns = 'qdhcp-%s' %network_id
append_cmd = 'sudo ip netns exec %s iptables -A INPUT -m mac --mac-source %s -j DROP' % \
(netns,mac_address)
cmd = [append_cmd]
xcat_util.xcat_ssh(ip,port,username,password,cmd)
def _ssh_delete_dhcp_rule(self,ip,port,username,password,network_id,mac_address):
""" delete the iptable rule on network node to recover the environment"""
netns = 'qdhcp-%s' %network_id
cancel_cmd = 'sudo ip netns exec %s iptables -D INPUT -m mac --mac-source %s -j DROP' % \
(netns,mac_address)
cmd = [cancel_cmd]
xcat_util.xcat_ssh(ip,port,username,password,cmd)
def _wait_for_node_deploy(self, task):
"""Wait for xCAT node deployment to complete."""
locals = {'errstr':''}
driver_info = _parse_deploy_info(task.node)
node_mac_addrsses = driver_utils.get_node_mac_addresses(task)
i_info = task.node.instance_info
def _wait_for_deploy():
out,err = xcat_util.exec_xcatcmd(driver_info,'nodels','nodelist.status')
if err:
locals['errstr'] = _("Error returned when quering node status"
" for node %s:%s") % (driver_info['xcat_node'], err)
LOG.warning(locals['errstr'])
raise loopingcall.LoopingCallDone()
if out:
node,status = out.split(": ")
status = status.strip()
if status == "booted":
LOG.info(_("Deployment for node %s completed.")
% driver_info['xcat_node'])
raise loopingcall.LoopingCallDone()
if (CONF.xcat.deploy_timeout and
timeutils.utcnow() > expiration):
locals['errstr'] = _("Timeout while waiting for"
" deployment of node %s.") % driver_info['xcat_node']
LOG.warning(locals['errstr'])
raise loopingcall.LoopingCallDone()
expiration = timeutils.utcnow() + datetime.timedelta(
seconds=CONF.xcat.deploy_timeout)
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_deploy)
# default check every 10 seconds
timer.start(interval=CONF.xcat.deploy_checking_interval).wait()
if locals['errstr']:
raise xcat_exception.xCATDeploymentFailure(locals['errstr'])
# deploy end, delete the dhcp rule for xcat
self._ssh_delete_dhcp_rule(CONF.xcat.network_node_ip,CONF.xcat.ssh_port,CONF.xcat.ssh_user,
CONF.xcat.ssh_password,i_info['network_id'],node_mac_addrsses[0])

View File

@ -1,444 +0,0 @@
"""
IPMI power manager driver.
"""
import contextlib
import os
import stat
import tempfile
import time
from oslo.config import cfg
from ironic.common import exception
from ironic.common import states
from ironic.common import utils
from ironic.conductor import task_manager
from ironic.drivers import base
from ironic.drivers.modules import console_utils
from ironic.openstack.common import excutils
from ironic.openstack.common import log as logging
from ironic.openstack.common import loopingcall
from ironic.openstack.common import processutils
from ironic.drivers.modules import xcat_exception
from ironic.drivers.modules import xcat_util
CONF = cfg.CONF
CONF.import_opt('retry_timeout',
'ironic.drivers.modules.ipminative',
group='ipmi')
CONF.import_opt('min_command_interval',
'ironic.drivers.modules.ipminative',
group='ipmi')
LOG = logging.getLogger(__name__)
VALID_PRIV_LEVELS = ['ADMINISTRATOR', 'CALLBACK', 'OPERATOR', 'USER']
REQUIRED_PROPERTIES = {
'ipmi_address': _("IP address or hostname of the node. Required.")
}
OPTIONAL_PROPERTIES = {
'ipmi_password': _("password. Optional."),
'ipmi_priv_level': _("privilege level; default is ADMINISTRATOR. One of "
"%s. Optional.") % ', '.join(VALID_PRIV_LEVELS),
'ipmi_username': _("username; default is NULL user. Optional.")
}
COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy()
COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES)
CONSOLE_PROPERTIES = {
'ipmi_terminal_port': _("node's UDP port to connect to. Only required for "
"console access.")
}
TIMING_SUPPORT = None
def _is_timing_supported(is_supported=None):
# shim to allow module variable to be mocked in unit tests
global TIMING_SUPPORT
if (TIMING_SUPPORT is None) and (is_supported is not None):
TIMING_SUPPORT = is_supported
return TIMING_SUPPORT
def check_timing_support():
"""Check the installed version of ipmitool for -N -R option support.
Support was added in 1.8.12 for the -N -R options, which enable
more precise control over timing of ipmi packets. Prior to this,
the default behavior was to retry each command up to 18 times at
1 to 5 second intervals.
http://ipmitool.cvs.sourceforge.net/viewvc/ipmitool/ipmitool/ChangeLog?revision=1.37 # noqa
This method updates the module-level TIMING_SUPPORT variable so that
it is accessible by any driver interface class in this module. It is
intended to be called from the __init__ method of such classes only.
:returns: boolean indicating whether support for -N -R is present
:raises: OSError
"""
if _is_timing_supported() is None:
# Directly check ipmitool for support of -N and -R options. Because
# of the way ipmitool processes' command line options, if the local
# ipmitool does not support setting the timing options, the command
# below will fail.
try:
out, err = utils.execute(*['ipmitool', '-N', '0', '-R', '0', '-h'])
except processutils.ProcessExecutionError:
# the local ipmitool does not support the -N and -R options.
_is_timing_supported(False)
else:
# looks like ipmitool supports timing options.
_is_timing_supported(True)
def _console_pwfile_path(uuid):
"""Return the file path for storing the ipmi password for a console."""
file_name = "%(uuid)s.pw" % {'uuid': uuid}
return os.path.join(tempfile.gettempdir(), file_name)
def _parse_driver_info(node):
"""Gets the parameters required for ipmitool to access the node.
:param node: the Node of interest.
:returns: dictionary of parameters.
:raises: InvalidParameterValue if any required parameters are missing.
"""
info = node.driver_info or {}
address = info.get('ipmi_address')
username = info.get('ipmi_username')
password = info.get('ipmi_password')
port = info.get('ipmi_terminal_port')
priv_level = info.get('ipmi_priv_level', 'ADMINISTRATOR')
xcat_node = info.get('xcat_node')
xcatmaster = info.get('xcatmaster')
netboot = info.get('netboot')
if port:
try:
port = int(port)
except ValueError:
raise exception.InvalidParameterValue(_(
"IPMI terminal port is not an integer."))
if not address:
raise exception.InvalidParameterValue(_(
"IPMI address not supplied to xcat driver."))
if priv_level not in VALID_PRIV_LEVELS:
valid_priv_lvls = ', '.join(VALID_PRIV_LEVELS)
raise exception.InvalidParameterValue(_(
"Invalid privilege level value:%(priv_level)s, the valid value"
" can be one of %(valid_levels)s") %
{'priv_level': priv_level, 'valid_levels': valid_priv_lvls})
if not xcat_node:
raise exception.InvalidParameterValue(_(
"xcat node name not supplied to xcat driver"))
if not xcatmaster:
raise exception.InvalidParameterValue(_(
"xcatmaster not supplied to xcat driver"))
if not netboot:
raise exception.InvalidParameterValue(_(
"netboot not supplied to xcat driver"))
return {
'address': address,
'username': username,
'password': password,
'port': port,
'uuid': node.uuid,
'priv_level': priv_level,
'xcat_node': xcat_node,
'xcatmaster': xcatmaster,
'netboot': netboot
}
def chdef_node(driver_info):
"""Run the chdef command in xcat, config the node
:param driver_info: driver_info for the xcat node
"""
cmd = 'chdef'
args = 'mgt=ipmi' + \
' bmc=' + driver_info['address'] + \
' bmcusername=' + driver_info['username'] + \
' bmcpassword=' + driver_info['password'] + \
' xcatmaster=' + driver_info['xcatmaster']+ \
' netboot=' + driver_info['netboot']+ \
' primarynic=mac'+ \
' installnic=mac'+ \
' monserver=' + driver_info['xcatmaster'] + \
' nfsserver=' + driver_info['xcatmaster'] + \
' serialflow=hard'+ \
' serialspeed=115200' + \
' serialport=' + str(driver_info['port']);
try:
xcat_util.exec_xcatcmd(driver_info, cmd, args)
except xcat_exception.xCATCmdFailure as e:
LOG.warning(_("xcat chdef failed for node %(node_id)s with "
"error: %(error)s.")
% {'node_id': driver_info['uuid'], 'error': e})
def _sleep_time(iter):
"""Return the time-to-sleep for the n'th iteration of a retry loop.
This implementation increases exponentially.
:param iter: iteration number
:returns: number of seconds to sleep
"""
if iter <= 1:
return 1
return iter ** 2
def _set_and_wait(target_state, driver_info):
"""Helper function for DynamicLoopingCall.
This method changes the power state and polls the BMCuntil the desired
power state is reached, or CONF.ipmi.retry_timeout would be exceeded by the
next iteration.
This method assumes the caller knows the current power state and does not
check it prior to changing the power state. Most BMCs should be fine, but
if a driver is concerned, the state should be checked prior to calling this
method.
:param target_state: desired power state
:param driver_info: the ipmitool parameters for accessing a node.
:returns: one of ironic.common.states
:raises: IPMIFailure on an error from ipmitool (from _power_status call).
"""
if target_state == states.POWER_ON:
state_name = "on"
elif target_state == states.POWER_OFF:
state_name = "off"
def _wait(mutable):
try:
# Only issue power change command once
if mutable['iter'] < 0:
xcat_util.exec_xcatcmd(driver_info,'rpower',state_name)
else:
mutable['power'] = _power_status(driver_info)
except Exception:
# Log failures but keep trying
LOG.warning(_("xcat rpower %(state)s failed for node %(node)s."),
{'state': state_name, 'node': driver_info['uuid']})
finally:
mutable['iter'] += 1
if mutable['power'] == target_state:
raise loopingcall.LoopingCallDone()
sleep_time = _sleep_time(mutable['iter'])
if (sleep_time + mutable['total_time']) > CONF.ipmi.retry_timeout:
# Stop if the next loop would exceed maximum retry_timeout
LOG.error(_('xcat rpower %(state)s timed out after '
'%(tries)s retries on node %(node_id)s.'),
{'state': state_name, 'tries': mutable['iter'],
'node_id': driver_info['uuid']})
mutable['power'] = states.ERROR
raise loopingcall.LoopingCallDone()
else:
mutable['total_time'] += sleep_time
return sleep_time
# Use mutable objects so the looped method can change them.
# Start 'iter' from -1 so that the first two checks are one second apart.
status = {'power': None, 'iter': -1, 'total_time': 0}
timer = loopingcall.DynamicLoopingCall(_wait, status)
timer.start().wait()
return status['power']
def _power_on(driver_info):
"""Turn the power ON for this node.
:param driver_info: the xcat parameters for accessing a node.
:returns: one of ironic.common.states POWER_ON or ERROR.
:raises: IPMIFailure on an error from ipmitool (from _power_status call).
"""
return _set_and_wait(states.POWER_ON, driver_info)
def _power_off(driver_info):
"""Turn the power OFF for this node.
:param driver_info: the xcat parameters for accessing a node.
:returns: one of ironic.common.states POWER_OFF or ERROR.
:raises: IPMIFailure on an error from ipmitool (from _power_status call).
"""
return _set_and_wait(states.POWER_OFF, driver_info)
def _power_status(driver_info):
"""Get the power status for a node.
:param driver_info: the xcat access parameters for a node.
:returns: one of ironic.common.states POWER_OFF, POWER_ON or ERROR.
:raises: IPMIFailure on an error from ipmitool.
"""
cmd = "rpower"
try:
out_err = xcat_util.exec_xcatcmd(driver_info,cmd,'status')
except Exception as e:
LOG.warning(_("xcat rpower status failed for node %(node_id)s with "
"error: %(error)s.")
% {'node_id': driver_info['uuid'], 'error': e})
if out_err[0].split(' ')[1].strip() == "on":
return states.POWER_ON
elif out_err[0].split(' ')[1].strip() == "off":
return states.POWER_OFF
else:
return states.ERROR
class XcatPower(base.PowerInterface):
def __init__(self):
try:
check_timing_support()
except OSError:
raise exception.DriverLoadError(
driver=self.__class__.__name__,
reason="Unable to locate usable xcat command in "
"the system path when checking xcat version")
def get_properties(self):
return COMMON_PROPERTIES
def validate(self, task):
"""Validate driver_info for xcat driver.
Check that node['driver_info'] contains IPMI credentials.
:param task: a TaskManager instance containing the node to act on.
:raises: InvalidParameterValue if required ipmi parameters are missing.
"""
driver_info = _parse_driver_info(task.node)
try:
chdef_node(driver_info)
except exception:
LOG.error(_("chdef xcat info error!"))
def get_power_state(self, task):
"""Get the current power state of the task's node.
:param task: a TaskManager instance containing the node to act on.
:returns: one of ironic.common.states POWER_OFF, POWER_ON or ERROR.
"""
driver_info = _parse_driver_info(task.node)
return _power_status(driver_info)
@task_manager.require_exclusive_lock
def set_power_state(self, task, pstate):
"""Turn the power on or off.
:param task: a TaskManager instance containing the node to act on.
:param pstate: The desired power state, one of ironic.common.states
POWER_ON, POWER_OFF.
:raises: InvalidParameterValue if required ipmi parameters are missing
or if an invalid power state was specified.
:raises: PowerStateFailure if the power couldn't be set to pstate.
"""
driver_info = _parse_driver_info(task.node)
if pstate == states.POWER_ON:
state = _power_on(driver_info)
elif pstate == states.POWER_OFF:
state = _power_off(driver_info)
else:
raise exception.InvalidParameterValue(_("set_power_state called "
"with invalid power state %s.") % pstate)
if state != pstate:
raise exception.PowerStateFailure(pstate=pstate)
@task_manager.require_exclusive_lock
def reboot(self, task):
"""Cycles the power to the task's node.
:param task: a TaskManager instance containing the node to act on.
:raises: InvalidParameterValue if required ipmi parameters are missing.
:raises: PowerStateFailure if the final state of the node is not
POWER_ON.
"""
driver_info = _parse_driver_info(task.node)
_power_off(driver_info)
state = _power_on(driver_info)
if state != states.POWER_ON:
raise exception.PowerStateFailure(pstate=states.POWER_ON)
class IPMIShellinaboxConsole(base.ConsoleInterface):
"""A ConsoleInterface that uses ipmitool and shellinabox."""
def __init__(self):
try:
check_timing_support()
except OSError:
raise exception.DriverLoadError(
driver=self.__class__.__name__,
reason="Unable to locate usable xcat command in "
"the system path when checking xcat version")
def get_properties(self):
return COMMON_PROPERTIES
def validate(self, task):
"""Validate the Node console info.
:param task: a task from TaskManager.
:raises: InvalidParameterValue
"""
driver_info = _parse_driver_info(task.node)
if not driver_info['xcat_node']:
raise exception.InvalidParameterValue(_(
"xcat node name not supplied to xcat baremetal driver."))
if not driver_info['port']:
raise exception.InvalidParameterValue(_(
"IPMI terminal port not supplied to IPMI driver."))
def start_console(self, task):
"""Start a remote console for the node."""
driver_info = _parse_driver_info(task.node)
path = _console_pwfile_path(driver_info['uuid'])
pw_file = console_utils.make_persistent_password_file(
path, driver_info['password'])
ipmi_cmd = "/:%(uid)s:%(gid)s:HOME:ipmitool -H %(address)s" \
" -I lanplus -U %(user)s -f %(pwfile)s" \
% {'uid': os.getuid(),
'gid': os.getgid(),
'address': driver_info['address'],
'user': driver_info['username'],
'pwfile': pw_file}
if CONF.debug:
ipmi_cmd += " -v"
ipmi_cmd += " sol activate"
console_utils.start_shellinabox_console(driver_info['uuid'],
driver_info['port'],
ipmi_cmd)
def stop_console(self, task):
"""Stop the remote console session for the node."""
driver_info = _parse_driver_info(task.node)
console_utils.stop_shellinabox_console(driver_info['uuid'])
utils.unlink_without_raise(_console_pwfile_path(driver_info['uuid']))
def get_console(self, task):
"""Get the type and connection information about the console."""
driver_info = _parse_driver_info(task.node)
url = console_utils.get_shellinabox_console_url(driver_info['port'])
return {'type': 'shellinabox', 'url': url}

View File

@ -1,110 +0,0 @@
"""
util for xcat baremetal driver
exec_xcatcmd
xcat_ssh to excute remote cmd
"""
import paramiko
import time
import socket
from ironic.openstack.common import log as logging
from oslo.config import cfg
from ironic.drivers.modules import xcat_exception
from ironic.common import utils
xcat_opts = [
cfg.IntOpt('ssh_session_timeout',
default=10,
help='ssh session time'),
cfg.FloatOpt('ssh_shell_wait',
default=0.5,
help='wait time for the ssh cmd excute'),
cfg.IntOpt('ssh_buf_size',
default=65535,
help='Maximum size (in charactor) of cache for ssh, '
'including those in use'),
cfg.StrOpt('ssh_key',
default=None,
help='ssh private key to login '),
cfg.StrOpt('ssh_key_pass',
default=None,
help='Maximum size (in charactor) of cache for ssh, '
'including those in use'),
]
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF.register_opts(xcat_opts, group='xcat')
LAST_CMD_TIME = {}
def xcat_ssh(ip,port,username,password,cmd):
""" exec remote command with ssh """
key =None
if CONF.xcat.ssh_key:
try:
key=paramiko.RSAKey.from_private_key_file(CONF.xcat.ssh_key)
except paramiko.PasswordRequiredException:
if not CONF.ssh_key_pass:
raise Exception.message("no pubkey password")
key = paramiko.RSAKey.from_private_key_file(
CONF.xcat.ssh_key, CONF.xcat.ssh_key.ssh_key_pass)
s = paramiko.SSHClient()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
s.connect(ip,port,username=username,password=password,pkey=key,
timeout=CONF.xcat.ssh_session_timeout)
except socket.timeout as e:
LOG.error(_("Unable to connect to the ssh server Exception: %(exception)s"),
{'exception': e})
chan = s.invoke_shell()
output = chan.recv(CONF.xcat.ssh_buf_size)
while not output.rstrip().endswith('#') and not output.rstrip().endswith('$'):
output = chan.recv(CONF.xcat.ssh_buf_size)
for c in cmd :
_xcat_ssh_exec(chan,c,password)
def _xcat_ssh_exec(chan,cmd,password):
""" exec ssh command """
chan.send(cmd + '\n')
time.sleep(CONF.xcat.ssh_shell_wait)
ret = chan.recv(CONF.xcat.ssh_buf_size)
if 'password' in ret and ret.rstrip().endswith(':'):
chan.send(password + '\n')
output = chan.recv(CONF.xcat.ssh_buf_size)
while not output.rstrip().endswith('#') and not output.rstrip().endswith('$'):
output = chan.recv(CONF.xcat.ssh_buf_size)
return output
def _tsplit(string, delimiters):
""" Behaves str.split but supports multiple delimiters. """
delimiters = tuple(delimiters)
stack = [string,]
for delimiter in delimiters:
for i, substring in enumerate(stack):
substack = substring.split(delimiter)
stack.pop(i)
for j, _substring in enumerate(substack):
stack.insert(i+j, _substring)
return stack
def exec_xcatcmd(driver_info, command, args):
""" excute xcat cmd """
cmd = [command,
driver_info['xcat_node']
]
cmd.extend(args.split(" "))
# NOTE: ensure that no communications are excuted more
# often than once every min_command_interval seconds.
time_till_next_poll = CONF.ipmi.min_command_interval - (
time.time() - LAST_CMD_TIME.get(driver_info['xcat_node'], 0))
if time_till_next_poll > 0:
time.sleep(time_till_next_poll)
try:
out, err = utils.execute(*cmd)
if err:
raise xcat_exception.xCATCmdFailure(cmd=cmd,node=driver_info['xcat_node'],
args=args)
finally:
LAST_CMD_TIME[driver_info['xcat_node']] = time.time()
return out, err

View File

@ -1,27 +0,0 @@
"""
XCATBaremetalDriver
use xcat to deploy a baremetal machine
"""
from ironic.drivers import base
from ironic.drivers.modules import ipmitool
from ironic.drivers.modules import pxe
from ironic.drivers.modules import xcat_pxe
from ironic.drivers import utils
from ironic.drivers.modules import xcat_rpower
class XCATBaremetalDriver(base.BaseDriver):
"""xCAT driver
This driver implements the `core` functionality, combinding
:class:`ironic.drivers.xcat_rpower.XcatPower` for power on/off and reboot with
:class:`ironic.driver.xcat_pxe.PXEDeploy` for image deployment. Implementations are in
those respective classes; this class is merely the glue between them.
"""
def __init__(self):
self.power = xcat_rpower.XcatPower()
self.console = ipmitool.IPMIShellinaboxConsole()
self.deploy = xcat_pxe.PXEDeploy()
self.management = ipmitool.IPMIManagement()
self.vendor = pxe.VendorPassthru()

View File

@ -1,33 +0,0 @@
[DEFAULT]
# The list of modules to copy from oslo-incubator
module=cliutils
module=config.generator
module=context
module=db
module=db.sqlalchemy
module=db.sqlalchemy.migration_cli
module=eventlet_backdoor
module=excutils
module=fileutils
module=gettextutils
module=importutils
module=jsonutils
module=local
module=lockutils
module=log
module=loopingcall
module=network_utils
module=periodic_task
module=policy
module=processutils
module=service
module=strutils
module=timeutils
module=versionutils
# Tools
# The base module to hold the copy of openstack.common
base=ironic

View File

@ -1,51 +0,0 @@
[metadata]
name = ironic
version = 2014.2
summary = OpenStack Bare Metal Provisioning
description-file =
README.rst
author = chenglch
author-email = chenglch@cn.ibm.com
home-page = http://xcat.sf.net/
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 2.6
[files]
packages =
ironic
[entry_points]
ironic.drivers =
agent_ipmitool = ironic.drivers.agent:AgentAndIPMIToolDriver
agent_pyghmi = ironic.drivers.agent:AgentAndIPMINativeDriver
agent_ssh = ironic.drivers.agent:AgentAndSSHDriver
fake = ironic.drivers.fake:FakeDriver
fake_agent = ironic.drivers.fake:FakeAgentDriver
fake_iboot = ironic.drivers.fake:FakeIBootDriver
fake_ipminative = ironic.drivers.fake:FakeIPMINativeDriver
fake_ipmitool = ironic.drivers.fake:FakeIPMIToolDriver
fake_pxe = ironic.drivers.fake:FakePXEDriver
fake_seamicro = ironic.drivers.fake:FakeSeaMicroDriver
fake_ssh = ironic.drivers.fake:FakeSSHDriver
ilo = ironic.drivers.ilo:IloDriver
pxe_iboot = ironic.drivers.pxe:PXEAndIBootDriver
pxe_ipminative = ironic.drivers.pxe:PXEAndIPMINativeDriver
pxe_ipmitool = ironic.drivers.pxe:PXEAndIPMIToolDriver
pxe_seamicro = ironic.drivers.pxe:PXEAndSeaMicroDriver
pxe_ssh = ironic.drivers.pxe:PXEAndSSHDriver
pxe_xcat = ironic.drivers.xcat:XCATBaremetalDriver
[pbr]
autodoc_index_modules = True
[global]
setup-hooks =
pbr.hooks.setup_hook

View File

@ -1,30 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools
# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
setuptools.setup(
setup_requires=['pbr'],
pbr=True)

View File

@ -1,22 +0,0 @@
hacking>=0.8.0,<0.9
coverage>=3.6
discover
fixtures>=0.3.14
mock>=1.0
Babel>=1.3
MySQL-python
psycopg2
python-ironicclient
python-subunit>=0.0.18
testrepository>=0.0.18
testtools>=0.9.34
# Doc requirements
sphinx>=1.1.2,!=1.2.0,<1.3
sphinxcontrib-pecanwsme>=0.8
oslosphinx
# Required for Nova unit tests in ironic/nova/tests/ and can be removed
# once the driver code lands in Nova.
http://tarballs.openstack.org/nova/nova-master.tar.gz#egg=nova
mox>=0.5.3

View File

@ -89,7 +89,7 @@ rm -rf $RPM_BUILD_ROOT
%ifos linux
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
if [ -f $RPM_INSTALL_PREFIX0/sbin/xcatd ]; then
/etc/init.d/xcatd restart
/etc/init.d/xcatd reload
fi
fi
%endif

View File

@ -38,9 +38,11 @@ if (scalar(@ARGV)>1) { $usage->(1); }
my $hnmatch = $ARGV[0]; # if they specified a hostname match, only show svrs that start with that
readconf("$ENV{HOME}/.slconfig"); # get the userid and api key from the config file
#my $api_username = 'SL276540';
#my $api_key = '799d5d9267a927a330ec016f00bfe17e6fc532d203cf68b3b0d997b2d27a3ce1';
my $slinstalled = eval { push @INC, $CONFIG{apidir}; require SoftLayer::API::SOAP; };
if (!$slinstalled) { die "$@\nError: either the SoftLayer::API::SOAP perl module is not installed, or some dependencies are missing. Download it using 'git clone https://github.com/softlayer/softlayer-api-perl-client', put the directory in ~/.slconfig , and ensure its dependencies are installed."; }
if (!$slinstalled) { die "Error: the SoftLayer::API::SOAP perl module is not installed. Download it using 'git clone https://github.com/softlayer/softlayer-api-perl-client' and put the directory in ~/.slconfig ."; }
my $client = SoftLayer::API::SOAP->new('SoftLayer_Account', undef, $CONFIG{userid}, $CONFIG{apikey});
@ -62,23 +64,12 @@ foreach my $server (@$servers) {
print "\tbmc=".$server->{remoteManagementComponent}->{ipmiIpAddress}."\n";
print "\tbmcusername=".$server->{remoteManagementAccounts}->[0]->{username}."\n";
print "\tbmcpassword=".$server->{remoteManagementAccounts}->[0]->{password}."\n";
# find the 1st active private nic that is not the bmc
foreach my $nic (@{$server->{backendNetworkComponents}}) {
#print "nic:\n"; foreach my $key (keys(%$nic)) { print " $key = ", $nic->{$key}, "\n"; }
if ($nic->{status} eq 'ACTIVE' && $nic->{name} eq 'eth' && $nic->{macAddress} && $nic->{primaryIpAddress}) {
# found it
print "\tmac=".$nic->{macAddress}."\n";
print "\tip=".$nic->{primaryIpAddress}."\n";
}
}
#print "\tip=".$server->{privateIpAddress}."\n"; # getting this from the backendNetworkComponents instead
print "\tserial=".$server->{manufacturerSerialNumber}."\n";
print "\tmac=".$server->{backendNetworkComponents}->[0]->{macAddress}."\n";
print "\tip=".$server->{privateIpAddress}."\n";
print "\tnetboot=xnba\n";
print "\tarch=x86_64\n";
print "\tusercomment=hostname:".$server->{fullyQualifiedDomainName}.", user:".$server->{operatingSystem}->{passwords}->[0]->{username}.", pw:".$server->{operatingSystem}->{passwords}->[0]->{password}."\n";
verbose('SoftLayer API bare metal server entry: ' . Dumper($server));
#print Dumper($server->{remoteManagementAccounts});
#print "#Softlayer_account_info_for ".$server->{fullyQualifiedDomainName} . " Username: ";
#print $server->{operatingSystem}->{passwords}->[0]->{username} . " Password: ";

View File

@ -1,111 +0,0 @@
#!/usr/bin/env python
"""
Usage: getslnodes.py [-h] [-v] [<hostname-match>]
Description:
Query your SoftLayer account and get attributes for each bare metal server.
The attributes can be piped to 'mkdef -z' to define the nodes into the xCAT
Database so that xCAT can manage them.
getslnodes requires a the .softlayer configuration file defined which can
be set by running "sl config setup" on the command line.
positional arguments:
hostname-match Select servers that include this partial hostname.
Optional:
-h, --help show this help message and exit
-v, --verbose display verbose output
"""
import sys
try:
import docopt
import pprint
import SoftLayer
except ImportError as e:
print 'Error: install missing python module before running this command: ' + str(e)
sys.exit(2)
def get_sl_servers():
# username, api_key, endpoint_url come from the .softlayer file
client = SoftLayer.Client()
mask = "hostname, fullyQualifiedDomainName, manufacturerSerialNumber, \
operatingSystem.id, operatingSystem.passwords.username, operatingSystem.passwords.password, \
remoteManagementAccounts.username, remoteManagementAccounts.password, remoteManagementComponent.ipmiIpAddress, \
primaryBackendNetworkComponent.primaryIpAddress, primaryBackendNetworkComponent.macAddress"
#
# If they specified hnmatch, it would be faster to have softlayer filter the response with something like:
# filter={'hardware': {'hostname': {'operation': '*= '+hostname}, 'domain': {'operation': '*= '+domain}}}
# But those 2 operations are ANDed together, so it will not work. And currently, filtering does not work on fullyQualifiedDomainName.
#
servers = client['Account'].getHardware(mask=mask)
return servers
def print_xcat_node_stanza(servers, hnmatch):
for server in servers:
if hnmatch and server['fullyQualifiedDomainName'].find(hnmatch) == -1:
continue
print "\n"+server['hostname']+":"
print "\tobjtype=node"
print "\tgroups=slnode,ipmi,all"
print "\tmgt=ipmi"
print "\tbmc="+server['remoteManagementComponent']['ipmiIpAddress']
# I have seen svrs with no remoteManagementAccounts entries
if len(server['remoteManagementAccounts']):
print "\tbmcusername="+server['remoteManagementAccounts'][0]['username']
print "\tbmcpassword="+server['remoteManagementAccounts'][0]['password']
print "\tip="+server['primaryBackendNetworkComponent']['primaryIpAddress']
print "\tmac="+server['primaryBackendNetworkComponent']['macAddress']
print "\tserial="+server['manufacturerSerialNumber']
print "\tnetboot=xnba"
print "\tarch=x86_64"
# Find the root or Administrator username and pw
username = None
password = None
for entry in server['operatingSystem']['passwords']:
if entry['username'] == 'root' or entry['username'] == 'Administrator':
# found it
username = entry['username']
password = entry['password']
break
elif not username:
# save the 1st entry, in case we never find root or Administrator
username = entry['username']
password = entry['password']
if username and password:
userStr = ", user:"+username+", pw:"+password
print "\tusercomment=hostname:"+server['fullyQualifiedDomainName']+userStr
if __name__ == '__main__':
try:
arguments = (docopt.docopt(__doc__, version="1.0"))
# print arguments
servers = get_sl_servers()
if arguments['--verbose']:
pprint.pprint(servers)
print_xcat_node_stanza(servers, arguments['<hostname-match>'])
except docopt.DocoptExit as e:
print e
except SoftLayer.exceptions.SoftLayerAPIError as e:
print e
sys.exit(1)

View File

@ -1,88 +0,0 @@
#!/usr/bin/perl
# remove entries from the .ssh/known_hosts file for a node
use strict;
use Getopt::Long;
use Data::Dumper;
#$Data::Dumper::Maxdepth=2;
# Globals - these are set once and then only read.
my $HELP;
my $VERBOSE;
my $file = '~/.ssh/known_hosts';
my $usage = sub {
my $exitcode = shift @_;
print "Usage: khrem <node>\n";
print " Removes the entries in the .ssh/known_hosts file associated with this node.\n";
exit $exitcode;
};
# Process the cmd line args
Getopt::Long::Configure("bundling");
#Getopt::Long::Configure("pass_through");
Getopt::Long::Configure("no_pass_through");
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE)) { $usage->(1); }
if ($HELP) { $usage->(0); }
if (scalar(@ARGV)!=1) { $usage->(1); }
my $node = $ARGV[0]; # if they specified a hostname match, only show svrs that start with that
my @output = runcmd("host $node");
my $hostname;
my $line = shift @output;
#print "line=$line\n";
if ($line =~ m/is an alias for /) {
($hostname) = $line =~ m/is an alias for ([^\.]+)/;
#print "hostname=$hostname\n";
$line = shift @output;
}
#print "line=$line\n";
my ($ip) = $line =~ m/has address (.+)$/;
if (defined($hostname)) {
print "Removing entries from $file for: $node, $hostname, $ip\n";
runcmd("sed -i '/^$node/d;/^$hostname/d;/^$ip/d' $file");
}
else {
print "Removing entries from $file for: $node, $ip\n";
runcmd("sed -i '/^$node/d;/^$ip/d' $file");
}
exit(0);
# Pring msg only if -v was specified
sub verbose { if ($VERBOSE) { print shift, "\n"; } }
# Run a command. If called in the context of return an array, it will capture the output
# of the cmd and return it. Otherwise, it will display the output to stdout.
# If the cmd has a non-zero rc, this function will die with a msg.
sub runcmd
{
my ($cmd) = @_;
my $rc;
$cmd .= ' 2>&1' ;
verbose($cmd);
my @output;
if (wantarray) {
@output = `$cmd`;
$rc = $?;
}
else {
system($cmd);
$rc = $?;
}
if ($rc) {
$rc = $rc >> 8;
if ($rc > 0) { die "Error: rc $rc return from cmd: $cmd\n"; }
else { die "Error: system error returned from cmd: $cmd\n"; }
}
elsif (wantarray) { return @output; }
}

View File

@ -12,43 +12,25 @@ use Socket;
# Globals - these are set once and then only read.
my $HELP;
my $VERBOSE;
my $DRYRUN;
my $WAITTIME;
my $PROVMETHOD;
my $XCATNETBOOTTITLE = 'xCAT network boot kernel and initrd';
my $usage = sub {
my $exitcode = shift @_;
print "Usage: modifygrub [-?|-h|--help] [-v|--verbose] [--dryrun] [-w <waittime>] [-p <provmethod] <kernel-path> <initrd-path> <kernel-parms> <mn-ip>\n\n";
print "Usage: modifygrub [-?|-h|--help] [-v|--verbose] [-w <waittime>] <kernel-path> <initrd-path> <kernel-parms> <mn-ip>\n\n";
if (!$exitcode) {
print "Modify the grub config file on the node to boot the specified kernel and initrd.\n";
}
exit $exitcode;
};
my $file = '/etc/os-release';
if (-f $file) {
#
# SLES and RHEL also have /etc/os-release file, so actually need to open the file
# and look for Ubuntu in the 'NAME=' lines before declaring Ubuntu
#
open my $info, $file or die "Could not open $file: $!";
while( my $line = <$info>) {
if (index($line, 'NAME=') != -1) {
if ($line =~ /Ubuntu/i) {
die "This script does not support Ubuntu at this time.\n";
}
}
}
close $info;
}
if (-f '/etc/os-release') { die "This script doesn't support ubuntu yet.\n"; }
# Process the cmd line args
Getopt::Long::Configure("bundling");
#Getopt::Long::Configure("pass_through");
Getopt::Long::Configure("no_pass_through");
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'dryrun' => \$DRYRUN, 'w|waittime=s' => \$WAITTIME, 'p|provmethod=s' => \$PROVMETHOD)) { $usage->(1); }
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME)) { $usage->(1); }
if ($HELP) { $usage->(0); }
if (scalar(@ARGV) != 4) { $usage->(1); }
@ -76,121 +58,41 @@ sub addKernelParms {
# replace <nodename> with the nodename
my $nodename = $ENV{NODE}; # this env var is set by xdsh
$args->{kernelparms} =~ s/<nodename>/$nodename/g;
# get node ip and add it to the kernel parms
my ($nic, $ip, $netmask, $network, $broadcast, $gateway, $mac) = getNodeIpInfo($args);
if (!$ip) { die "Error: could not find the NIC that would connect to the xCAT mgmt node's IP (".$args->{mnip}.").\n"; }
#if (defined($PROVMETHOD) && $PROVMETHOD eq 'sysclone') {
if ($args->{kernelpath} =~ m/genesis\.kernel\.x86_64/) {
# genesis case, add additional parms for sysclone or nodeset shell
my $bootif = $mac;
$bootif =~ s/:/-/g;
$bootif = "BOOTIF=01-$bootif";
# DEVICE=eth0 IPADDR=10.0.0.99 NETMASK=255.255.255.0 NETWORK=10.0.0.0 BROADCAST=10.0.0.255 GATEWAY=10.0.0.1 GATEWAYDEV=eth0
#todo: should we also add ETHER_SLEEP=$WAITTIME textmode=1 dns=$mnip ?
$args->{kernelparms} .= " $bootif IPADDR=$ip NETMASK=$netmask NETWORK=$network BROADCAST=$broadcast GATEWAY=$gateway HOSTNAME=$nodename DEVICE=$nic GATEWAYDEV=$nic";
}
else { # scripted install (kickstart or autoyast)
if ($args->{kernelparms} =~ m/autoyast=/) { # sles
# if site.managedaddressmode=static is set, it will put several of these kernel parms on there for us. Do not duplicate in that case.
if ($args->{kernelparms} !~ m/ hostip=/) { $args->{kernelparms} .= " hostip=$ip"; }
if ($args->{kernelparms} !~ m/ netmask=/) { $args->{kernelparms} .= " netmask=$netmask"; }
if ($args->{kernelparms} !~ m/ gateway=/) { $args->{kernelparms} .= " gateway=$gateway"; }
if ($args->{kernelparms} !~ m/ hostname=/) { $args->{kernelparms} .= " hostname=$nodename"; }
if ($args->{kernelparms} !~ m/ dns=/) { $args->{kernelparms} .= " dns=$mnip"; }
# If they set installnic=mac (recommended), the netdevice will already be set to the mac.
# If they explicitly set installnic=<nic>, then ksdevice will be set to that and we will not disturb it here.
# Otherwise add netdevice set to the nic we calculated it should be.
if ($args->{kernelparms} !~ m/ netdevice=/) { $args->{kernelparms} .= " netdevice=$nic"; }
$args->{kernelparms} .= " netwait=$WAITTIME textmode=1";
# print Dumper($args->{kernelparms})
}
elsif ($args->{kernelparms} =~ m/ks=/) { # rhel/centos
# See https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-kickstart2-startinginstall.html
# and http://fedoraproject.org/wiki/Anaconda/NetworkIssues for description of kickstart kernel parms
# if site.managedaddressmode=static is set, it will put several of these kernel parms on there for us. Do not duplicate in that case.
if ($args->{kernelparms} !~ m/ ip=/) { $args->{kernelparms} .= " ip=$ip"; }
if ($args->{kernelparms} !~ m/ netmask=/) { $args->{kernelparms} .= " netmask=$netmask"; }
if ($args->{kernelparms} !~ m/ gateway=/) { $args->{kernelparms} .= " gateway=$gateway"; }
if ($args->{kernelparms} !~ m/ hostname=/) { $args->{kernelparms} .= " hostname=$nodename"; }
if ($args->{kernelparms} !~ m/ dns=/) { $args->{kernelparms} .= " dns=$mnip"; }
# If they set installnic=mac (recommended), the ksdevice will already be set to the mac.
# If they explicitly set installnic=<nic>, then ksdevice will be set to that and we will not disturb it here.
# Otherwise ksdevice will be set to bootif, and we change it to the nic we calculated it should be.
if ($args->{kernelparms} =~ m/ ksdevice=bootif/) { $args->{kernelparms} =~ s/ ksdevice=bootif/ ksdevice=$nic/; }
elsif ($args->{kernelparms} !~ m/ ksdevice=/) { $args->{kernelparms} .= " ksdevice=$nic"; }
$args->{kernelparms} .= " nicdelay=$WAITTIME linksleep=$WAITTIME textmode=1";
# print Dumper($args->{kernelparms})
}
else { die "Error: for scripted installs, only support SLES or RHEL/CentOS as the target OS.\n"; }
}
# get node ip and add it to the kernel parms
my ($nic, $ip, $netmask, $gateway) = getNodeIpInfo($args);
if (!$ip) { die "Error: could not find the NIC that would connect to the xCAT mgmt node's IP (".$args->{mnip}.").\n"; }
$args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1";
}
# get this nodes nic, ip, netmask, gateway, and mac. Returns them in a 5 element array.
# get this nodes nic, ip, netmask, and gateway. Returns them in a 4 element array.
sub getNodeIpInfo {
my $args = shift @_;
my ($ipprefix) = $args->{mnip}=~m/^(\d+)\./; #todo: this is a hack, just using the 1st octet of the mn ip addr
my ($ipprefix) = $args->{mnip}=~m/^(\d+\.\d+)\./; #todo: this is a hack, just using the 1st 2 octets of the mn ip addr
verbose("using IP prefix $ipprefix");
# parse ip addr show output, looking for ipprefix, to determine nic, ip, mac
my @output = runcmd("/sbin/ip addr show");
my ($nic, $mac, $ipandmask);
# parse ip addr show output, looking for ipprefix, to determine nic and ip
my @output = runcmd("ip addr show");
my ($nic, $ipandmask);
foreach my $line (@output) {
my ($nictmp, $mactmp, $iptmp);
my ($nictmp, $iptmp);
if (($nictmp) = $line=~m/^\d+:\s+(\S+): /) { $nic = $nictmp; } # new stanza, remember it
if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) |) { $mac = $mactmp; } # got mac, remember it
if (($iptmp) = $line=~m/^\s+inet\s+($ipprefix\S+) /) { $ipandmask = $iptmp; last; } # got ip, we are done
}
if (!defined($ipandmask)) { die "Error: can't find a NIC with a prefix $ipprefix that communicates with".$args->{mnip}.".\n"; }
my ($ip, $netmask, $network, $broadcast) = convertIpAndMask($ipandmask);
my ($ip, $netmask) = convertIpAndMask($ipandmask);
# if the nic is a bonded nic (common on sl), then find the 1st real nic that is up that is part of it.
# also find that real nics real mac
my $realnic;
# if the nic is a bonded nic (common on sl), then find the 1st real nic that is part of it
my $realnic = $nic;
if ($nic =~ /^bond/) {
my @nics = grep(m/\s+master\s+$nic\s+/, @output);
if (!scalar(@nics)) { die "Error: can't find the NICs that are part of $nic.\n"; }
foreach my $line (@nics) {
my ($nictmp, $state) = $line=~m/^\d+:\s+(\S+): .* state\s+(\S+)/;
if (defined($nictmp) && defined($state) && $state eq 'UP') { $realnic = $nictmp; last; } # got ip, we are done
}
if (!defined($realnic)) { die "Error: can't find a physical NIC that is up and part of $nic.\n"; }
# now get the real mac of this real nic (when 2 nics are bonded, ip addr show displays one of the nics
# macs for both nics and the bond). So we have to depend on /proc/net/bonding/$bond instead.
my @bondout = runcmd("cat /proc/net/bonding/$nic");
my $foundnic;
foreach my $line (@bondout) {
my $mactmp;
if ($line=~m/^Slave Interface:\s+$realnic/) { $foundnic = 1; } # found the stanza for this nic, remember it
if ($foundnic && (($mactmp) = $line=~m/^Permanent HW addr:\s+(\S+)/)) { $mac = $mactmp; last; }
}
}
else { $realnic = $nic; }
# centos/redhat seems to name the nic in a different order than sles on some svrs.
# sles seems to name them in the same order as 'ip addr show' displays them, centos does not.
# so if we are on centos right now, we need to count down to determine the number that sles
# will give the nic that we have selected, because it is the sles naming that we care about,
# because that is the initrd that will be running in the scripted install case.
# This works similarly (at least in some case) when rhel is the target OS.
# The preferred way is for the user to set installnic=mac, then we do not need to run this code.
# For the sysclone case, genesis doxcat uses the mac to find the nic.
if (isRedhat() && $args->{kernelparms} !~ m/ ksdevice=\S*:/ && $args->{kernelparms} !~ m/ netdevice=\S*:/) {
my @nics = grep(m/^\d+:\s+eth/, @output);
my $i = 0;
foreach my $line (@nics) {
my ($nictmp) = $line=~m/^\d+:\s+(\S+):/;
if (defined($nictmp) && $nictmp eq $realnic) { $realnic = "eth$i"; last; } # got ip, we are done
$i++;
}
print "Determined that SLES/RHEL will call the install NIC $realnic (it has mac $mac)\n";
($realnic) = $nics[0]=~m/^\d+:\s+(\S+): /;
}
# finally, find the gateway
my $gateway;
my @output = runcmd("/sbin/ip route");
my @output = runcmd("ip route");
# we are looking for a line like: 10.0.0.0/8 via 10.54.51.1 dev bond0
my @networks = grep(m/ via .* $nic\s*$/, @output);
if (scalar(@networks)) { ($gateway) = $networks[0]=~m/ via\s+(\S+)/; }
@ -200,37 +102,19 @@ sub getNodeIpInfo {
verbose("using xCAT mgmt node IP as the fall back gateway.");
}
verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway, mac=$mac");
return ($realnic, $ip, $netmask, $network, $broadcast, $gateway, $mac);
verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway");
return ($realnic, $ip, $netmask, $gateway);
}
# Convert an ip/mask in slash notation (like 10.1.1.1/26) to separate ip, netmask, network, and broadcast values,
# like: 10.1.1.1, 255.255.255.192, 10.1.1.0, 10.1.1.63
# Convert an ip/mask in slash notation (like 10.0.0.1/26) to separate ip and netmask like 10.0.0.1 and 255.255.255.192
sub convertIpAndMask {
my $ipandmask = shift @_;
my ($ip, $masknum) = split('/', $ipandmask);
# build the netmask
my $nmbin = oct("0b" . '1' x $masknum . '0' x (32-$masknum)); # create a str like '1111100', then convert to binary
my @nmarr=unpack('C4',pack('N',$nmbin)); # separate into the 4 octets
my $netmask=join('.',@nmarr); # put them together into the normal looking netmask
# create binary form of ip
my @iparr=split(/\./,$ip);
my ( $ipbin ) = unpack('N', pack('C4',@iparr ) );
# Calculate network address by logical AND operation of ip & netmask and convert network address to IP address format
my $netbin = ( $ipbin & $nmbin );
my @netarr=unpack('C4', pack('N',$netbin ) );
my $network=join(".",@netarr);
# Calculate broadcast address by inverting the netmask and adding it to the network address
my $bcbin = ( $ipbin & $nmbin ) + ( ~ $nmbin );
my @bcarr=unpack('C4', pack('N',$bcbin ) ) ;
my $broadcast=join(".",@bcarr);
return ($ip, $netmask, $network, $broadcast);
my $netbin = oct("0b" . '1' x $masknum . '0' x (32-$masknum)); # create a str like '1111100', then convert to binary
my @netarr=unpack('C4',pack('N',$netbin)); # separate into the 4 octets
my $netmask=join('.',@netarr); # put them together into the normal looking netmask
return ($ip, $netmask);
}
@ -271,11 +155,6 @@ sub updateGrub {
"\tkernel " . $fileprefix . $args->{kernelpath} . ' ' . $args->{kernelparms} . "\n",
"\tinitrd " . $fileprefix . $args->{initrdpath} . "\n",
);
if ($DRYRUN) {
print "Dry run: would add this stanza to $grubfile:\n";
foreach my $l (@entry) { print $l; }
return;
}
my $needtowritefile = 1;
if (grep(/^title\s+$XCATNETBOOTTITLE/, @lines)) { $needtowritefile = updateGrubEntry(\@lines, \@entry); } # there is already an entry in there

View File

@ -4,7 +4,7 @@
# even across vlans (w/o setting up pxe/dhcp broadcast relay). This assumes a working
# OS is on the node. This script is primarily meant to be used in the softlayer environment.
#todo: work with site.managedaddressmode=static for sles
#todo: site attr for using static ip?
use strict;
use Getopt::Long;
@ -13,88 +13,64 @@ use Data::Dumper;
# Globals - these are set once and then only read.
my $HELP;
my $VERBOSE;
my $DRYRUN;
my $WAITTIME;
my $NOAUTOINST;
my $usage = sub {
my $exitcode = shift @_;
print "Usage: pushinitrd [-?|-h|--help] [-v|--verbose] [--dryrun] [-w <waittime>] [--noautoinst] <noderange>\n\n";
print "Usage: pushinitrd [-?|-h|--help] [-v|--verbose] [-w <waittime>] <noderange>\n\n";
if (!$exitcode) {
print "Copy the initrd, kernel, params, and static IP info to nodes, so they can net install\n";
print "even across vlans (w/o setting up pxe/dhcp broadcast relay). This assumes a working\n";
print "OS is on the node, that you've run nodeset for these nodes, and that all of the nodes\n";
print "in this noderange are using the same osimage.\n";
print "are using the same osimage.\n";
}
exit $exitcode;
};
# Process the cmd line args
Getopt::Long::Configure("bundling");
# Getopt::Long::Configure("pass_through");
#Getopt::Long::Configure("pass_through");
Getopt::Long::Configure("no_pass_through");
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'dryrun' => \$DRYRUN, 'w|waittime=s' => \$WAITTIME, 'a|noautoinst' => \$NOAUTOINST)) { $usage->(1); }
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME, 'a|noautoinst' => \$NOAUTOINST)) { $usage->(1); }
if ($HELP) { $usage->(0); }
if (scalar(@ARGV) != 1) { $usage->(1); }
if (!defined($WAITTIME)) { $WAITTIME = 75; } # seconds to wait after configuring the nic (to let the switch handle the state change)
my $noderange = $ARGV[0];
#
# Run some Node verification before starting pushinitrd
#
verifyNodeConfiguration($noderange);
my %bootparms = getBootParms($noderange);
copyFilesToNodes($noderange, \%bootparms);
updateGrubOnNodes($noderange, \%bootparms);
if ($DRYRUN) { exit(0); }
if ($bootparms{osimageprovmethod} eq 'install' && $bootparms{osimageosvers}=~ m/^sles/ && !$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); }
if ($bootparms{osimageprovmethod} eq 'sysclone') { copySyscloneFiles(); }
if (!$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); }
exit(0);
# Query the db for the kernel, initrd, and kcmdline attributes of the 1st node in the noderange
sub getBootParms {
my $nr = shift @_;
my %bootparms;
my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod");
my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline");
# the attributes can be displayed in a different order than requested, so need to grep for them
foreach my $attr (qw(bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod)) {
my ($a) = $attr =~ m/\.(.*)$/;
my @gresults = grep(/^\S+:\s+$attr:/, @output);
my @gresults;
foreach my $a (qw(kernel initrd kcmdline)) {
my $attr = "bootparams.$a";
@gresults = grep(/^\S+:\s+$attr:/, @output);
if (!scalar(@gresults)) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset <noderange> osimage=<osimage>' ?\n"; }
# for now just pick the 1st one. They should all be the same, except for the node name in kcmdline
chomp($gresults[0]);
$gresults[0] =~ s/^\S+:\s+$attr:\s*//;
#print "gresults='$gresults[0]'\n";
if ($gresults[0] !~ m/\S/) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset <noderange> osimage=<osimage>' ?\n"; }
$bootparms{$a} = $gresults[0];
if ($a eq 'kcmdline') { $bootparms{$a} =~ s|/install/autoinst/\S+|/install/autoinst/<nodename>|; }
}
$bootparms{kcmdline} =~ s|/install/autoinst/\S+|/install/autoinst/<nodename>|;
# from the nodes provmethod, get the osimage provmethod, so we know the type of install
@output = runcmd("lsdef -t osimage $bootparms{provmethod} -ci provmethod,osvers");
foreach my $line (@output) {
chomp($line);
if ($line =~ m/^Could not find/) { die "Error: provmethod $bootparms{provmethod} is set for the node, but there is no osimage definition by that name."; }
if ($line =~ m/ provmethod=/) {
my ($junk, $provmethod) = split(/=/, $line);
$bootparms{osimageprovmethod} = $provmethod;
}
if ($line =~ m/ osvers=/) {
my ($junk, $osvers) = split(/=/, $line);
$bootparms{osimageosvers} = $osvers;
}
}
#print "provmethod=$bootparms{osimageprovmethod}, osvers=$bootparms{osimageosvers}\n"; exit;
# get the mgmt node cluster-facing ip addr
@output = runcmd('lsdef -t site -ci master');
@output = runcmd('lsdef -t site -i master -c');
chomp($output[0]);
my ($junk, $ip) = split(/=/, $output[0]);
$bootparms{mnip} = $ip;
@ -114,15 +90,8 @@ sub copyFilesToNodes {
my $localfile = "/tftpboot/$file";
# for the
my $remotefile = '/boot/' . remoteFilename($file);
my $cmd = "xdcp $nr -p $localfile $remotefile";
if ($DRYRUN) {
print "Dry run: Copying $localfile to $nr:$remotefile\n";
print "Dry run: $cmd\n";
}
else {
print "Copying $localfile to $nr:$remotefile\n";
runcmd($cmd);
}
print "Copying $localfile to $nr:$remotefile\n";
runcmd("xdcp $nr -p $localfile $remotefile");
}
}
@ -130,7 +99,7 @@ sub copyFilesToNodes {
# Form the remote file name, using the last 2 parts of the path, separated by "-"
sub remoteFilename {
my $f = shift @_;
$f =~ s|^.*?([^/]+)/([^/]+)$|$1-$2|;
$f =~ s|^.*/([^/]+)/([^/]+)$|$1-$2|;
return $f;
}
@ -141,12 +110,10 @@ sub updateGrubOnNodes {
my $nr = shift @_;
my $bootparms = shift @_;
my $vtxt = ($VERBOSE ? '-v' : '');
my $dtxt = ($DRYRUN ? '--dryrun' : '');
my @output = runcmd('which modifygrub');
my $modifygrub = $output[0];
chomp($modifygrub);
my $euser ="root";
my $cmd = "xdsh $nr -l $euser -e $modifygrub $vtxt $dtxt -w $WAITTIME -p " . $bootparms->{osimageprovmethod} . ' ' . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' ';
my $cmd = "xdsh $nr -e $modifygrub $vtxt -w $WAITTIME " . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' ';
# we need to quote the kernel parms, both here when passing it to xdsh, and on the node
# when xdsh is passing it to modifygrub. The way to get single quotes inside single quotes
# is to quote each of the outer single quotes with double quotes.
@ -157,7 +124,8 @@ sub updateGrubOnNodes {
}
# Hack the autoinst files to overcome the nic coming up delay.
# Hack the autoinst files to wait in a key spot to make them work even tho it takes
# the NICs almost a min before they can transmit after a state change.
#todo: this has only been tested with SLES nodes
sub modifyAutoinstFiles {
my $nr = shift @_;
@ -167,160 +135,30 @@ sub modifyAutoinstFiles {
my @nodes = runcmd("nodels $nr");
chomp(@nodes);
# Modify chroot.sles to insert a wait in the /etc/init.d/network of each node. This is
# necessary because even tho compute.sles11.softlayer.tmpl configures bonding, when autoyast
# reboots the node after installing the rpms, it does not bring up the network in the normal way
# at first and seems to skip any bonding and the if-up.d scripts. So we are left doing this.
# (After autoyast is done with all of its post-configuration, it brings up the network in the
# normal way, so bonding gets done then, which is good at least.)
# Edit each file to have chroot.sles insert a wait at the end of /etc/init.d/network
# this finds the end of boot.sh script (which is chroot.sles)
my $search = '\n\]\]>\s*</source>\s*</script>\s*</chroot-scripts>';
# hack the /etc/init.d/network script to put a wait in it
my $file = '/mnt/etc/init.d/network'; # at this point in the installation, the permanent file system is just mounted
# this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escaped for sed
my $waitstring = 'echo -n Waiting to reach xCAT mgmt node ' . $bootparms->{mnip} . '.;xcatretries=60;while \[ \$\(\(xcati+=1\)\) -le \$xcatretries \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .' \>\/dev\/null 2\>\&1; do echo -n .; done; if \[ \$xcati -le \$xcatretries \]; then echo success; else echo failed; fi';
#my $waitstring = 'echo Sleeping for 55s;sleep 55';
# this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escape for sed
my $waitstring = 'echo Waiting to reach xCAT mgmt node...;while \[ \$\(\(xcati+=1\)\) -le 60 \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .'; do echo i=\$xcati ; done; sleep 10';
# this crazy sed string is from google. It gathers up the whole file into the hold buffer, and then the substitution is done on the whole file
my $sedstring = q|sed -n '1h;1!H;${;g;s/\(\t\treload_firewall\n\)\n/\1\t\t| . $waitstring . q(\n\n/g;p;}') . " $file > $file.new";
# finally create the perl replace string that will be used to modify the autoinst file
my $replace = "$sedstring\nchmod 755 $file.new; mv -f $file.new $file";
# Add a script that gets invoked by the OS after the nic is brought up
# Note: this does not work, because midway thru the autoyast process, the if-up.d scripts do not seem to get invoked
# so autoyast fails to get the media
# these are specific to SLES
#my $netdir = '/etc/sysconfig/network';
#my $filename = '/etc/sysconfig/network/if-up.d/xcat-sl-wait';
#my $mnip = $bootparms->{mnip};
#todo: to support rhel, use these values instead
#my $netdir='/etc/sysconfig/network-scripts';
#my $filename='/sbin/ifup-local';
#my $replace = qq(
#FILENAME=$filename
#NETDIR=$netdir
#MNIP=$mnip
#);
# $replace .= q(
#cat >$FILENAME << EOF1
#MNIP=$MNIP
#NETDIR=$NETDIR
#EOF1
#
# this part of the file we do NOT want to expand the variables in the content
#cat >>$FILENAME << 'EOF2'
#NIC="$1"
# look in this ifcfg script to get the nics ip to see if this is the one we should be waiting on
#NICIP=`awk -F= '/^IPADDR/ {print $2}' $NETDIR/ifcfg-$NIC | tr -d \' `
#if [ "${NICIP%.*.*}" != "${MNIP%.*.*}" ]; then exit; fi # hack: compare the 1st 2 octets
#echo -n Waiting to reach xCAT mgmt node $MNIP.
#xcatretries=60
#while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $MNIP >/dev/null 2>&1; do echo -n .; done
#if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi
#sleep 3
#EOF2
#
#chmod +x $FILENAME
#);
# The compute.sles11.softlayer.tmpl file contains 2 variables (node ip and netmask) that are
# not replaced by Template.pm. Substitute those in the autoinst files now.
# Also use our own multiline sed to put the network script hack in.
# now actually update the file
print "Updating /install/autoinst files.\n";
foreach my $n (@nodes) {
my $f = "/install/autoinst/$n";
my ($ip, $netmask, $gateway) = getNodeIpInfo($n);
runcmd("sudo sed -i 's/#NODEIPADDR#/$ip/;s/#NODENETMASK#/$netmask/;s/#NODEGATEWAY#/$gateway/' $f");
my $matches = sed($f, $search, $replace, mode=>'insertbefore');
if (!$matches) { die "Error: could not find the right place in $f to insert the sed of the network wait.\n"; }
}
}
sub verifyNodeConfiguration {
my $nr = shift @_;
my @nodes = runcmd("nodels $nr");
chomp(@nodes);
foreach my $n (@nodes) {
# Verify the IP is set for the node
my @output = runcmd("nodels $n hosts.ip");
chomp($output[0]);
my ($junk, $ip) = split(/\s+/, $output[0]);
#todo: also support getting the ip from name resolution
if (!$ip) {
die "Error: The ip attribute must be set for $n.\n";
}
}
}
# Copy softlayer specific systemimager post-install scripts to the systemimager location.
# These cause si to use static ip and insert a wait into the bring up of the network.
sub copySyscloneFiles {
my $cmd = "cp -f /opt/xcat/share/xcat/sysclone/post-install/* /install/sysclone/scripts/post-install";
print "Copying SoftLayer-specific post scripts to the SystemImager post-install directory.\n";
runcmd($cmd);
}
# Get IP and network of a node
sub getNodeIpInfo {
my $node = shift;
# get ip for the node
my @output = runcmd("nodels $node hosts.ip");
chomp($output[0]);
my ($junk, $ip) = split(/\s+/, $output[0]);
#todo: also support getting the ip from name resolution
# find relevant network in the networks table
# first get the networks in a hash
my %networks;
@output = runcmd("lsdef -t network -ci net,mask,gateway");
foreach my $line (@output) {
chomp($line);
my ($netname, $attr, $val) = $line =~ m/^(.+):\s+(.+?)=(.+)$/;
$networks{$netname}->{$attr} = $val;
}
# now go thru the networks looking for the correct one
my ($netmask, $gateway);
foreach my $key (keys %networks) {
if (isIPinNet($ip, $networks{$key}->{net}, $networks{$key}->{mask})) { # found it
$netmask = $networks{$key}->{mask};
$gateway = $networks{$key}->{gateway};
last;
}
}
if (!$netmask) { die "Error: could not find a network in the networks table that $node $ip is part of.\n"; }
if (!$gateway) { die "Error: gateway not specified in the networks table for the network that $node $ip is part of.\n"; }
verbose("IP info for $node: ip=$ip, netmask=$netmask, gateway=$gateway");
return ($ip, $netmask, $gateway);
}
# Is the IP in the network/netmask combo
sub isIPinNet {
my ($ip, $net, $mask) = @_;
my $ipbin = convert2bin($ip);
my $netbin = convert2bin($net);
my $maskbin = convert2bin($mask);
$ipbin &= $maskbin;
if ($ipbin && $netbin && ($ipbin == $netbin)) { return 1; }
else { return 0; }
}
# Convert dotted decimal format (1.2.3.4) to a binary number
sub convert2bin {
my @arr=split(/\./, shift);
my ($bin) = unpack('N', pack('C4',@arr ) );
return $bin;
}
# this is like multi-line sed replace function
# Args: filename, search-string, replace-string, options (mode=>{insertbefore,insertafter,replace})
# Args: filename, search-string, replace-string
sub sed {
my ($file, $search, $replace, %options) = @_;
#my $opts = 's';

View File

@ -1,140 +0,0 @@
#!/usr/bin/python
"""
Usage:
softlayer_storage.py --type=<type> [--hostname=<hostname> --username=<username> --password=<password> --mountpoint=<mountpoint> ] (mount | unmount)
softlayer_storage.py --type=<type> [options] (mount | unmount)
Options:
-h --help Show help screen
--version Show version
--type=<type> Type of File Storage to mount ( consistent | nas )
--hostname=<hostname> SoftLayer Storage hostname
--username=<username> SoftLayer Storage LUN username
--password=<password> SoftLayer Storage LUN password
--mountpoint=<mountpoint> The mountpoint to use [default: /mnt/nas]
Description:
For consistent performance file storate, make sure the host accessing the
file storage has been authorized through the SoftLayer portal.
"""
import os
import sys
import docopt
path = os.path.dirname(os.path.realpath(__file__))
path = os.path.realpath(os.path.join(path, '..', 'lib', 'python'))
if path.startswith('/opt'):
# if installed into system path, do not muck with things
sys.path.append(path)
from xcat import xcatutils
def mount_nas_storage(hostname, user, passwd, mountPoint):
print "Attempting to mount the NAS File Storage at %s" %(mountPoint)
if xcatutils.isMounted(mountPoint):
raise xcatutils.xCatError("The mount point %s is already in use." %(mountPoint))
cmd = "mount -t cifs //%s/%s -o username=%s,password=%s,rw,nounix,iocharset=utf8,file_mode=0644,dir_mode=0755 %s" %(hostname, user, user, passwd, mountPoint)
out,err = xcatutils.run_command(cmd)
if err:
raise xcatutils.xCatError("Error when mounting. (%s)" %(err))
else:
print "Success\n"
# To help out with automount, print this msg
print "\nNote: To configure automount on reboot, add the following into /etc/fstab:"
cmd = "//%s/%s %s cifs defaults,username=%s,password=%s 0 0" %(hostname,user,mountPoint,user,passwd)
print "%s\n" %(cmd)
def mount_consistent_storage(hostname, user, mountPoint):
# TODO: would be good to be able to specify the nfs version as a argument
print "Attempting to mount the Consistent Performance File Storage at %s" %(mountPoint)
if xcatutils.isMounted(mountPoint):
raise xcatutils.xCatError("The mount point %s is already in use." %(mountPoint))
cmd = "mount -t nfs4 %s:/%s %s" %(hostname, user, mountPoint)
out,err = xcatutils.run_command(cmd)
if err:
raise xcatutils.xCatError("Error when mounting. (%s)" %(err))
else:
print "Success\n"
# To help out with automount, print this msg
print "\nNote: To configure automount on reboot, add the following into /etc/fstab:"
cmd = "%s:/%s %s nfs4 defaults,hard,intr 0 0" %(hostname,user,mountPoint)
print "%s\n" %(cmd)
def unmount_storage(mountPoint):
print "Attempting to unmount the NAS at %s..." %(mountPoint)
if not xcatutils.isMounted(mountPoint):
raise xcatutils.xCatError("The mount point %s is NOT mounted." %(mountPoint))
else:
cmd = "umount %s" %(mountPoint)
out,err = xcatutils.run_command(cmd)
if err:
print "Encountered error while unmounting..."
print err
def setup_softlayer_storage():
#
# set code defaults to consistent file storage options
#
requirePassword=False
preReqPackages = ['nfs-utils','nfs-utils-lib']
#
# if NAS is selected as the type, override the code defaults
#
if 'nas' in arguments['--type']:
requirePassword=True
preReqPackages = ['cifs-utils']
#
# verify information before starting
#
if arguments['--hostname'] is None:
arguments['--hostname'] = xcatutils.getUserInput("Enter the SoftLayer storage hostname")
if arguments['--username'] is None:
arguments['--username'] = xcatutils.getUserInput("Enter the SoftLayer storage username")
if arguments['--password'] is None and requirePassword:
arguments['--password'] = xcatutils.getUserInput("Enter the SoftLayer storage password")
#
# install prereqs
#
print "Checking for installed packages: %s" %(preReqPackages)
xcatutils.installPackages(preReqPackages)
#
# mount the file storage
#
if 'nas' in arguments['--type']:
mount_nas_storage(arguments['--hostname'],arguments['--username'],arguments['--password'],arguments['--mountpoint'])
elif 'consistent' in arguments['--type']:
mount_consistent_storage(arguments['--hostname'],arguments['--username'],arguments['--mountpoint'])
if __name__ == '__main__':
try:
arguments = (docopt.docopt(__doc__, version="1.0"))
if not arguments['--type'] in ('nas', 'consistent'):
raise xcatutils.xCatError("The type=%s is not a supported file system type." %(arguments['--type']))
if arguments['unmount']:
unmount_storage(arguments['--mountpoint'])
else:
setup_softlayer_storage()
except docopt.DocoptExit as e:
print e
except xcatutils.xCatError as e:
print "xCatError: %s" %(e)

View File

@ -1,85 +0,0 @@
import sys
import os
import platform
class xCatError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def isMounted(mountPoint):
if os.path.ismount(mountPoint):
return True
else:
return False
def run_command(cmd):
"""
Function: run_command
Arguments: cmd - string to be run as a command
Description: runs the command then returns out and err
"""
import subprocess
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
(out,err) = p.communicate()
return (out,err)
def isRhel():
myDistro = platform.linux_distribution()
if "Red Hat Enterprise Linux Server" or "CentOS" in myDistro:
return True
else:
return False
def isSles():
myDistro = platform.linux_distribution()
if "SUSE Linux Enterprise Server" in myDistro:
return True
else:
return False
def isUbuntu():
myDistro = platform.linux_distribution()
if "Ubuntu" in myDistro:
return True
else:
return False
def getUserInput(question):
response = raw_input("%s: " %(question))
return response
def filterInstalledPackages(pkglist=[]):
fulllist = ""
if isRhel():
# using YUM
import yum
yb = yum.YumBase()
for x in pkglist:
if not yb.rpmdb.searchNevra(name='%s' %(x)):
fulllist += "%s " %(x)
return fulllist
def installPackages(pkglist=[]):
fulllist = filterInstalledPackages(pkglist)
if isRhel():
if fulllist.strip() != "":
cmd = "yum -y install %s" %(fulllist)
out,err = xcatutils.run_command(cmd)
elif isSles():
print "Using zyppr..."
elif isUbuntu():
print "Using apt-get..."
else:
print "Error!"

View File

@ -0,0 +1,6 @@
#!/bin/bash
# set the default route of the node to the ip address and nic passed in
set -x
ip route replace to default via $1 dev $2

View File

@ -67,6 +67,7 @@
</user>
</users>
<networking>
<keep_install_network config:type="boolean">true</keep_install_network>
<dns>
<domain>#TABLE:site:key=domain:value#</domain>
<hostname>#TABLE:nodelist:$NODE:node#</hostname>
@ -77,53 +78,10 @@
<search>#TABLE:site:key=domain:value#</search>
</searchlist>
</dns>
<interfaces config:type="list">
<interface>
<bonding_master>yes</bonding_master>
<bonding_module_opts>mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1</bonding_module_opts>
<bonding_slave0>eth0</bonding_slave0>
<bonding_slave1>eth2</bonding_slave1>
<device>bond0</device>
<bootproto>static</bootproto>
<startmode>auto</startmode>
<ipaddr>#NODEIPADDR#</ipaddr>
<netmask>#NODENETMASK#</netmask>
<usercontrol>no</usercontrol>
</interface>
<interface>
<bootproto>none</bootproto>
<device>eth0</device>
<name>Ethernet Card 0</name>
<startmode>off</startmode>
</interface>
<interface>
<bootproto>none</bootproto>
<device>eth2</device>
<name>Ethernet Card 2</name>
<startmode>off</startmode>
</interface>
</interfaces>
<routing>
<ip_forward config:type="boolean">false</ip_forward>
<routes config:type="list">
<route>
<destination>default</destination>
<device>-</device>
<gateway>#NODEGATEWAY#</gateway>
<netmask>-</netmask>
</route>
</routes>
</routing>
</networking>
<files config:type="list">
<file>
<file_contents><![CDATA[alias bond0 bonding
]]></file_contents>
<file_owner>root</file_owner>
<file_path>/etc/modprobe.d/bond0.conf</file_path>
<file_permissions>644</file_permissions>
</file>
</files>
<scripts>
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles#

View File

@ -1,82 +0,0 @@
#!/bin/bash
# SI post-install script to configure the efi boot mgr or grub after SI has installed the OS
# SI post-install scripts run in a chroot environment of the final OS image
if [ -d /sys/firmware/efi ]; then
echo "Setting Boot Manager for the next boot."
echo "delete all sysclone boot list"
str_bootnums=`efibootmgr | grep 'syscloneLinux' | awk '{print $1}' | sed 's/boot//i' | sed 's/*//'`
for str_num in $str_bootnums
do
efibootmgr -b $str_num -B -q
done
if [ -f "/boot/efi/EFI/redhat/grub.efi" ];then
efibootmgr -c -l \\EFI\\redhat\\grub.efi -L syscloneLinux
elif [ -f "/boot/efi/efi/SuSE/elilo.efi" ];then
efibootmgr -c -l \\efi\\SuSE\\elilo.efi -L syscloneLinux
else
echo "Can not find the boot loader."
exit 1
fi
else
echo "run grub-install to configure the MBR."
if [ -e /etc/mtab ];then
mv /etc/mtab /etc/mtab.bak
fi
grep -v rootfs /proc/mounts > /etc/mtab
boot_device=''
if [ -f "/etc/systemconfig/systemconfig.conf" ];then
boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'`
else
boot_root=`mount | grep -E ' on\s+/ type ' | awk '{print $1}'`
boot_device=`echo $boot_root | sed -e 's/[0-9]*$//'`
#str_temp=`mount | awk '{print $1","$3}'`
#for line in $str_temp
#do
# mp=`echo $line | awk -F, '{print $2}'`
# if [ "$mp" = "/" ];then
# boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'`
# break
# fi
#done
fi
if [ -n "$boot_device" ];then
echo "The boot device is $boot_device"
echo "The boot root device is $boot_root"
else
echo "Can not find the boot device, return error"
exit 1
fi
# set grub to use this boot device
if grep -qe '^VERSION\s*=\s*11' /etc/SuSE-release; then
#sles11, run grub-install.unsupported directly
echo "grub-install.unsupported --no-floppy --recheck $boot_device"
grub-install.unsupported --no-floppy --recheck $boot_device
# note: the error about grub-set-default not existing is harmless, because we want the default to be 0 anyway
else
#for sles10, should run grub-install with parameters
echo "grub-install --no-floppy --recheck $boot_device"
grub-install --no-floppy --recheck $boot_device
fi
# change the entries in the grub conf file to use the correct boot root device
# (not the one leftover from the golden image)
if [ -f "/boot/grub/grub.conf" ];then
conffile="/boot/grub/grub.conf"
else
conffile="/boot/grub/menu.lst"
fi
sed -i 's| root=\S*| root='$boot_root'|' $conffile
sed -i 's| resume=\S*| noresume|' $conffile
if [ -e /etc/mtab.bak ];then
mv -f /etc/mtab.bak /etc/mtab
else
rm -f /etc/mtab
fi
fi

View File

@ -1,209 +0,0 @@
#!/bin/bash
# SI post-install script to configure network settings after SI has installed the OS
# SI post-install scripts run in a chroot environment of the final OS image
. /tmp/post-install/variables.txt
bondingopts='mode=4 miimon=100 downdelay=0 updelay=0 lacp_rate=fast xmit_hash_policy=1'
# determine if we should be using a static ip or dhcp
staticIP () {
# Eventually we should use the SI variable IP_ASSIGNMENT_METHOD below to determine this.
# But this requires a patch in both xcat/sysclone (to set si_getimage -ip-assignment method)
# and SI (to set IP_ASSIGNMENT_METHOD as a result of that). Until both of those patches
# are in the main releases, assume that if we have set the IPADDR kernel parm for the boot
# kernel to use static ip, that the final OS should use static ip too.
# Note: the IPADDR environment variable will be set by SI, even if it got it thru dhcp, so
# that is not a reliable way to decide.
str=`cat /proc/cmdline`
#str='netmask=255.255.255.192 IPADDR=10.54.51.11 GATEWAY=10.54.51.1 dns=10.54.51.2 hostname=sap64-4 DEVICE=eth0'
for parm in $str; do
key=`echo $parm|awk -F= '{print $1}'`
value=`echo $parm|awk -F= '{print $2}'`
if [[ $key == "IPADDR" || $key == "ipaddr" ]]; then
return 0 # yes, we should use static ip
fi
done
if [[ -n $IP_ASSIGNMENT_METHOD && ${IP_ASSIGNMENT_METHOD,,} == "static" ]]; then
return 0 # this means yes/true
fi
return 1
}
#delete the udev rule in the image
rule_file=`ls /etc/udev/rules.d/*net_persistent_names.rules 2>/dev/null`
if [ -n "$rule_file" ];then
rm -f $rule_file
fi
hostname $HOSTNAME
bond=bond0
# this is a softlayer assumption that the two devices on the private net will be eth0 and eth2
if [[ $DEVICE == "eth0" ]]; then
DEVICE2=eth2
elif [[ $DEVICE == "eth2" ]]; then
DEVICE2=eth0
fi
ip addr show|grep -q -E "^[0-9]+:\s+$DEVICE2:" # make sure it exists on the system
if [[ $? == 0 ]]; then
DEVICE2EXISTS="yes"
fi
device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'`
str_cfg_file=''
if [ -d "/etc/sysconfig/network-scripts/" ];then
#redhat
dir="/etc/sysconfig/network-scripts"
grep -i HOSTNAME /etc/sysconfig/network
if [ $? -eq 0 ];then
sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network
else
echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network
fi
if staticIP; then
# delete all nic cfg files left over from the golden node
for i in $device_names;do
rm -f "$dir/ifcfg-$i"
done
# set static ip from variables in variables.txt
# write ifcfg-bond0. For now we assume the installnic should be part of bond0,
# because in SL i think that is always the case.
i="$bond"
str_cfg_file="$dir/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=none" >> $str_cfg_file
echo "ONBOOT=yes" >> $str_cfg_file
echo "USERCTL=no" >> $str_cfg_file
echo 'BONDING_OPTS="'$bondingopts'"' >> $str_cfg_file
echo "IPADDR=$IPADDR" >> $str_cfg_file
echo "NETMASK=$NETMASK" >> $str_cfg_file
echo "NETWORK=$NETWORK" >> $str_cfg_file
echo "BROADCAST=$BROADCAST" >> $str_cfg_file
#todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway
# write ifcfg-eth0
i="$DEVICE"
str_cfg_file="$dir/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=none" >> $str_cfg_file
echo "MASTER=$bond" >> $str_cfg_file
echo "ONBOOT=yes" >> $str_cfg_file
echo "SLAVE=yes" >> $str_cfg_file
echo "USERCTL=no" >> $str_cfg_file
i="$DEVICE2"
str_cfg_file="$dir/ifcfg-$i"
if [[ $DEVICE2EXISTS == "yes" ]]; then
# write ifcfg-eth2
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=none" >> $str_cfg_file
echo "MASTER=$bond" >> $str_cfg_file
echo "ONBOOT=yes" >> $str_cfg_file
echo "SLAVE=yes" >> $str_cfg_file
echo "USERCTL=no" >> $str_cfg_file
else
rm -f $str_cfg_file # in case it was left over in the image that was captured
fi
# write modprobe alias config
str_cfg_file="/etc/modprobe.d/$bond.conf"
echo "alias $bond bonding" > $str_cfg_file
#todo: figure out how to set the default gateway in rhel
else
# use dhcp for all nics
for i in $device_names;do
str_cfg_file="$dir/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "NM_CONTROLLED=yes" >> $str_cfg_file
echo "ONBOOT=yes" >> $str_cfg_file
done
fi
elif [ -d "/etc/sysconfig/network/" ];then
#suse
dir="/etc/sysconfig/network"
echo "$HOSTNAME" > /etc/HOSTNAME
if staticIP; then
# delete all nic cfg files left over from the golden node
for i in $device_names;do
rm -f "$dir/ifcfg-$i"
done
# set static ip from variables in variables.txt
# write ifcfg-bond0. For now we assume the installnic should be part of bond0,
# because in SL i think that is always the case.
i="$bond"
str_cfg_file="$dir/ifcfg-$i"
echo "BOOTPROTO=static" > $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
echo "BONDING_MASTER=yes" >> $str_cfg_file
echo "BONDING_MODULE_OPTS='$bondingopts'" >> $str_cfg_file
echo "NAME='Bonded Interface'" >> $str_cfg_file
echo "IPADDR=$IPADDR" >> $str_cfg_file
echo "NETMASK=$NETMASK" >> $str_cfg_file
echo "NETWORK=$NETWORK" >> $str_cfg_file
echo "BROADCAST=$BROADCAST" >> $str_cfg_file
echo "USERCONTROL=no" >> $str_cfg_file
echo "BONDING_SLAVE_0=$DEVICE" >> $str_cfg_file
if [[ $DEVICE2EXISTS == "yes" ]]; then
echo "BONDING_SLAVE_1=$DEVICE2" >> $str_cfg_file
fi
# write ifcfg-eth0
i="$DEVICE"
str_cfg_file="$dir/ifcfg-$i"
echo "BOOTPROTO=none" > $str_cfg_file
echo "STARTMODE=hotplug" >> $str_cfg_file
i="$DEVICE2"
str_cfg_file="$dir/ifcfg-$i"
if [[ $DEVICE2EXISTS == "yes" ]]; then
# write ifcfg-eth2
echo "BOOTPROTO=none" > $str_cfg_file
echo "STARTMODE=hotplug" >> $str_cfg_file
else
rm -f $str_cfg_file # in case it was left over in the image that was captured
fi
# write modprobe alias config
str_cfg_file="/etc/modprobe.d/$bond.conf"
echo "alias $bond bonding" > $str_cfg_file
# set the default gateway (at this point this is the private nic gateway, to handle provision across vlans)
file=/etc/sysconfig/network/routes
if grep -q -E '^default ' $file; then
# replace the default route that is already in there
sed -i 's/^default .*$/default '$GATEWAY' - -/' $file
else
# no default route yet, append to file
echo "default $GATEWAY - -" >>$file
fi
# this was the original config of the eth0 nic (without bonding)
#echo "DEVICE=$i" > $str_cfg_file
#echo "BOOTPROTO=static" >> $str_cfg_file
#echo "STARTMODE=onboot" >> $str_cfg_file
#echo "IPADDR=$IPADDR" >> $str_cfg_file
#echo "NETMASK=$NETMASK" >> $str_cfg_file
#echo "NETWORK=$NETWORK" >> $str_cfg_file
#echo "BROADCAST=$BROADCAST" >> $str_cfg_file
#todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway
else
# use dhcp for all nics
for i in $device_names;do
str_cfg_file="$dir/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
echo "DHCLIENT_PRIMARY_DEVICE=yes" >> $str_cfg_file
done
fi
else
#ubuntu
echo "Does not support ubuntu."
exit 1
fi

View File

@ -1,20 +0,0 @@
#!/bin/bash
#Used only by sysclone
# This SI post-install script is needed because the initrd that autoyast/kickstart/ubuntu builds when installing
# sles/rh/ubuntu on the golden node may not have the drivers when that initrd runs on the node that is
# being deployed with this image (specifically, drivers to be able to mount the disk).
# So rebuild the initrd on the to-node after putting the image on the disk, but before rebooting.
#todo: Make this script work on red hat by checking for dracut and using that if it exists.
# And do whatever is necessary on ubuntu.
if [[ -f /sbin/dracut ]]; then
# redhat/centos
echo "Running dracut to regenerate the initrd with the drivers needed by this node:"
dracut --force
else
# suse/sles
echo "Running mkinitrd to regenerate the initrd with the drivers needed by this node:"
mkinitrd
fi

View File

@ -1,25 +0,0 @@
#!/bin/bash
# SI post-install script, run after SI has installed the OS, to kill processes SI does not kill
# (so /a can be umounted cleanly)
# SI post-install scripts run in a chroot environment of the final OS image
if [ -f "/etc/SuSE-release" ];then
str_out=`ps -ef | grep -v grep | grep syslog-ng`
if [ $? -eq 0 ];then
str_id=`echo $str_out | awk '{print $2}'`
kill -9 $str_id
fi
fi
# SI starts klogd in the chroot, but does not kill it. Remove this line when SI fixes their bug.
killall klogd
# flush all write buffers, just in case SI can not umount /a
echo "Syncing file systems"
sync
#todo: remove
#echo "Processes still using /:"
#fuser -v /
#sleep 30

View File

@ -17,11 +17,6 @@ BuildArch: noarch
Requires: xCAT-server
#Requires: xCAT-server >= %{epoch}:%(cat Version|cut -d. -f 1,2)
# perl-ExtUtils-MakeMaker, perl-CPAN, perl-Test-Harness are only available in rhel.
# When this rpm supports being installed in sles, need to add these to xcat-dep.
# perl-SOAP-Lite is already in xcat-dep
Requires: perl-ExtUtils-MakeMaker perl-CPAN perl-Test-Harness perl-SOAP-Lite
Provides: xCAT-SoftLayer = %{epoch}:%{version}
%description
@ -47,28 +42,19 @@ xCAT-SoftLayer provides Utilities to make xCAT work in a SoftLayer environment.
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/python
mkdir -p $RPM_BUILD_ROOT/%{prefix}/lib/python/xcat
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/install
#mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/postscripts
mkdir -p $RPM_BUILD_ROOT/install/postscripts
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install
cp -p -R share/xcat/install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/install/
cp -d bin/* $RPM_BUILD_ROOT/%{prefix}/bin
chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
cp -d lib/python/xcat/* $RPM_BUILD_ROOT/%{prefix}/lib/python/xcat/
#cp -d postscripts/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/postscripts
#chmod 755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/postscripts/*
cp -d si-post-install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install
chmod 755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install/*
cp -d postscripts/* $RPM_BUILD_ROOT/install/postscripts
chmod 755 $RPM_BUILD_ROOT/install/postscripts/*
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer
chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer/*
@ -85,7 +71,4 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root)
#%doc LICENSE.html
%{prefix}
%post
# We are shipping the postscripts in a sysclone dir and then copying them to /install/postscripts here,
# because we want to allow base xcat to eventually ship them and not conflict on the file name/path
/install/postscripts

View File

@ -71,7 +71,7 @@ sub createDummyPods {
my $cmd = "grep -r -E 'L<.+\\([57]\\)\\|.+\\.[57]>' " . $poddir;
#print "Running cmd: ", $cmd, "\n";
my @lines = `$cmd`;
if ($?) { print "Did not find any section 5 man page, creating dummy pods...\n"; print join('', @lines); }
if ($?) { print "Error running: $cmd\n"; print join('', @lines); }
#my @lines;
#system($cmd);
my @dummyPods;

0
xCAT-UI/debian/rules Executable file → Normal file
View File

View File

@ -101,13 +101,15 @@ ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/webportal
# Inspect whether PHP related RPM packages are installed
%ifos linux
if [ -e "/etc/redhat-release" ]; then
if [ ! -e "/etc/httpd/conf.d/php.conf" ]; then
rpm -q php >/dev/null
if [ $? != 0 ]; then
echo ""
echo "Error! php has not been installed. Please run 'yum install php' before installing xCAT-UI.";
exit -1;
fi
else # SUSE
if [ ! -e "/etc/apache2/conf.d/php5.conf" ]; then
rpm -q apache2-mod_php5 php5 >/dev/null
if [ $? != 0 ]; then
echo ""
echo "Error! apache2-mod_php5 and php5 have not been installed. Please run 'zypper install apache2-mod_php5 php5' before installing xCAT-UI."
exit -1;

View File

@ -322,7 +322,6 @@ if (
'k|kitversion=s' => \$::KITVERSION,
'r|kitrelease=s' => \$::KITRELEASE,
'l|kitloc=s' => \$::KITLOC,
'for=s' => \$::FOROSVERSARCH,
)
)
{
@ -338,34 +337,18 @@ if ($::HELP)
}
my $debianflag = 0;
my $dpkg_flag = '-uc -us';
my $tempstring = xCAT::BuildKitUtils->osver();
if ( $tempstring =~ /debian/ || $tempstring =~ /ubuntu/ ){
$debianflag = 1;
}
# This is an undocumented flag to support our local build team
# to allow building Ubuntu kits on our RH build machines.
# It requires RH rpms such as dep, fakeroot, perl-File-DesktopEntry,
# perl-File-BaseDir, and html2text to be installed on the build server
# for this to work. To use this flag:
# buildkit --for ubuntu buildrepo <reponame>
# buildkit --for ubuntu buildtar
if ($::FOROSVERSARCH) {
if ( $::FOROSVERSARCH =~ /debian/ || $::FOROSVERSARCH =~ /ubuntu/ ) {
$debianflag=1;
$dpkg_flag .= ' -A -d';
}
}
# display the version statement if -v or --version is specified
if ($::VERSION)
{
my $versioncmd = "rpm -q --qf \"%{NAME}: %{VERSION}-%{RELEASE} \n\" xCAT-buildkit";
my $message = "Error quering xCAT-buildkit rpm. Version info is not available. \n";
if ( $debianflag ){
$versioncmd = "dpkg-query --show -f='\${binary:Package}: \${Version}\n' xcat-buildkit";
$versioncmd = "dpkg-query --show -f='\${PackageSpec}: \${Version}\n' xcat-buildkit";
$message = "Error quering xcat-buildkit package. Version info is not available. \n";
}
if ( system($versioncmd) ) {
@ -781,21 +764,20 @@ sub kit_buildrepo1
}
}
# Build kitcomponent preppackages and metapackages
# Build kitcomponent metapackages
if ( $debianflag ){
foreach my $kc (@{$::bldkit_config->{kitcomponent}{entries}}) {
if ($repoid ne $kc->{kitrepoid}) { next; }
my $debname = "$repodir/".&comppkgname($kc);
if (-r $debname) { next; }
if ($::VERBOSE) { print "building kitcomponent package for $kc->{basename} \n";}
if ($::VERBOSE) { print "building kitcomponent metapackage for $kc->{basename} \n";}
if (&build_kitcomp_debian($kc)) {
print "Error building kitcomponent metapackage for $kc->{basename} \n";
return 1;
}
}
if ( system("cd $repodir;dpkg-scanpackages . > Packages") ) {
print "Error building the repository meta-data with the dpkg-scanpackages command \n";
if ( system("dpkg-scanpackages $repodir > $repodir/Packages") ) {
print "Error building the repository meta-data with the dpkg-scanpackages command \n";
return 1;
}
}
@ -1023,7 +1005,7 @@ sub kit_buildtar
}
}
print "Creating tar file $::current_dir/$kitfilename.\n";
print "Creating tar file $tarfile.\n";
if ( system("cd $::deploy_dir; cd ..; tar -cjhf $tarfile $kitname/*") ) {
print "Error building tarfile $tarfile \n";
@ -1163,16 +1145,8 @@ sub edit_bldkitconf
my ($osbasename,$osmore) = split(/\,/, $osinfo);
my ($osmajorversion,$osminorversion) = split(/\./, $osmore);
my $osarch=`uname -p`;
chomp($osarch);
my $kitcomponent_basename = $kitname."_compute";
if ($debianflag==1) {
if($osarch eq "ppc64le"){
$osarch="ppc64el";
}
$kitcomponent_basename = $kitname."-compute";
}
for (@lines) {
s/<<<INSERT_kitbasename_HERE>>>/$kitname/;
s/<<<INSERT_kitrepoid_HERE>>>/$kitrepoid/;
@ -1891,12 +1865,6 @@ sub validate_os
my ($osmajorversion,$osminorversion) = split(/\./, $osmore);
my $osarch=`uname -p`;
chomp($osarch);
if ($debianflag==1) {
if($osarch eq "ppc64le"){
$osarch="ppc64el";
}
}
$osinfo =~ s/\,//;
my $repo_osinfo = "$repo->{osbasename}$repo->{osmajorversion}";
if (defined($repo->{osminorversion})){
@ -2001,7 +1969,7 @@ sub build_kitcomp
$::VALID_PRER_COMPONENT = 0;
if ( !$::PREREQUISITE ) {
if ( $comp->{ospkgdeps} || $comp->{preinstall} || $comp->{preupgrade} ) {
if ( $comp->{ospkgdeps} || $comp->{preinstall} || $comp->{preupgrade} || $comp->{preuninstall} ) {
if ( &gen_kitcomp_spec($comp,\%repo, 'PREREQUISITE') ) { return 1; }
# run the rpmbuild command
@ -2376,7 +2344,7 @@ sub gen_kitcomp_spec
s/<<<INSERT_kitcomponent_postinstall_script_HERE>>>/$postscript/;
s/<<<INSERT_kitcomponent_preupgrade_script_HERE>>>//;
s/<<<INSERT_kitcomponent_postupgrade_script_HERE>>>/$postupscript/;
s/<<<INSERT_kitcomponent_preuninstall_script_HERE>>>/$preunscript/;
s/<<<INSERT_kitcomponent_preuninstall_script_HERE>>>//;
s/<<<INSERT_kitcomponent_postuninstall_script_HERE>>>/$postunscript/;
}
}
@ -2439,45 +2407,14 @@ sub build_kitcomp_debian{
}
}
#run the dpkg-buildpackage command
my $curdir = $::workdir;
my $cmd = "rm -Rf $debbuilddir";
system($cmd);
mkpath($debbuilddir);
$::VALID_PREP_COMPONENT = 0;
if ( !$::PREREQUISITE ) {
if ( $comp->{ospkgdeps} || $comp->{preinstall} || $comp->{preupgrade} || $comp->{preuninstall} ) {
#Create debian directory for this kit component preppackage
if ( &gen_kitcomp_debdir_prep($comp,\%repo) ) { return 1; }
$::VALID_PREP_COMPONENT = 1;
# build prep deb
my $prep_compversion = $comp->{version} . "-" . $comp->{release};
my $prep_buildstring = "Prep Kit component build package.";
my $prep_debbuilddir = $::workdir."/debbuild/"."prep-".$comp->{kitcompname};
my $prep_debianbuildcmd = "cd $prep_debbuilddir;debchange -v $prep_compversion -b -c debian/changelog $prep_buildstring;dpkg-buildpackage $dpkg_flag";
if ( system($prep_debianbuildcmd) ) {
print "Error running \"dpkg-buildpackage $dpkg_flag\" command for kit component prep-$comp->{kitcompname} meta package\n";
return 1;
}
}
#Create debian directory for this kit component metapackage
if ( &gen_kitcomp_debdir($comp,\%repo,'METADEB') ) { return 1; }
} else {
#Create debian directory for this kit component
if ( &gen_kitcomp_debdir($comp,\%repo,'ALL') ) { return 1; }
}
#Create debian directory for this kit component
if ( &gen_kitcomp_debdir($comp,\%repo) ) { return 1; }
if (defined($comp->{non_native_pkgs}) ) {
my $sourcedir = $::workdir."/source_packages";
@ -2499,11 +2436,11 @@ sub build_kitcomp_debian{
}
}
my $compversion = $comp->{version} . "-" . $comp->{release};
my $buildstring = "\'Kit component build package.\'";
my $debianbuildcmd = "cd $debbuilddir;debchange -v $compversion -b -c debian/changelog $buildstring;dpkg-buildpackage $dpkg_flag";
my $buildstring = "Kit component build package.";
my $debianbuildcmd = "cd $debbuilddir;dch -v $compversion -b -c debian/changelog $buildstring;dpkg-buildpackage -uc -us";
if ( !$::NON_NATIVE_PKGS->{$comp->{kitcompname}} ) {
if ( system($debianbuildcmd) ) {
print "Error running \"dpkg-buildpackage $dpkg_flag\" command for kit component $comp->{kitcompname} meta package\n";
print "Error running \"dpkg-buildpackage -uc -us\" command for kit component $comp->{kitcompname} meta package\n";
return 1;
}
my $repodir = $::base_repodir."/".$repo{kitreponame};
@ -2519,99 +2456,6 @@ sub build_kitcomp_debian{
return 0;
}
#-----------------------------------------------------------------------------
=head3 gen_kitcomp_debdir_prep
=cut
#-----------------------------------------------------------------------------
sub gen_kitcomp_debdir_prep{
my $comp = shift;
my $repo = shift;
my $scriptdir = $::workdir."/scripts/";
my $combuilddir = $::workdir."/debbuild/"."prep-".$comp->{kitcompname};
#copy the debian dir template to the build path
mkpath("$combuilddir/debian");
my $cmd = "cp -Rf " . $::XCATSHARE . "/kits/debian_template/* $combuilddir/debian/";
system($cmd);
my $kitname = $::bldkit_config->{kit}{entries}[0]->{basename};
my $kitcompname = "prep-".$comp->{kitcompname};
my $upgradeflag = "pre-".$comp->{basename} . ".tmp";
my ($prescript,$postscript,$preupscript,$postupscript,$preunscript,$postunscript,$nonnativepkgs) = '';
if (defined($comp->{preinstall})) {
$prescript = &load_script("$scriptdir$comp->{preinstall}");
}
if (defined($comp->{preupgrade})) {
$preupscript = &load_script("$scriptdir$comp->{preupgrade}");
}
if (defined($comp->{preuninstall})) {
$preunscript = &load_script("$scriptdir$comp->{preuninstall}");
}
#replace all special sub string in all files under debian
unless (opendir(DH, "${combuilddir}/debian/")){
print "Can not open the xCAT Kit Component debian dir: ${combuilddir}/debian/";
return 1;
}
foreach (readdir(DH)){
my $file = "${combuilddir}/debian/$_";
if ( -d $file){
next;
}
unless ( open ( FH, "<", $file )){
print "Error attempting to open the xCAT Kit Component ${kitcompname}'s debian template file $file.\n";
close(DH);
return 1;
}
if ($::VERBOSE){
print "Reading the xCAT Kit Component ${kitcompname}'s debian template file $file. \n";
}
my @lines = <FH>;
close(FH);
my $prep_comp_name="prep-".$comp->{basename};
for(@lines) {
chomp;
s/<<<INSERT_kitcomponent_basename_HERE>>>/$prep_comp_name/;
s/<<<INSERT_kitcomponent_ospkgdeps_HERE>>>/$comp->{ospkgdeps}/;
s/<<<INSERT_kitcomponent_kitpkgdeps_HERE>>>//;
s/<<<INSERT_kitcomponent_kitcompdeps_HERE>>>//;
s/<<<INSERT_kitcomponent_desc_HERE>>>/$comp->{description}/;
s/<<<INSERT_kitcomponent_upgrade_flag_HERE>>>/$upgradeflag/;
s/<<<INSERT_kitcomponent_preinstall_script_HERE>>>/$prescript/;
s/<<<INSERT_kitcomponent_postinstall_script_HERE>>>//;
s/<<<INSERT_kitcomponent_preupgrade_script_HERE>>>/$preupscript/;
s/<<<INSERT_kitcomponent_postupgrade_script_HERE>>>//;
s/<<<INSERT_kitcomponent_preuninstall_script_HERE>>>/$preunscript/;
s/<<<INSERT_kitcomponent_postuninstall_script_HERE>>>//;
}
my $joined_lines = join("\n", @lines);
@lines = split(/\\n/,$joined_lines);
open (FH, ">", $file);
if ($::VERBOSE){
print "Created kitcomponent ${kitcompname}'s build file under debian dir $file";
}
print FH @lines;
close(FH);
}
closedir(DH);
return 0;
}
#-----------------------------------------------------------------------------
=head3 gen_kitcomp_debdir
@ -2624,7 +2468,6 @@ sub gen_kitcomp_debdir_prep{
sub gen_kitcomp_debdir{
my $comp = shift;
my $repo = shift;
my $level = shift;
my $scriptdir = $::workdir."/scripts/";
my $combuilddir = $::workdir."/debbuild/".$comp->{kitcompname};
@ -2638,38 +2481,29 @@ sub gen_kitcomp_debdir{
my $upgradeflag = $comp->{basename} . ".tmp";
my ($prescript,$postscript,$preupscript,$postupscript,$preunscript,$postunscript,$nonnativepkgs) = '';
if ($level eq 'METADEB' || $level eq 'ALL')
{
if (defined($comp->{postinstall})) {
$postscript = &load_script("$scriptdir$comp->{postinstall}");
}
if (defined($comp->{postupgrade})) {
$postupscript = &load_script("$scriptdir$comp->{postupgrade}");
}
if (defined($comp->{postuninstall})) {
$postunscript = &load_script("$scriptdir$comp->{postuninstall}");
}
if (defined($comp->{non_native_pkgs})) {
$nonnativepkgs = "\n";
$nonnativepkgs .= "mkdir -p \$RPM_BUILD_ROOT/opt/xcat/kits/$kitname/$kitcompname \n";
$nonnativepkgs .= "cp -a * \$RPM_BUILD_ROOT/opt/xcat/kits/$kitname/$kitcompname \n";
}
if (defined($comp->{preinstall})) {
$prescript = &load_script("$scriptdir$comp->{preinstall}");
}
if (defined($comp->{postinstall})) {
$postscript = &load_script("$scriptdir$comp->{postinstall}");
}
if (defined($comp->{preupgrade})) {
$preupscript = &load_script("$scriptdir$comp->{preupgrade}");
}
if (defined($comp->{postupgrade})) {
$postupscript = &load_script("$scriptdir$comp->{postupgrade}");
}
if (defined($comp->{preuninstall})) {
$preunscript = &load_script("$scriptdir$comp->{preuninstall}");
}
if (defined($comp->{postuninstall})) {
$postunscript = &load_script("$scriptdir$comp->{postuninstall}");
}
if (defined($comp->{non_native_pkgs})) {
$nonnativepkgs = "\n";
$nonnativepkgs .= "mkdir -p \$RPM_BUILD_ROOT/opt/xcat/kits/$kitname/$kitcompname \n";
$nonnativepkgs .= "cp -a * \$RPM_BUILD_ROOT/opt/xcat/kits/$kitname/$kitcompname \n";
}
if ($level eq 'ALL')
{
if (defined($comp->{preinstall})) {
$prescript = &load_script("$scriptdir$comp->{preinstall}");
}
if (defined($comp->{preupgrade})) {
$preupscript = &load_script("$scriptdir$comp->{preupgrade}");
}
if (defined($comp->{preuninstall})) {
$preunscript = &load_script("$scriptdir$comp->{preuninstall}");
}
}
#replace all special sub string in all files under debian
unless (opendir(DH, "${combuilddir}/debian/")){
@ -2694,20 +2528,12 @@ sub gen_kitcomp_debdir{
}
my @lines = <FH>;
close(FH);
my $prepcomp="prep-".$comp->{basename};
for(@lines) {
chomp;
s/<<<INSERT_kitcomponent_basename_HERE>>>/$comp->{basename}/;
s/<<<INSERT_kitcomponent_ospkgdeps_HERE>>>/$comp->{ospkgdeps}/;
s/<<<INSERT_kitcomponent_kitpkgdeps_HERE>>>/$comp->{kitpkgdeps}/;
if ( $::VALID_PREP_COMPONENT ) {
s/<<<INSERT_kitcomponent_kitcompdeps_HERE>>>/$comp->{kitcompdeps},$prepcomp/;
}
else
{
s/<<<INSERT_kitcomponent_kitcompdeps_HERE>>>/$comp->{kitcompdeps}/;
}
s/<<<INSERT_kitcomponent_kitcompdeps_HERE>>>/$comp->{kitcompdeps}/;
s/<<<INSERT_kitcomponent_desc_HERE>>>/$comp->{description}/;
s/<<<INSERT_kitcomponent_upgrade_flag_HERE>>>/$upgradeflag/;
s/<<<INSERT_kitcomponent_preinstall_script_HERE>>>/$prescript/;
@ -2856,13 +2682,8 @@ sub create_kitconf
$::kit_config->{$s}{entries}[$li]->{kitreponame} =
$se->{kitreponame};
if ( !$::PREREQUISITE and ($se->{ospkgdeps} || $se->{preinstall} || $se->{preupgrade} || $se->{preuninstall}) ) {
if ( $debianflag ){
$::kit_config->{$s}{entries}[$li]->{prerequisite} =
"prep-" . $se->{basename};
}else{
$::kit_config->{$s}{entries}[$li]->{prerequisite} =
$::kit_config->{$s}{entries}[$li]->{prerequisite} =
"prep_" . $se->{basename};
}
}
}
$li++;
@ -3580,7 +3401,7 @@ sub kit_addpkgs
#for debian/ubuntu
my $repodir = $tmpdir . "/repos/".$non_native_kitreponame;
if ( $debianflag ){
my $debbuildcmd = "cd $source_dir;dpkg-buildpackage $dpkg_flag";
my $debbuildcmd = "cd $source_dir;dpkg-buildpackage -uc -us";
if ( system($debbuildcmd) ){
print "error running debian build cmd for kit component $non_native_basename meta package.\n";
return 1;
@ -3766,13 +3587,9 @@ sub NEW_kit_addpkgs
if ($kp->{isexternalpkg} eq 'yes') {
my $ext_filename = $kp->{filename};
my $ext_reponames = $kp->{kitreponame};
my $files;
if($debianflag){
$files = xCAT::BuildKitUtils->find_latest_pkg_deb(\@pkgdirlist, $ext_filename);
}
else {
$files = xCAT::BuildKitUtils->find_latest_pkg(\@pkgdirlist, $ext_filename);
}
my $files = xCAT::BuildKitUtils->find_latest_pkg(\@pkgdirlist, $ext_filename);
if (!defined($files) ) {
print "Error: The product package file $ext_filename was not found in the package directory(s) @pkgdirlist.\n";
# Cleanup
@ -3892,47 +3709,6 @@ sub NEW_kit_addpkgs
}
}
#When using -k -r, there are useless repodir
#delete useless repo dir
my $kitrepodirby=$::base_repodir;
my $cmdby = "/bin/ls $kitrepodirby 2>/dev/null";
my $outputby = `$cmdby`;
my @allrepolist = split(/\n/, $outputby);
my @dellist;
foreach my $reponame (@allrepolist)
{
my $match=0;
foreach my $kr (@{$::bldkit_config->{kitrepo}{entries}})
{
my $repodirname = "$kr->{kitreponame}";
if ( ${repodirname} eq ${reponame} )
{
${match}++;
}
}
if ( ${match} == 0 )
{
push(@dellist,$reponame);
}
}
foreach my $del (@dellist)
{
my $delrepodir=$::base_repodir."/".$del ;
if ( -d $delrepodir )
{
my $delcmd="rm -Rf $delrepodir";
if ( system($delcmd) )
{
print "Failed to delete useless repo directory \n";
}
}
}
# Build the full kit tar file
my $buildtar_rc = &kit_buildtar;

View File

@ -134,87 +134,6 @@ sub get_latest_version
}
}
#--------------------------------------------------------------------------
=head3 get_latest_version_deb
Find the latest version in a list of debs with the same basename
Arguments:
- the repo location
- a list of debs with the same basename
Returns:
- name of deb
- undef
Example:
my $new_d = xCAT::BuildKitUtils->get_latest_version($repodir, \@rpmlist);
Comments:
=cut
#--------------------------------------------------------------------------
sub get_latest_version_deb
{
my ($class, $repodir, $debs) = @_;
my @deblist = @$debs;
my %localversions_hash = ();
my $file_name;
my %founddeb;
my $latest;
my $i = 0;
foreach my $deb (@deblist)
{
# include path
my $fulldebpath = "$repodir/$deb*";
chomp $deb;
# get the basename, version, and release for this deb
print "dpkg -I $repodir/$deb |grep Package|awk '{print \$2}'";
my $basenamedeb = `dpkg -I $repodir/$deb |grep Package|awk '{print \$2}'`;
chomp $basenamedeb;
my $versiondeb = `dpkg -I $repodir/$deb |grep Version|awk '{print \$2}'`;
chomp $versiondeb;
$founddeb{$basenamedeb}{$deb}{version}=$versiondeb;
$i++;
}
if ($i == 0)
{
print "error\n";
return undef;
}
foreach my $r (keys %founddeb ) {
# if more than one with same basename then find the latest
my $latestmatch="";
foreach my $fdeb (keys %{$founddeb{$r}} ) {
# if we already found a match in some other dir
if ($latestmatch) {
# then we need to figure out which is the newest
# if the $fdeb is newer than use iti
if ( ! xCAT::BuildKitUtils->testVersion_deb($founddeb{$r}{$fdeb}{version}, 'gt', $founddeb{$r}{$latestmatch}{version}) ) {
$latestmatch = $fdeb;
}
} else {
$latestmatch = $fdeb;
}
}
$latest=$latestmatch;
}
if ($i == 0)
{
print "Error: Could not determine the latest version for the following list of debs: @deblist\n";
return undef;
} else {
return ($latest);
}
}
#--------------------------------------------------------------------------
=head3 find_latest_pkg
@ -241,7 +160,6 @@ sub find_latest_pkg
my @rpms;
my %foundrpm;
# need to check each pkgdir for the rpm(s)
# - if more than one match need to pick latest
# find all the matches in all the directories
@ -305,128 +223,6 @@ sub find_latest_pkg
}
}
#--------------------------------------------------------------------------
=head3 find_latest_pkg_deb
Find the latest deb package give the deb name and a list of
possible package locations.
Arguments:
- a list of package directories
- the name of the deb
Returns:
- \@founddeblist
- undef
Example:
my $newrpm = xCAT::BuildKitUtils->find_latest_pkg_deb(\@pkgdirs, $debname);
Comments:
=cut
#--------------------------------------------------------------------------
sub find_latest_pkg_deb
{
my ($class, $pkgdirs, $debname) = @_;
my @pkgdirlist = @$pkgdirs;
my @debs;
my %founddeb;
# need to check each pkgdir for the deb(s)
# - if more than one match need to pick latest
# find all the matches in all the directories
foreach my $debdir (@pkgdirlist) {
my $ffile = $debdir."/".$debname;
if ( system("/bin/ls $ffile > /dev/null 2>&1") ){
# if not then skip to next dir
next;
} else {
# if so then get the details and add it to the %founddeb hash
my $cmd = "/bin/ls $ffile 2>/dev/null";
my $output = `$cmd`;
my @deblist = split(/\n/, $output);
if ( scalar(@deblist) == 0) {
next;
}
foreach my $r (@deblist) {
my $basename = `dpkg -I $r* |grep Package|awk '{print \$2}'|head -1`;
chomp $basename;
my $version = `dpkg -I $r* |grep Version|awk '{print \$2}'|head -1`;
chomp $version;
$founddeb{$basename}{$r}{version}=$version;
}
}
}
# for each unique deb basename
foreach my $r (keys %founddeb ) {
# if more than one with same basename then find the latest
my $latestmatch="";
foreach my $fdeb (keys %{$founddeb{$r}} ) {
# if we already found a match in some other dir
if ($latestmatch) {
# then we need to figure out which is the newest
# if the $fdeb is newer than use it
if ( ! xCAT::BuildKitUtils->testVersion_deb($founddeb{$r}{$fdeb}{version}, 'gt', $founddeb{$r}{$latestmatch}{version}) ) {
$latestmatch = $fdeb;
}
} else {
$latestmatch = $fdeb;
}
}
push(@debs, $latestmatch);
}
if (scalar(@debs)) {
return \@debs;
} else {
return undef;
}
}
#------------------------------------------------------------------------------
=head3 testVersion_deb
Compare version1 and version2 according to the operator and
return 1 0 or 0.
Arguments:
$version1
$operator
$version2
Returns:
1 or 0
Example:
Comments:
The return value is generated with the Require query
=cut
#-----------------------------------------------------------------------------
sub testVersion_deb
{
my ($class, $version1, $operator, $version2) = @_;
if ($::VERBOSE) {
print "dpkg --compare-versions $version1 $operator $version2 \n";
}
my $result =`dpkg --compare-versions $version1 $operator $version2`;
return $result;
}
#------------------------------------------------------------------------------

View File

@ -210,11 +210,11 @@ Add product package rpms to a previously built kit tar file. This is used for p
=over 3
=item <B>0
=item 0
The command completed successfully.
=item <B>1
=item 1
An error has occurred.

View File

@ -21,7 +21,7 @@ set -e
case "$1" in
configure)
<<<INSERT_kitcomponent_postinstall_script_HERE>>>
if [ -f /tmp/<<<INSERT_kitcomponent_upgrade_flag_HERE>>> ]; then
if [ -f /tmp/<<<INSERT_kitcomponent_upgrade_flag_HERE>>> ]
<<<INSERT_kitcomponent_postupgrade_script_HERE>>>
rm /tmp/<<<INSERT_kitcomponent_upgrade_flag_HERE>>>
fi

View File

@ -17,12 +17,10 @@ set -e
case "$1" in
install)
<<<INSERT_kitcomponent_preinstall_script_HERE>>>
echo "preinstall processing"
;;
upgrade)
if [ -f /tmp/<<<INSERT_kitcomponent_upgrade_flag_HERE>>> ]; then
echo "preupgrade processing"
if [ -f /tmp/<<<INSERT_kitcomponent_upgrade_flag_HERE>>> ]
<<<INSERT_kitcomponent_preupgrade_script_HERE>>>
fi
;;

Some files were not shown because too many files have changed in this diff Show More