Compare commits

..

1 Commits

Author SHA1 Message Date
arif 6e0969ca21 defect #4026, allow for SN facing ip to be seen 2014-04-04 12:08:26 +01:00
99 changed files with 7444 additions and 7934 deletions
-14
View File
@@ -1,14 +0,0 @@
xCAT - eXtreme Cloud Administration Toolkit
xCAT is a toolkit for the deployment and administration of clusters.
xCAT documentation is available at: http://xcat.sourceforge.net/
xCAT is made available as open source software under the EPL license:
http://www.opensource.org/licenses/eclipse-1.0.php
+1 -1
View File
@@ -1 +1 @@
2.8.4ocf
2.8.4
+3 -3
View File
@@ -86,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`
@@ -279,7 +279,7 @@ __EOF__
cat << '__EOF__' > mklocalrepo.sh
. /etc/lsb-release
cd `dirname $0`
echo deb [arch=amd64] 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
@@ -380,7 +380,7 @@ __EOF__
cat << '__EOF__' > mklocalrepo.sh
. /etc/lsb-release
cd `dirname $0`
echo deb [arch=amd64] 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
+2 -5
View File
@@ -44,10 +44,8 @@ FRS=/home/frs/project/x/xc/xcat
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 has PCM specific configuration - conserver-xcat, syslinux-xcat
# xCAT-server has PCM specific configuration - RESTAPI(perl-JSON)
PCMBUILD="xCAT xCAT-server"
PCMLINK="perl-xCAT xCAT-client xCAT-buildkit xCAT-genesis-scripts-x86_64"
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=""
@@ -243,7 +241,6 @@ for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xC
#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 $GREP $rpmname $GITUP || [ "$BUILDALL" == 1 ]; then
UPLOAD=1
maker $rpmname
-160
View File
@@ -1,160 +0,0 @@
#######################################################################
#build script for local usage
#used for Linux/AIX/Ubuntu
#
###########################################################################
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
if [ $? -gt 0 ]; then
echo "Error:no repo exist, exit 1."
exit 1
fi
# Get a lock, so can not do 2 builds at once
exec 8>/var/lock/xcatbld.lock
if ! flock -n 8; then
echo "Can't get lock /var/lock/xcatbld.lock. Someone else must be doing a build right now. Exiting...."
exit 1
fi
#delete old package if there is
rm -rf $CURDIR/build/
cd $CURDIR
echo "==============================================="
echo $NAMEALL | egrep "Ubuntu"
#Check if it is an Ubuntu system
if [ $? -eq 0 ]; then
echo "This is an Ubuntu system"
pkg_type="snap"
build_string="Snap_Build"
cur_date=`date +%Y%m%d`
short_ver=`cat Version|cut -d. -f 1,2`
pkg_version="${short_ver}-${pkg_type}${cur_date}"
mkdir -p $CURDIR/build
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"
cd $rpmname
dch -v $pkg_version -b -c debian/changelog $build_string
dpkg-buildpackage -uc -us
rc=$?
if [ $rc -gt 0 ]; then
echo "Error: $rpmname build package failed exit code $rc"
fi
cd -
mv ${rpmname_low}* $CURDIR/build
done
#delete all files except .deb file
find $CURDIR/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
# Build the rest of the noarch rpms
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
done
#build xCAT-genesis-scripts if it is x86_64 platform
ARCH=$(uname -p)
if [ "$ARCH" = "x64_64" ]; then
$CURDIR/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
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname"; fi
else
for arch in x86_64 ppc64 s390x; do
$CURDIR/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/issue;
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/
else
rm -f /etc/zypp/repos.d/xCAT-core.repo
zypper ar file://$CURDIR/build xCAT-core
fi
fi
-1
View File
@@ -85,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
+26 -40
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)
if (defined(@$nodes))
{
my $rsp = {};
$rsp->{error}->[0] =
@@ -4408,7 +4405,7 @@ sub parse_and_run_dcp
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.";
@@ -4505,7 +4502,7 @@ sub parse_and_run_dcp
#
# build list of nodes
my @nodelist;
if (@$nodes)
if (defined(@$nodes))
{ # there are nodes
@nodelist = @$nodes;
$options{'nodes'} = join(',', @nodelist);
@@ -4975,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>)
{
@@ -5017,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
@@ -5038,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
@@ -5211,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;
@@ -5240,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
@@ -5323,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;
@@ -5353,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
@@ -6043,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'],
+58
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);
}
}
}
#---------------------------------------------------------------------------
+31 -199
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,15 +48,6 @@ 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',
'vmphyslots' => 'part_get_all_io_bus_info',
'vmnics' => 'part_get_all_vio_info',
'vmstorage' => 'part_get_all_vio_info',
'del_vadapter' => 'part_get_all_vio_info'
);
sub chvm_parse_extra_options {
my $args = shift;
@@ -66,7 +57,6 @@ sub chvm_parse_extra_options {
if (ref($args) ne 'ARRAY') {
return "$args";
}
my %tmp_hash = ();
foreach (@$args) {
my ($cmd, $value) = split (/\=/, $_);
if (!defined($value)) {
@@ -85,24 +75,14 @@ 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 "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 "vmstorage") {
@@ -177,7 +157,6 @@ sub chvm_parse_extra_options {
}
$opt->{$cmd} = $value;
}
@query_array = keys(%tmp_hash);
return undef;
}
@@ -740,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})) {
@@ -779,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)) {
@@ -849,17 +827,17 @@ sub do_op_extra_cmds {
if ($2 == "G" or $2 == '') {
$min = $min * 1024;
}
$min = int($min/$memsize);
$min = $min/$memsize;
my $cur = $3;
if ($4 == "G" or $4 == '') {
$cur = $cur * 1024;
}
$cur = int($cur/$memsize);
$cur = $cur/$memsize;
my $max = $5;
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 {
@@ -892,15 +870,8 @@ sub do_op_extra_cmds {
push @values, [$name, "Success", '0'];
}
}
my $rethash = query_cec_info_actions($request, $name, $d, 1, \@query_array);
# 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 {
@@ -1681,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);
@@ -1702,12 +1672,9 @@ sub parse_part_get_info {
$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];
@@ -1720,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";
}
}
}
}
@@ -1773,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 = ();
@@ -1788,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];
@@ -1852,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;
@@ -1925,36 +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;
$lpar_hash{$name} = \%tmp_hash;
$lpar_hash{$name}->{parent} = @$d[3];
}
if (@td[0] == 0) {
my $rethash = query_cec_info_actions($request, @td[3],\@td, $usage);
my $rethash = query_cec_info_actions($request, @td[3],\@td, 0);
#push @result, [@td[3], $rethash, 0];
push @result, @$rethash;
}
}
if ($args->{updatedb} and %lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@result;
}
@@ -2071,19 +1931,6 @@ 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;
@@ -2207,7 +2054,6 @@ 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]]);
@@ -2280,9 +2126,9 @@ sub mkspeclpar {
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 {
@@ -2332,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})) {
@@ -2373,18 +2213,10 @@ sub mkspeclpar {
$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"]);
$lpar_hash{$name} = $rethash;
$lpar_hash{$name}->{parent} = @$d[3];
$name = undef;
$d = undef;
}
}
if (%lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@result;
}
+1 -1
View File
@@ -1023,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;
+9 -127
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 };
@@ -697,26 +696,19 @@ sub get_nic_ip
# Base address:0x2600 Memory:fbfe0000-fc0000080
#
# eth1 ...
# Redhat7
#eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
# inet 10.1.0.178 netmask 255.255.0.0 broadcast 10.1.255.255
#
##############################################################
my @adapter= split /\n{2,}/, $result;
foreach ( @adapter ) {
if ( !($_ =~ /LOOPBACK/ ) and
$_ =~ /UP( |,|>)/ and
$_ =~ /$mode/ ) {
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 =~ /^(eth\d:|ib\d:|hf\d:)\s+/) {
$nic = $1;
}
$ent=~ s/addr://; # works for Redhat7 also
if ( $ent =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) {
}
if ( $ent =~ /^\s*inet addr:\s*(\d+\.\d+\.\d+\.\d+)/ ) {
$iphash{$nic} = $1;
next;
}
@@ -1628,10 +1620,8 @@ sub gethost_ips
else
{
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
#@ip = split(":", $addr1);
#push @ipaddress, $ip[1];
$addr1 =~ s/.*://;
push @ipaddress, $addr1;
@ip = split(":", $addr1);
push @ipaddress, $ip[1];
}
}
else
@@ -1991,108 +1981,6 @@ sub isIpaddr
}
}
#-------------------------------------------------------------------------------
=head3 getSubnetGateway
Description:
Get gateway from the networks table of the specified net.
Arguments:
net: the net, ie. the "net" field of the networks table
Returns:
Return a string, of the gateway
undef - Failed to get the gateway
Globals:
none
Error:
none
Example:
my $gateway = xCAT::NetworkUtils::getSubnetGateway('192.168.1.0');
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub getSubnetGateway
{
my $netname=shift;
if( $netname =~ /xCAT::NetworkUtils/)
{
$netname=shift;
}
my $gateway=undef;
my $nettab = xCAT::Table->new("networks");
unless($nettab) { die "No entry defined in networks"; }
my @nets = $nettab->getAllAttribs('net','gateway');
foreach(@nets)
{
if("$_->{net}" eq "$netname")
{
$gateway = $_->{gateway};
last;
}
}
return $gateway;
}
#-------------------------------------------------------------------------------
=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
@@ -2119,23 +2007,17 @@ 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;
for my $net (keys %$nets)
{
my $netname;
($netname,$mask) = split /\//, $net;
$gateway=xCAT::NetworkUtils::getSubnetGateway($netname);
last if ( xCAT::NetworkUtils::isInSameSubnet( $netname, $ip, $mask, 1));
}
return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask,1,0));
return ($ip, $node, undef, xCAT::NetworkUtils::formatNetmask($mask,1,0));
}
#-------------------------------------------------------------------------------
+1 -1
View File
@@ -156,7 +156,7 @@ sub connect {
# Shell prompt regexp based on HW Type
##################################################
my %prompt = (
hmc => "~>\\s*\$",
hmc => "~> \$",
ivm => "\\\$ \$"
);
##################################################
+1 -33
View File
@@ -532,7 +532,7 @@ nodegroup => {
},
},
nodehm => {
cols => [qw(node power mgt cons termserver termport conserver serialport serialspeed serialflow getmac cmdmapping consoleondemand comments disable)],
cols => [qw(node power mgt cons termserver termport conserver serialport serialspeed serialflow getmac cmdmapping comments disable)],
keys => [qw(node)],
tablespace =>'XCATTBS16K',
table_desc => "Settings that control how each node's hardware is managed. Typically, an additional table that is specific to the hardware type of the node contains additional info. E.g. the ipmi, mp, and ppc tables.",
@@ -549,7 +549,6 @@ nodehm => {
serialflow => "The flow control value of the serial port for this node. For SOL this is typically 'hard'.",
getmac => 'The method to use to get MAC address of the node with the getmac command. If not set, the mgt attribute will be used. Valid values: same as values for mgmt attribute.',
cmdmapping => 'The fully qualified name of the file that stores the mapping between PCM hardware management commands and xCAT/third-party hardware management commands for a particular type of hardware device. Only used by PCM.',
consoleondemand => 'This overrides the value from site.consoleondemand; (0=no, 1=yes). Default is the result from site.consoleondemand.',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
@@ -917,11 +916,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".
@@ -942,12 +936,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".
" -------------------------\n".
"HARDWARE CONTROL ATTRIBUTES\n".
" -------------------------\n".
@@ -1103,10 +1091,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".
@@ -1579,18 +1563,6 @@ 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
@@ -1934,10 +1906,6 @@ my @nodeattrs = (
{attr_name => 'serialflow',
tabentry => 'nodehm.serialflow',
access_tabentry => 'nodehm.node=attr:node',
},
{attr_name => 'consoleondemand',
tabentry => 'nodehm.consoleondemand',
access_tabentry => 'nodehm.node=attr:node',
},
##################
# vpd table #
Executable → Regular
+3 -4
View File
@@ -429,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
@@ -622,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");
@@ -1177,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;
+1 -1
View File
@@ -222,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
-56
View File
@@ -3459,61 +3459,5 @@ sub fullpathbin
return $fullpath;
}
#--------------------------------------------------------------------------------
=head3 gettimezone
returns the name of the timezone defined on the Linux distro.
This routine was written to replace the use of /etc/sysconfig/clock which in no
longer supported on future Linux releases such as RHEL7. It is suppose to be a routine
that can find the timezone on any Linux OS or AIX.
Arguments:
none
Returns:
Name of timezone, for example US/Eastern
Globals:
none
Error:
None
Example:
my $timezone = xCAT::Utils->gettimezone();
Comments:
none
=cut
#--------------------------------------------------------------------------------
sub gettimezone
{
my ($class) = @_;
my $tz;
if (xCAT::Utils->isAIX()) {
$tz= $ENV{'TZ'};
} else { # all linux
my $localtime = "/etc/localtime";
my $zoneinfo = "/usr/share/zoneinfo";
my $cmd = "find $zoneinfo -type f -exec cmp -s $localtime {} \\; -print | grep -v posix | grep -v SystemV";
my $zone_result = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
$tz="Could not determine timezone checksum";
return $tz;
}
my @zones = split /\n/, $zone_result;
$zones[0] =~ s/$zoneinfo\///;
if (!$zones[0]) { # if we still did not get one, then default
$tz = `cat /etc/timezone`;
chomp $tz;
} else {
$tz=$zones[0];
}
}
return $tz;
}
1;
-2
View File
@@ -29,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",
@@ -71,7 +70,6 @@ require Exporter;
"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
"1194015916.783841" => "fedora8",
"1194015385.299901" => "fedora8",
"1210112435.291709" => "fedora9",
File diff suppressed because it is too large Load Diff
@@ -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
@@ -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);
}
@@ -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
@@ -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
+1 -1
View File
@@ -66,7 +66,7 @@ else { # the normal case of the user running the cmd - expand the noderange us
SSL_cert_file=> xCAT::Utils->getHomeDir()."/.xcat/client-cred.pem",
SSL_ca_file => xCAT::Utils->getHomeDir()."/.xcat/ca.pem",
SSL_use_cert => 1,
SSL_verify_mode => 1,
#SSL_verify_mode => 1,
);
die "Connection failure: $!\n" unless ($client);
my %cmdref = (command => 'noderange', noderange => $noderange);
-22
View File
@@ -119,28 +119,6 @@ Wake up the target nodes which is in B<suspend> state.
Don't try to run B<wake> against the 'on' state node, it would cause the node gets to 'off' state.
For some of xCAT hardware such as NeXtScale, it may need to enable S3 before using B<wake>. The following steps can be used to enable S3. Please reference L<pasu(1)|pasu.1> for "pasu" usage.
[root@xcatmn home]# echo "set Power.S3Enable Enable" > power-setting
[root@xcatmn home]# pasu -b power-setting node01
node01: Batch mode start.
node01: [set Power.S3Enable Enable]
node01: Power.S3Enable=Enable
node01:
node01: Beginning intermediate batch update.
node01: Waiting for command completion status.
node01: Command completed successfully.
node01: Completed intermediate batch update.
node01: Batch mode completed successfully.
[root@xcatmn home]# pasu node01 show all|grep -i s3
node01: IMM.Community_HostIPAddress3.1=
node01: IMM.Community_HostIPAddress3.2=
node01: IMM.Community_HostIPAddress3.3=
node01: IMM.DNS_IP_Address3=0.0.0.0
node01: IMM.IPv6DNS_IP_Address3=::
node01: Power.S3Enable=Enable
=item B<stat>|B<state>
Print the current power state/status.
-2
View File
@@ -49,8 +49,6 @@ Remove the DNS records.
Update DNS records to the external DNS server listed in /etc/resolv.conf.
Enabling the site attribute I<externaldns> means use 'external' DNS by default. If setting I<externaldns> to 1, you need NOT use B<-e> flag in every makedns call.
=item B<noderange>
A set of comma delimited node names and/or group names. See the "noderange" man page for details on additional supported formats.
+6
View File
@@ -253,6 +253,9 @@ dracut_install /usr/share/zoneinfo/posix/America/Knox_IN
dracut_install /usr/share/zoneinfo/posix/America/Goose_Bay
dracut_install /usr/share/zoneinfo/posix/EET
dracut_install /usr/share/zoneinfo/posix/EST5EDT
dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh89
dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh88
dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh87
dracut_install /usr/share/zoneinfo/posix/MST
dracut_install /usr/share/zoneinfo/posix/Iceland
dracut_install /usr/share/zoneinfo/posix/Atlantic/Faeroe
@@ -393,6 +396,7 @@ dracut_install /usr/share/zoneinfo/posix/NZ-CHAT
dracut_install /usr/share/zoneinfo/posix/Asia/Istanbul
dracut_install /usr/share/zoneinfo/posix/Asia/Kuwait
dracut_install /usr/share/zoneinfo/posix/Asia/Saigon
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh89
dracut_install /usr/share/zoneinfo/posix/Asia/Urumqi
dracut_install /usr/share/zoneinfo/posix/Asia/Brunei
dracut_install /usr/share/zoneinfo/posix/Asia/Ujung_Pandang
@@ -434,6 +438,7 @@ dracut_install /usr/share/zoneinfo/posix/Asia/Tokyo
dracut_install /usr/share/zoneinfo/posix/Asia/Macao
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh
dracut_install /usr/share/zoneinfo/posix/Asia/Rangoon
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh88
dracut_install /usr/share/zoneinfo/posix/Asia/Jakarta
dracut_install /usr/share/zoneinfo/posix/Asia/Aden
dracut_install /usr/share/zoneinfo/posix/Asia/Calcutta
@@ -471,6 +476,7 @@ dracut_install /usr/share/zoneinfo/posix/Asia/Tel_Aviv
dracut_install /usr/share/zoneinfo/posix/Asia/Taipei
dracut_install /usr/share/zoneinfo/posix/Asia/Kabul
dracut_install /usr/share/zoneinfo/posix/Asia/Macau
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh87
dracut_install /usr/share/zoneinfo/posix/Asia/Choibalsan
dracut_install /usr/share/zoneinfo/posix/Asia/Vientiane
dracut_install /usr/share/zoneinfo/posix/Asia/Dacca
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
instmods nfs sunrpc
instmods e1000 e1000e virtio_net igb enic ines sfc mlx4_en cxgb3 cxgb4 tg3 bnx2 bnx2x bna ixgb ixgbe qlge mptsas mpt2sas mpt3sas ata_piix megaraid_sas virtio_blk ahci ibmaem xhci-hcd sd_mod pmcraid be2net vfat ext3 ext4 btrfs reiserfs usb_storage scsi_wait_scan kvm kvm-intel kvm-amd ipmi_si ipmi_devintf
instmods e1000 e1000e virtio_net igb enic ines sfc mlx4_en cxgb3 cxgb4 tg3 bnx2 bnx2x bna ixgb ixgbe qlge mptsas mpt2sas ata_piix megaraid_sas virtio_blk ahci ibmaem xhci-hcd sd_mod pmcraid be2net vfat ext3 ext4 btrfs reiserfs usb_storage scsi_wait_scan kvm kvm-intel kvm-amd ipmi_si ipmi_devintf
instmods macvlan macvtap 8021q bridge bonding vmxnet3 cpufreq_ondemand acpi-cpufreq powernow-k8 cdc_ether
instmods mptctl #LSI firmware management requires this
instmods mlx4_ib ib_umad #make the mellanox ib available enough to examine /sys
+1 -1
View File
@@ -59,4 +59,4 @@ fi
%Files
%defattr(-,root,root)
/opt/xcat/share/xcat/netboot/genesis/%{tarch}
/
-1
View File
@@ -5,7 +5,6 @@ clear
echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bashrc
echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bash_profile
mkdir -p /etc/ssh
mkdir -p /var/tmp/
mkdir -p /var/empty/sshd
echo root:x:0:0::/:/bin/bash >> /etc/passwd
echo sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin >> /etc/passwd
+2 -2
View File
@@ -185,7 +185,7 @@ for bmcu in $BMCUS; do
if [ "$bmcu" = "" ]; then continue; fi
DISABLEUSERS="1 2 3 4"
if [ ! -z "$LOCKEDUSERS" ]; then
USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep -w "$BMCUS"|awk '{print $1}'`
USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep " $BMCUS"|awk '{print $1}'`
if [ -z "$USERSLOT" ]; then
USERSLOT=4
fi
@@ -220,7 +220,7 @@ done
TRIES=0
# Last param in ipmitool user priv is the channel to set it on.
# Penguin boxes are all channel 2
CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'`
CURRPRIV=`ipmitool -d $idev user list 1|grep ^$USERSLOT|awk '{print $6}'`
if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then
while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do
sleep 1
+1 -1
View File
@@ -7,6 +7,6 @@ Standards-Version: 3.7.2
Package: xcat-server
Architecture: all
Depends: ${perl:Depends}, perl-xcat (>= 2.5.0-1), xcat-client (>= 2.5.0-1), libsys-syslog-perl, libio-socket-ssl-perl, libxml-simple-perl, make, libdbd-sqlite3-perl, libexpect-perl, libnet-dns-perl, libsoap-lite-perl, libxml-libxml-perl, libsnmp-perl, debootstrap,libcrypt-rijndael-perl,libcrypt-cbc-perl
Depends: ${perl:Depends},grub2-xcat, perl-xcat (>= 2.5.0-1), xcat-client (>= 2.5.0-1), libsys-syslog-perl, libio-socket-ssl-perl, libxml-simple-perl, make, libdbd-sqlite3-perl, libexpect-perl, libnet-dns-perl, libsoap-lite-perl, libxml-libxml-perl, libsnmp-perl, debootstrap
Description: Server and configuration utilities of the xCAT management project
xCAT-server provides the core server and configuration management components of xCAT. This package should be installed on your management server
+1 -3
View File
@@ -1394,9 +1394,7 @@ sub collect_all_attribs_for_tables_in_template
$::GLOBAL_TAB_HASH{$tabname}{$node}{$attrib} = $ent->{$node}->[0]->{$attrib};
#for noderes.xcatmaster
if ($tabname =~ /^noderes$/ && $attrib =~ /^xcatmaster$/ &&
( ! exists($::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster}) ||
$::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster} == "" ) )
if ($tabname =~ /^noderes$/ && $attrib =~ /^xcatmaster$/ && $::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster} == "")
{
my $value;
$value = xCAT::NetworkUtils->my_ip_facing($node);
-1
View File
@@ -115,7 +115,6 @@ sub run_remote_shell_api {
my $rc=1;
if ($t) {
#Wait for command prompt
$t->print("\t");
my ($prematch, $match) = $t->waitfor(Match => '/login[: ]*$/i',
Match => '/username[: ]*$/i',
Match => '/password[: ]*$/i',
+5 -278
View File
@@ -14,7 +14,6 @@ use xCAT::ADUtils; #to allow setting of one-time machine passwords
use xCAT::Utils;
use xCAT::TableUtils;
use xCAT::NetworkUtils;
use XML::Simple;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
@@ -104,8 +103,6 @@ sub subvars {
$ENV{NODESTATUS}=$tmp;
}
#replace the env with the right value so that correct include files can be found
$inc =~ s/#ENV:([^#]+)#/envvar($1)/eg;
@@ -232,7 +229,6 @@ sub subvars {
$inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg;
$inc =~ s/#COMMAND:([^#]+)#/command($1)/eg;
$inc =~ s/#KICKSTARTNET#/kickstartnetwork()/eg;
$inc =~ s/#YAST2NET#/yast2network()/eg;
$inc =~ s/#ESXIPV6SETUP#/esxipv6setup()/eg;
$inc =~ s/#WINTIMEZONE#/xCAT::TZUtils::get_wintimezone()/eg;
$inc =~ s/#WINPRODKEY:([^#]+)#/get_win_prodkey($1)/eg;
@@ -243,7 +239,6 @@ sub subvars {
$inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg;
$inc =~ s/#MANAGEDADDRESSMODE#/managed_address_mode()/eg;
$inc =~ s/#HOSTNAME#/$node/g;
$inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg;
my $nrtab = xCAT::Table->new("noderes");
my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']);
@@ -276,9 +271,7 @@ sub subvars {
my $tempstr = "%include /tmp/partitionfile\n";
$inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/;
#modify the content in the file, and write into %pre part
#$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n";
$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent .= "chmod 755 /tmp/partscript\n";
$partcontent .= "/tmp/partscript\n";
#replace the #XCA_PARTITION_SCRIPT#
@@ -288,8 +281,7 @@ sub subvars {
elsif ($inc =~ /<!-- XCAT-PARTITION-START -->/){
my $tempstr = "<drive><device>XCATPARTITIONTEMP</device></drive>";
$inc =~ s/<!-- XCAT-PARTITION-START -->[\s\S]*<!-- XCAT-PARTITION-END -->/$tempstr/;
#$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n";
$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent .= "chmod 755 /tmp/partscript\n";
$partcontent .= "/tmp/partscript\n";
$inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/;
@@ -615,22 +607,6 @@ sub get_win_prodkey {
sub managed_address_mode {
return $::XCATSITEVALS{managedaddressmode};
}
sub get_node_domain {
my $lcnode=shift;
if ( $lcnode eq 'THISNODE' ){
$lcnode=$node;
}
my $nd = xCAT::NetworkUtils->getNodeDomains([$lcnode]);
my %nodedomains = %$nd;
my $domain=$nodedomains{$lcnode};
return $domain;
}
sub esxipv6setup {
if (not $::XCATSITEVALS{managedaddressmode} or $::XCATSITEVALS{managedaddressmode} =~ /v4/) { return ""; } # blank line for ipv4 schemes
my $v6addr;
@@ -656,12 +632,9 @@ sub esxipv6setup {
return 'esxcfg-vmknic -i '.$v6addr.'/64 "Management Network"'." #ESXISTATICV6\n";
}
sub kickstartnetwork {
my $line = "network --onboot=yes --bootproto=";
my $hoststab;
my $line = "network --onboot=yes --bootproto=";
my $hoststab;
my $mactab = xCAT::Table->new('mac',-create=>0);
unless ($mactab) { die "mac table should always exist prior to template processing when doing autoula"; }
my $ent = $mactab->getNodeAttribs($node,['mac'],prefetchcache=>1);
@@ -675,258 +648,12 @@ sub kickstartnetwork {
$hoststab->setNodeAttribs($node,{ip=>$ulaaddr});
$line .= $ulaaddr;
} elsif ($::XCATSITEVALS{managedaddressmode} =~ /static/) {
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) { die "cannot resolve the network configuration of $node"; }
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
$line .="static --device=$suffix --ip=$ipaddr --netmask=$netmask --gateway=$gateway --hostname=$hostname ";
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
#there is no network option to set dns search domain in kickstart, it will be set in %post
if (scalar @nameserversIP) {
$line .=" --nameserver=". join(",",@nameserversIP);
}
#return "#KSNET static unsupported";
return "#KSNET static unsupported";
} else {
$line .= "dhcp --device=$suffix";
}
return $line;
}
sub yast2network {
my $line;
my $hoststab;
my $mactab = xCAT::Table->new('mac',-create=>0);
unless ($mactab) { die "mac table should always exist prior to template processing when doing autoula"; }
my $ent = $mactab->getNodeAttribs($node,['mac'],prefetchcache=>1);
unless ($ent and $ent->{mac}) { die "missing mac data for $node"; }
my $suffix = $ent->{mac};
$suffix = lc($suffix);
if ($::XCATSITEVALS{managedaddressmode} eq "autoula") {
#TODO
return "#YAST2NET autoula unsupported"
} elsif ($::XCATSITEVALS{managedaddressmode} =~ /static/) {
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) { die "cannot resolve the network configuration of $node"; }
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
# get the domains for each node - one call for all nodes in hosts file
my $nd = xCAT::NetworkUtils->getNodeDomains([$node]);
my %nodedomains = %$nd;
my $domain=$nodedomains{$node};
my $networkhash={
'networking' => [
{
'dns' => [
{
'domain' => [
"$domain"
],
'dhcp_hostname' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'dhcp_resolv' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'nameservers' => [
{
'config:type' => 'list',
'nameserver' => [@nameserversIP]
}
],
'hostname' => [
$hostname
],
'searchlist' => [
{
'search' => [
$domain
],
'config:type' => 'list'
}
]
}
],
'interfaces' => [
{
'interface' => [
{
'bootproto' => [
'static'
],
'startmode' => [
'onboot'
],
'netmask' => [
$netmask
],
'device' => [
'eth0'
],
'ipaddr' => [
$ipaddr
]
}
],
'config:type' => 'list'
}
],
'routing' => [
{
'ip_forward' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'routes' => [
{
'route' => [
{
'destination' => [
'default'
],
'gateway' => [
$gateway
],
'netmask' => [
'-'
],
'device' => [
'-'
]
}
],
'config:type' => 'list'
}
]
}
]
}
]
};
my $xml = new XML::Simple(KeepRoot => 1);
$line=$xml->XMLout($networkhash);
#return "#KSNET static unsupported";
} else {
my $networkhash={
'networking' => [
{
'dns' => [
{
'domain' => [
'local'
],
'dhcp_hostname' => [
{
'content' => 'true',
'config:type' => 'boolean'
}
],
'hostname' => [
'linux'
],
'dhcp_resolv' => [
{
'content' => 'true',
'config:type' => 'boolean'
}
]
}
],
'interfaces' => [
{
'interface' => [
{
'startmode' => [
'onboot'
],
'bootproto' => [
'dhcp'
],
'device' => [
'eth0'
]
}
],
'config:type' => 'list'
}
],
'routing' => [
{
'ip_forward' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'routes' => [
{
'config:type' => 'list'
}
]
}
]
}
]
};
my $xml = new XML::Simple(KeepRoot => 1);
$line=$xml->XMLout($networkhash);
}
return $line;
}
sub autoulaaddress {
my $suffix = shift;
my $prefix = $::XCATSITEVALS{autoulaprefix};
-64
View File
@@ -10,7 +10,6 @@ use xCAT::Table;
use xCAT::MsgUtils;
use Data::Dumper;
use xCAT::NodeRange;
use xCAT::Utils;
#--------------------------------------------------------------------------------
=head1 xCAT::XCATD
@@ -271,67 +270,4 @@ sub validate {
xCAT::MsgUtils->message("S","Request matched no policy rule: peername=$peername, peerhost=$peerhost ".$request->{command}->[0]);
return 0;
}
my $tokentimeout = 86400; # one day
# this subroutine search the token table
# 1. find the existed token entry for the user and reset the expire time
# 1.1. if not find existed token, create a new one and add it to token table
# 2. clean up the expired token
#
# this subroutine is called after the account has been authorized
sub gettoken {
my $class=shift;
my $req = shift;
my $user = $req->{gettoken}->[0]->{username}->[0];
my $tokentb = xCAT::Table->new('token');
unless ($tokentb) {
return undef;
}
my $tokens = $tokentb->getAllEntries;
my $expiretime = time() + $tokentimeout;
foreach my $token (@{$tokens}) {
if ($token->{username} eq $user) {
#delete old token
$tokentb->delEntries({'tokenid'=>$token->{tokenid}});
} else {
#clean the expired token
if ($token->{expire} > $expiretime) {
$tokentb->delEntries({'tokenid'=>$token->{tokenid}});
}
}
}
# create a new token for this request
my $uuid = xCAT::Utils->genUUID();
$tokentb->setAttribs({tokenid=>$uuid, username => $user}, {expire => $expiretime});
$tokentb->close();
return ($uuid, $expiretime);
}
# verify the token has correct entry in token table and expire time is not exceeded.
sub verifytoken {
my $class=shift;
my $req = shift;
my $tokenid = $req->{tokens}->[0]->{tokenid}->[0];
my $tokentb = xCAT::Table->new('token');
unless ($tokentb) {
return undef;
}
my $token = $tokentb->getAttribs({'tokenid' => $tokenid}, ('username', 'expire'));
if (defined ($token) && defined ($token->{'username'}) && defined ($token->{'expire'})) {
my $expiretime = time() + $tokentimeout;
if ($token->{'expire'} < time()) {
$tokentb->delEntries({'tokenid'=>$token->{tokenid}});
return undef;
} else {
return $token->{'username'};
}
} else {
return undef;
}
}
1;
+13 -29
View File
@@ -380,7 +380,7 @@ sub processArgs
{
my $gotattrs = 0;
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
} else {
if ($::command eq "lsdef") {
@@ -391,9 +391,8 @@ sub processArgs
return 2;
}
}
if ( defined ($::args) && @{$::args} ) {
if ( scalar(@{$::args}) eq 1 and $::args->[0] eq '-S')
{
if ( scalar(@{$::args}) eq 1 and $::args->[0] eq '-S')
{
if ($::command eq "lsdef") {
push @ARGV, "-t";
push @ARGV, "node";
@@ -401,7 +400,6 @@ sub processArgs
} else {
return 2;
}
}
}
if ($::command eq "lsdef") {
@@ -2468,21 +2466,15 @@ sub defch
# give results
my $rsp;
my $nodenum = scalar(keys %::FINALATTRS);
if ($nodenum) {
$rsp->{data}->[0] =
"The database was updated for the following objects:";
xCAT::MsgUtils->message("I", $rsp, $::callback);
$rsp->{data}->[0] =
"The database was updated for the following objects:";
xCAT::MsgUtils->message("I", $rsp, $::callback);
my $n = 1;
foreach my $o (sort(keys %::FINALATTRS))
{
$rsp->{data}->[$n] = "$o\n";
$n++;
}
} else {
$rsp->{data}->[0] =
"No database was updated";
my $n = 1;
foreach my $o (sort(keys %::FINALATTRS))
{
$rsp->{data}->[$n] = "$o\n";
$n++;
}
xCAT::MsgUtils->message("I", $rsp, $::callback);
}
@@ -2490,13 +2482,8 @@ sub defch
{
my $rsp;
my $nodenum = scalar(keys %::FINALATTRS);
if ($nodenum) {
$rsp->{data}->[0] =
"$nodenum object definitions have been created or modified.";
} else {
$rsp->{data}->[0] =
"No object definitions have been created or modified.";
}
$rsp->{data}->[0] =
"$nodenum object definitions have been created or modified.";
xCAT::MsgUtils->message("I", $rsp, $::callback);
if (scalar(keys %newobjects) > 0)
{
@@ -2644,9 +2631,6 @@ sub setFINALattrs
{
# special case for the nic* attributes
# merge nic*.eth0, nic*.eth1
unless(exists($::CLIATTRS{$objname})) {
next;
}
if ($::CLIATTRS{$objname}{objtype} eq 'node')
{
# Even if only the nicips.eth0 is specified with CLI,
+2 -1
View File
@@ -232,7 +232,8 @@ sub parse_args
my $args = $request->{arg};
my $gotattrs = 0;
my %opt =();
if ( defined ($args) && @{$args}) {
if (defined(@{$args})) {
@ARGV = @{$args};
} else {
return 2;
+13 -20
View File
@@ -154,13 +154,6 @@ sub preprocess_request
# - either the NIMprime attr of the site table or the management node
my $nimprime = xCAT::InstUtils->getnimprime();
chomp $nimprime;
if (!defined($nimprime))
{
my $rsp={};
$rsp->{error}->[0] = "Could not determine nimprime. Check if nimprime defined in site table or site table master is not resolvable to the MN name.";
xCAT::MsgUtils->message("E", $rsp, $cb,1);
return undef;
}
my $nimprimeip = xCAT::NetworkUtils->getipaddr($nimprime);
if ($nimprimeip =~ /:/) #IPv6
{
@@ -624,7 +617,7 @@ sub nimnodeset
my $Sname = xCAT::InstUtils->myxCATname();
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -1800,7 +1793,7 @@ sub chkosimage
my $image_name;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -2267,7 +2260,7 @@ sub mknimimage
my $dump_name;
my $install_dir = xCAT::TableUtils->getInstallDir();
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -5705,7 +5698,7 @@ sub prermnimimage
my @servicenodes = (); # pass back list of service nodes
my %imagedef; # pass back image def hash
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -6215,7 +6208,7 @@ sub rmnimimage
%allsn = %{$nodehash};
}
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -7822,7 +7815,7 @@ sub prenimnodecust
@nodelist = @$nodes;
}
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -8060,7 +8053,7 @@ sub nimnodecust
@nodelist = @$nodes;
}
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -8217,7 +8210,7 @@ sub prenimnodeset
my $subreq = shift;
my $error = 0;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -9944,7 +9937,7 @@ sub define_SN_resource
}
my %attrs;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -10983,7 +10976,7 @@ sub mkdsklsnode
# - just set global for now
$::callback = $callback;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -12993,7 +12986,7 @@ sub make_SN_resource
}
my %attrs;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -13653,7 +13646,7 @@ sub prermdsklsnode
{
my $callback = shift;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -13763,7 +13756,7 @@ sub rmdsklsnode
# - just set global for now
$::callback = $callback;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
-49
View File
@@ -1377,19 +1377,12 @@ sub mkinstall
$instserver=$ent->{nfsserver};
}
if ($::XCATSITEVALS{managedaddressmode} =~ /static/){
unless($instserver eq '!myipfn!'){
my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($instserver);
$instserver=$ip;
}
}
my $httpprefix=$pkgdir;
if ($installroot =~ /\/$/) {
$httpprefix =~ s/^$installroot/\/install\//;
} else {
$httpprefix =~ s/^$installroot/\/install/;
}
my $kcmdline =
"quiet repo=$httpmethod://$instserver:$httpport$httpprefix ks=$httpmethod://"
. $instserver . ":". $httpport
@@ -1444,48 +1437,6 @@ sub mkinstall
unless ($ksdev eq "bootif" and $os =~ /7/) {
$kcmdline .= " ksdevice=" . $ksdev;
}
#if site.managedaddressmode=static, specify the network configuration as kernel options
#to avoid multicast dhcp
if($::XCATSITEVALS{managedaddressmode} =~ /static/){
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) {
$callback->(
{
error => [
"cannot resolve the ip address of $node"
],
errorcode => [1]
}
);
}
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
$kcmdline .=" ip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname ";
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
if(scalar @nameserversIP){
$kcmdline .=" dns=".join(",",@nameserversIP);
}
}
#TODO: dd=<url> for driver disks
if (defined($sent->{serialport}))
+2 -15
View File
@@ -12,7 +12,6 @@ use strict;
use Data::Dumper;
my @cservers = qw(mrv cyclades);
my %termservers; #list of noted termservers
my $siteondemand; # The site value for consoleondemand
my $usage_string=
" makeconservercf [-d|--delete] noderange
@@ -277,10 +276,6 @@ sub docfheaders {
my $site_entry = $entries[0];
if ( defined($site_entry) and $site_entry eq "yes" ) {
push @newheaders," options ondemand;\n";
$siteondemand=1;
}
else {
$siteondemand=0;
}
push @newheaders,"}\n";
@@ -327,7 +322,7 @@ sub makeconservercf {
my $hmtab = xCAT::Table->new('nodehm');
my @cfgents1;# = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport']);
if (($nodes and @$nodes > 0) or $req->{noderange}->[0]) {
@cfgents1 = $hmtab->getNodesAttribs($nodes,['node','cons','serialport','mgt','conserver','termserver','termport','consoleondemand']);
@cfgents1 = $hmtab->getNodesAttribs($nodes,['node','cons','serialport','mgt','conserver','termserver','termport']);
# Adjust the data structure to make the result consistent with the getAllNodeAttribs() call we make if a noderange was not specified
my @tmpcfgents1;
foreach my $ent (@cfgents1)
@@ -340,7 +335,7 @@ sub makeconservercf {
@cfgents1 = @tmpcfgents1
} else {
@cfgents1 = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport','consoleondemand']);
@cfgents1 = $hmtab->getAllNodeAttribs(['cons','serialport','mgt','conserver','termserver','termport']);
}
@@ -543,14 +538,6 @@ foreach my $node (sort keys %$cfgenthash) {
push @$content," exec $locerror".$::XCATROOT."/share/xcat/cons/".$cmeth." ".$node.";\n"
}
}
if (defined($cfgent->{consoleondemand})) {
if ($cfgent->{consoleondemand} && !$siteondemand ) {
push @$content," options ondemand;\n";
}
elsif (!$cfgent->{consoleondemand} && $siteondemand ) {
push @$content," options !ondemand;\n";
}
}
push @$content,"}\n";
push @$content,"#xCAT END $node CONS\n";
}
+221 -228
View File
@@ -51,7 +51,7 @@ sub getzonesfornet {
die "Not supporting having a mask like $mask on an ipv6 network like $net";
}
my $netnum= getipaddr($net,GetNumber=>1);
unless ($netnum) { return (); }
unless ($netnum) { return (); }
$netnum->brsft(128-$maskbits);
my $prefix=$netnum->as_hex();
my $nibbs=$maskbits/4;
@@ -228,9 +228,6 @@ sub process_request {
return;
}
}
if ($::XCATSITEVALS{externaldns}) {
$external=1;
}
if ($help)
{
@@ -285,6 +282,7 @@ sub process_request {
xCAT::SvrUtils::sendmsg([0,"Warning:SELINUX is not disabled. The makedns command will not be able to generate a complete DNS setup. Disable SELINUX and run the command again."], $callback);
}
my @entries = xCAT::TableUtils->get_site_attribute("nameservers");
my $sitens = $entries[0];
unless ( defined($site_entry)) {
@@ -297,6 +295,7 @@ sub process_request {
unless ($networkstab) { xCAT::SvrUtils::sendmsg([1,'Unable to enumerate networks, try to run makenetworks'], $callback); }
my @networks = $networkstab->getAllAttribs('net','mask','ddnsdomain','domain','nameservers');
# exclude the net if it is using an external dns server.
foreach my $net (@networks)
{
@@ -325,73 +324,73 @@ sub process_request {
if ($allnodes) {
#read all nodelist specified nodes
} else {
if (not $request->{node} and $deletemode) {
#when this was permitted, it really ruined peoples' days
xCAT::SvrUtils::sendmsg([1,"makedns -d without noderange or -a is not supported"],$callback);
umask($oldmask);
return;
}
my @contents;
my $domain;
if ($request->{node}) { #leverage makehosts code to flesh out the options
require xCAT_plugin::hosts;
my @content1;
my @content2;
xCAT_plugin::hosts::add_hosts_content(nodelist=>$request->{node},callback=>$callback,hostsref=>\@content1);
xCAT_plugin::hosts::donics(nodes=>$request->{node},callback=>$callback,hostsref=>\@content2);
if (not $request->{node} and $deletemode) {
#when this was permitted, it really ruined peoples' days
xCAT::SvrUtils::sendmsg([1,"makedns -d without noderange or -a is not supported"],$callback);
umask($oldmask);
return;
}
my @contents;
my $domain;
if ($request->{node}) { #leverage makehosts code to flesh out the options
require xCAT_plugin::hosts;
my @content1;
my @content2;
xCAT_plugin::hosts::add_hosts_content(nodelist=>$request->{node},callback=>$callback,hostsref=>\@content1);
xCAT_plugin::hosts::donics(nodes=>$request->{node},callback=>$callback,hostsref=>\@content2);
@contents = (@content1, @content2);
} else {
#legacy behavior, read from /etc/hosts
my $hostsfile;
open($hostsfile,"<","/etc/hosts");
flock($hostsfile,LOCK_SH);
@contents = <$hostsfile>;
flock($hostsfile,LOCK_UN);
close($hostsfile);
}
} else {
#legacy behavior, read from /etc/hosts
my $hostsfile;
open($hostsfile,"<","/etc/hosts");
flock($hostsfile,LOCK_SH);
@contents = <$hostsfile>;
flock($hostsfile,LOCK_UN);
close($hostsfile);
}
my $addr;
my $name;
my $canonical;
my $aliasstr;
my @aliases;
my $names;
my @hosts;
my %nodehash;
foreach (@contents) {
chomp; #no newline
s/#.*//; #strip comments;
s/^[ \t\n]*//; #remove leading whitespace
next unless ($_); #skip empty lines
($addr,$names) = split /[ \t]+/,$_,2;
if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/ and $addr !~ /^[abcdef0123456789:]+$/) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, address seems malformed.", $callback);
next;
}
unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback);
next;
}
my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr);
push @hosts, $host;
$nodehash{$addr}{names}=$names;
$nodehash{$addr}{host}=$host;
}
my @hosts;
my %nodehash;
# get the domains for each node - one call for all nodes in hosts file
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
foreach my $n (keys %nodehash) {
$addr=$n;
$names=$nodehash{$n}{names};
# - need domain for this node
my $host = $nodehash{$n}{host};
$domain=$nodedomains{$host};
# remove the first . at domain name since it's not accepted by high dns parser
if ($domain =~ /^\./) { $domain =~ s/^\.//;; }
foreach (@contents) {
chomp; #no newline
s/#.*//; #strip comments;
s/^[ \t\n]*//; #remove leading whitespace
next unless ($_); #skip empty lines
($addr,$names) = split /[ \t]+/,$_,2;
if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/ and $addr !~ /^[abcdef0123456789:]+$/) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, address seems malformed.", $callback);
next;
}
unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback);
next;
}
my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr);
push @hosts, $host;
$nodehash{$addr}{names}=$names;
$nodehash{$addr}{host}=$host;
}
# get the domains for each node - one call for all nodes in hosts file
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
foreach my $n (keys %nodehash) {
$addr=$n;
$names=$nodehash{$n}{names};
# - need domain for this node
my $host = $nodehash{$n}{host};
$domain=$nodedomains{$host};
# remove the first . at domain name since it's not accepted by high dns parser
if ($domain =~ /^\./) { $domain =~ s/^\.//;; }
($canonical,$aliasstr) = split /[ \t]+/,$names,2;
if ($aliasstr) {
@@ -407,7 +406,7 @@ sub process_request {
unless ($canonical =~ /$domain/) {
$canonical.=".".$domain;
}
# for only the sake of comparison, ensure consistant dot suffix
# for only the sake of comparison, ensure consistant dot suffix
unless ($canonical =~ /\.\z/) { $canonical .= '.' }
foreach my $alias (@aliases) {
unless ($alias =~ /$domain/) {
@@ -419,13 +418,13 @@ sub process_request {
if ($alias eq $canonical) {
next;
}
# remember alias for CNAM records later
# remember alias for CNAM records later
$ctx->{aliases}->{$node}->{$alias}=1;
}
# exclude the nodes not belong to any nets defined in networks table
# because only the nets defined in networks table will be add
# zones later.
# zones later.
my $found = 0;
foreach (@networks)
{
@@ -508,13 +507,13 @@ sub process_request {
$ctx->{domain} =~ s/^\.//; # remove . if it's the first char of domain name
$ctx->{zonestotouch}->{$ctx->{domain}}=1;
foreach (@networks) {
if ($_->{domain}) {
$_->{domain} =~ s/^\.//; # remove . if it's the first char of domain name
$ctx->{zonestotouch}->{$_->{domain}}=1;
}
}
foreach (@networks) {
if ($_->{domain}) {
$_->{domain} =~ s/^\.//; # remove . if it's the first char of domain name
$ctx->{zonestotouch}->{$_->{domain}}=1;
}
}
xCAT::SvrUtils::sendmsg("Getting reverse zones, this may take several minutes for a large cluster.", $callback);
foreach (@nodes) {
@@ -528,10 +527,10 @@ sub process_request {
xCAT::SvrUtils::sendmsg("Completed getting reverse zones.", $callback);
if (1) {
#TODO: function to detect and return 1 if the master server is
# DNS SOA for all the zones we care about here, we are examining
#TODO: function to detect and return 1 if the master server is
# DNS SOA for all the zones we care about here, we are examining
# files to assure that our key is in named.conf, the zones we
# care about are there, and that if active directory is in use,
# care about are there, and that if active directory is in use,
# allow the domain controllers to update specific zones
@entries = xCAT::TableUtils->get_site_attribute("directoryprovider");
$site_entry = $entries[0];
@@ -541,13 +540,13 @@ sub process_request {
if ( defined($site_entry)) {
my @dservers = split /[ ,]/,$site_entry;
$ctx->{adservers} = \@dservers;
############################
# - should this include all domains?
# - multi-domains not supported with activedirectory
# - TODO in future release
###################
############################
# - should this include all domains?
# - multi-domains not supported with activedirectory
# - TODO in future release
###################
$ctx->{adzones} = {
"_msdcs.". $ctx->{domain} => 1,
"_sites.". $ctx->{domain} => 1,
@@ -556,109 +555,50 @@ sub process_request {
};
}
}
@entries = xCAT::TableUtils->get_site_attribute("dnsupdaters");
$site_entry = $entries[0];
if ( defined($site_entry) ) {
my @nservers = split /[ ,]/,$site_entry;
$ctx->{dnsupdaters} = \@nservers;
my @nservers = split /[ ,]/,$site_entry;
$ctx->{dnsupdaters} = \@nservers;
}
unless ($external) { # only generate the named.conf and zone files for xCAT dns when NOT using external dns
if ($zapfiles || $slave) { #here, we unlink all the existing files to start fresh
if (xCAT::Utils->isAIX())
{
system("/usr/bin/stopsrc -s $service");
}
else
{
system("service $service stop"); #named may otherwise hold on to stale journal filehandles
}
my $conf = get_conf();
unlink $conf;
my $DBDir = get_dbdir();
foreach (<$DBDir/db.*>) {
unlink $_;
}
}
#We manipulate local namedconf
$ctx->{dbdir} = get_dbdir();
$ctx->{zonesdir} = get_zonesdir();
chmod 0775, $ctx->{dbdir}; # assure dynamic dns can actually execute against the directory
update_namedconf($ctx, $slave);
unless ($slave)
if ($zapfiles || $slave) { #here, we unlink all the existing files to start fresh
if (xCAT::Utils->isAIX())
{
update_zones($ctx);
system("/usr/bin/stopsrc -s $service");
}
if ($ctx->{restartneeded}) {
xCAT::SvrUtils::sendmsg("Restarting $service", $callback);
if (xCAT::Utils->isAIX())
{
#try to stop named
my $cmd = "/usr/bin/stopsrc -s $service";
my @output=xCAT::Utils->runcmd($cmd, 0);
$cmd = "/usr/bin/startsrc -s $service";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
}
else
{
my $cmd = "service $service stop";
my @output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
$cmd = "service $service start";
@output=xCAT::Utils->runcmd($cmd, 0);
$outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
}
xCAT::SvrUtils::sendmsg("Restarting named complete", $callback);
else
{
system("service $service stop"); #named may otherwise hold on to stale journal filehandles
}
my $conf = get_conf();
unlink $conf;
my $DBDir = get_dbdir();
foreach (<$DBDir/db.*>) {
unlink $_;
}
}
} else {
unless ($ctx->{privkey}) {
xCAT::SvrUtils::sendmsg([1,"Unable to update DNS due to lack of credentials in passwd to communicate with remote server"], $callback);
}
}
if ($slave)
{
return;
}
#We manipulate local namedconf
$ctx->{dbdir} = get_dbdir();
$ctx->{zonesdir} = get_zonesdir();
chmod 0775, $ctx->{dbdir}; # assure dynamic dns can actually execute against the directory
# check if named is active before update dns records.
unless ($external) { # only start xCAT local dns when NOT using external dns
if (xCAT::Utils->isAIX())
update_namedconf($ctx, $slave);
unless ($slave)
{
my $cmd = "/usr/bin/lssrc -s $service |grep active";
my @output=xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
update_zones($ctx);
}
if ($ctx->{restartneeded}) {
xCAT::SvrUtils::sendmsg("Restarting $service", $callback);
if (xCAT::Utils->isAIX())
{
#try to stop named
my $cmd = "/usr/bin/stopsrc -s $service";
my @output=xCAT::Utils->runcmd($cmd, 0);
$cmd = "/usr/bin/startsrc -s $service";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
@@ -670,15 +610,10 @@ sub process_request {
return;
}
}
}
else
{
my $cmd = "service $service status|grep running";
my @output=xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
else
{
$cmd = "service $service start";
@output=xCAT::Utils->runcmd($cmd, 0);
my $cmd = "service $service stop";
my @output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
@@ -687,19 +622,79 @@ sub process_request {
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
$cmd = "service $service start";
@output=xCAT::Utils->runcmd($cmd, 0);
$outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
}
xCAT::SvrUtils::sendmsg("Restarting named complete", $callback);
}
} else {
unless ($ctx->{privkey}) {
xCAT::SvrUtils::sendmsg([1,"Unable to update DNS due to lack of credentials in passwd to communicate with remote server"], $callback);
}
}
if ($slave)
{
return;
}
# check if named is active before update dns records.
if (xCAT::Utils->isAIX())
{
my $cmd = "/usr/bin/lssrc -s $service |grep active";
my @output=xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
$cmd = "/usr/bin/startsrc -s $service";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
}
}
else
{
my $cmd = "service $service status|grep running";
my @output=xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
$cmd = "service $service start";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
}
}
#now we stick to Net::DNS style updates, with TSIG if possible. TODO: kerberized (i.e. Windows) DNS server support, maybe needing to use nsupdate -g....
if ($external)
{
# based on /etc/resolv.conf
# based on /etc/resolv.conf
$ctx->{resolver} = Net::DNS::Resolver->new();
}
else
{
# default to localhost
# default to localhost
$ctx->{resolver} = Net::DNS::Resolver->new(nameservers=>['127.0.0.1']);
}
@@ -717,9 +712,9 @@ sub get_zonesdir {
my @entries = xCAT::TableUtils->get_site_attribute("bindzones");
my $site_entry = $entries[0];
if ( defined($site_entry) ) {
$ZonesDir= $site_entry;
}
if ( defined($site_entry) ) {
$ZonesDir= $site_entry;
}
return "$ZonesDir";
}
@@ -728,16 +723,16 @@ sub get_conf {
my $conf="/etc/named.conf";
# is this ubuntu ?
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
$conf="/etc/bind/named.conf";
}
my @entries = xCAT::TableUtils->get_site_attribute("bindconf");
my $site_entry = $entries[0];
if ( defined($site_entry) ) {
$conf= $site_entry;
}
if ( defined($site_entry) ) {
$conf= $site_entry;
}
return "$conf";
}
@@ -747,9 +742,9 @@ sub get_dbdir {
my @entries = xCAT::TableUtils->get_site_attribute("binddir");
my $site_entry = $entries[0];
if ( defined($site_entry) ) {
$DBDir = $site_entry;
}
if ( defined($site_entry) ) {
$DBDir = $site_entry;
}
if ( -d "$DBDir" ) {
return "$DBDir"
@@ -790,13 +785,13 @@ sub update_zones {
my $name = hostname;
my $node = $name;
# get the domain for the node - which is the local hostname
my ($host, $nip) = xCAT::NetworkUtils->gethostnameandip($node);
my @hosts;
push (@hosts, $host);
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
my $domain = $nodedomains{$host};
# get the domain for the node - which is the local hostname
my ($host, $nip) = xCAT::NetworkUtils->gethostnameandip($node);
my @hosts;
push (@hosts, $host);
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
my $domain = $nodedomains{$host};
xCAT::SvrUtils::sendmsg("Updating zones.", $callback);
@@ -830,7 +825,7 @@ sub update_zones {
my $serial = ($mday * 100) + (($mon + 1) * 10000) + (($year + 1900) * 1000000);
foreach $currzone (@neededzones) {
my $zonefilename = $currzone;
my $zonefilename = $currzone;
if ($currzone =~ /IN-ADDR\.ARPA/) {
$currzone =~ s/\.IN-ADDR\.ARPA.*//;
my @octets = split/\./,$currzone;
@@ -854,7 +849,7 @@ sub update_zones {
}
flock($zonehdl,LOCK_UN);
close($zonehdl);
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
chown(scalar(getpwnam('root')),scalar(getgrnam('bind')),$dbdir."/db.$zonefilename");
}
else{
@@ -890,7 +885,7 @@ sub update_namedconf {
$gotoptions=1;
my $skip=0;
do {
#push @newnamed,"\t\t//listen-on-v6 { any; };\n";
#push @newnamed,"\t\t//listen-on-v6 { any; };\n";
if ($ctx->{forwarders} and $line =~ /forwarders {/) {
push @newnamed,"\tforwarders \{\n";
$skip=1;
@@ -1006,11 +1001,11 @@ sub update_namedconf {
}
}
unless ($gotoptions) {
push @newnamed,"options {\n";
push @newnamed,"options {\n";
unless ($slave && xCAT::Utils->isLinux()) {
push @newnamed,"\tdirectory \"".$ctx->{zonesdir}."\";\n";
}
push @newnamed,"\t\t//listen-on-v6 { any; };\n";
push @newnamed,"\t\t//listen-on-v6 { any; };\n";
if ($ctx->{forwarders}) {
push @newnamed,"\tforwarders {\n";
foreach (@{$ctx->{forwarders}}) {
@@ -1038,7 +1033,6 @@ sub update_namedconf {
}
push @newnamed,"};\n\n";
}
unless ($slave) {
unless ($gotkey) {
unless ($ctx->{privkey}) { #need to generate one
@@ -1129,7 +1123,7 @@ sub update_namedconf {
for my $l (@newnamed) { print $newnameconf $l; }
flock($newnameconf,LOCK_UN);
close($newnameconf);
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
chown (scalar(getpwnam('root')),scalar(getgrnam('bind')),$namedlocation);
}
else{
@@ -1157,9 +1151,9 @@ sub add_or_delete_records {
$ctx->{nsmap} = {}; #will store a map to known NS records to avoid needless redundant queries to sort nodes into domains
$ctx->{updatesbyzone}={}; #sort all updates into their respective zones for bulk update for fewer DNS transactions
# get node domains
my $nd = xCAT::NetworkUtils->getNodeDomains(\@{$ctx->{nodes}});
my %nodedomains = %{$nd};
# get node domains
my $nd = xCAT::NetworkUtils->getNodeDomains(\@{$ctx->{nodes}});
my %nodedomains = %{$nd};
foreach $node (@{$ctx->{nodes}}) {
my $name = $node;
@@ -1169,8 +1163,8 @@ sub add_or_delete_records {
next;
}
my $domain = $nodedomains{$node};
if ($domain =~ /^\./) { $domain =~ s/^\.//; } # remove . if it's the first char of domain name
my $domain = $nodedomains{$node};
if ($domain =~ /^\./) { $domain =~ s/^\.//; } # remove . if it's the first char of domain name
unless ($name =~ /$domain/) { $name .= ".".$domain } # $name needs to represent fqdn, but must preserve $node as a nodename for cfg lookup
@@ -1178,9 +1172,9 @@ sub add_or_delete_records {
@ips = ($ctx->{hoststab}->{$node}->[0]->{ip});
} else {
@ips = getipaddr($node,GetAllAddresses=>1);
if (not @ips and keys %{$ctx->{nodeips}->{$node}}) {
@ips = keys %{$ctx->{nodeips}->{$node}};
}
if (not @ips and keys %{$ctx->{nodeips}->{$node}}) {
@ips = keys %{$ctx->{nodeips}->{$node}};
}
if (!defined($ips[0])) {
xCAT::SvrUtils::sendmsg([1,"Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts)"], $callback);
next;
@@ -1215,12 +1209,11 @@ sub add_or_delete_records {
}
my $zone;
foreach $zone (keys %{$ctx->{updatesbyzone}}) {
my $ip = xCAT::NetworkUtils->getipaddr($ctx->{nsmap}->{$zone});
my $ip = xCAT::NetworkUtils->getipaddr($ctx->{nsmap}->{$zone});
if( !defined $ip) {
xCAT::SvrUtils::sendmsg([1,"Please make sure $ctx->{nsmap}->{$zone} exist either in /etc/hosts or DNS."], $callback);
xCAT::SvrUtils::sendmsg([1,"Please make sure $ctx->{nsmap}->{$zone} exist in /etc/hosts or DNS."], $callback);
return 1;
}
my $resolver = Net::DNS::Resolver->new(nameservers=>[$ip]);
my $entry;
my $numreqs = 300; # limit to 300 updates in a payload, something broke at 644 on a certain sample, choosing 300 for now
@@ -1297,9 +1290,9 @@ sub find_nameserver_for_dns {
}
if (defined $ctx->{aliases}->{$node}) {
foreach (keys %{$ctx->{aliases}->{$node}}) {
push @rrcontent, "$_ IN CNAME $name";
}
foreach (keys %{$ctx->{aliases}->{$node}}) {
push @rrcontent, "$_ IN CNAME $name";
}
}
if ($ctx->{deletemode}) {
push @rrcontent,"$name TXT";
@@ -1312,7 +1305,7 @@ sub find_nameserver_for_dns {
unless (defined $ctx->{nsmap}->{$zone}) { #ok, we already thought about this zone and made a decision
if ($zone =~ /^\.*192.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*172.IN-ADDR.ARPA\.*/ or $zone =~ /127.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*IN-ADDR.ARPA\.*/ or $zone =~ /^\.*ARPA\.*/) {
$ctx->{nsmap}->{$zone} = 0; #ignore zones that are likely to appear, but probably not ours
} elsif ($::XCATSITEVALS{ddnsserver}) {
} elsif ($::XCATSITEVALS{ddnsserver}) {
$ctx->{nsmap}->{$zone} = $::XCATSITEVALS{ddnsserver};
} else {
my $reply = $ctx->{resolver}->query($zone,'NS');
@@ -1393,9 +1386,9 @@ sub get_dns_slave
foreach my $sn (@ents)
{
if ($sn->{'nameserver'} == 2)
{
{
push @sns, $sn->{'node'};
}
}
}
@slaves = xCAT::NodeRange::noderange(join(',',@sns));
+2 -7
View File
@@ -884,15 +884,10 @@ sub check_options
# if not help and not -n, dhcpd needs to be running
if (!($opt->{h})&& (!($opt->{n}))) {
if (xCAT::Utils->isLinux()) {
my $DHCPSERVER="dhcpd";
if( -e "/etc/init.d/isc-dhcp-server" ){
$DHCPSERVER="isc-dhcp-server";
}
my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1);
my @output = xCAT::Utils->runcmd("service dhcpd status", -1);
if ($::RUNCMD_RC != 0) { # not running
my $rsp = {};
$rsp->{data}->[0] = "$DHCPSERVER is not running. Run service $DHCPSERVER start and rerun your command.";
$rsp->{data}->[0] = "dhcpd is not running. Run service dhcpd start and rerun your command.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return 1;
}
+3 -4
View File
@@ -1332,7 +1332,7 @@ sub fpc_firmxfer_watch {
return;
}
my $percent = 0;
if ($rsp->{data} and (scalar(@{$rsp->{data}}) > 0)) {
if ($rsp->{data} and (length(@{$rsp->{data}}) > 0)) {
$percent = $rsp->{data}->[0];
}
#$callback->({sinfo=>"$percent%"});
@@ -2971,13 +2971,12 @@ sub parsefru {
my $currsize;
if ($bytes->[$curridx] <= 5) { #don't even try to parse unknown stuff
#some records don't comply to any SPEC
while (not $last and $curridx < (scalar @$bytes)) {
while (not $last) {
if ($bytes->[$curridx+1] & 128) {
$last=1;
}
$currsize=$bytes->[$curridx+2];
push @{$fruhash->{extra}},@{$bytes}[$curridx..$curridx+4+$currsize-1];
$curridx += 5 + $currsize;
push @{$fruhash->{extra}},$bytes->[$curridx..$curridx+4+$currsize-1];
}
}
}
+4 -3
View File
@@ -3563,7 +3563,8 @@ sub create_error_response {
#-----------------------------------------------------------------------------
sub lskit_processargs {
if ( defined ($::args) && @{$::args} ){
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
@@ -3664,7 +3665,7 @@ sub lskit_processargs {
#-----------------------------------------------------------------------------
sub lskitcomp_processargs {
if ( defined ($::args) && @{$::args} ){
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
@@ -3757,7 +3758,7 @@ sub lskitcomp_processargs {
#-----------------------------------------------------------------------------
sub lskitdeployparam_processargs {
if ( defined ($::args) && @{$::args} ){
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
+1 -1
View File
@@ -192,7 +192,7 @@ sub lskmodules_usage {
#-----------------------------------------------------------------------------
sub processArgs {
if ( defined ($::args) && @{$::args} ) {
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
-45
View File
@@ -4,13 +4,11 @@
# This plugin is used to handle the command requests for Xeon Phi (mic) support
#
package xCAT_plugin::mic;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
use strict;
use Getopt::Long;
@@ -615,28 +613,6 @@ sub rflash {
my @args = ("-s", "-v", "-e");
push @args, "$::XCATROOT/sbin/flashmic";
my $master = $request->{'_xcatdest'};
# in case there are multiple servicenode entries, assume the first entry
# is the master
($master) = split (/,/,$master);
# assume that all hosts are on the same network connected to this master
# (otherwise, will need to move this call into loop above for each host
# and build separate miccfg calls for each unique returned value from
# my_ip_facing)
my $ipfn = xCAT::NetworkUtils->my_ip_facing(@hosts[0]);
if ($ipfn) {
$master = $ipfn;
} else {
my $hostname = "";
my $hostnamecmd = "/bin/hostname";
my @thostname = xCAT::Utils->runcmd($hostnamecmd, 0);
if ($::RUNCMD_RC = 0) {
$hostname = "from server $thostname[0]";
}
xCAT::MsgUtils->message("E", {error=>["Cannot detect an active network interface $hostname to @hosts[0]."], errorcode=>["1"]}, $callback);
return;
}
push @args, ("-m", "$master");
push @args, ("-p", "$tftpdir/xcat/miccfg");
@@ -937,27 +913,6 @@ sub nodeset {
my @args = ("-s", "-v", "-e");
push @args, "$::XCATROOT/sbin/configmic";
my $master = $request->{'_xcatdest'};
# in case there are multiple servicenode entries, assume the first entry
# is the master
($master) = split (/,/,$master);
# assume that all hosts are on the same network connected to this master
# (otherwise, will need to move this call into loop above for each host
# and build separate miccfg calls for each unique returned value from
# my_ip_facing)
my $ipfn = xCAT::NetworkUtils->my_ip_facing(@hosts[0]);
if ($ipfn) {
$master = $ipfn;
} else {
my $hostname = "";
my $hostnamecmd = "/bin/hostname";
my @thostname = xCAT::Utils->runcmd($hostnamecmd, 0);
if ($::RUNCMD_RC = 0) {
$hostname = "from server $thostname[0]";
}
xCAT::MsgUtils->message("E", {error=>["Cannot detect an active network interface $hostname to @hosts[0]."], errorcode=>["1"]}, $callback);
return;
}
push @args, ("-m", "$master");
push @args, ("-p", "$tftpdir/xcat/miccfg");
+3 -2
View File
@@ -26,7 +26,8 @@ sub preprocess_request
my @requests = ({%$req}); #first element is local instance
$::args = $req->{arg};
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
}
@@ -87,7 +88,7 @@ sub process_request
$::args = $request->{arg};
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
}
+2 -2
View File
@@ -412,13 +412,13 @@ sub create_imgconf_file {
my $rootpw = undef;
my $passwdtab = xCAT::Table->new('passwd');
if ($passwdtab) {
my $et = $passwdtab->getAttribs({key => 'vios', username => 'padmin'}, 'password');
my $et = $passwdtab->getAttribs({key => 'system', username => 'root'}, 'password');
if ($et and defined ($et->{'password'})) {
$rootpw = $et->{'password'};
}
}
unless (defined($rootpw)) {
return "Unable to find requested password from passwd, with key=vios,username=padmin";
return "Unable to find requested password from passwd, with key=system,username=root";
}
unless (-e $bootimg_root."/viobootimg") {
return "Unable to find VIOS bootimg file";
+48 -63
View File
@@ -54,7 +54,6 @@ my $command;
my $args;
# Put arguments in a hash.
my %args_dict;
my %general_arg;
#-------------------------------------------------------
@@ -101,8 +100,6 @@ sub process_request {
$command = $request->{command}->[0];
$args = $request->{arg};
my $gereral_arg = get_general_args();
# There is no need to acquire lock for command nodediscoverstatus, nodediscoverls and noderegenips.
if ($command eq "nodediscoverstatus"){
nodediscoverstatus();
@@ -115,11 +112,7 @@ sub process_request {
return;
}
my $non_block = 1;
if ( $general_arg{'blockmode'} == 1) {
$non_block = 0;
}
my $lock = xCAT::Utils->acquire_lock("nodemgmt", $non_block);
my $lock = xCAT::Utils->acquire_lock("nodemgmt", 1);
if (! $lock){
setrsp_errormsg("Cannot acquire lock, another process is already running.");
return;
@@ -138,7 +131,7 @@ sub process_request {
);
setrsp_errormsg("Cannot $errormsg_dict{$command} while node discovery is running.");
xCAT::Utils->release_lock($lock, $non_block);
xCAT::Utils->release_lock($lock, 1);
return;
}
}
@@ -163,32 +156,7 @@ sub process_request {
nodechmac();
}
xCAT::Utils->release_lock($lock, $non_block);
}
sub get_general_args
{
my ($help, $ver, $blockmode);
%general_arg = ();
@ARGV = ();
if($args) {
@ARGV = @$args;
}
GetOptions(
'h|help' => \$help,
'v|version' => \$ver,
'b|block' => \$blockmode,
);
if($help){
$general_arg{'help'} = 1;
}
if($ver){
$general_arg{'version'} = 1;
}
if ($blockmode) {
$general_arg{'blockmode'} = 1;
}
xCAT::Utils->release_lock($lock, 1);
}
#-------------------------------------------------------
@@ -234,21 +202,37 @@ sub validate_args{
my $enabledparamsref = shift;
my $mandatoryparamsref = shift;
if ($general_arg{'help'} == 1){
my %process_help_commands = (
'nodediscoverstart' => 1,
'nodediscoverstop' => 1,
'nodediscoverls' => 1,
'nodediscoverstatus' => 1,
);
# The -h -v are handled by seqdiscovery.pm
# -t -u -l only works for nodediscoverls, and them only handled by seqdiscovery.pm
my ($help, $ver, $type, $uuid, $long);
# do not process help message for these noddiscover* commands, cover them in seqdiscovery.pm
unless ($process_help_commands{$command} == 1) {
setrsp_infostr($helpmsg);
return 0;
}
@ARGV = ();
if($args) {
@ARGV = @$args;
}
GetOptions(
'h|help' => \$help,
'v|version' => \$ver,
't=s' => \$type,
'u=s' => \$uuid,
'l' => \$long,
);
if($help){
# just return to make sequential discovery to handle it
return 0;
}
if($ver){
# just return to make sequential discovery to handle it
return 0;
}
if ($type || $uuid || $long) {
# these args for general discovery, return directly
return 0;
}
my $parseret = parse_args();
if ($parseret){
setrsp_errormsg($parseret);
@@ -498,8 +482,6 @@ Usage:
$warnstr = "Warning: failed to import some nodes.";
setrsp_progress($warnstr);
}
# setup node provisioning status.
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>\@nodelist, arg=>['defined']}, $request_command, -1, 2);
setrsp_progress("Configuring nodes...");
my $retref = xCAT::Utils->runxcmd({command=>["kitnodeadd"], node=>\@nodelist, sequential=>[1], macflag=>[$mac_addr_mode]}, $request_command, 0, 2);
@@ -744,6 +726,9 @@ Usage:
# Update nodes' attributes
foreach (@$nodes) {
$updatenodeshash{$_}{'groups'} .= $profile_groups;
if ($profile_status){
$updatenodeshash{$_}{'status'} = $profile_status;
}
}
#update DataBase.
@@ -752,11 +737,6 @@ Usage:
$nodetab->setNodesAttribs(\%updatenodeshash);
$nodetab->close();
#update node's status:
if($profile_status eq "defined"){
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>$nodes, arg=>['defined']}, $request_command, -1, 2);
}
my $retref;
my $retstrref;
# Call update plugins first.
@@ -1174,7 +1154,17 @@ Usage:
# Update node's status.
setrsp_progress("Updating node status...");
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>[$hostname], arg=>['defined']}, $request_command, -1, 2);
my $nodelisttab = xCAT::Table->new('nodelist',-create=>1);
my (
$sec, $min, $hour, $mday, $mon,
$year, $wday, $yday, $isdst
) = localtime(time);
my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d",
$mon + 1, $mday, $year + 1900,
$hour, $min, $sec);
$nodelisttab->setNodeAttribs($hostname, {status=>'defined', statustime=>$currtime});
$nodelisttab->close();
setrsp_progress("Updated MAC address.");
}
@@ -1450,9 +1440,7 @@ Usage:
my $mactab = xCAT::Table->new("mac");
my $macsref = $mactab->getNodesAttribs(\@nodes, ['mac']);
my $nodelisttab = xCAT::Table->new("nodelist");
# Get node current provisioning status.
my $provisionapp = "provision";
my $provision_status = xCAT::TableUtils->getAppStatus(\@nodes,$provisionapp);
my $statusref = $nodelisttab->getNodesAttribs(\@nodes, ['status']);
my $rspentry;
my $i = 0;
@@ -1473,8 +1461,8 @@ Usage:
}
}
if ($provision_status->{$_}){
$rspentry->{node}->[$i]->{"status"} = $provision_status->{$_};
if ($statusref->{$_}->[0]){
$rspentry->{node}->[$i]->{"status"} = $statusref->{$_}->[0]->{status};
} else{
$rspentry->{node}->[$i]->{"status"} = "defined";
}
@@ -1638,9 +1626,6 @@ sub findme{
}
my @nodelist = keys %hostinfo_dict;
# setup node provisioning status.
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>\@nodelist, arg=>['defined']}, $request_command, -1, 2);
# call makehosts to get the IP by resolving the name
my $retref = xCAT::Utils->runxcmd({command=>["makehosts"], node=>\@nodelist, sequential=>[1]}, $request_command, 0, 2);
+1 -1
View File
@@ -250,7 +250,7 @@ sub runrollupdate_usage {
sub processArgs {
my $gotattrs = 0;
if ( defined ($::args) && @{$::args} ) {
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
else {
+28 -95
View File
@@ -449,7 +449,7 @@ sub process_makeroutes {
delete_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $route_hash->{ifname});
}
else {
set_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name, $route_hash->{ifname});
set_route($callback, $route_hash->{net}, $route_hash->{mask}, $gw_ip, $gw_name,$route_hash->{ifname});
}
}
}
@@ -526,7 +526,6 @@ sub route_exists {
my $mask = shift;
my $gw_ip = shift;
my $gw=shift;
my $ifname = shift;
my $islinux=xCAT::Utils->isLinux();
@@ -558,8 +557,7 @@ sub route_exists {
my $net1=$a[0];
my $mask1=$a[2];
my $gw1=$a[1];
my $ifname1=$a[7];
if (($net1 eq $net) && ($mask1 eq $mask) && (($gw1 eq $gw) || ($gw1 eq $gw_ip) || ($ifname1 eq $ifname))) {
if (($net1 eq $net) && ($mask1 eq $mask) && (($gw1 eq $gw) || ($gw1 eq $gw_ip))) {
return 1;
}
}
@@ -604,27 +602,19 @@ sub set_route {
#print "set_route get called\n";
my $result;
if (!route_exists($net, $mask, $gw_ip, $gw, $ifname)) {
if (!route_exists($net, $mask, $gw_ip, $gw)) {
#set temporay route
my $cmd;
# ipv6 network
if ($net =~ /:/) {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "::" ) {
$cmd="ip -6 route add $net/$mask dev $ifname";
} else {
$cmd="ip -6 route add $net/$mask via $gw_ip";
}
$cmd="ip -6 route add $net/$mask via $gw_ip";
} else {
# AIX TODO
}
} else {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$cmd="route add -net $net netmask $mask dev $ifname";
} else {
$cmd="route add -net $net netmask $mask gw $gw_ip";
}
$cmd="route add -net $net netmask $mask gw $gw_ip";
} else {
$cmd="route add -net $net -netmask $mask $gw_ip";
}
@@ -686,26 +676,18 @@ sub delete_route {
#print "delete_route get called\n";
my $result;
if (route_exists($net, $mask, $gw_ip, $gw, $ifname)) {
if (route_exists($net, $mask, $gw_ip, $gw)) {
#delete route temporarily
my $cmd;
if ($net =~ /:/) {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "::" ) {
$cmd = "ip -6 route delete $net/$mask dev $ifname";
} else {
$cmd = "ip -6 route delete $net/$mask via $gw_ip";
}
$cmd = "ip -6 route delete $net/$mask via $gw_ip";
} else {
# AIX TODO
}
} else {
if (xCAT::Utils->isLinux()) {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$cmd="route delete -net $net netmask $mask dev $ifname";
} else {
$cmd="route delete -net $net netmask $mask gw $gw_ip";
}
$cmd="route delete -net $net netmask $mask gw $gw_ip";
} else {
$cmd="route delete -net $net -netmask $mask $gw_ip";
}
@@ -845,22 +827,14 @@ sub addPersistentRoute_Sles {
#print "old output=" . join("\n", @output) . "\n";
my $hasConfiged=0;
if (@output && (@output > 0)) {
$hasConfiged=checkConfig_Sles($net, $mask, $gw_ip, $gw, $ifname, \@output);
$hasConfiged=checkConfig_Sles($net, $mask, $gw_ip, $gw, \@output);
}
#print "hasConfiged=$hasConfiged\n";
my $new_config;
if ($net =~ /:/) {
if ( $gw_ip == "" || $gw_ip == "::" ) {
$new_config = "$net/$mask :: - $ifname\n";
} else {
$new_config = "$net/$mask $gw_ip - -\n";
}
$new_config = "$net/$mask $gw_ip - -\n";
} else {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$new_config="$net 0.0.0.0 $mask $ifname\n";
} else {
$new_config="$net $gw_ip $mask $ifname\n";
}
$new_config="$net $gw_ip $mask $ifname\n";
}
if (!$hasConfiged) {
push(@output, $new_config);
@@ -898,7 +872,7 @@ sub deletePersistentRoute_Sles {
my @new_output=();
my $bigfound=0;
foreach my $tmp_conf (@output) {
my $found = checkConfig_Sles($net, $mask, $gw_ip, $gw, $ifname, [$tmp_conf]);
my $found = checkConfig_Sles($net, $mask, $gw_ip, $gw, [$tmp_conf]);
if (!$found) {
push(@new_output, $tmp_conf);
} else {
@@ -935,18 +909,13 @@ sub checkConfig_Sles {
my $mask = shift;
my $gw_ip = shift;
my $gw=shift;
my $ifname=shift;
my $output=shift;
# Format:
# DESTINATION GATEWAY NETMASK INTERFACE
# DESTINATION/PREFIXLEN GATEWAY - INTERFACE
# ipv4 format: 192.168.0.0 207.68.156.51 255.255.0.0 eth1
# ipv6 format: fd59::/64 fd57:faaf:e1ab:336:21a:64ff:fe01:1 - -
foreach my $line (@$output) {
my @a=split(' ', $line);
my ($net1,$mask1,$gw1,$ifname1);
my ($net1,$mask1,$gw1);
if ($net =~ /:/) {
if (@a>0) {
my $ipv6net = $a[0];
@@ -956,10 +925,6 @@ sub checkConfig_Sles {
$gw1=$a[1];
if ($gw1 eq '-') { $gw1=$gw_ip; }
}
if (@a>3) {
$ifname1=$a[3];
if ($ifname1 eq '-') { $ifname1=$ifname;}
}
} else {
if (@a>0) {
@@ -974,14 +939,10 @@ sub checkConfig_Sles {
$mask1=$a[2];
if ($mask1 eq '-') { $mask1=$mask;}
}
if (@a>3) {
$ifname1=$a[3];
if ($ifname1 eq '-') { $ifname1=$ifname;}
}
}
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip ifname=$ifname1\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip) || ($ifname1 && $ifname1 eq $ifname))) {
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip))) {
return 1;
}
}
@@ -1011,7 +972,7 @@ sub addPersistentRoute_RH {
#print "old output=" . join("\n", @output) . "\n";
my $hasConfiged=0;
if (@output && (@output > 0)) {
$hasConfiged=checkConfig_RH($net, $mask, $gw_ip, $gw, $ifname, \@output);
$hasConfiged=checkConfig_RH($net, $mask, $gw_ip, $gw, \@output);
}
#print "hasConfiged=$hasConfiged\n";
my $new_config;
@@ -1026,11 +987,7 @@ sub addPersistentRoute_RH {
$new_config="$ifname $net/$mask $gw_ip";
} else {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$new_config="any net $net netmask $mask dev $ifname\n";
} else {
$new_config="any net $net netmask $mask gw $gw_ip\n";
}
$new_config="any net $net netmask $mask gw $gw_ip $ifname\n";
}
if (!$hasConfiged) {
push(@output, $new_config);
@@ -1074,7 +1031,7 @@ sub deletePersistentRoute_RH {
my @new_output=();
my $bigfound=0;
foreach my $tmp_conf (@output) {
my $found = checkConfig_RH($net, $mask, $gw_ip, $gw, $ifname, [$tmp_conf]);
my $found = checkConfig_RH($net, $mask, $gw_ip, $gw, [$tmp_conf]);
if (!$found) {
push(@new_output, $tmp_conf);
} else {
@@ -1108,16 +1065,14 @@ sub checkConfig_RH {
my $mask = shift;
my $gw_ip = shift;
my $gw=shift;
my $ifname=shift;
my $output=shift;
foreach my $line (@$output) {
my @a=split(' ', $line);
#The format is: any net 172.16.0.0 netmask 255.240.0.0 gw 192.168.0.1 eth0
# ipv6 format: eth1 fd60::/64 fd57::214:5eff:fe15:1
my ($net1,$mask1,$gw1,$ifname1);
my ($net1,$mask1,$gw1);
if ($net =~ /:/) {
$ifname1 = $a[0];
if (@a>1) {
my $ipv6net = $a[1];
($net1,$mask1) = split("/",$ipv6net);
@@ -1135,18 +1090,13 @@ sub checkConfig_RH {
if ($mask1 eq '-') { $mask1=$mask;}
}
if (@a>6) {
if ( $a[5] eq 'dev' ) {
$ifname1=$a[6];
if ($ifname1 eq '-') { $ifname1=$ifname;}
} else {
$gw1=$a[6];
if ($gw1 eq '-') { $gw1=$gw_ip; }
}
$gw1=$a[6];
if ($gw1 eq '-') { $gw1=$gw_ip; }
}
}
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip ifname=$ifname1,ifname\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip) || ($ifname1 && $ifname1 eq $ifname))) {
#print "net=$net1,$net mask=$mask1,$mask gw=$gw1,$gw_ip\n";
if (($net1 && $net1 eq $net) && ($mask1 && $mask1 eq $mask) && (($gw1 && $gw1 eq $gw) || ($gw1 && $gw1 eq $gw_ip))) {
return 1;
}
}
@@ -1170,21 +1120,12 @@ sub addPersistentRoute_Debian{
#ipv6
if ( $net =~ /:/){
if ( $gw_ip == "" || $gw_ip == "::" ) {
$cmd = "grep \"$net/$mask dev $ifname\" $conf_file";
$route_conf = " up route -A inet6 add $net/$mask dev $ifname \n down route -A inet6 del $net/$mask dev $ifname \n";
} else {
$cmd = "grep \"$net/$mask gw $gw_ip\" $conf_file";
$route_conf = " up route -A inet6 add $net/$mask gw $gw_ip \n down route -A inet6 del $net/$mask gw $gw_ip \n";
}
$cmd = "grep \"$net/$mask gw $gw_ip\" $conf_file";
$route_conf = " up route -A inet6 add $net/$mask gw $gw_ip \n down route -A inet6 del $net/$mask gw $gw_ip \n";
}
else { #ipv4
$cmd = "grep \"-net $net netmask $mask gw $gw_ip\" $conf_file";
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$route_conf = " up route add -net $net netmask $mask dev $ifname \n down route del -net $net netmask $mask dev $ifname \n";
} else {
$route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip\n";
}
$route_conf = " up route add -net $net netmask $mask gw $gw_ip \n down route del -net $net netmask $mask gw $gw_ip \n";
}
#fine the corresponding config in the config file
@@ -1242,18 +1183,10 @@ sub deletePersistentRoute_Debian{
preParse_Debian();
#ipv6
if ( $net =~ /:/){
if ( $gw_ip == "" || $gw_ip == "::" ) {
$match = "$net/$mask dev $ifname";
} else {
$match = "$net/$mask gw $gw_ip";
}
$match = "$net/$mask gw $gw_ip";
}
else {
if ( $gw_ip == "" || $gw_ip == "0.0.0.0" ) {
$match = "net $net netmask $mask dev $ifname";
} else {
$match = "net $net netmask $mask gw $gw_ip";
}
$match = "net $net netmask $mask gw $gw_ip";
}
open(FH, "<", $conf_file);
-60
View File
@@ -957,8 +957,6 @@ sub mkinstall
my $tmppkgdir=$pkgdir;
my @srcdirs = split(",", $pkgdir);
$pkgdir = $srcdirs[0];
# trim the "/" in /install/sles11.3/x86_64/
$pkgdir =~ s/\/$//;
if( $pkgdir =~/^($installroot\/$os\/$arch)$/) {
$srcdirs[0]="$pkgdir/1";
$tmppkgdir=join(",", @srcdirs);
@@ -1075,14 +1073,6 @@ sub mkinstall
{
$netserver = $ent->{nfsserver};
}
if ($::XCATSITEVALS{managedaddressmode} =~ /static/){
unless($netserver eq '!myipfn!'){
my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($netserver);
$netserver=$ip;
}
}
my $httpprefix = $pkgdir;
if ($installroot =~ /\/$/) { #must prepend /install/
$httpprefix =~ s/^$installroot/\/install\//;
@@ -1147,56 +1137,6 @@ sub mkinstall
$kcmdline .= " dud=file:/cus_driverdisk/$_";
}
#if site.managedaddressmode=static, specify the network configuration as kernel options
#to avoid multicast dhcp
if($::XCATSITEVALS{managedaddressmode} =~ /static/){
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) {
$callback->(
{
error => [
"cannot resolve the ip address of $node"
],
errorcode => [1]
}
);
}
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
$kcmdline .=" hostip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname ";
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
if(scalar @nameserversIP){
$kcmdline .=" Nameserver=".join(",",@nameserversIP);
}
my $nd = xCAT::NetworkUtils->getNodeDomains([$node]);
my %nodedomains = %$nd;
my $domain=$nodedomains{$node};
$kcmdline .=" Domain=$domain ";
}
if (defined $sent->{serialport})
{
unless ($sent->{serialspeed})
-15
View File
@@ -2975,21 +2975,6 @@ sub getAttribs
# <comments>This is a comment</comments>
#</xcatrequest>
#
#
#<xcatrequest>
#<clienttype>PCM</clienttype>
#<command>setAttribs</command>
#<table>networks</table>
#<keys>
# <net>10.0.1.0</net>
# <mask>255.255.255.0</mask>
#</keys>
#<attr>
# <netname>mynet</netname>
# <gateway>10.0.1.254</gateway>
#</attr>
#</xcatrequest>
sub setAttribs
{
my $request = shift;
+32 -89
View File
@@ -14,7 +14,6 @@ use xCAT::Schema;
use Data::Dumper;
use xCAT::Utils;
use xCAT::SvrUtils;
use xCAT::Scope;
use xCAT::Usage;
use Storable qw(dclone);
use xCAT::TableUtils;
@@ -189,7 +188,6 @@ sub preprocess_updatenode
my @requests = ();
my $installdir = xCAT::TableUtils->getInstallDir();
my $localhost = hostname();
# subroutine to display the usage
sub updatenode_usage
@@ -253,40 +251,20 @@ sub preprocess_updatenode
$callback->($rsp);
return;
}
# preprocess generate mypostscripts files (-g) for hierarchy
# if no sharedtftp then we need to broadcast this updatenode -g to all service nodes inorder
# to be able to support service node pools
#
# Just generate mypostscripts file and get out
if ($::GENMYPOST)
{
# precreatemypostscript has to be yes/1 or do nothing
my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts");
if ($entries[0] ) {
$entries[0] =~ tr/a-z/A-Z/;
if ($entries[0] =~ /^(1|YES)$/ ) {
# now check if sharedtftp = 0, if it is we need to broadcast to all the servicenode
# if there are service nodes
my @entries = xCAT::TableUtils->get_site_attribute("sharedtftp");
my $t_entry = $entries[0];
if ( defined($t_entry) and ($t_entry eq "0" or $t_entry eq "no" or $t_entry eq "NO")) {
# see if there are any servicenodes. If so then run updatenode -g on all of them
my @SN;
my @CN;
my $nodes = $request->{node};
xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN);
if (@CN >0 ) { # if compute nodes broadcast to all servicenodes
return xCAT::Scope->get_broadcast_scope($request,@_);
}
} else { # sharedtftp=yes, just run on MN
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files on $localhost";
$callback->($rsp);
return 0;
}
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files";
$callback->($rsp);
} else { # not valid unless precreatemypostscripts enabled
my $rsp = {};
$rsp->{error}->[0] =
@@ -295,7 +273,7 @@ sub preprocess_updatenode
$callback->($rsp);
return ;
}
} else { # precreatemypostscripts not in the site table
} else { # not in the site table
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
@@ -303,9 +281,8 @@ sub preprocess_updatenode
$callback->($rsp);
return ;
}
} # end GENMYPOST
return 0;
}
# -c must work with -S for AIX node
if ($::CMDLINE && !$::SWMAINTENANCE)
@@ -1033,6 +1010,27 @@ sub updatenode
}
#create each /tftpboot/mypostscript/mypostscript.<nodename> for each node
# This first removes the old one if precreatemypostscripts =0 or undefined
# call create files but no tmp files
my $notmpfiles=1;
my $nofiles=0;
#my $nofiles=1;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
# convert the hashes back to the way they were passed in
my $flatreq = xCAT::InstUtils->restore_request($request, $callback);
my $imgdefs;
my $updates;
if ($flatreq->{imagedef})
{
$imgdefs = $flatreq->{imagedef};
}
if ($flatreq->{updateinfo})
{
$updates = $flatreq->{updateinfo};
}
# get the NIM primary server name
my $nimprime = xCAT::InstUtils->getnimprime();
chomp $nimprime;
@@ -1045,7 +1043,6 @@ sub updatenode
'A|updateallsw' => \$::ALLSW,
'c|cmdlineonly' => \$::CMDLINE,
'd=s' => \$::ALTSRC,
'g|genmypost' => \$::GENMYPOST,
'h|help' => \$::HELP,
'v|version' => \$::VERSION,
'V|verbose' => \$::VERBOSE,
@@ -1088,60 +1085,6 @@ sub updatenode
$::attrres{$attr} = $value;
}
}
# Just generate mypostscripts file and get out
if ($::GENMYPOST)
{
my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts");
if ($entries[0] ) {
$entries[0] =~ tr/a-z/A-Z/;
if ($entries[0] =~ /^(1|YES)$/ ) {
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files on $localhostname";
$callback->($rsp);
} else { # not valid unless precreatemypostscripts enabled
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
$rsp->{errorcode}->[0] =1;
$callback->($rsp);
return ;
}
} else { # not in the site table
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
$rsp->{errorcode}->[0] =1;
$callback->($rsp);
return ;
}
return 0;
}
#create each /tftpboot/mypostscript/mypostscript.<nodename> for each node
# This first removes the old one if precreatemypostscripts =0 or undefined
# call create files but no tmp files
my $notmpfiles=1;
my $nofiles=0;
#my $nofiles=1;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
# convert the hashes back to the way they were passed in
my $flatreq = xCAT::InstUtils->restore_request($request, $callback);
my $imgdefs;
my $updates;
if ($flatreq->{imagedef})
{
$imgdefs = $flatreq->{imagedef};
}
if ($flatreq->{updateinfo})
{
$updates = $flatreq->{updateinfo};
}
# if not just using the -k flag, then set all nodes to syncing in
# nodelist updatestatus for the other updatenode options
if (!($::SECURITY)) {
File diff suppressed because it is too large Load Diff
+1 -7
View File
@@ -412,7 +412,7 @@ sub mkinstall
$custmplpath = "$installroot/custom/install/hyperv";
$tmplpath = "$::XCATROOT/share/xcat/install/hyperv";
}
$tmplfile=xCAT::SvrUtils::get_tmpl_file_name($custmplpath, $profile, $os, $arch);
my $tmplfile=xCAT::SvrUtils::get_tmpl_file_name($custmplpath, $profile, $os, $arch);
if (! $tmplfile) { $tmplfile=xCAT::SvrUtils::get_tmpl_file_name($tmplpath, $profile, $os, $arch); }
}
@@ -736,12 +736,6 @@ sub copycd
$darch = "x86_64";
} elsif (/BuildBranch=win7_rtm/){
$distname = "win7";
} elsif (/BuildBranch=winblue_rtm/){
if (-r $mntpath . "/sources/background_svr.bmp") {
if (! -r $mntpath . "/sources/EI.CFG") {
$distname = "win2012r2";
}
}
} elsif (/BuildBranch=win8_rtm/){
if (-r $mntpath . "/sources/background_cli.bmp") {
$distname = "win8";
+2 -2
View File
@@ -199,7 +199,7 @@ sub prexcat2nim
my @nodelist=(); # pass back list of nodes - if applicable
my @servicenodes=(); # pass back list of service nodes - if applicable
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
} else {
&xcat2nim_usage($callback);
@@ -359,7 +359,7 @@ sub processArgs
my $gotattrs = 0;
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
} else {
return 3;
+2 -38
View File
@@ -131,16 +131,6 @@ sub process_request
&usage($callback,$command);
exit 1;
}
# if the ARGS still have data we have invalid input
if (@ARGV) {
my $args=join(',', @ARGV);
my $rsp = {};
$rsp->{error}->[0] =
"The input to the command: $command contained invalid arguments: $args.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
exit 1;
}
if ($options{'help'})
{
&usage($callback,$command);
@@ -180,14 +170,6 @@ sub process_request
}
}
}
# cannot enter -K and -k
if (($options{'sshkeypath'}) && ($options{'gensshkeys'})) {
my $rsp = {};
$rsp->{error}->[0] =
"The input of -k and -K is not valid on the command : $command.";
xCAT::MsgUtils->message("E", $rsp, $callback);
exit 1;
}
# check for site.sshbetweennodes attribute, put out a warning it will not be used as long
# as zones are defined in the zone table.
@@ -491,18 +473,6 @@ sub rmzone
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# see if they input invalid flags
if (($$options{'sshkeypath'}) || ($$options{'gensshkeys'}) ||
( $$options{'addnoderange'}) || ( $$options{'rmnoderange'}) ||
( $$options{'defaultzone'}) ||
($$options{'sshbetweennodes'})) {
my $rsp = {};
$rsp->{error}->[0] =
"The following flags are not valid input for the rmzone command: -k,-K,-a,-r,-f,-s ";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# check to see if the input zone already exists
# cannot remove it if it is not defined
my $zonename=$request->{zonename};
@@ -620,11 +590,11 @@ sub usage
my $usagemsg2="";
if ($command eq "mkzone") {
$usagemsg1 = " mkzone -h \n mkzone -v \n";
$usagemsg2 = " mkzone <zonename> [-V] [--defaultzone] [-k <full path to the ssh RSA private key>] \n [-a <noderange>] [-g] [-f] [-s <yes/no>]";
$usagemsg2 = " mkzone <zonename> [-V] [--defaultzone] [-k <full path to the ssh RSA private key] \n [-a <noderange>] [-g] [-f] [-s <yes/no>]";
} else {
if ($command eq "chzone") {
$usagemsg1 = " chzone -h \n chzone -v \n";
$usagemsg2 = " chzone <zonename> [-V] [--defaultzone] [-k <full path to the ssh RSA private key>] \n [-K] [-a <noderange>] [-r <noderange>] [-g] [-s <yes/no>]";
$usagemsg2 = " chzone <zonename> [-V] [--defaultzone] [-k <full path to the ssh RSA private key] \n [-K] [-a <noderange>] [-r <noderange>] [-g] [-s <yes/no>]";
} else {
if ($command eq "rmzone") {
$usagemsg1 = " rmzone -h \n rmzone -v \n";
@@ -735,9 +705,6 @@ sub addtozonetable
my $curdefaultzone = xCAT::Zone->getdefaultzone($callback);
if (!(defined ($curdefaultzone))) { # no default defined
$tb_cols{defaultzone} ="yes";
$tab->setAttribs({zonename => $zonename}, \%tb_cols);
$tab->commit();
$tab->close();
} else { # already a default
if ($$options{'force'}) { # force the default
$tb_cols{defaultzone} ="yes";
@@ -813,9 +780,6 @@ sub updatezonetable
my $curdefaultzone = xCAT::Zone->getdefaultzone($callback);
if (!(defined ($curdefaultzone))) { # no default defined
$tb_cols{defaultzone} ="yes";
$tab->setAttribs({zonename => $zonename}, \%tb_cols);
$tab->commit();
$tab->close();
} else { # already a default
if ($$options{'force'}) { # force the default
$tb_cols{defaultzone} ="yes";
-34
View File
@@ -1981,40 +1981,6 @@ sub service_connection {
delete($req->{becomeuser}); #Remove it to keep it from view
}
# If the request is to aquire a token for a specific account
if (defined $req->{gettoken}) {
# authencitate the username:password
$peername=becomeuser($req->{gettoken}->[0]->{username}->[0],
$req->{gettoken}->[0]->{password}->[0]);
my $resp;
if ($peername) {
# for a valid account, get a token
my ($tokenid, $exptime) = xCAT::xcatd->gettoken($req);
my ($sec,$min,$hour,$mday,$mon,$year) = localtime($exptime);
$year += 1900;
my $htime = "$year-$mon-$mday $hour:$min:$sec";
$resp = {data=>[{token => [{id => $tokenid, expire => $htime}]}]};
} else {
$resp={error=>["Authentication failure"],errorcode=>[1]};
}
$resp->{serverdone}=[ undef ] ;
print $sock XMLout($resp,RootName => 'xcatresponse',NoAttr=>1);
return;
}
# If user trying to use 'token' to authenticate
if (defined $req->{tokens}) {
# get the valid user name by the token id
$peername = xCAT::xcatd->verifytoken($req);
unless (defined $peername) {
my $resp={error=>["Authentication failure"],errorcode=>[1]};
$resp->{serverdone}=[ undef ] ;
print $sock XMLout($resp,RootName => 'xcatresponse',NoAttr=>1);
return;
}
delete($req->{tokenid});
}
#we have a full request..
#printf $request."\n";
$request="";
@@ -98,6 +98,7 @@ emailAddress = optional
####################################################################
[ req ]
default_md = sha256
default_bits = 2048
default_keyfile = private/ca-key.pem
distinguished_name = req_distinguished_name
+6 -6
View File
@@ -98,10 +98,10 @@ my $ipmitool = "ipmitool";
if (-x "$XCATROOT/bin/ipmitool-xcat") {
$ipmitool = "$XCATROOT/bin/ipmitool-xcat";
}
my @mcinfo=`$ipmitool -I lan -U $username -P '$password' -H $bmc mc info`;#| grep 'Manufacturer ID : 343' > /dev/null 2>&1";
my @mcinfo=`$ipmitool -I lan -U $username -P $password -H $bmc mc info`;#| grep 'Manufacturer ID : 343' > /dev/null 2>&1";
$rc = $?;
if ($rc) { #some shoddy vendors ignore the IPMI 2.0 requirement to support IPMI 1.5 formats for BMC capability determination, attempt IPMI 2.0 even without the ability to confirm IPMI 2.0 support. Though SOL was not baked in prior IPMI 2.0, this script supports pre-2.0 'ISOL' on older devices, hence why we are checking for 1.5/2.0 before proceeding normally
@mcinfo=`$ipmitool -I lanplus -U $username -P '$password' -H $bmc mc info`;
@mcinfo=`$ipmitool -I lanplus -U $username -P $password -H $bmc mc info`;
$rc = $?;
}
while ($rc != 0) {
@@ -109,10 +109,10 @@ while ($rc != 0) {
print "Failure to reach IPMI device, retrying in $sleepint seconds (Hit Ctrl-E,c,o to skip)\n";
exec("sleep $sleepint");
#sleep $sleepint;
@mcinfo=`$ipmitool -I lan -U $username -P '$password' -H $bmc mc info`;#| grep 'Manufacturer ID : 343' > /dev/null 2>&1";
@mcinfo=`$ipmitool -I lan -U $username -P $password -H $bmc mc info`;#| grep 'Manufacturer ID : 343' > /dev/null 2>&1";
$rc = $?;
if ($rc) { #repeat workaround for shoddy vendors
@mcinfo=`$ipmitool -I lanplus -U $username -P '$password' -H $bmc mc info`;
@mcinfo=`$ipmitool -I lanplus -U $username -P $password -H $bmc mc info`;
$rc = $?;
}
}
@@ -130,9 +130,9 @@ if ($isintel) {
$inteloption=" -o intelplus";
}
if ($iface eq "lanplus") {
system "$ipmitool -I lanplus $inteloption -U $username -P '$password' -H $bmc $solcom deactivate"; #Stop any active session
system "$ipmitool -I lanplus $inteloption -U $username -P $password -H $bmc $solcom deactivate"; #Stop any active session
}
exec "$ipmitool -I $iface $inteloption -U $username -P '$password' -H $bmc $solcom activate";
exec "$ipmitool -I $iface $inteloption -U $username -P $password -H $bmc $solcom activate";
@@ -2,7 +2,6 @@
#cmdline
lang en_US
#KICKSTARTNET#
#
# Where's the source?
@@ -1,8 +1,7 @@
#
lang en_US
#network --bootproto dhcp
#KICKSTARTNET#
network --bootproto dhcp
#
# Where's the source?
@@ -3,7 +3,6 @@
#cmdline
lang en_US
#KICKSTARTNET#
#
# Where's the source?
@@ -2,8 +2,6 @@
# Setup hostname
#
echo "post scripts" >/root/post.log
export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic#
if [ "$PRINIC" == "mac" ]
then
@@ -1,10 +1,6 @@
#!/bin/sh
export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE#
cd /etc/sysconfig/network
if [ "$MANAGEDADDRESSMODE" != "static" ]
then
rm -f ifcfg-eth-id*
rm -f ifcfg-myri*
cat >ifcfg-eth0 <<EOF
@@ -12,7 +8,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
STARTMODE=onboot
EOF
fi
. /tmp/prinicsetting
rm /tmp/prinicsetting
if [ "$PRINIC" != "eth0" ]
@@ -26,12 +22,7 @@ then
# echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC
fi
fi
if [ "$MANAGEDADDRESSMODE" != "static" ]
then
echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC
fi
perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config
/etc/init.d/network restart
@@ -182,10 +182,9 @@ addsiteyum
/xcatpost/mypostscript
sed -i 's/^serial/#serial/' /boot/grub/grub.conf
sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
#the following command should always be run to prevent infinite installation loops
updateflag.awk $MASTER 3002
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
updateflag.awk $MASTER 3002
fi
cd /
#rm -Rf /xcatpost
#rm -f /xcatpost/mypostscript
+1 -15
View File
@@ -14,17 +14,6 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then
fi
#there is no boot option to set dns search domain in kickstart file,
#the search domain in /etc/resolv.conf is set in the pre installation script
export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE#
export SEARCHDOMAIN=#GETNODEDOMAIN:THISNODE#
if [ "$MANAGEDADDRESSMODE" == "static" ]; then
echo "#appended by %pre " >> /etc/resolv.conf
echo "search $SEARCHDOMAIN" >> /etc/resolv.conf
fi
cat >/tmp/baz.py <<EOF
#!/usr/bin/python
@@ -195,7 +184,7 @@ if [ -z "$instdisk" ]; then
"ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
"mptsas"|"mpt2sas"|"mpt3sas") #*PROBABLY* not SAN, but SAS SAN is possible
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
*)
@@ -230,10 +219,7 @@ if [ `uname -m` = "ppc64" ]; then
echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning
fi
if [ -d /sys/firmware/efi ]; then
echo 'bootloader --driveorder='$instdisk >> /tmp/partitioning
echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype vfat' >> /tmp/partitioning
else
echo 'bootloader' >> /tmp/partitioning
fi
#TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen...
@@ -159,7 +159,7 @@ if [ -z "$instdisk" ]; then
"ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
"mptsas"|"mpt2sas"|"mpt3sas") #*PROBABLY* not SAN, but SAS SAN is possible
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
*)
@@ -145,7 +145,7 @@ if [ -z "$instdisk" ]; then
"ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
"mptsas"|"mpt2sas"|"mpt3sas") #*PROBABLY* not SAN, but SAS SAN is possible
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
*)
@@ -63,7 +63,25 @@
<surname/>
</user>
</users>
#YAST2NET#
<networking>
<dns>
<dhcp_hostname config:type="boolean">true</dhcp_hostname>
<dhcp_resolv config:type="boolean">true</dhcp_resolv>
<domain>local</domain>
<hostname>linux</hostname>
</dns>
<interfaces config:type="list">
<interface>
<bootproto>dhcp</bootproto>
<device>eth0</device>
<startmode>onboot</startmode>
</interface>
</interfaces>
<routing>
<ip_forward config:type="boolean">false</ip_forward>
<routes config:type="list"/>
</routing>
</networking>
<scripts>
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles#
+138
View File
@@ -0,0 +1,138 @@
#!/bin/sh
#
# stateless
#
# chkconfig: 345 11 99
# description: action stateless
#
# Source the library functions
. /etc/rc.d/init.d/functions
ZONE="US/Mountain"
case "$1" in
start)
echo -n "Starting stateless configuration: "
if [ -r /etc/stateless_done ]
then
echo_failure
echo
echo " already run!"
exit $?
fi
#initrd=xcat/netboot/fedora8/x86_64/compute/initrd.gz imgurl=nfs://rro000/install/netboot/fedora8/x86_64/compute/rootimg console=ttyS1,19200n8r BOOT_IMAGE=xcat/netboot/fedora8/x86_64/compute/kernel
cat /proc/cmdline | grep imgurl >/dev/null 2>&1
if [ "$?" != "0" ]
then
echo_failure
echo
echo " imgurl missing from /proc/cmdline, i.e. stateful!"
exit $?
fi
for i in $(cat /proc/cmdline)
do
KEY=$(echo $i | awk -F= '{print $1}')
VALUE=$(echo $i | awk -F= '{print $2}')
if [ "$KEY" = "imgurl" ]
then
SERVER=$(echo $VALUE | awk -F/ '{print $3}')
fi
done
if [ -z "$SERVER" ]
then
echo_failure
echo
echo "bogus server in imgurl"
exit $?
fi
echo
echo " Universal Server: $SERVER"
echo -n " Syslog: "
echo "*.* @$SERVER" >/etc/rsyslog.conf
echo_success
echo
if [ -r /etc/rc.d/init.d/ntpd ]
then
echo -n " NTP: "
if [ ! -r /etc/sysconfig/clock ]
then
echo "ZONE=\"$ZONE\"
UTC=true
ARC=false" >/etc/sysconfig/clock
fi
echo "server $SERVER
driftfile /etc/ntp/drift
multicastclient
broadcastdelay 0.008
disable auth
keys /etc/ntp/keys
trustedkey 65535
requestkey 65535
controlkey 65535" >/etc/ntp.conf
echo "$SERVER" >/etc/ntp/step-tickers
echo_success
echo
fi
if [ -r /etc/ldap.conf -a -r /etc/resolv.conf ]
then
echo -n " LDAP: "
DC=$(
cat /etc/resolv.conf | \
egrep '(domain|search)' | \
head -1 | \
awk '{print $2}' | \
sed 's/\./,dc=/g' | \
sed 's/^/dc=/'
)
echo "host $SERVER
base $DC
nss_base_passwd ou=People,$DC
nss_base_shadow ou=People,$DC
nss_base_group ou=Group,$DC
timelimit 120
bind_timelimit 120
idle_timelimit 3600
nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat,radiusd,news,mailman,nscd
ssl no
tls_cacertdir /etc/openldap/cacerts
pam_password md5" >/etc/ldap.conf
echo "URI ldap://$SERVER
BASE $DC
TLS_CACERTDIR /etc/openldap/cacerts" >/etc/openldap/ldap.conf
cd /etc
cp nsswitch.conf nsswitch.conf.ORIG
sed -r 's/^((passwd|shadow|group):.*)/\1 ldap/' <nsswitch.conf.ORIG >nsswitch.conf
cd /etc/pam.d
cp system-auth system-auth.ORIG
sed -r 's/(account\s+required\s+pam_unix.so)/account sufficient pam_ldap.so\n\1/' <system-auth.ORIG >system-auth
echo_success
echo
fi
touch /etc/stateless_done
;;
stop)
;;
*)
echo "Usage: stateless {start|stop}"
exit 1
esac
+170
View File
@@ -0,0 +1,170 @@
################################################################################
# Create a generic HPC image
# This script is an example of how to create an HPC image with xCAT stateless.
# in this example you may need to change some of the parameters. In the future
# we should probably place this in the database...
# All good sys admins can reproduce their environments. Creating a stateless
# image should be reproducable. Doing this with a script is a good idea.
#
################################################################################
# specify the OS stuff. You'll probably want to change this. If you do then you'll
# need to make sure there is a *.pkglist and *.exlist
PROFILE=compute
ARCH=x86_64
OS=centos5.3
# this is where the OS image will reside
IMGROOT=/install/netboot/$OS/$ARCH/$PROFILE/rootimg
# remove the old image if it exists.
rm -rf /install/netboot/$OS/$ARCH/$PROFILE
# generate the base image
# for IBM: tg3 in older blades, bnx in newer stuff, and igb in the nehalem based products.
/opt/xcat/share/xcat/netboot/centos/genimage -i eth0 -n libphy,tg3,bnx2,igb -o $OS -p $PROFILE
# update the yum database in the image
rm -rf $IMGROOT/etc/yum.repos.d
yum --installroot=$IMGROOT clean all
cp -a /etc/yum.repos.d/ $IMGROOT/etc/
rm -rf $IMGROOT/etc/yum.repos.d/xCAT-*
# no selinux!!
echo SELINUX=disabled > $IMGROOT/etc/sysconfig/selinux
# fix respawns
cp $IMGROOT/etc/inittab $IMGROOT/etc/inittab.ORIG
grep -v 38400 $IMGROOT/etc/inittab.ORIG > $IMGROOT/etc/inittab
# filesystem setup, you'll want to customize this. We have swap and scratch
# configured here. But if you don't have disks then this may not help.
# we name our / partition the image name (compute by default) plus a timestamp.
TIME=`date +%s`
cp $IMGROOT/etc/fstab $IMGROOT/etc/fstab.ORIG
echo "proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
$PROFILE-$TIME / tmpfs rw 0 1
#/dev/sda1 swap swap defaults 0 0
#/dev/sda2 /scratch ext3 defaults 0 0
" > $IMGROOT/etc/fstab
mkdir $IMGROOT/scratch
### get ntp to start on boot
chroot $IMGROOT chkconfig --level 345 ntpd on
#### user stuff so that we can do some work ####
cp /etc/shadow $IMGROOT/etc/
cp /etc/group $IMGROOT/etc/
cp /etc/passwd $IMGROOT/etc/
cp /etc/hosts $IMGROOT/etc/
### scaling fixes #####
echo "# increase TCP max buffer size
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.core.rmem_default = 65536
net.core.wmem_default = 65536
# increase Linux autotuning TCP buffer limits
# min, default, and max number of bytes to use
net.ipv4.tcp_rmem = 4096 33554432 33554432
net.ipv4.tcp_wmem = 4096 33554432 33554432
net.ipv4.tcp_mem= 33554432 33554432 33554432
net.ipv4.route.flush=1
net.core.netdev_max_backlog=1500
#GPFS / NFS Tuning
net.ipv4.conf.all.arp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.neigh.default.gc_thresh1 = 1024
net.ipv4.neigh.default.gc_thresh2 = 4096
net.ipv4.neigh.default.gc_thresh3 = 8192
net.ipv4.neigh.default.gc_stale_time = 24" >> $IMGROOT/etc/sysctl.conf
## Limits: need to make sure users can have unlimited memory (ulimit -l unlimited)
cp /etc/security/limits.conf $IMGROOT/etc/security/
### add torque ###
/opt/xcat/share/xcat/netboot/add-on/torque/add_torque $IMGROOT mgt /opt/torque / local
# update the limit on pegged memory limit and if they have old xCAT then make sure
# it says torque instead of pbs in the paths of the config file.
perl -pi -e 's/ulimit -n 20000/ulimit -n 20000; ulimit -l unlimited/g' $IMGROOT/etc/init.d/pbs_mom
perl -pi -e 's/spool\/pbs/spool\/torque/g' $IMGROOT/etc/init.d/pbs_mom
perl -pi -e 's/spool\/pbs/spool\/torque/g' $IMGROOT/etc/init.d/pbs_mom
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/epilogue
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/prologue
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/takedownnode
### stateless init script does NTP, syslog, etc. ####
cp /etc/localtime $IMGROOT/etc/
cp /opt/xcat/share/xcat/netboot/add-on/stateless/stateless $IMGROOT/etc/init.d/
perl -pi -e 's!Mountain!Mexico/General!g' $IMGROOT/etc/init.d/stateless
perl -pi -e 's/driftfile \/etc\/ntp/driftfile \/var\/lib\/ntp/g' $IMGROOT/etc/init.d/stateless
perl -pi -e 's/keys \/etc\/ntp/keys \/var\/lib\/ntp/g' $IMGROOT/etc/init.d/stateless
rm -rf $IMGROOT/etc/sysconfig/clock
chroot $IMGROOT chkconfig --level 345 stateless on
chroot $IMGROOT chkconfig --level 345 rsyslog on
### make sure dhcp boot protocol is set to none ###
perl -pi -e 's/dhcp/none/g' $IMGROOT/etc/sysconfig/network-scripts/ifcfg-eth0
#### add GPFS stuff ###
# this is an example of a stateless GPFS implementation. Uncomment the below if you
# want GPFS. Make sure you have the GPFS RPMs to do this.
#GPFSSRCDIR=/install/GPFS
#yum --installroot=$IMGROOT -y install glibc ksh compat-libstdc++-33 binutils rsh
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.base*rpm
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.gpl*rpm
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.msg*rpm
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.base*rpm
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.gpl*rpm
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.msg*rpm
##
#AUTOGPFSDIR=/opt/xcat/share/xcat/netboot/add-on/autogpfs
#cp $AUTOGPFSDIR/autogpfsc.pl $IMGROOT/usr/sbin
#cp $AUTOGPFSDIR/autogpfsc $IMGROOT/etc/init.d/
#echo "SERVERS=mgt
#PORT=3003
#BLOCK=no" >> $IMGROOT/etc/sysconfig/autogpfsc
#
#chroot $IMGROOT chkconfig --level 345 autogpfsc on
#cp $GPFSSRCDIR/2.6.18-128.el5/* $IMGROOT/usr/lpp/mmfs/bin/
#cp /etc/profile.d/gpfs.sh $IMGROOT/etc/profile.d/
### End GPFS Stuff ####
### IB Stuff ####
# if you have InfiniBand on your machines then you probably have an OFED distribution you
# need to add. Here is an example of how to add it.
#echo "Adding InfiniBand"
#yum --installroot=$IMGROOT -y install bind-utils which rpm tcl tk glibc-devel.i386 pciutils expat libgfortran.x86_64 libgomp.x86_64 tcsh
#
#IBROOT=/install/voltaire/VoltaireOFED-1.4.2_2-k2.6.18-128.el5-x86_64
#mount -o bind /proc $IMGROOT/proc
#mount -o bind /sys $IMGROOT/sys
#mount -o bind $IBROOT $IMGROOT/mnt
#chroot $IMGROOT /mnt/install.sh --without-mpi
#umount $IMGROOT/mnt
#umount $IMGROOT/sys
#umount $IMGROOT/proc
# configure IB IP address
#echo "IP=\`host \$HOSTNAME-ib0 | awk '{ print \$4 }' | head -1\`" >> $IMGROOT/etc/rc.d/rc.local
#echo "ifconfig ib0 \$IP" >> $IMGROOT/etc/rc.d/rc.local
#echo "ifconfig ib0 netmask 255.255.0.0" >> $IMGROOT/etc/rc.d/rc.local
### End IB Stuff ####
# configure name resolution
# change this to what you want it to be. (this is in site.tab as the domain and nameservers)
echo "search cluster.foo
nameserver 172.20.0.1" >$IMGROOT/etc/resolv.conf
### uniq-i-fy Torque OS name
echo "opsys compute_centos5.3" >> $IMGROOT/var/spool/torque/mom_priv/config
packimage -p $PROFILE -a $ARCH -o $OS
echo "Image $PROFILE-$TIME created"
+1 -1
View File
@@ -177,7 +177,7 @@ if ($netdriver) {
# Add the default driver list
if ($arch eq 'x86' or $arch eq 'x86_64') {
push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx_en be2net/;
push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e igb mlx_en be2net/;
} elsif ($arch eq 'ppc64') {
push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/;
} elsif ($arch eq "s390x") {
Regular → Executable
+6 -16
View File
@@ -16,28 +16,18 @@ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root
AutoReqProv: no
%endif
%define fsm %(if [ "$fsm" = "1" ];then echo 1; else echo 0; fi)
%define pcm %(if [ "$pcm" = "1" ];then echo 1; else echo 0; fi)
%define notpcm %(if [ "$pcm" = "1" ];then echo 0; else echo 1; fi)
# AIX will build with an arch of "ppc"
# also need to fix Requires for AIX
%ifos linux
BuildArch: noarch
Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser
Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser grub2-xcat
Obsoletes: atftp-xcat
%endif
# The aix rpm cmd forces us to do this outside of ifos type stmts
%if %notpcm
%ifos linux
%ifnarch s390x
# PCM does not use or ship grub2-xcat
#Requires: grub2-xcat
%endif
%endif
%endif
%define fsm %(if [ "$fsm" = "1" ];then echo 1; else echo 0; fi)
%define pcm %(if [ "$pcm" = "1" ];then echo 1; else echo 0; fi)
%define notpcm %(if [ "$pcm" = "1" ];then echo 0; else echo 1; fi)
%if %fsm
# nothing needed here
@@ -165,7 +155,7 @@ rm $RPM_BUILD_ROOT/%{prefix}/sbin/stopstartxcatd
#rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/blade.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/hpblade.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/hpilo.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/ipmi.pm
#rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/ipmi.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/nodediscover.pm
#rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/switch.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/xen.pm
-321
View File
@@ -1,321 +0,0 @@
#! /usr/bin/perl
package genrestapidoc;
my @apigroups = (
{
groupname => 'tokens',
header => "Token Resources",
desc => "The URI list which can be used to create tokens for account .",
resources => ['tokens'],
},
{
groupname => 'nodes',
header => "Node Resources",
desc => "The URI list which can be used to create, query, change and manage node objects.",
resources => ['allnode', 'nodeallattr', 'nodeattr', 'nodehost', 'nodedns', 'nodedhcp', 'nodestat', 'subnodes',
'power', 'energy', 'energyattr', 'serviceprocessor', 'nextboot', 'bootstate',
'vitals', 'vitalsattr', 'inventory', 'inventoryattr', 'eventlog', 'beacon',
'updating','filesyncing','software_maintenance','postscript', 'nodeshell', 'nodecopy',
]
},
{
groupname => 'osimages',
header => "Osimage resources",
desc => "URI list which can be used to query, create osimage resources.",
resources => ['osimage', 'osimage_allattr', 'osimage_attr', 'osimage_op']
},
{
groupname => 'networks',
header => "Network Resources",
desc => "The URI list which can be used to create, query, change and manage network objects.",
resources => ['allnetwork', 'network_allattr','network_attr']
},
{
groupname => 'policy',
header => "Policy Resources",
desc => "The URI list which can be used to create, query, change and manage policy entries.",
resources => ['policy', 'policy_allattr', 'policy_attr']
},
{
groupname => 'groups',
header => "Group Resources",
desc => "The URI list which can be used to create, query, change and manage group objects.",
resources => ['all_groups','group_allattr','group_attr',
]
},
{
groupname => 'globalconf',
header => "Global Configuration Resources",
desc => "The URI list which can be used to create, query, change global configuration.",
resources => ['all_site', 'site']
},
{
groupname => 'services',
header => "Service Resources",
desc => "The URI list which can be used to manage the host, dns and dhcp services on xCAT MN.",
resources => ['dns','dhcp','host', 'slpnodes', 'specific_slpnodes',]
},
{
groupname => 'tables',
header => "Table Resources",
desc => "URI list which can be used to create, query, change table entries.",
resources => ['table_nodes', 'table_nodes_attrs', 'table_all_rows', 'table_rows', 'table_rows_attrs']
},
);
my %formathdl = (
text => \&outtext,
wiki => \&outwiki,
);
my @errmsg;
sub outtext {
my $def = shift;
my $opt = shift;
my $res = shift;
if ($res) {
if (defined ($res->{'desc'})) {
print "\n$res->{'desc'}\n";
}
foreach (1..10) {
if (defined ($res->{'desc'.$_})) {
print $res->{'desc'.$_}."\n";
}
}
}
my $postfix = "?userName=root&password=cluster&pretty=1";
if (defined ($def->{desc})) {
print " $opt - $def->{desc}\n";
}
foreach (1..10) {
if (defined ($def->{'desc'.$_})) {
print " ".$def->{'desc'.$_}."\n";
}
}
if (defined ($def->{usage})) {
my @parts = split ('\|', $def->{usage});
if ($parts[1]) {
print " Parameters: $parts[1]\n";
}
if ($parts[2]) {
print " Returns: $parts[2]\n";
}
}
my @example_array = ();
if (defined($def->{example})) {
push @example_array, $def->{example};
} else {
foreach (1..10) {
if (defined($def->{'example'.$_})) {
push @example_array, $def->{'example'.$_};
}
}
}
if (@example_array) {
foreach my $line (@example_array) {
my @parts = split ('\|', $line);
print " Example:\n";
if ($parts[1]) {
print " $parts[1]\n";
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
if ($parts[2] && $parts[3] && ($parts[4] || $opt ne "GET")) {
my ($uri, $data);
if ($parts[3] =~ /\s+/) {
($uri, $data) = split(/ /, $parts[3]);
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$uri$postfix\' -H Content-Type:application/json --data \'$data\'\n";
} else {
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$parts[3]$postfix\'\n";
}
$parts[4] =~ s/\n/\n /g;
print " $parts[4]\n";
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
}
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
}
sub outwiki {
my $def = shift;
my $opt = shift;
my $res = shift;
if ($res) {
if (defined ($res->{'desc'})) {
print "===$res->{'desc'}===\n";
}
foreach (1..10) {
if (defined ($res->{'desc'.$_})) {
print $res->{'desc'.$_}."\n\n";
}
}
}
my $postfix = "?userName=root&password=cluster&pretty=1";
if (defined ($def->{desc})) {
print "===='''$opt - $def->{desc}'''====\n";
}
foreach (1..10) {
if (defined ($def->{'desc'.$_})) {
print $def->{'desc'.$_}."\n\n";
}
}
if (defined ($def->{cmd})) {
my $manpath = search_manpage($def->{cmd});
if ($manpath) {
print "Refer to the man page:[http://xcat.sourceforge.net".$manpath.".html ".$def->{cmd}."]\n\n";
} else {
print "Refer to the man page of ".$def->{cmd}." command.\n\n";
}
}
if (defined ($def->{usage})) {
my @parts = split ('\|', $def->{usage});
if ($parts[1]) {
print "'''Parameters:'''\n\n*$parts[1]\n";
}
if ($parts[2]) {
print "'''Returns:'''\n\n*$parts[2]\n";
}
}
my @example_array = ();
if (defined($def->{example})) {
push @example_array, $def->{example};
} else {
foreach (1..10) {
if (defined($def->{'example'.$_})) {
push @example_array, $def->{'example'.$_};
}
}
}
if (@example_array) {
foreach my $line (@example_array) {
my @parts = split ('\|', $line);
print "'''Example:'''\n\n";
if ($parts[1]) {
print "$parts[1]\n";
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
}
if ($parts[2] && $parts[3] && ($parts[4] || $opt ne "GET")) {
my ($uri, $data);
if ($parts[3] =~ /\s+/) {
($uri, $data) = split(/ /, $parts[3]);
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$uri$postfix\' -H Content-Type:application/json --data \'$data\'\n";
} else {
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$parts[3]$postfix\'\n";
}
$parts[4] =~ s/\n/\n /g;
print " $parts[4]\n";
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
}
}
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
}
}
sub search_manpage {
my $cmd = shift;
if (-d "/opt/xcat/share/man") {
my $run = "cd /opt/xcat/share/man; find . | grep \'$cmd\\.\'";
my @output = `$run`;
if (@output) {
$output[0] =~ s/^\.//;
chomp($output[0]);
return $output[0];
}
}
return undef;
}
sub gendoc {
my $URIdef = shift;
my $format = shift;
unless ($format) {
$format = "text";
}
foreach my $group (@apigroups) {
my $groupname = $group->{'groupname'};
if (defined ($URIdef->{$groupname})) {
# display the head of resource group
if ($format eq "text") {
print "############################################\n";
print "##########".$group->{'header'}."\n";
print $group->{'desc'}."\n";
print "############################################\n";
} elsif ($format eq "wiki") {
print "==".$group->{'header'}."==\n";
print $group->{'desc'}."\n";
}
foreach my $res (@{$group->{'resources'}}) {
if (defined ($URIdef->{$groupname}->{$res})) {
my $headdone;
if (defined ($URIdef->{$groupname}->{$res}->{GET})) {
$formathdl{$format}->($URIdef->{$groupname}->{$res}->{GET}, "GET", $URIdef->{$groupname}->{$res});
$headdone = 1;
}
if (defined ($URIdef->{$groupname}->{$res}->{PUT})) {
if ($headdone) {
$formathdl{$format}->($URIdef->{$groupname}->{$res}->{PUT}, "PUT");
} else {
$formathdl{$format}->($URIdef->{$groupname}->{$res}->{PUT}, "PUT", $URIdef->{$groupname}->{$res});
}
$headdone = 1;
}
if (defined ($URIdef->{$groupname}->{$res}->{POST})) {
if ($headdone) {
$formathdl{$format}->($URIdef->{$groupname}->{$res}->{POST}, "POST");
} else {
$formathdl{$format}->($URIdef->{$groupname}->{$res}->{POST}, "POST", $URIdef->{$groupname}->{$res});
}
}
if (defined ($URIdef->{$groupname}->{$res}->{DELETE})) {
$formathdl{$format}->($URIdef->{$groupname}->{$res}->{DELETE}, "DELETE");
}
} else {
push @errmsg, "Cannot find the definition for resource [$res]\n";
}
}
} else {
push @errmsg, "Cannot find the definition for resource group [$groupname]\n";
}
}
if (@errmsg) {
print "\n\n\n================= Error Messages ===================\n";
print @errmsg;
}
}
1;
-197
View File
@@ -1,197 +0,0 @@
#! /bin/sh
# Get all the parameters
for i in $@
do
if [ "$paramname" = "USER" ]; then
USER=$i
paramname=
fi
if [ "$paramname" = "PW" ]; then
PW=$i
paramname=
fi
if [ "$paramname" = "HOST" ]; then
HOST=$i
paramname=
fi
if [ $i = '-u' ]; then
paramname=USER
fi
if [ $i = '-p' ]; then
paramname=PW
fi
if [ $i = '-h' ]; then
paramname=HOST
fi
if [ $i = '-c' ]; then
cert=yes
fi
if [ $i = '-t' ]; then
token=yes
fi
done
# display the usage message
function usage {
echo "Usage:"
echo " xcatws-test.sh -u <USER> -p <pw> [-t]"
echo " xcatws-test.sh -u <USER> -p <pw> -h <FQDN - Full hostname of server> [-c] [-t]"
echo " -u The username of xCAT user which is used to access xCAT resource"
echo " -p The password of username"
echo " <FQDN of xCAT MN> The fully qualified hostname of xCAT management node. It can be an IP if using -k."
echo " -c Check the server identity. The server certificate authentication must be enabled."
echo " -t Using token authentication method."
}
if [ "$USER" = "" ] || [ "$PW" = "" ]; then
echo "Error: Miss username or password"
usage
exit 1
fi
if [ "$cert" = "yes" ] && [ "$HOST" = "" ]; then
echo "Error: -c must be used with -h that user needs specify the FQDN of xCAT MN"
usage
exit 1
fi
if [ "$HOST" = "" ]; then
HOST="127.0.0.1"
fi
ctype='-H Content-Type:application/json'
# Perform the REST API request
function REST {
METHOD=$1 # it should be GET/PUT/POST/DELETE
SRC=$2 # The resource path like /nodes/node1
DATA=$3 # The operation data for PUT/POST/DELETE
if [ "$DATA" != "" ]; then
datamsg="$ctype -d $DATA"
fi
if [ "$cert" = "yes" ]; then
if [ "$token" = "yes" ]; then
CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1"
else
CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW"
fi
else
if [ "$token" = "yes" ]; then
CMD="curl -X $METHOD -k -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1"
else
CMD="curl -X $METHOD -k $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW"
fi
fi
echo "-------------------------------------------------------------------------------"
echo "Run: [$RESTMSG]"
echo " $CMD"
echo "Output:"
`$CMD 2>/dev/null >/tmp/xcatws-test.log`
cat "/tmp/xcatws-test.log"
echo ""
ERROR=`grep "errorcode" "/tmp/xcatws-test.log"`
if [ "$ERROR" != "" ]; then
echo "FAILED to continue. See the error message in 'error' section."
echo ""
exit 2
fi
}
function PUT {
SRC=$1
}
# echo debug message
echo "***********************************************************"
echo "** Username: $USER"
echo "** Password: $PW"
echo "** Hostname: $HOST"
# get the CA of server certificate
if [ "$cert" = "yes" ]; then
rm -f /tmp/ca-cert.pem
cd /tmp
wget http://$HOST/install/postscripts/ca/ca-cert.pem 2>1 1>/dev/null
echo "** Using CA /tmp/ca-cert.pem for server certificate checking"
fi
# get a token
if [ "$token" = "yes" ]; then
TOKENID=$(curl -X POST -k "https://$HOST/xcatws/tokens?pretty=1" -H Content-Type:application/json --data "{\"userName\":\"$USER\",\"password\":\"$PW\"}" 2>/dev/null | grep '"id"' | awk -F: {'print $2'} | awk -F \" {'print $2'})
echo "** Using Token: $TOKENID to authenticate"
fi
echo "***********************************************************"
echo ""
# clean the env
rmdef -t node restapinode[1-9] 1>/dev/null 2>1
rmdef -t group restapi 1>/dev/null 2>1
# get all resources
RESTMSG="Get all available resource"
REST GET "/"
# test global conf
RESTMSG="Get all global configuration resource"
REST GET "/globalconf"
RESTMSG="Change the global configuration domain to cluster.com"
REST PUT "/globalconf/attrs/domain" '{"domain":"cluster.com"}'
RESTMSG="Get the global configuration domain"
REST GET "/globalconf/attrs/domain"
# test node create/change/list/delete
RESTMSG="Create node restapinode1"
REST POST "/nodes/restapinode1" '{"groups":"restapi","arch":"x86_64","mgt":"ipmi","netboot":"xnba"}'
RESTMSG="Display the node restapinode1"
REST GET "/nodes/restapinode1"
RESTMSG="Change the attributes for node restapinode1"
REST PUT "/nodes/restapinode1" '{"mgt":"fsp","netboot":"yaboot"}'
RESTMSG="Display the node restapinode1"
REST GET "/nodes/restapinode1"
RESTMSG="Delete node restapinode1"
REST DELETE "/nodes/restapinode1"
# test multiple nodes manipulation
RESTMSG="Create node restapinode1 and restapinode2"
REST POST "/nodes/restapinode1,restapinode2" '{"groups":"restapi","arch":"x86_64","mgt":"ipmi","netboot":"xnba"}'
RESTMSG="Display the node restapinode1 and restapinode2"
REST GET "/nodes/restapinode1,restapinode2"
RESTMSG="Change the attributes for node restapinode1 and restapinode2"
REST PUT "/nodes/restapinode1,restapinode2" '{"mgt":"hmc","netboot":"grub2"}'
RESTMSG="Display the node restapinode1 and restapinode2"
REST GET "/nodes/restapinode1,restapinode2"
RESTMSG="Display all the nodes in the cluster"
REST GET "/nodes"
# test group
RESTMSG="Display the group restapi"
REST GET "/groups/restapi"
RESTMSG="Change attributes for group restapi"
REST PUT "/groups/restapi" '{"os":"rh7"}'
RESTMSG="Display the group restapi"
REST GET "/groups/restapi"
RESTMSG="Display the nodes in group restapi"
REST GET "/nodes/restapi"
File diff suppressed because it is too large Load Diff
+15 -17
View File
@@ -22,6 +22,21 @@ cmd:rmdef -t node testnode
check:rc==0
end
start:chdef_group_p
cmd:chdef abcnode1 -p groups=abc
check:rc==0
cmd:chdef abcnode2 -p groups=abcabc
check:rc==0
cmd:chdef -t group abc members=abcnode2
check:rc==0
cmd:nodels abc
check:output!~abcnode1
check:output=~abcnode2
cmd:rmdef abcnode1
cmd:rmdef abcnode2
end
start:chdef_t_network
description:chdef -t network
cmd:chdef -t network -o testnetwork net=111.222.33.0 mask=255.255.255.254
@@ -115,23 +130,6 @@ cmd:rmdef -t node -o testnode1-testnode4
check:rc==0
end
start:chdef_group_p
cmd:chdef abcnode1 -p groups=abc
check:rc==0
cmd:chdef abcnode2 -p groups=abcabc
check:rc==0
cmd:chdef -t group abc members=abcnode2
check:rc==0
cmd:nodels abc
check:output!~abcnode1
check:output=~abcnode2
cmd:rmdef abcnode1
cmd:rmdef abcnode2
end
start:chdef_dynamic_group
description:chdef with dynamic node group
cmd:mkdef -t node -o testnode1-testnode2 mgt=hmc cons=hmc groups=all,systemp
@@ -30,8 +30,6 @@ cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ;then xdsh $$SN mount $$MN:/insta
check:rc==0
cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute
check:rc==0
cmd:rsetboot $$CNWITHSN net
check:rc==0
cmd:rpower $$CNWITHSN reset
check:rc==0
cmd:sleep 200
@@ -54,8 +52,6 @@ check:rc==0
check:output=~\d\d:\d\d:\d\d
cmd:nodeset $$CNWITHSN netboot
check:rc==0
cmd:rsetboot $$CNWITHSN net
check:rc==0
cmd:rpower $$CNWITHSN reset
check:rc==0
cmd:sleep 200
@@ -2,7 +2,7 @@ start:Linux_diskless_installation_flat_ppc64
os:Linux
cmd:rscan __GETNODEATTR($$CN,hcp)__ -w
check:rc==0
cmd:makedns
cmd:makedns -n
check:rc==0
cmd:service named restart
check:rc==0
@@ -25,7 +25,7 @@ cmd:copycds $$ISO
check:rc==0
cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__
check:rc==0
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
@@ -1,55 +0,0 @@
start:Linux_diskless_installation_flat_x86_64_sles
os:Linux
cmd:makedns -n
check:rc==0
cmd:service named restart
check:rc==0
cmd:makeconservercf $$CN
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:sleep 60
cmd:makedhcp -n
check:rc==0
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:cat /var/lib/dhcp/db/dhcpd.leases| grep $$CN
check:output=~$$CN
cmd:if [ ! -d /install/custom/netboot/sles ]; then mkdir -p /install/custom/netboot/sles; fi
check:rc==0
cmd:if [ ! -e /install/custom/netboot/sles/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/sles/compute.synclist; fi
check:rc==0
cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-__GETNODEATTR($$CN,provmethod)__-__GETNODEATTR($$CN,profile)__ synclists=/install/custom/netboot/sles/compute.synclist
cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/x86_64/compute
check:rc==0
cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__
check:rc==0
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
cmd:rsetboot $$CN net
check:rc==0
cmd:rpower $$CN reset
check:rc==0
cmd:sleep 200
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
cmd:nodeset $$CN osimage
check:rc==0
cmd:rsetboot $$CN net
check:rc==0
cmd:rpower $$CN reset
check:rc==0
cmd:sleep 200
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
end
@@ -2,7 +2,7 @@ start:Linux_full_installation_flat_ppc64
os:Linux
cmd:rscan __GETNODEATTR($$CN,hcp)__ -w
check:rc==0
cmd:makedns
cmd:makedns -n
check:rc==0
cmd:service named restart
check:rc==0
@@ -1,48 +0,0 @@
start:Linux_full_installation_flat_x86_64_sles
os:Linux
cmd:makedns -n
check:rc==0
cmd:service named restart
check:rc==0
cmd:makeconservercf $$CN
check:rc==0
cmd:cat /etc/conserver.cf | grep $$CN
check:output=~$$CN
cmd:sleep 60
cmd:makedhcp -n
check:rc==0
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute synclists=/install/custom/install/sles/compute.synclist
check:rc==0
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute
check:rc==0
cmd:rsetboot $$CN net
check:rc==0
cmd:rpower $$CN reset
check:rc==0
cmd:sleep 2000
cmd:ping $$CN -c 3
check:output=~64 bytes from $$CN
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
cmd:nodeset $$CN osimage
check:rc==0
cmd:rsetboot $$CN net
check:rc==0
cmd:rpower $$CN reset
check:rc==0
cmd:sleep 2000
cmd:ping $$CN -c 3
check:output=~64 bytes from $$CN
cmd:lsdef -l $$CN | grep status
check:output=~booted
cmd:xdsh $$CN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
end
@@ -1,53 +0,0 @@
#first define
start:Linux_sn_installation_flat_x86_64_redhat
os:Linux
cmd:makedns -n
check:rc==0
cmd:chdef $$SN groups=service,all
check:rc==0
cmd:chdef -t group service arch=__GETNODEATTR($$SN,arch)__ os=__GETNODEATTR($$SN,os)__ profile=service netboot=xnba primarynic=eth0
check:rc==0
cmd:chdef -t group -o service setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1
check:rc==0
cmd:chdef $$SN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN
check:rc==0
cmd:makeconservercf
check:rc==0
cmd:cat /etc/conserver.cf | grep $$SN
check:output=~$$SN
cmd:sleep 60
cmd:makedhcp -n
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service synclists=/install/custom/install/rh/service.synclist
check:rc==0
cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service otherpkglist=/opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.otherpkgs.pkglist
check:rc==0
cmd:mkdir -p /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/
check:rc==0
cmd:cp -rf /xcat-core /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/
check:rc==0
cmd:createrepo /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/xcat-core
check:rc==0
cmd:for i in mysql-server mysql mysql-bench mysql-devel mysql-connector-odbc; do cat /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist; fi done
cmd:chtab node=service postscripts.postscripts="servicenode,odbcsetup"
check:rc==0
cmd:nodeset $$SN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service
check:rc==0
cmd:rsetboot $$SN net
check:rc==0
cmd:rpower $$SN reset
check:rc==0
cmd:sleep 700
cmd:ping $$SN -c 3
check:output=~64 bytes from $$SN
cmd:lsdef -l $$SN | grep status
check:output=~booted
cmd:xdsh $$SN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
cmd:xdsh $$SN nodels
check:rc==0
end
@@ -1,53 +0,0 @@
#first define
start:Linux_sn_installation_flat_x86_64_sles
os:Linux
cmd:makedns -n
check:rc==0
cmd:chdef $$SN groups=ipmi,service,all
check:rc==0
cmd:chdef -t group service arch=__GETNODEATTR($$SN,arch)__ os=__GETNODEATTR($$SN,os)__ profile=service netboot=xnba primarynic=eth0
check:rc==0
cmd:chdef -t group -o service setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1
check:rc==0
cmd:chdef $$SN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN
check:rc==0
cmd:makeconservercf
check:rc==0
cmd:cat /etc/conserver.cf | grep $$SN
check:output=~$$SN
cmd:sleep 60
cmd:makedhcp -n
cmd:makedhcp -a
check:rc==0
cmd:service dhcpd restart
check:rc==0
cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service synclists=/install/custom/install/sles/service.synclist
check:rc==0
cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service otherpkglist=/opt/xcat/share/xcat/install/sles/service.sles11.x86_64.otherpkgs.pkglist
check:rc==0
cmd:mkdir -p /install/post/otherpkgs/sles11.2/x86_64/xcat/
check:rc==0
cmd:cp -rf /xcat-core /install/post/otherpkgs/sles11.2/x86_64/xcat/
check:rc==0
cmd:createrepo /install/post/otherpkgs/sles11.2/x86_64/xcat/xcat-core
check:rc==0
cmd:for i in mysql-client libmysqlclient_r15 libqt4-sql-mysql libmysqlclient15 perl-DBD-mysql mysql iscsi-initiator-utils bridge-utils kvm perl-Sys-Virt; do cat /opt/xcat/share/xcat/install/sles/service.sles11.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /opt/xcat/share/xcat/install/sles/service.sles11.pkglist; fi done
cmd:chtab node=service postscripts.postscripts="servicenode,odbcsetup"
check:rc==0
cmd:nodeset $$SN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service
check:rc==0
cmd:rsetboot $$SN net
check:rc==0
cmd:rpower $$SN reset
check:rc==0
cmd:sleep 3000
cmd:ping $$SN -c 3
check:output=~64 bytes from $$SN
cmd:lsdef -l $$SN | grep status
check:output=~booted
cmd:xdsh $$SN date
check:rc==0
check:output=~\d\d:\d\d:\d\d
cmd:xdsh $$SN nodels
check:rc==0
end
-503
View File
@@ -1,503 +0,0 @@
#!/usr/bin/env perl
###############################################################################
# This script is used for rest-api automation test
# Flags are used for test input:
# -m method. Should be GET, POST, PUT, DELETE
# -r resource
# -t token
# -h host
# -u user
# -p passwd
# -P port (BC)
# -d data
# -c cert
# -n hostname
# Flags are used for check output:
# -o expected output
# -l logical operator
#
# Expected result format is '{ANY:{ANY:content}}'
# These steps are used to explain how to scan result
# step 1. go through to see if content can be found
# step 2. compare content if found
# options are used as followed:
# == returns 0 if found and equal, returns 1 if not found or found but not equal
# != returns 0 if found, returns 1 if not found
# =~ returns 0 if match, returns 1 if not match
# !=~ returns 0 if not match, returns 1 if match
################################################################################
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use Getopt::Long;
use Data::Dumper;
use strict;
my $help;
my $method;
my $token;
my $resource;
my $host;
my $user;
my $passwd;
my $port;
my $data;
my $cert;
my $hostname;
my $output;
my $loperator;
my $debug;
my $defaulthash;
my $defaulthttpresult = 0;
my $outputfile = "/tmp/testrestapiresult";
if (
!GetOptions("h|?" => \$help,
"m=s" => \$method,
"t=s" => \$token,
"r=s" => \$resource,
"h=s" => \$host,
"u=s" => \$user,
"p=s" => \$passwd,
"P=s" => \$port,
"d=s" => \$data,
"c=s" => \$cert,
"n=s" => \$hostname,
"o=s" => \$output,
"l=s" => \$loperator,
"debug" => \$debug,
)
) {
&usage;
exit 1;
}
##############################################################
# check result
##############################################################
if ($output) {
if ($method or $resource) {
&usage;
exit 1;
}
my $res = check_result($output,$loperator,$outputfile);
print_debug( "check result runs with $output and $loperator, result is $res\n" );
exit $res;
}
##############################################################
# return help
##############################################################
if ($help) {
&usage;
exit 0;
}
##############################################################
# Give default values for optional vars.
###############################################################
my $rootdir = "$::XCATROOT/share/xcat/tools/autotest";
my $resultdir = "$rootdir/result";
my $logfile = "$rootdir/result/restapitest.log"; #/opt/xcat/share/xcat/tools/autotest/result/restapitest.log
my $cert1 = "/root/ca-cert.pem";
# get token
my $gettoken = `curl -X POST -k 'https://127.0.0.1/xcatws/tokens?userName=root&password=cluster' -H Content-Type:application/json --data '{"userName":"root","password":"cluster"}' 2>/dev/null`;
my $reshash = parse_json($gettoken);
my $token1 = $$reshash{token}{id};
# get hostname
unless ($hostname) {
$hostname = `hostname`;
chomp($hostname);
}
# keey default test result for save
my $res = run_restapi($method, $resource, $data, "", $port, "127.0.0.1", "root", "cluster");
$defaulthash = parse_json($res);
$defaulthttpresult = check_errcode();
# debug info
print_debug( "get token $token1. \n" );
print_debug( "get hostname $hostname.\n");
print_debug( "default result is $res. \n" );
print_debug( "default resulthash is: \n" );
print_debug($defaulthash);
print_debug( "default errcode is $defaulthttpresult \n" );
####################################################
# Begin to run test cases
####################################################
my @users = ("root","wsuser", $user);
my @passwds = ("cluster","cluster", $passwd);
my @tokens = ("", $token1, $token);
my @certs = ("", $cert1, $cert);
unless ($host) {
$host = "127.0.0.1";
}
log_me("**************begin restapi test***************");
my $i = 0;
for my $u (@users) {
next unless($u);
my $p = $passwds[$i];
$i++;
for my $t (@tokens) {
for my $c (@certs){
my $res = run_restapi($method, $resource, $data, $c, $port, $host, $u, $p, $t);
if($res){
my $reshash = parse_json($res);
print_debug("parse curl result and got:\n");
print_debug($reshash);
if (%$reshash != %$defaulthash) {
log_me("restapi test cases run different result");
print_debug( "restapi test cases run different result with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" );
exit 1;
}
}
my $errcode = check_errcode();
print_debug("get curl error code: $errcode\n");
if ($errcode != $defaulthttpresult) {
log_me("restapi test cases run different errcode");
print_debug( "restapi test cases run different error code with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" );
exit 1;
}
}
}
}
exit $defaulthttpresult;
################################################
# begin subroutine
################################################
##########
# usage #
##########
sub usage
{
print "Usage:testrestapi - Run xcat test cases.\n";
print " testrestapi [-?|-h]\n";
print " testrestapi [-m method] [-r resource] [-t tocken]\n";
print " [-h host] [-P port][-u user] [-p passwd]\n";
print " [-d data] [-c cert] [-n hostname]\n";
print " [-o expect_output] [-l logical_operator] [-debug]\n";
print " [-debug]\n";
print "\n";
return;
}
###############
# record log #
###############
sub log_me
{
my $msg = shift;
open (LOG, ">>$logfile")
or return 1;
my $date = `date`;
print LOG "$date\: $msg\n";
}
#####################
# print debug infor #
#####################
sub print_debug
{
my $msg = shift;
return 0 unless($debug);
if(ref($msg) eq 'HASH') {
print Dumper($msg);
} elsif( ref($msg) eq 'ARRAY') {
print Dumper($msg);
} else {
print "$msg";
}
}
#########################
# run rest-api command #
#########################
sub run_restapi
{
my ($m,$r,$d,$c,$p,$h,$u,$a,$t) = @_;
my $cmd = "curl";
$cmd .= " -X $m";
unless ($c) {
$cmd .= " -k ";
}else {
$cmd .= " --cacert $c";
}
if($t){
$cmd .= " -H X-Auth-Token:$t ";
}
if($t or $c){
$cmd .= " 'https://$hostname";
} else {
$cmd .= " 'https://$h";
}
if ($p) {
$cmd .= ":$p";
}
$cmd .= "/xcatws";
$cmd .= "$r?";
unless($t){
$cmd .= "userName=$u&password=$a'";
}else {
$cmd .= "'";
}
if($d) {
$cmd .= " -H Content-Type:application/json --data '$d'";
}
$cmd .= " -D /tmp/err.log";
log_me("Begin to run restapi test with $cmd");
my $res = `$cmd 2>/dev/null`;
print_debug("run curl: $cmd\n");
print_debug("result is $res\n");
if (!open (RESULT, ">$outputfile")) {
log_me("wirte outputfile error");
}
print RESULT $res;
close RESULT;
return $res;
}
############################
# transfer json into hash #
############################
sub parse_json
{
my $input = shift;
my %hash;
if ($input =~ /:/) {
# for those who look like:
# {"networks":[{"mgtifname":"eth1","mask":"255.255.255.0"},{"mgtifname":"eth1","mask":"255.255.255.0"}]}
if ($input =~ /^\[(.*)\]$/s) {
my $content = $1;
print "[:] content is $content \n" if($debug);
parse_json($content);
}
# for those who look like
# {"clustersite":{"domain":"cluster.com","master":"192.168.1.15"}}
elsif ($input =~ /^\s*{(.*)}\s*$/s) {
my $content = $1;
print "{} content is $content \n" if($debug);
parse_json($content);
}
# for those who look like
# "domain":"cluster.com","master":"192.168.1.15"
elsif ($input =~ /,/ and !($input =~ /}/)) {
my @contents = split /,/, $input;
my @reval;
# record result
foreach my $t (@contents) {
print ", content is $t \n" if($debug);
my $re = parse_json($t);
push @reval, $re;
}
# merge hash
foreach my $t (@reval) {
if(ref($t) =~ "HASH") {
foreach my $k (keys %$t){
$hash{$k} = $$t{$k};
}
}
}
return \%hash;
}
# for those who look like:
# "clustersite":{"domain":"cluster.com","master":"192.168.1.15"}
# "domain":"cluster.com"
elsif ($input =~ /\"(\S+?)\":(.+)/s) {
my $key = $1;
my $value = $2;
if ($value =~ /{/) {
# "clustersite":{"domain":"cluster.com","master":"192.168.1.15"}
print "{ content is $value \n" if($debug);
$hash{$key} = parse_json($value, $key);
return \%hash;
} else {
# "domain":"cluster.com"
$value =~ /\"(\S+)\"/;
$hash{$key} = $1;
return \%hash;
}
}
}
# for those who look like
# ["10.1.255.250","192.168.200.16","192.168.200.19","192.168.200.22"]
else {
if ($input =~ /^\[(.*)\]/s) {
my $content = $1;
print "[] content is $content \n" if($debug);
my @all = split /,/, $content;
foreach my $n (@all) {
$n =~ /\"(.*)\"/;
$hash{$1} = 1;
}
return \%hash;
}
}
}
############################
# check curl running code #
############################
sub check_errcode
{
if(!open (ERRLOG, "</tmp/err.log")) {
log_me("can't open err.log in tmp");
return 1;
}
my $num;
while (<ERRLOG>){
if (/HTTP\/\w*\.*\w* (\w+) (\w+)/) {
$num = $1;
last;
}
}
close ERRLOG;
print_debug("can't get errorcode\n") unless($num);
return $num;
}
############################
# check curl return result #
############################
sub check_result
{
my $data = shift;
my $opterator = shift;
my $output = shift;
if ( !open (OUTPUT, "<$output")) {
log_me("can't read output file");
return 1;
}
my $res;
while (<OUTPUT>) {
$res .= $_;
}
close OUTPUT;
my $expects = transf_hash(parse_json($data)); # one entry
my $actuals = transf_hash(parse_json($res)); # serval entries
print_debug("expected result is:\n");
print_debug($expects);
print_debug("testcase run result is \n");
print_debug($actuals);
my $flag = 0;
my %flaghash;
my $expect = $$expects[0]; # $expect = ANY:ANY:x86_64
my @expectvalue = split /:/, $expect; #@expectvalue = ANY, ANY, x86_64
$flag = 0;
foreach my $expval (@expectvalue) { # $expval = ANY
foreach my $actual (@$actuals) { # $actual = nodetype:arch:x86_64
if($flaghash{$actual} eq "none"){
next;
}
my @actualvalue = split /:/, $actual; # @actualvalue = nodetype, arch, x86_64
print_debug("begin to compare $expval and $actualvalue[$flag]");
if(($expval eq $actualvalue[$flag]) or ($expval eq "ANY")) { #ANY =~ nodetype
$flaghash{$actual} = "eq";
} elsif (($expval =~ $actualvalue[$flag]) or ($expval eq "ANY")) {
$flaghash{$actual} = "match";
} else {
$flaghash{$actual} = "none";
}
print_debug(", compare result is $flaghash{$actual}\n");
}
$flag++;
}
print_debug("search result is \n");
print_debug(\%flaghash);
if ($opterator eq "!="){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "eq") {
print_debug("compare result: failed\n");
return 1; # fail
}
}
print_debug("compare result: succeed\n");
return 0; #succeed
}
if ($opterator eq "=="){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "eq") {
print_debug("compare result: succeed\n");
return 0; # succeed
}
}
print_debug("compare result: failed\n");
return 1; #fail
}
if ($opterator eq "=~"){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "match") {
print_debug("compare result: succeed\n");
return 0; # succeed
}
}
print_debug("compare result: failed\n");
return 1; #fail
}
if ($opterator eq "!=~"){
foreach my $val (keys %flaghash) {
if ($flaghash{$val} eq "match") {
print_debug("compare result: failed\n");
return 1; # fail
}
}
print_debug("compare result: succeed\n");
return 0; #succeed
}
}
####################################
# help to transfer hash into array #
####################################
sub find_key
{
my $input = shift;
my $en = shift;
my $ou = shift;
if( ref($input) =~ "HASH") {
foreach my $val (keys %$input) {
my $tmp = $$en; # keey head
$$en .= "$val:";
my $t1 = find_key($$input{$val}, $en, $ou);
if ($$en == ""){
$$en = $tmp; #restore head
}
}
} else {
$$en .= $input;
push @$ou, $$en;
$$en = ""; # clear entry;
}
}
############################
# transfer hash into array #
############################
sub transf_hash
{
my $input = shift;
my $entry;
my @array;
find_key($input, \$entry, \@array);
return \@array;
}
-4
View File
@@ -39,7 +39,6 @@ pod2html pods/man1/xcattest.1.pod > share/doc/man1/xcattest.1.html
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
mkdir -p $RPM_BUILD_ROOT/%{prefix}/sbin
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools/autotest
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
@@ -47,9 +46,6 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
cp xcattest $RPM_BUILD_ROOT/%{prefix}/bin
chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
cp restapitest $RPM_BUILD_ROOT/%{prefix}/sbin
chmod 755 $RPM_BUILD_ROOT/%{prefix}/sbin/*
# These were built dynamically in the build phase
cp share/man/man1/* $RPM_BUILD_ROOT/%{prefix}/share/man/man1
chmod 444 $RPM_BUILD_ROOT/%{prefix}/share/man/man1/*
+16 -41
View File
@@ -25,10 +25,10 @@ my $string1 = undef;
if (
!GetOptions("h|?" => \$needhelp,
"f=s" => \$configfile,
"b=s" => \$bundle_list,
"t=s" => \$case_list,
"c=s" => \$cmd_list,
"l" => \$needshow,
"b=s" => \$bundle_list,
"t=s" => \$case_list,
"c=s" => \$cmd_list,
"l" => \$needshow,
"restore"=>\$restore)
)
{
@@ -221,7 +221,7 @@ sub getConfig
}
}
}
if(exists $config{object}){
foreach my $type (keys %{$config{object}}){
foreach my $name (keys %{$config{object}{$type}}){
@@ -344,7 +344,7 @@ sub init
log_this("No compute node defined,can't get ARCH of compute node");
} else {
$config{var}{ARCH} = getnodeattr($config{var}{CN},"arch");
if($config{var}{ARCH} =~ /ppc/){
if($config{var}{ARCH} =~ /ppc/){
$config{var}{ARCH} = 'ppc';
}elsif($config{var}{ARCH}=~/86/){
$config{var}{ARCH} = 'x86';
@@ -432,7 +432,7 @@ sub loadcase
my $j = -1;
my $z = 0;
my $skip = 0;
my @caserange = ();
my @rightcase = ();
my @notrightcase = ();
@@ -452,7 +452,7 @@ sub loadcase
}
}
if($case_list){
@caserange = split /,/, $case_list;
@caserange = split /,/, $case_list;
}
foreach $file (@files){
if(!open(FILE, "<$file")){
@@ -477,11 +477,10 @@ sub loadcase
$j = -1;
$cases[$i]={};
$cases[$i]->{name}=$name;
$cases[$i]->{filename}=$file;
$cases[$i]->{filename}=$file;
if(!$needshow){
$cases[$i]->{cmd}=[];
$cases[$i]->{check}=[];
$cases[$i]->{cmdcheck}=[];
push(@rightcase, $name);
}else{
$skip = 1;
@@ -498,13 +497,13 @@ sub loadcase
$cases[$i]->{os}=$string1;
}
if($cases[$i]->{os} !~ /$config{var}{OS}/){
push(@notrightcase, $cases[$i]->{name});
pop(@rightcase);
$skip = 1;
}
}elsif($line =~ /^arch\s*:\s*(\w[\w\,]+)/){
next if $skip;
$cases[$i]->{arch}=$1;
@@ -546,14 +545,6 @@ sub loadcase
return 1;
}
$z = $z + 1;
}elsif($line =~ /^cmdcheck\s*:\s*(\w.+)/){
next if $skip;
$cases[$i]->{cmdcheck}->[$j][$z] = &getvar($1);
if($cases[$i]->{cmdcheck}->[$j][$z] eq ''){
close(FILE);
return 1;
}
$z = $z + 1;
}elsif($line =~ /^end/){
next if $skip;
$i = $i + 1;
@@ -631,7 +622,7 @@ sub getfunc
$func = $1;
$parameter = $2;
@para = split /\s*,\s*/, trim($parameter);
if($func eq "GETNODEATTR"){
if($func eq "GETNODEATTR"){
$value= getnodeattr(@para);
if($value eq "Unknown"){
$value = '';
@@ -669,9 +660,9 @@ sub runcase
my $time1=gmtime $now1;
log_this("------START:$$case{name}::Time:$time1------");
push @record, "------START:$$case{name}::Time:$time1------";
push @record, "FILENAME:$$case{filename}";
push @record, "FILENAME:$$case{filename}";
foreach my $cmd (@{$$case{cmd}}){
$cmd = getfunc($cmd);
$cmd = getfunc($cmd);
#by
my $runstart=timelocal(localtime());
@@ -684,10 +675,10 @@ sub runcase
my $diffduration=$runstop-$runstart;
log_this("\n[$cmd] Running Time:$diffduration sec");
push(@record,("\n[$cmd] Running Time:$diffduration sec"));
log_this("RETURN: rc = $rc","OUTPUT:",@output);
push(@record,("RETURN rc = $rc","OUTPUT:",@output));
foreach my $check (@{$$case{check}->[$j]}){
if($failed){
@@ -765,19 +756,6 @@ sub runcase
}
}
}
foreach my $cmdcheck (@{$$case{cmdcheck}->[$j]}){
if($cmdcheck) {
&runcmd($cmdcheck);
$rc = $::RUNCMD_RC;
if($rc == 1) {
log_this("CMDCHECK:output $cmdcheck\t[Failed]");
push(@record, "CHECK:output $cmdcheck\t[Failed]");
} elsif ($rc == 0) {
log_this("CMDCHECK:output $cmdcheck\t[Pass]");
push(@record, "CHECK:output $cmdcheck\t[Pass]");
}
}
}
$j = $j + 1;
}
my $now2=timelocal(localtime());
@@ -808,7 +786,6 @@ sub runcmd
if ($?)
{
$rc = $? ;
$rc = $rc >> 8;
$::RUNCMD_RC = $rc;
}
chomp(@$outref);
@@ -846,5 +823,3 @@ sub getreport
close(FD);
close(STDOUT);
}
-1
View File
@@ -5,5 +5,4 @@ install/prescripts
install/kdump
opt/xcat/share/xcat
etc/apache2/conf.d
etc/apache2/conf-enabled
opt/xcat/share/doc/packages/xCAT
+1 -1
View File
@@ -1,5 +1,5 @@
xcat.conf etc/apache2/conf.d/
xcat.conf.apach24 etc/apache2/conf-enabled
xcat.conf.apach24 etc/apache2/conf.d/
LICENSE.html opt/xcat/share/doc/packages/xCAT
postscripts/* install/postscripts/
prescripts/* install/prescripts/
+6 -4
View File
@@ -40,10 +40,12 @@ case "$1" in
else
xcatconfig -i -d -s
fi
# [ -e /etc/apache2/conf-enabled/xcat.conf ] && rm /etc/apache2/conf-enabled/xcat.conf
# mv /etc/apache2/conf-enabled/xcat.conf.apach24 /etc/apache2/conf-enabled/xcat.conf
ver=$(cat /etc/issue |awk '{print $2}')
num=${ver%.*}
file="xcat.conf.apach24"
if [ $num -gt 12 ];then
mv /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf-enabled/xcat.conf
fi
/etc/init.d/apache2 restart
;;
-11
View File
@@ -27,10 +27,6 @@ function configipv4(){
echo "NETWORK_${num_v4num}=${str_v4net}" >> $str_conf_file
echo "LABEL_${num_v4num}=${num_v4num}" >> $str_conf_file
fi
if [[ ${str_if_name} == [a-zA-Z0-9]*.[0-9]* ]]; then
echo "VLAN=yes" >> $str_conf_file
fi
#debian ubuntu
elif [ "$str_os_type" = "debian" ];then
str_conf_file="/etc/network/interfaces.d/${str_if_name}"
@@ -44,10 +40,6 @@ function configipv4(){
echo " address ${str_v4ip}" >> $str_conf_file
echo " netmask ${str_v4mask}" >> $str_conf_file
echo " network ${str_v4net}" >> $str_conf_file
if [[ ${str_if_name} == [a-zA-Z0-9]*.[0-9]* ]]; then
parent_device=`echo ${str_if_name} | sed -e 's/\([a-zA-Z0-9]*\)\.[0-9]*/\1/g'`
echo " vlan-raw-device ${parent_device}" >> $str_conf_file
fi
else
# Write the info to the ifcfg file for redhat
str_conf_file=""
@@ -64,9 +56,6 @@ function configipv4(){
echo "IPADDR=${str_v4ip}" >> $str_conf_file
echo "NETMASK=${str_v4mask}" >> $str_conf_file
echo "ONBOOT=yes" >> $str_conf_file
if [[ ${str_if_name} == [a-zA-Z0-9]*.[0-9]* ]]; then
echo "VLAN=yes" >> $str_conf_file
fi
fi
}
+43 -479
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# IBM(c) 2011EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------------------------------
@@ -6,26 +6,10 @@
#=head2 routeop is called by makeroutes command and setuproutes postscript to
# setup a route on a node.
# The syntax is:
# routeop add/delete net mask gateway ifnamea #NOTE: the add/delete will be
# obsoleted, using 'replace' is recommended.
# routeop replace net mask gateway ifname #NOTE: it only works for sles so far
# net - IP of net like 192.168.1.0. The keyword
# 'default' is used to set the default route.
# mask - The length of the netmask (CIDR) like 8,16,24 OR
# the dotted-decimal format like 255.255.0.0
# gateway - The next hop. It could be set to 0.0.0.0 for omitting
# ifname - The interface to route to the next hop
#=head3 example
# routeop replace default 0 10.1.0.209 eth0
# routeop replace 50.1.0.0 16 10.1.0.210 eth0
# routeop replace 60.1.1.0 24 0.0.0.0 eth0
# routeop replace 70.1.1.0 24 10.1.0.211 #NOTE: this is NOT supported for redhat
# routeop add/delete net mask gateway ifname
#=cut
#-------------------------------------------------------------------------------
str_dir_name=`dirname $0`
. $str_dir_name/xcatlib.sh
op=$1
net=$2
@@ -35,25 +19,6 @@ if [ -n "$5" ]; then
ifname=$5
fi
# use nummask to know whether the netmask format is 255.255.255.0 or CIDR (a number)
nummask=0
echo $mask | egrep "^[.0123456789]+$" > /dev/null
if [ $? -ne 0 ]; then
echo "Error: invalid format of netmask $mask."
exit 1
else
echo $mask | egrep "^[0123456789]+$" > /dev/null
if [ $? -eq 0 ]; then # only has digital
nummask=1 # the netmask is the length of network mask.
if [ $mask -ge 128 ]; then
echo "Error: invalid format of netmask $mask."
exit 1
fi
fi
fi
function debianpreconf(){
#create the config sub dir
if [ ! -d "/etc/network/interfaces.d" ];then
@@ -142,8 +107,7 @@ route_exists()
net1=`echo $x|cut -d',' -f1`
gw1=`echo $x|cut -d',' -f2`
mask1=`echo $x|cut -d',' -f3`
ifname1=`echo $x|cut -d',' -f8`
if [ "$net" = "$net1" ] && [ "$mask" = "$mask1" ] && [ "$gw" = "$gw1" ] && [ "$ifname" = "$ifname1" ]; then
if [ "$net" = "$net1" ] && [ "$mask" = "$mask1" ] && [ "$gw" = "$gw1" ]; then
ret=1
break
fi
@@ -178,238 +142,6 @@ route_exists()
echo $ret
}
# handle the route replace operation that adding the setting to configuration file
replace_persistent_route()
{
net=$1;
mask=$2;
gw=$3;
if [ -n "$4" ]; then
ifname=$4
fi
if [ "$(uname -s)" = "Linux" ]; then
#determine the os name
OS_name="something"
if [ -f /etc/redhat-release ]
then
OS_name="redhat" #it can be RedHatFerdora or CentOS
elif [ -f /etc/SuSE-release ]
then
OS_name="sles"
else
OS_name="debian"
fi
# The replace operation does not support debain so far
if [ "$OS_name" != "redhat" ] && [ "$OS_name" != "sles" ]; then
echo "Warning: replace operation only supports to add persistent route for sles and redhat by now."
return
fi
# set the destination of the route for searching in the route configuration file
if [ "$net" = "default" ]; then
routedest="default"
routedest1="default"
else
routedest="$net/$mask"
routedest1="$net\/$mask"
fi
case $OS_name in
sles)
filename="/etc/sysconfig/network/routes";
if echo $net | grep : 2>&1 1>/dev/null
then
# for ipv6
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$net/$mask :: - $ifname"
route1="$net\/$mask :: - $ifname";
else
route="$net/$mask $gw - -"
route1="$net\/$mask $gw - -";
fi
else
# for ipv4
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ "$net" = "default" ]; then
route="default - - $ifname";
route1="default - - $ifname";
else
route="$net/$mask - - $ifname";
route1="$net\/$mask - - $ifname";
fi
else
if [ "$net" = "default" ]; then
route="default $gw - $ifname";
route1="default $gw - $ifname";
else
route="$net/$mask $gw - $ifname";
route1="$net\/$mask $gw - $ifname";
fi
fi
fi
if [ -f $filename ]; then
egrep "^$routedest" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #route does not exist
echo $route >> $filename
echo "Persistent route \"$route\" has been added in $filename."
else
# replace it
sed -i -e "s/$routedest1.*/$route1/g" $filename
echo "Persistent route \"$route\" has been replaced in $filename."
fi
else
echo "$route" > $filename
echo "Persistent route \"$route\" has been added in $filename."
fi
;;
redhat)
#echo "rh/fedora/centos"
if [ -z "$ifname" ]; then
echo "Error: the device name is necessary to configure static route."
return
fi
if echo $net | grep : 2>&1 1>/dev/null
then
# ipv6
filename="/etc/sysconfig/network-scripts/route6-$ifname"
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$net/$mask dev $ifname"
route1="$net\/$mask dev $ifname"
else
route="$net/$mask via $gw"
route1="$net\/$mask via $gw"
fi
else
# ipv4
filename="/etc/sysconfig/network-scripts/route-$ifname"
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
route="$net/$mask dev $ifname"
route1="$net\/$mask dev $ifname"
else
route="$net/$mask via $gw"
route1="$net\/$mask via $gw"
fi
fi
if [ -f $filename ]; then
egrep "^$routedest" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #route does not exist
echo $route >> $filename
echo "Persistent route \"$route\" has been added in $filename."
else
# replace it
sed -i -e "s/$routedest1.*/$route1/g" $filename
echo "Persistent route \"$route\" has been replaced in $filename."
fi
else
echo "$route" > $filename
echo "Persistent route \"$route\" has been added in $filename."
fi
;;
debian)
debianpreconf
matchstr=""
v6flag=0
#on debian/ubuntu need the network device name
if [ ! $ifname ];then
ifname=`netstat -nr | grep "$net" | awk '{print $8}' | head -1`
fi
filename="/etc/network/interfaces.d/$ifname"
if [ ! -f $filename ];then
echo "auto $ifname" > $filename
echo "iface $ifname inet dhcp" >> $filename
fi
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
matchstr="$net/$mask gw $gw"
fi
v6flag=1
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
matchstr="net $net netmask $mask dev $ifname"
else
matchstr="net $net netmask $mask gw $gw"
fi
fi
grep "$matchstr" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ];then
foundflag=0
tempfile="/etc/network/interfaces.d/tmp"
while read LINE
do
echo $LINE | grep "iface" 2>&1 1>/dev/null
if [ $? -eq 0 -a $foundflag -eq 1 ];then
foundflag=0
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null
#this is the last line of the device
if [ $? -eq 0 ];then
foundflag=1
fi
echo $LINE >> $tempfile
done < $filename
#the insert place is the last line of the config file
if [ $foundflag -eq 1 ];then
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
fi
mv -f $tempfile $filename
echo "Persistent route \"$matchstr\" added in $filename."
else
echo "Persisten route \"$match\" already exists in $filename"
fi
;;
esac
else #AIX
echo "Adding persistent route on AIX is not supported yet."
fi
}
# handle the route add operation that adding the setting to configuration file
add_persistent_route()
{
net=$1;
@@ -435,14 +167,6 @@ add_persistent_route()
OS_name="debian"
fi
# The replace operation does not support redhat and debain so far
if [ "$op" = "replace" ]; then
if [ "$OS_name" = "redhat" -o "$OS_name" = "debain" ]; then
echo "Warning: replace operation only supports to add persistent route for sles by now."
return
fi
fi
case $OS_name in
sles)
#echo "sles"
@@ -450,56 +174,26 @@ add_persistent_route()
filename="/etc/sysconfig/network/routes";
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$net/$mask :: - $ifname"
route1="$net\/$mask :: - $ifname";
else
route="$net/$mask $gw - -"
route1="$net\/$mask $gw - -";
fi
route="$net/$mask $gw - -"
route1="$net\/$mask $gw - -";
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ $nummask -eq 1 ]; then
if [ "$net" = "default" ]; then
route="default - - $ifname";
route1="default - - $ifname";
else
route="$net/$mask - - $ifname";
route1="$net\/$mask - - $ifname";
fi
else
route="$net 0.0.0.0 $mask $ifname";
route1="$net 0.0.0.0 $mask $ifname";
fi
else
if [ $nummask -eq 1 ]; then
if [ "$net" = "default" ]; then
route="default $gw - $ifname";
route1="default $gw - $ifname";
else
route="$net/$mask $gw - $ifname";
route1="$net\/$mask $gw - $ifname";
fi
else
route="$net $gw $mask $ifname";
route1="$net $gw $mask $ifname";
fi
fi
route="$net $gw $mask $ifname";
route1="$net $gw $mask $ifname";
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #route does not exist
grep "$xcat_config_start" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #no xCAT section
echo $xcat_config_start >> $filename
echo $route >> $filename
echo $xcat_config_end >> $filename
else
sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename
fi
echo "Persistent route \"$route\" added in $filename."
grep "$xcat_config_start" $filename 2>&1 1>/dev/null
if [ $? -ne 0 ]; then #no xCAT section
echo $xcat_config_start >> $filename
echo $route >> $filename
echo $xcat_config_end >> $filename
else
sed -i -e s/"$xcat_config_end"/"$route1\n$xcat_config_end"/g $filename
fi
echo "Persistent route \"$route\" added in $filename."
else
echo "Persistent route \"$route\" already exists in $filename."
echo "Persistent route \"$route\" already exists in $filename."
fi
else
#echo "got here"
@@ -527,18 +221,10 @@ add_persistent_route()
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
matchstr="$net/$mask gw $gw"
fi
matchstr="$net/$mask gw $gw"
v6flag=1
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
matchstr="net $net netmask $mask dev $ifname"
else
matchstr="net $net netmask $mask gw $gw"
fi
matchstr="net $net netmask $mask gw $gw"
fi
grep "$matchstr" $filename 2>&1 1>/dev/null
@@ -551,21 +237,11 @@ add_persistent_route()
if [ $? -eq 0 -a $foundflag -eq 1 ];then
foundflag=0
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
echo $LINE | grep "iface $ifname " 2>&1 1>/dev/null
@@ -579,21 +255,11 @@ add_persistent_route()
#the insert place is the last line of the config file
if [ $foundflag -eq 1 ];then
if [ $v6flag -eq 1 ];then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
echo " up route -A inet6 add $net/$mask dev $ifname" >> $tempfile
echo " down route -A inet6 del $net/$mask dev $ifname" >> $tempfile
else
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
fi
echo " up route -A inet6 add $net/$mask gw $gw" >> $tempfile
echo " down route -A inet6 del $net/$mask gw $gw" >> $tempfile
else
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
echo " up route add -net $net netmask $mask dev $ifname" >> $tempfile
echo " down route del -net $net netmask $mask dev $ifname" >> $tempfile
else
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
echo " up route add -net $net netmask $mask gw $gw" >> $tempfile
echo " down route del -net $net netmask $mask gw $gw" >> $tempfile
fi
fi
mv -f $tempfile $filename
@@ -607,22 +273,14 @@ add_persistent_route()
# ipv6 net
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$gw" = "" ] ; then
$gw = "::";
fi
filename="/etc/sysconfig/static-routes-ipv6";
route="$ifname $net/$mask $gw";
# $net/mask does not work with sed cmd
route1="$ifname $net\/$mask $gw";
else
filename="/etc/sysconfig/static-routes";
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
route="any net $net netmask $mask dev $ifname";
route1="any net $net netmask $mask dev $ifname";
else
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@@ -682,23 +340,15 @@ rm_persistent_route()
# ipv6 net
if echo $net | grep : 2>&1 1>/dev/null
then
if [ $gw = "" -o $gw = "::" ] ; then
route="$net/$mask :: - $ifname";
route1="$net\/$mask :: - $ifname";
route="$net/$mask $gw - -";
route1="$net\/$mask $gw - -";
else
route="$net/$mask $gw - -";
route1="$net\/$mask $gw - -";
fi
else
if [ $gw = "" ] ; then
$gw = "0.0.0.0";
fi
if [ -n "$ifname" ]; then
route="$net $gw $mask $ifname";
route1="$net $gw $mask $ifname";
else
route="$net $gw $mask -";
route1="$net $gw $mask -";
route="$net $gw $mask";
route1="$net $gw $mask";
fi
fi
if [ -f $filename ]; then
@@ -726,18 +376,10 @@ rm_persistent_route()
echo $net | grep : 2>&1 1>/dev/null
#ipv6
if [ $? -eq 0 ];then
if [ $gw = "" -o $gw = "::" ] ; then
matchstr="$net/$mask dev $ifname"
else
matchstr="$net/$mask gw $gw"
fi
matchstr="$net/$mask gw $gw"
v6flag=1
else
if [ $gw = "" -o $gw = "0.0.0.0" ] ; then
matchstr="net $net netmask $mask dev $ifname"
else
matchstr="net $net netmask $mask gw $gw"
fi
matchstr="net $net netmask $mask gw $gw"
fi
grep "$matchstr" $filename
@@ -755,22 +397,12 @@ rm_persistent_route()
then
filename="/etc/sysconfig/static-routes-ipv6";
# $net/$mask does not work with sed
if [ "$gw" = "" -o "$gw" = "::" ] ; then
route="$ifname $net\/$mask ::"
route1="$ifname $net/$mask ::"
else
route="$ifname $net\/$mask $gw"
route1="$ifname $net/$mask $gw"
fi
route="$ifname $net\/$mask $gw"
route1="$ifname $net/$mask $gw"
else
filename="/etc/sysconfig/static-routes";
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
route="any net $net netmask $mask dev $ifname";
route1="any net $net netmask $mask dev $ifname";
else
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
route="any net $net netmask $mask gw $gw $ifname";
route1="any net $net netmask $mask gw $gw $ifname";
fi
if [ -f $filename ]; then
grep "$route" $filename 2>&1 1>/dev/null
@@ -799,22 +431,14 @@ if [ "$op" = "add" ]; then
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
cmd="ip -6 route add $net/$mask dev $ifname"
else
cmd="ip -6 route add $net/$mask via $gw"
fi
cmd="ip -6 route add $net/$mask via $gw"
else
# AIX TODO
cmd="ip -6 route add $net/$mask via $gw"
fi
else
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
cmd="route add -net $net netmask $mask dev $ifname"
else
cmd="route add -net $net netmask $mask gw $gw"
fi
cmd="route add -net $net netmask $mask gw $gw"
else
cmd="route add -net $net -netmask $mask $gw"
fi
@@ -848,22 +472,14 @@ elif [ "$op" = "delete" ]; then
if echo $net | grep : 2>&1 1>/dev/null
then
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
cmd="ip -6 route delete $net/$mask dev $ifname"
else
cmd="ip -6 route delete $net/$mask via $gw"
fi
cmd="ip -6 route delete $net/$mask via $gw"
else
# AIX TODO
cmd="ip -6 route delete $net/$mask via $gw"
fi
else
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
cmd="route delete -net $net netmask $mask dev $ifname"
else
cmd="route delete -net $net netmask $mask gw $gw"
fi
cmd="route delete -net $net netmask $mask gw $gw"
else
cmd="route delete -net $net -netmask $mask $gw"
fi
@@ -882,57 +498,5 @@ elif [ "$op" = "delete" ]; then
#remove the persistent route
rm_persistent_route $net $mask $gw $ifname
elif [ "$op" = "replace" ]; then
if [ $nummask -ne 1 ]; then
mask=$(v4mask2prefix $mask)
fi
if echo $net | grep : 2>&1 1>/dev/null
then # ipv6
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "::" ] ; then
if [ "$net" = "default" ]; then
cmd="ip -6 route replace default dev $ifname"
else
cmd="ip -6 route replace $net/$mask dev $ifname"
fi
else
if [ "$net" = "default" ]; then
cmd="ip -6 route replace default via $gw"
else
cmd="ip -6 route replace $net/$mask via $gw"
fi
fi
fi
else #ipv4
if [ "$(uname -s)" = "Linux" ]; then
if [ "$gw" = "" -o "$gw" = "0.0.0.0" ] ; then
if [ "$net" = "default" ]; then
cmd="ip route replace default dev $ifname"
else
cmd="ip route replace $net/$mask dev $ifname"
fi
else
if [ "$net" = "default" ]; then
cmd="ip route replace default via $gw"
else
cmd="ip route replace $net/$mask via $gw"
fi
fi
fi
fi
echo "Adding temporary route: $cmd"
result=`$cmd 2>&1`
code=$?
if [ $code -ne 0 ]; then
logger -t xCAT -p local4.err "Error: $cmd [error code=$code, result=$result]"
echo "Error: $cmd [error code=$code, result=$result]"
exit 1;
fi
#replace the persistent route
replace_persistent_route $net $mask $gw $ifname
fi
exit 0
+3 -1
View File
@@ -68,4 +68,6 @@ echo "$TMP" > /tmp/xcatenv
. /tmp/xcatenv
/xcatpost/addsiteyum
/xcatpost/updateflag.awk $MASTER 3002
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
/xcatpost/updateflag.awk $MASTER 3002
fi
+3 -12
View File
@@ -2,11 +2,8 @@
# IBM(c) 2011 EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------------------------------
#=head1 setroute [add]
# [add] - The operation to manipulate the route entry. It is optional.
# The default is 'replace' if ignoring it.
#
#=head2 setrout command replaces/adds the routes to the node according to
#=head1 setroute
#=head2 setrout command adds the routes to the node according to
# what is specified in the xCAT tables.
# The route name for the node is defined in noderes.routenames.
# The route itself is defined in the routes table.
@@ -17,12 +14,6 @@ if [ -z "$NODEROUTENAMES" ]; then
exit 0
fi
OP="replace"
if [ -n "$1" ] && [ "$1" = "add" ]; then
OP="add"
fi
for rn in `echo "$NODEROUTENAMES" | tr "," "\n"`
do
eval route_string=\$ROUTE_$rn
@@ -43,7 +34,7 @@ do
mask=`echo $mask | awk -F'/' '{print $2}'`
fi
cmd="routeop $OP $net $mask $gw $ifname"
cmd="routeop add $net $mask $gw $ifname"
result=`$cmd 2>&1`
echo $result
done
+5 -9
View File
@@ -42,16 +42,12 @@ download_postscripts()
return 1;
fi
# Do not override the parameter --installdir
if [ -z "$INSTALLDIR" ]; then
if [ -f /opt/xcat/xcatinfo ]; then
INSTALLDIR=`grep 'INSTALLDIR' /opt/xcat/xcatinfo |cut -d= -f2`
fi
if [ -z "$INSTALLDIR" ]; then
INSTALLDIR="/install"
fi
if [ -f /opt/xcat/xcatinfo ]; then
INSTALLDIR=`grep 'INSTALLDIR' /opt/xcat/xcatinfo |cut -d= -f2`
fi
if [ -z "$INSTALLDIR" ]; then
INSTALLDIR="/install"
fi
max_retries=5
retry=0
rc=1 # this is a fail return
+22 -18
View File
@@ -116,7 +116,6 @@ fi
%install
mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig
mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d
mkdir -p $RPM_BUILD_ROOT/install/postscripts
@@ -153,9 +152,10 @@ chmod 755 $RPM_BUILD_ROOT/install/postscripts/*
rm LICENSE.html
mkdir -p postscripts/hostkeys
cd -
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach22
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach24
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach22
cp %{SOURCE7} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach24
cp %{SOURCE5} $RPM_BUILD_ROOT/etc/xCATMN
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
@@ -163,22 +163,21 @@ cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
%post
%ifos linux
#Apply the correct httpd/apache configuration file according to the httpd/apache version
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
if expr match $(rpm -q --queryformat "%{VERSION}" httpd) '^2.4[\.0-9]*$' >/dev/null 2>&1
then
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
fi
if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/apache2/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
ln -s -f /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
else
ln -s -f /etc/httpd/conf.d/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf
fi
%endif
if expr match $(rpm -q --queryformat "%{VERSION}" apache2) '^2.4[\.0-9]*$' >/dev/null 2>&1
then
ln -s -f /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
else
ln -s -f /etc/apache2/conf.d/xcat.conf.apach22 /etc/apache2/conf.d/xcat.conf
fi
# create dir for the current pid
mkdir -p /var/run/xcat
@@ -212,9 +211,12 @@ exit 0
%files
%{prefix}
# one for sles, one for rhel. yes, it's ugly...
/etc/xcat/conf.orig/xcat.conf.apach24
/etc/httpd/conf.d/xcat.conf
/etc/apache2/conf.d/xcat.conf
/etc/httpd/conf.d/xcat.conf.apach22
/etc/httpd/conf.d/xcat.conf.apach24
/etc/apache2/conf.d/xcat.conf.apach22
/etc/apache2/conf.d/xcat.conf.apach24
/etc/xCATMN
/install/postscripts
/install/prescripts
@@ -228,6 +230,8 @@ exit 0
if [ "$1" = "0" ]; then
rm /etc/httpd/conf.d/xcat.conf
rm /etc/apache2/conf.d/xcat.conf
%ifnos linux
if grep "^xcatd" /etc/inittab >/dev/null
+1 -23
View File
@@ -15,7 +15,6 @@ Source1: xcat.conf
Source2: license.tar.gz
Source3: xCATSN
Source5: templates.tar.gz
Source6: xcat.conf.apach24
Provides: xCATsn = %{version}
Requires: xCAT-server xCAT-client perl-DBD-SQLite
@@ -81,7 +80,6 @@ tar -xf license.tar
%install
%ifos linux
mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig
mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d/
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/
@@ -89,8 +87,6 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf
cp %{SOURCE3} $RPM_BUILD_ROOT/etc/xCATSN
cp %{SOURCE1} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach22
cp %{SOURCE6} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
@@ -126,23 +122,6 @@ fi
%endif
%post
%ifos linux
#Apply the correct httpd/apache configuration file according to the httpd/apache version
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
fi
if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/apache2/conf.d/xcat.conf
cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
fi
%endif
# create dir for the current pid and move the original ones from /tmp/xcat to /var/run/xcat
mkdir -p /var/run/xcat
if [ -r "/tmp/xcat/installservice.pid" ]; then
@@ -182,6 +161,7 @@ if [ -e "/etc/redhat-release" ]; then
else # SuSE
apachedaemon='apache2'
fi
# start xcatd on linux
chkconfig $apachedaemon on
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
@@ -219,8 +199,6 @@ fi
%{prefix}
# one for sles, one for rhel. yes, it's ugly...
%ifos linux
/etc/xcat/conf.orig/xcat.conf.apach24
/etc/xcat/conf.orig/xcat.conf.apach22
/etc/httpd/conf.d/xcat.conf
/etc/apache2/conf.d/xcat.conf
%endif