Merge branch '2.8' of ssh://git.code.sf.net/p/xcat/xcat-core into 2.8
This commit is contained in:
commit
92ec068fe4
@ -41,6 +41,13 @@ printusage()
|
||||
# For the purpose of getting the distribution name
|
||||
. /etc/lsb-release
|
||||
|
||||
# Process cmd line variable assignments, assigning each attr=val pair to a variable of same name
|
||||
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
|
||||
|
||||
# Supported distributions
|
||||
dists="maverick natty oneiric precise"
|
||||
|
||||
@ -122,9 +129,40 @@ then
|
||||
|
||||
ver=`cat Version`
|
||||
if [ "$PROMOTE" != 1 ]; then
|
||||
code_change=0
|
||||
update_log=''
|
||||
#get the version
|
||||
echo "svn --quiet update Version"
|
||||
svn --quiet up Version
|
||||
if [ "$REL" = "xcat-core" ];then
|
||||
git_flag=1
|
||||
REL=`git rev-parse --abbrev-ref HEAD`
|
||||
if [ "$REL" = "master" ]; then
|
||||
REL="devel"
|
||||
fi
|
||||
if [ -z "$GITUP" ];then
|
||||
update_log=../coregitup
|
||||
echo "git pull > $update_log"
|
||||
git pull > $update_log
|
||||
else
|
||||
update_log=$GITUP
|
||||
fi
|
||||
|
||||
if ! grep -q 'Already up-to-date' $update_log; then
|
||||
code_change=1
|
||||
fi
|
||||
else
|
||||
git_flag=0
|
||||
if [ -z "$SVNUP" ]; then
|
||||
update_log=../coresvnup
|
||||
echo "svn up > $update_log"
|
||||
svn up > $update_log
|
||||
else
|
||||
update_log=$SVNUP
|
||||
fi
|
||||
|
||||
if ! grep -q 'At revision' $update_log;then
|
||||
code_change=1
|
||||
fi
|
||||
fi
|
||||
ver=`cat Version`
|
||||
short_ver=`cat Version|cut -d. -f 1,2`
|
||||
short_short_ver=`cat Version|cut -d. -f 1`
|
||||
@ -132,17 +170,6 @@ then
|
||||
#TODO: define the core path and tarball name
|
||||
tarball_name="core-debs-snap.tar.bz2"
|
||||
|
||||
#update the code from svn
|
||||
svn_up_log="../coresvnup"
|
||||
echo "svn update > $svn_up_log"
|
||||
svn update > $svn_up_log
|
||||
|
||||
#makesure the code change status
|
||||
code_change=0
|
||||
if ! grep -q 'At revision' $svn_up_log;then
|
||||
code_change=1
|
||||
fi
|
||||
|
||||
if [ $code_change == 0 -a "$UP" != 1 -a "$BUILDALL" != 1 ]; then
|
||||
echo "Nothing new detected"
|
||||
exit 0
|
||||
@ -167,7 +194,7 @@ then
|
||||
for file in `echo $packages`
|
||||
do
|
||||
file_low=`echo $file | tr '[A-Z]' '[a-z]'`
|
||||
if grep -q $file $svn_up_log || [ "$BUILDALL" == 1 -o "$file" = "perl-xCAT" ]; then
|
||||
if grep -q $file $update_log || [ "$BUILDALL" == 1 -o "$file" = "perl-xCAT" ]; then
|
||||
rm -f ../../debs/${file_low}_*.deb
|
||||
#only for genesis package
|
||||
rm -f ../../debs/${file_low}-amd64_*.deb
|
||||
|
@ -1,5 +1,6 @@
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
package xCAT::NodeRange;
|
||||
use Text::Balanced qw/extract_bracketed/;
|
||||
require xCAT::Table;
|
||||
require Exporter;
|
||||
use strict;
|
||||
@ -549,6 +550,26 @@ sub abbreviate_noderange {
|
||||
return (join ',',keys %targetelems,keys %nodesleft);
|
||||
}
|
||||
|
||||
sub set_arith {
|
||||
my $operand = shift;
|
||||
my $op = shift;
|
||||
my $newset = shift;
|
||||
if ($op =~ /@/) { # compute the intersection of the current atom and the node list we have received before this
|
||||
foreach (keys %$operand) {
|
||||
unless ($newset->{$_}) {
|
||||
delete $operand->{$_};
|
||||
}
|
||||
}
|
||||
} elsif ($op =~ /,-/) { # add the nodes from this atom to the exclude list
|
||||
foreach (keys %$newset) {
|
||||
delete $operand->{$_}
|
||||
}
|
||||
} else { # add the nodes from this atom to the total node list
|
||||
foreach (keys %$newset) {
|
||||
$operand->{$_}=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
# Expand the given noderange
|
||||
# Input args:
|
||||
# - noderange to expand
|
||||
@ -573,6 +594,38 @@ sub noderange {
|
||||
}
|
||||
my %nodes = ();
|
||||
my %delnodes = ();
|
||||
if ($range =~ /\(/) {
|
||||
my ($middle, $end, $start) =
|
||||
extract_bracketed($range, '()', qr/[^()]*/);
|
||||
unless ($middle) { die "Unbalanced parentheses in noderange" }
|
||||
$middle = substr($middle,1,-1);
|
||||
my $op = ",";
|
||||
if ($start =~ m/-$/) { #subtract the parenthetical
|
||||
$op .= "-"
|
||||
} elsif ($start =~ m/@$/) {
|
||||
$op = "@"
|
||||
}
|
||||
$start =~ s/,-$//;
|
||||
$start =~ s/,$//;
|
||||
$start =~ s/@$//;
|
||||
%nodes = map { $_ => 1 } noderange($start,$verify,$exsitenode,%options);
|
||||
my %innernodes = map { $_ => 1 } noderange($middle,$verify,$exsitenode,%options);
|
||||
set_arith(\%nodes,$op,\%innernodes);
|
||||
$op=",";
|
||||
if ($end =~ m/^,-/) {
|
||||
$op = ",-";
|
||||
$end =~ s/^,-//;
|
||||
} elsif ($end =~ m/^@/) {
|
||||
$op = "@";
|
||||
$end =~ s/^@//;
|
||||
} else {
|
||||
$end =~ s/^,//;
|
||||
}
|
||||
my %endnodes = map { $_ => 1 } noderange($end,$verify,$exsitenode,%options);
|
||||
set_arith(\%nodes,$op,\%endnodes);
|
||||
return sort(keys %nodes)
|
||||
}
|
||||
|
||||
my $op = ",";
|
||||
my @elems = split(/(,(?![^[]*?])(?![^\(]*?\)))/,$range); # commas outside of [] or ()
|
||||
if (scalar(@elems)==1) {
|
||||
|
@ -550,6 +550,32 @@ sub get_allnode_singleattrib_hash
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 get_db_swtiches
|
||||
Description : Get all records of switch config from a table, then return a string list.
|
||||
Arguments : $tabname - the table name.
|
||||
Returns : Reference of the records hash.
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub get_db_switches
|
||||
{
|
||||
my $class = shift;
|
||||
my $table = xCAT::Table->new("switches");
|
||||
my @attribs = ("switch");
|
||||
my @entries = $table->getAllAttribs(@attribs);
|
||||
$table->close();
|
||||
my %allrecords;
|
||||
foreach (@entries)
|
||||
{
|
||||
if ($_->{'switch'}){
|
||||
$allrecords{$_->{'switch'}} = 0;
|
||||
}
|
||||
}
|
||||
return \%allrecords;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 get_db_swtichports
|
||||
Description : Get all records of switch config from a table, then return a string list.
|
||||
Arguments : $tabname - the table name.
|
||||
@ -563,6 +589,7 @@ sub get_db_switchports
|
||||
my $table = xCAT::Table->new("switch");
|
||||
my @attribs = ("switch", "port");
|
||||
my @entries = $table->getAllAttribs(@attribs);
|
||||
$table->close();
|
||||
my %allrecords;
|
||||
foreach (@entries)
|
||||
{
|
||||
|
@ -30,7 +30,6 @@ use strict;
|
||||
Example:
|
||||
my $retdata = xCAT::ServiceNodeUtils->readSNInfo;
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub readSNInfo
|
||||
{
|
||||
@ -102,13 +101,17 @@ sub isServiceReq
|
||||
require xCAT::Table;
|
||||
my ($class, $servicenodename, $serviceip) = @_;
|
||||
|
||||
# list of all services from service node table
|
||||
# note this must be updated if more services added
|
||||
my @services = (
|
||||
"nameserver", "dhcpserver", "tftpserver", "nfsserver",
|
||||
"conserver", "monserver", "ldapserver", "ntpserver",
|
||||
"ftpserver", "ipforward"
|
||||
);
|
||||
# get list of all services from service node table ( actually all defined attributes)
|
||||
# read the schema
|
||||
my $schema = xCAT::Table->getTableSchema("servicenode");
|
||||
my @services; # list of only the actual service attributes from the servicenode table
|
||||
my @servicesattrs; # building second copy for call to getAllNodeAttribs, which modifies the array
|
||||
foreach my $c (@{$schema->{cols}}) {
|
||||
if (($c ne "node") && ($c ne "comments") && ($c ne "disable")) {
|
||||
push @servicesattrs,$c;
|
||||
push @services,$c;
|
||||
}
|
||||
}
|
||||
|
||||
my @ips = @$serviceip; # list of service node ip addresses and names
|
||||
my $rc = 0;
|
||||
@ -139,10 +142,11 @@ sub isServiceReq
|
||||
}
|
||||
|
||||
my $servicehash;
|
||||
# read all the nodes from the table, for each service
|
||||
foreach my $service (@services)
|
||||
|
||||
# read all the nodes from the table, all the service attributes
|
||||
my @snodelist= $servicenodetab->getAllNodeAttribs(\@servicesattrs);
|
||||
foreach my $service (@services) # check list of services
|
||||
{
|
||||
my @snodelist = $servicenodetab->getAllNodeAttribs([$service]);
|
||||
|
||||
foreach $serviceip (@ips) # check the table for this servicenode
|
||||
{
|
||||
|
@ -323,6 +323,8 @@ sub handle_dbc_request {
|
||||
return $opentables{$tablename}->{$autocommit}->getAllNodeAttribs(@args);
|
||||
} elsif ($functionname eq 'getAllEntries') {
|
||||
return $opentables{$tablename}->{$autocommit}->getAllEntries(@args);
|
||||
} elsif ($functionname eq 'getMAXMINEntries') {
|
||||
return $opentables{$tablename}->{$autocommit}->getMAXMINEntries(@args);
|
||||
} elsif ($functionname eq 'writeAllEntries') {
|
||||
return $opentables{$tablename}->{$autocommit}->writeAllEntries(@args);
|
||||
} elsif ($functionname eq 'getAllAttribsWhere') {
|
||||
@ -3988,5 +3990,97 @@ sub output_table {
|
||||
print $fh "\n";
|
||||
return 0;
|
||||
}
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
=head3 getMAXMINEntries
|
||||
|
||||
Description: Select the rows in the Table which has the MAX and the row with the
|
||||
Min value for the input attribute.
|
||||
Currently only the auditlog and evenlog are setup to have such an attribute (recid).
|
||||
|
||||
Arguments:
|
||||
Table handle
|
||||
attribute name ( e.g. recid)
|
||||
|
||||
Returns:
|
||||
HASH
|
||||
max=> max value
|
||||
min=> min value
|
||||
Globals:
|
||||
|
||||
Error:
|
||||
|
||||
Example:
|
||||
|
||||
my $tabh = xCAT::Table->new($table);
|
||||
my $recs=$tabh->getMAXMINEntries("recid");
|
||||
|
||||
Comments:
|
||||
none
|
||||
|
||||
=cut
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getMAXMINEntries
|
||||
{
|
||||
my $self = shift;
|
||||
if ($dbworkerpid) {
|
||||
return dbc_call($self,'getMAXMINEntries',@_);
|
||||
}
|
||||
my $attr = shift;
|
||||
my $rets;
|
||||
my $query;
|
||||
my $xcatcfg=get_xcatcfg();
|
||||
# delimit the disable column based on the DB
|
||||
my $disable= &delimitcol("disable");
|
||||
my $qstring;
|
||||
if ($xcatcfg =~ /^DB2:/) { # for DB2
|
||||
$qstring = "SELECT MAX (\"$attr\") FROM " . $self->{tabname} . " WHERE " . $disable . " is NULL or " . $disable . " in ('0','no','NO','No','nO')";
|
||||
} else {
|
||||
$qstring = "SELECT MAX($attr) FROM " . $self->{tabname} . " WHERE " . $disable . " is NULL or " . $disable . " in ('0','no','NO','No','nO')";
|
||||
}
|
||||
$query = $self->{dbh}->prepare($qstring);
|
||||
|
||||
$query->execute();
|
||||
while (my $data = $query->fetchrow_hashref())
|
||||
{
|
||||
foreach (keys %$data)
|
||||
{
|
||||
if ($data->{$_} =~ /^$/)
|
||||
{
|
||||
$rets->{"max"} = undef;
|
||||
} else {
|
||||
$rets->{"max"} = $data->{$_};
|
||||
|
||||
}
|
||||
last; # better only be one value for max
|
||||
|
||||
}
|
||||
}
|
||||
$query->finish();
|
||||
if ($xcatcfg =~ /^DB2:/) { # for DB2
|
||||
$qstring = "SELECT MIN (\"$attr\") FROM " . $self->{tabname} . " WHERE " . $disable . " is NULL or " . $disable . " in ('0','no','NO','No','nO')";
|
||||
} else {
|
||||
$qstring = "SELECT MIN($attr) FROM " . $self->{tabname} . " WHERE " . $disable . " is NULL or " . $disable . " in ('0','no','NO','No','nO')";
|
||||
}
|
||||
$query = $self->{dbh}->prepare($qstring);
|
||||
|
||||
$query->execute();
|
||||
while (my $data = $query->fetchrow_hashref())
|
||||
{
|
||||
foreach (keys %$data)
|
||||
{
|
||||
if ($data->{$_} =~ /^$/)
|
||||
{
|
||||
$rets->{"min"} = undef;
|
||||
} else {
|
||||
$rets->{"min"} = $data->{$_};
|
||||
}
|
||||
last; # better be only one value for min
|
||||
}
|
||||
}
|
||||
return $rets;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
@ -343,7 +343,7 @@ my %usage = (
|
||||
renergy noderange [-V] { cappingstatus={on | enable | off | disable} | {cappingwatt|cappingvalue}=watt }",
|
||||
"updatenode" =>
|
||||
"Usage:
|
||||
updatenode [-h|--help|-v|--version]
|
||||
updatenode [-h|--help|-v|--version | -g|--genmypost]
|
||||
or
|
||||
updatenode <noderange> [-V|--verbose] [-k|--security] [-s|--sn]
|
||||
or
|
||||
@ -368,6 +368,9 @@ Options:
|
||||
[-f|--snsync] Performs File Syncing to the service nodes that service
|
||||
the nodes in the noderange.
|
||||
|
||||
[-g|--genmypost] Will generate a new mypostscript file for the
|
||||
the nodes in the noderange, if site precreatemypostscripts is 1 or YES.
|
||||
|
||||
[-l|--user] User name to run the updatenode command. It overrides the
|
||||
current user which is the default.
|
||||
|
||||
|
@ -21,10 +21,13 @@ use File::Path;
|
||||
use Socket;
|
||||
use strict;
|
||||
use Symbol;
|
||||
my $sha1support = eval {
|
||||
require Digest::SHA1;
|
||||
1;
|
||||
};
|
||||
my $sha1support;
|
||||
if ( -f "/etc/debian_version" ){
|
||||
$sha1support = eval {require Digest::SHA; 1;};
|
||||
}
|
||||
else {
|
||||
$sha1support = eval { require Digest::SHA1; 1;};
|
||||
}
|
||||
use IPC::Open3;
|
||||
use IO::Select;
|
||||
use xCAT::GlobalDef;
|
||||
@ -176,7 +179,13 @@ sub genUUID
|
||||
return $uuid;
|
||||
} elsif ($args{url} and $sha1support) { #generate a UUIDv5 from URL
|
||||
#6ba7b810-9dad-11d1-80b4-00c04fd430c8 is the uuid for URL namespace
|
||||
my $sum = Digest::SHA1::sha1('6ba7b810-9dad-11d1-80b4-00c04fd430c8'.$args{url});
|
||||
my $sum = '';
|
||||
if ( -f "/etc/debian_version" ){
|
||||
$sum = Digest::SHA::sha1('6ba7b810-9dad-11d1-80b4-00c04fd430c8'.$args{url});
|
||||
}
|
||||
else{
|
||||
$sum = Digest::SHA1::sha1('6ba7b810-9dad-11d1-80b4-00c04fd430c8'.$args{url});
|
||||
}
|
||||
my @data = unpack("C*",$sum);
|
||||
splice @data,16;
|
||||
$data[6] = $data[6] & 0xf;
|
||||
|
@ -19,10 +19,19 @@ use File::Path;
|
||||
use Socket;
|
||||
use strict;
|
||||
use Symbol;
|
||||
my $sha1support = eval {
|
||||
require Digest::SHA1;
|
||||
1;
|
||||
};
|
||||
if ( -f "/etc/debian_version" ) {
|
||||
$sha1support = eval {
|
||||
require Digest::SHA;
|
||||
1;
|
||||
};
|
||||
}
|
||||
else {
|
||||
|
||||
$sha1support = eval {
|
||||
require Digest::SHA1;
|
||||
1;
|
||||
};
|
||||
}
|
||||
use IPC::Open3;
|
||||
use IO::Select;
|
||||
use warnings "all";
|
||||
|
@ -171,6 +171,12 @@ sub process_request {
|
||||
# Do the check
|
||||
my $imageprofile = parse_str_arg($request->{arg}->[0]);
|
||||
|
||||
if (! exists($request->{kitdata}))
|
||||
{
|
||||
$rsp->{data}->[0] = "Skipped running \"$command\" plugin command for \"$PLUGIN_KITNAME\" kit.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
return;
|
||||
}
|
||||
my $kitdata = $request->{kitdata};
|
||||
if (! defined($kitdata)) {
|
||||
$kitdata = xCAT::KitPluginUtils->get_kits_used_by_image_profiles([$imageprofile]);
|
||||
@ -742,4 +748,4 @@ sub parse_list_arg {
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
@ -88,6 +88,7 @@ if (
|
||||
'v|version' => \$::VERSION,
|
||||
'V|verbose' => \$::VERBOSE,
|
||||
'F|sync' => \$::FILESYNC,
|
||||
'g|genmypost' => \$::GENMYPOST,
|
||||
'f|snsync' => \$::SNFILESYNC,
|
||||
'l|user:s' => \$::USER,
|
||||
'S|sw' => \$::SWMAINTENANCE,
|
||||
|
@ -21,12 +21,7 @@ set -e
|
||||
case "$1" in
|
||||
configure)
|
||||
. /etc/profile.d/xcat.sh
|
||||
if [ ! -e "/etc/rc0.d/K60xcatd" ];then
|
||||
update-rc.d xcatd start 85 2 3 4 5 . stop 60 0 1 6 .
|
||||
update-rc.d xcatd enable 2
|
||||
else
|
||||
update-rc.d xcatd enable
|
||||
fi
|
||||
update-rc.d xcatd defaults
|
||||
if [ -f /tmp/xCAT-server_upgrade.tmp ]; then
|
||||
if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image
|
||||
/etc/init.d/xcatd reload
|
||||
@ -36,12 +31,6 @@ case "$1" in
|
||||
ln -sf /opt/xcat/sbin/xcatd /usr/sbin/xcatd
|
||||
#SHA1 has been get rid of after Squeeze released. Its functionality is also provided by Digest::SHA (which is in core).
|
||||
#but ipmi.pm need SHA1.pm, so create this link
|
||||
shalocate=`find /usr/lib/perl -name "SHA.pm"`
|
||||
shalocate=${shalocate%SHA.pm}
|
||||
cd $shalocate
|
||||
if [ ! -e SHA1.pm ];then
|
||||
ln -s SHA.pm SHA1.pm
|
||||
fi
|
||||
cd -
|
||||
;;
|
||||
|
||||
|
@ -46,13 +46,24 @@ use Digest::MD5 qw/md5/;
|
||||
my $pendingpackets=0;
|
||||
my %tabooseq; #TODO: this is a global which means one taboo in the whole set causes unrelated session objects to consider it taboo unnecessarily
|
||||
my $maxpending; #determined dynamically based on rcvbuf detection
|
||||
my $ipmi2support = eval {
|
||||
require Digest::SHA1;
|
||||
Digest::SHA1->import(qw/sha1/);
|
||||
require Digest::HMAC_SHA1;
|
||||
Digest::HMAC_SHA1->import(qw/hmac_sha1/);
|
||||
1;
|
||||
};
|
||||
if ( -f "/etc/debian_release" ){
|
||||
$ipmi2support = eval {
|
||||
require Digest::SHA;
|
||||
Digest::SHA->import(qw/sha1/);
|
||||
require Digest::HMAC_SHA1;
|
||||
Digest::HMAC_SHA1->import(qw/hmac_sha1/);
|
||||
1;
|
||||
};
|
||||
}
|
||||
else {
|
||||
$ipmi2support = eval {
|
||||
require Digest::SHA1;
|
||||
Digest::SHA1->import(qw/sha1/);
|
||||
require Digest::HMAC_SHA1;
|
||||
Digest::HMAC_SHA1->import(qw/hmac_sha1/);
|
||||
1;
|
||||
};
|
||||
}
|
||||
my $aessupport;
|
||||
if ($ipmi2support) {
|
||||
$aessupport = eval {
|
||||
|
@ -178,7 +178,7 @@ sub subvars {
|
||||
my $source_in_pre;
|
||||
my $c = 0;
|
||||
foreach my $pkgdir(@pkgdirs) {
|
||||
if( $platform =~ /^(rh|SL)$/ ) {
|
||||
if( $platform =~ /^(rh|SL|centos)$/ ) {
|
||||
if ( $c == 0 ) {
|
||||
# After some tests, if we put the repo in pre scripts in the kickstart like for rhels6.x
|
||||
# the rhels5.9 will not be installed successfully. So put in kickstart directly.
|
||||
|
@ -69,15 +69,18 @@ sub validate {
|
||||
$policytable->close;
|
||||
my $rule;
|
||||
my $peerstatus="untrusted";
|
||||
# This sorts the policy table rows based on the level of the priority field in the row.
|
||||
# note the lower the number in the policy table the higher the priority
|
||||
my @sortedpolicies = sort { $a->{priority} <=> $b->{priority} } (@$policies);
|
||||
# check to see if peerhost is trusted
|
||||
foreach $rule (@$policies) {
|
||||
foreach $rule (@sortedpolicies) {
|
||||
|
||||
if (($rule->{name} and $rule->{name} eq $peername) && ($rule->{rule}=~ /trusted/i)) {
|
||||
$peerstatus="Trusted";
|
||||
last;
|
||||
}
|
||||
}
|
||||
RULE: foreach $rule (@$policies) {
|
||||
RULE: foreach $rule (@sortedpolicies) {
|
||||
if ($rule->{name} and $rule->{name} ne '*') {
|
||||
#TODO: more complex matching (lists, wildcards)
|
||||
next unless ($peername and $peername eq $rule->{name});
|
||||
|
@ -75,28 +75,65 @@ sub process_request {
|
||||
my $nodelist = $request->{node};
|
||||
my $retref;
|
||||
my $rsp;
|
||||
|
||||
if($command eq 'kitnodeadd')
|
||||
{
|
||||
setrsp_progress("Updating hosts entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makehosts"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Updating DNS entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makedns"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
if($macflag)
|
||||
{
|
||||
setrsp_progress("Update DHCP entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makedhcp"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
# Get nodes profile
|
||||
my $profileref = xCAT::ProfiledNodeUtils->get_nodes_profiles($nodelist);
|
||||
my %profilehash = %$profileref;
|
||||
|
||||
# Check whetehr we need to run makeconservercf
|
||||
# If one node has hardwareprofile, we need to run makeconservercf
|
||||
my $runconservercmd = 0;
|
||||
foreach (keys %profilehash) {
|
||||
if (exists $profilehash{$_}{'HardwareProfile'}) {
|
||||
$runconservercmd = 1;
|
||||
last;
|
||||
}
|
||||
|
||||
setrsp_progress("Update known hosts");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeknownhosts"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
}
|
||||
|
||||
my @commandslist;
|
||||
my %argslist;
|
||||
my %msghash = ( "makehosts" => "Updating hosts entries",
|
||||
"makedns" => "Updating DNS entries",
|
||||
"makedhcp" => "Update DHCP entries",
|
||||
"makeknownhosts" => "Update known hosts",
|
||||
"makeconservercf" => "Updating conserver configuration files",
|
||||
"kitnoderemove" => "Remove nodes entries from system configuration files first.",
|
||||
"nodeset" => "Update nodes' boot settings",
|
||||
"rspconfig" => "Updating FSP's IP address",
|
||||
"rscan" => "Update node's some attributes through 'rscan -u'",
|
||||
"mkhwconn" => "Sets up connections for nodes to FSP",
|
||||
);
|
||||
|
||||
# Stage1: pre-run
|
||||
if ($command eq 'kitnoderefresh') {
|
||||
# This is due to once update nicips table, we need remove node's records first and then re-create by run make* commands. If not, old records can't be removed.
|
||||
push @commandslist, ['makedns', '-d'];
|
||||
push @commandslist, ['makehosts', '-d'];
|
||||
}
|
||||
|
||||
# Stage2: run xcat commands
|
||||
if ($command eq 'kitnodeadd' or $command eq 'kitnodeupdate' or $command eq 'kitnoderefresh') {
|
||||
push @commandslist, ['makehosts', ''];
|
||||
push @commandslist, ['makedns', ''];
|
||||
if ($macflag) {
|
||||
push @commandslist, ['makedhcp', ''];
|
||||
}
|
||||
push @commandslist, ['makeknownhosts', ''];
|
||||
if ($runconservercmd) {
|
||||
push @commandslist, ['makeconservercf', ''];
|
||||
}
|
||||
}elsif ($command eq 'kitnoderemove') {
|
||||
if ($runconservercmd) {
|
||||
push @commandslist, ['makeconservercf', '-d'];
|
||||
}
|
||||
push @commandslist, ['makeknownhosts', '-r'];
|
||||
if ($macflag) {
|
||||
push @commandslist, ['makedhcp', '-d'];
|
||||
}
|
||||
}
|
||||
|
||||
# Stage3: post-run
|
||||
if ($command eq 'kitnodeadd') {
|
||||
my $firstnode = (@$nodelist)[0];
|
||||
my $chaintab = xCAT::Table->new("chain");
|
||||
my $chainref = $chaintab->getNodeAttribs($firstnode, ['chain']);
|
||||
@ -106,107 +143,37 @@ sub process_request {
|
||||
if($macflag)
|
||||
{
|
||||
if ($chainarray[0]){
|
||||
setrsp_progress("Update nodes' boot settings");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["nodeset"], node=>$nodelist, arg=>[$chainarray[0]]}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
push @commandslist, ['nodeset', $chainarray[0]];
|
||||
}
|
||||
}
|
||||
my $isfsp = xCAT::ProfiledNodeUtils->is_fsp_node([$firstnode]);
|
||||
if ($isfsp) {
|
||||
setrsp_progress("Updating FSP's IP address");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["rspconfig"], node=>$nodelist, arg=>['network=*']}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
my $cmmref = xCAT::ProfiledNodeUtils->get_nodes_cmm($nodelist);
|
||||
my @cmmchassis = keys %$cmmref;
|
||||
setrsp_progress("Update node's some attributes through 'rscan -u'");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["rscan"], node=>\@cmmchassis, arg=>['-u']}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Sets up connections for nodes to FSP");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["mkhwconn"], node=>$nodelist, arg=>['-t']}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
push @commandslist, ['rspconfig', 'network=*'];
|
||||
push @commandslist, ['rscan', '-u'];
|
||||
push @commandslist, ['mkhwconn', '-t'];
|
||||
}
|
||||
|
||||
setrsp_progress("Updating conserver configuration files");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeconservercf"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
}
|
||||
elsif ($command eq 'kitnoderemove'){
|
||||
setrsp_progress("Updating conserver configuration files");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeconservercf"], node=>$nodelist, arg=>['-d']}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Update nodes' boot settings");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["nodeset"], node=>$nodelist, arg=>['offline']}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Update known hosts");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeknownhosts"], node=>$nodelist, arg=>['-r']}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Update DHCP entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makedhcp"], node=>$nodelist, arg=>['-d']}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
}
|
||||
elsif ($command eq 'kitnodeupdate'){
|
||||
setrsp_progress("Updating hosts entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makehosts"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Updating DNS entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makedns"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Update DHCP entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makedhcp"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Update known hosts");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeknownhosts"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
}elsif ($command eq 'kitnoderemove') {
|
||||
push @commandslist, ['nodeset', 'offline'];
|
||||
}elsif ($command eq 'kitnodeupdate') {
|
||||
my $firstnode = (@$nodelist)[0];
|
||||
my $profileref = xCAT::ProfiledNodeUtils->get_nodes_profiles([$firstnode]);
|
||||
my %profilehash = %$profileref;
|
||||
if (exists $profilehash{$firstnode}{"ImageProfile"}){
|
||||
setrsp_progress("Update nodes' boot settings");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["nodeset"], node=>$nodelist, arg=>['osimage='.$profilehash{$firstnode}{"ImageProfile"}]}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
my $osimage = 'osimage='.$profilehash{$firstnode}{"ImageProfile"};
|
||||
push @commandslist, ['nodeset', $osimage];
|
||||
}
|
||||
|
||||
setrsp_progress("Updating conserver configuration files");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeconservercf"], node=>$nodelist}, $request_command, 0, 2);
|
||||
}
|
||||
|
||||
# Run commands
|
||||
foreach (@commandslist) {
|
||||
my $current_cmd = $_->[0];
|
||||
my $current_args = $_->[1];
|
||||
setrsp_progress($msghash{$current_cmd});
|
||||
my $retref = xCAT::Utils->runxcmd({command=>[$current_cmd], node=>$nodelist, arg=>[$current_args]}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
}
|
||||
elsif ($command eq 'kitnoderefresh'){
|
||||
# This is due to once update nicips table, we need remove node's records first and then re-create by run make* commands.
|
||||
setrsp_progress("Remove nodes entries from system configuration files first.");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["kitnoderemove"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Updating hosts entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makehosts"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Updating DNS entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makedns"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Update DHCP entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makedhcp"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Update known hosts");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeknownhosts"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
|
||||
setrsp_progress("Updating conserver configuration files");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makeconservercf"], node=>$nodelist}, $request_command, 0, 2);
|
||||
log_cmd_return($retref);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
@ -438,7 +438,7 @@ sub get_files{
|
||||
my @files;
|
||||
my $dir = "$installroot/netboot/$osvers/s390x/$profile";
|
||||
opendir(DIR, $dir) or $callback->({error=>["Could not open image files in directory $dir"], errorcode=>[1]});
|
||||
|
||||
|
||||
while (my $file = readdir(DIR)) {
|
||||
# We only want files in the directory that end with .img
|
||||
next unless (-f "$dir/$file");
|
||||
@ -449,7 +449,7 @@ sub get_files{
|
||||
if (@files) {
|
||||
$attrs->{rawimagefiles}->{files} = [@files];
|
||||
}
|
||||
|
||||
|
||||
closedir(DIR);
|
||||
}
|
||||
else {
|
||||
@ -465,37 +465,51 @@ sub get_files{
|
||||
$attrs->{linuximage}->{pkglist} = $temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@arr = ("$installroot/netboot");
|
||||
|
||||
# look for ramdisk
|
||||
my $ramdisk = look_for_file('initrd-stateless.gz', $callback, $attrs, @arr);
|
||||
unless($ramdisk){
|
||||
$callback->({error=>["Couldn't find ramdisk (initrd-stateless.gz) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{ramdisk} = $ramdisk;
|
||||
}
|
||||
|
||||
# look for kernel
|
||||
my $kernel = look_for_file('kernel', $callback, $attrs, @arr);
|
||||
unless($kernel){
|
||||
$callback->({error=>["Couldn't find kernel (kernel) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{kernel} = $kernel;
|
||||
}
|
||||
|
||||
# look for rootimg.gz
|
||||
my $rootimg = look_for_file('rootimg.gz', $callback, $attrs, @arr);
|
||||
unless($rootimg){
|
||||
$callback->({error=>["Couldn't find rootimg (rootimg.gz) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{rootimg} = $rootimg;
|
||||
}
|
||||
}
|
||||
} elsif ($provmethod =~ /statelite/) {
|
||||
my $rootimgdir=$attrs->{linuximage}->{rootimgdir};
|
||||
my $ramdisk;
|
||||
my $kernel;
|
||||
my $rootimg;
|
||||
# look for ramdisk, kernel and rootimg.gz
|
||||
if($rootimgdir) {
|
||||
if (-f "$rootimgdir/initrd-stateless.gz") {
|
||||
$ramdisk="$rootimgdir/initrd-stateless.gz";
|
||||
}
|
||||
if (-f "$rootimgdir/kernel") {
|
||||
$kernel="$rootimgdir/kernel";
|
||||
}
|
||||
if (-f "$rootimgdir/rootimg.gz") {
|
||||
$rootimg="$rootimgdir/rootimg.gz";
|
||||
}
|
||||
|
||||
} else {
|
||||
$ramdisk = look_for_file('initrd-stateless.gz', $callback, $attrs, @arr);
|
||||
$kernel = look_for_file('kernel', $callback, $attrs, @arr);
|
||||
$rootimg = look_for_file('rootimg.gz', $callback, $attrs, @arr);
|
||||
}
|
||||
unless($ramdisk){
|
||||
$callback->({error=>["Couldn't find ramdisk (initrd-stateless.gz) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{ramdisk} = $ramdisk;
|
||||
}
|
||||
|
||||
unless($kernel){
|
||||
$callback->({error=>["Couldn't find kernel (kernel) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{kernel} = $kernel;
|
||||
}
|
||||
|
||||
unless($rootimg){
|
||||
$callback->({error=>["Couldn't find rootimg (rootimg.gz) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{rootimg} = $rootimg;
|
||||
}
|
||||
}
|
||||
} elsif ($provmethod =~ /statelite/) {
|
||||
@arr = ("$installroot/custom/netboot", "$xcatroot/share/xcat/netboot");
|
||||
#get .pkglist file
|
||||
if (! $attrs->{linuximage}->{pkglist}) {
|
||||
@ -510,25 +524,36 @@ sub get_files{
|
||||
}
|
||||
|
||||
@arr = ("$installroot/netboot");
|
||||
|
||||
# look for kernel
|
||||
my $kernel = look_for_file('kernel', $callback, $attrs, @arr);
|
||||
unless($kernel){
|
||||
$callback->({error=>["Couldn't find kernel (kernel) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{kernel} = $kernel;
|
||||
}
|
||||
my $rootimgdir=$attrs->{linuximage}->{rootimgdir};
|
||||
my $kernel;
|
||||
my $ramdisk;
|
||||
#look for kernel and ramdisk
|
||||
if($rootimgdir) {
|
||||
if (-f "$rootimgdir/kernel") {
|
||||
$kernel="$rootimgdir/kernel";
|
||||
}
|
||||
if (-f "$rootimgdir/initrd-statelite.gz") {
|
||||
$ramdisk="$rootimgdir/initrd-statelite.gz";
|
||||
}
|
||||
} else {
|
||||
$kernel = look_for_file('kernel', $callback, $attrs, @arr);
|
||||
$ramdisk = look_for_file('initrd-statelite.gz', $callback, $attrs, @arr);
|
||||
}
|
||||
|
||||
unless($kernel){
|
||||
$callback->({error=>["Couldn't find kernel (kernel) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{kernel} = $kernel;
|
||||
}
|
||||
|
||||
# look for ramdisk
|
||||
my $ramdisk = look_for_file('initrd-statelite.gz', $callback, $attrs, @arr);
|
||||
unless($ramdisk){
|
||||
$callback->({error=>["Couldn't find ramdisk (initrd-statelite.gz) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{ramdisk} = $ramdisk;
|
||||
}
|
||||
}
|
||||
unless($ramdisk){
|
||||
$callback->({error=>["Couldn't find ramdisk (initrd-statelite.gz) for $imagename"],errorcode=>[1]});
|
||||
$errors++;
|
||||
}else{
|
||||
$attrs->{ramdisk} = $ramdisk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (( $provmethod =~ /raw/ ) and ( $arch =~ /s390x/ )) {
|
||||
|
@ -73,7 +73,6 @@ use IO::Socket;
|
||||
use IO::Select;
|
||||
use Class::Struct;
|
||||
use Digest::MD5 qw(md5);
|
||||
use Digest::SHA1 qw(sha1);
|
||||
use POSIX qw(WNOHANG mkfifo strftime);
|
||||
use Fcntl qw(:flock);
|
||||
|
||||
@ -3906,8 +3905,8 @@ sub getaddsensorevent {
|
||||
0x0f => "Enabling docking station",
|
||||
0x10 => "Docking staion ejection",
|
||||
0x11 => "Disable docking station",
|
||||
0x12 => "Calling operation system wake-up vector",
|
||||
0x13 => "Starting operation system boot process, call init 19h",
|
||||
0x12 => "Calling operating system wake-up vector",
|
||||
0x13 => "Starting operating system boot process, call init 19h",
|
||||
0x14 => "Baseboard or motherboard initialization",
|
||||
0x16 => "Floppy initialization",
|
||||
0x17 => "Keyboard test",
|
||||
|
@ -1046,69 +1046,80 @@ sub xhrm_satisfy {
|
||||
foreach (@nics) {
|
||||
s/=.*//; #this code cares not about the model of virtual nic
|
||||
my $nic=$_;
|
||||
my $vlanip;
|
||||
my $netmask;
|
||||
my $subnet;
|
||||
my $vlanip;
|
||||
my $netmask;
|
||||
my $subnet;
|
||||
my $vlan;
|
||||
my $interface;
|
||||
if ($nic =~ /^vl([\d]+)$/) {
|
||||
$vlan=$1;
|
||||
my $nwtab=xCAT::Table->new("networks", -create =>0);
|
||||
if ($nwtab) {
|
||||
my $sent = $nwtab->getAttribs({vlanid=>"$vlan"},'net','mask');
|
||||
if ($sent and ($sent->{net})) {
|
||||
$subnet=$sent->{net};
|
||||
$netmask=$sent->{mask};
|
||||
}
|
||||
if (($subnet) && ($netmask)) {
|
||||
my $hoststab = xCAT::Table->new("hosts", -create => 0);
|
||||
if ($hoststab) {
|
||||
my $tmp = $hoststab->getNodeAttribs($hyp, ['otherinterfaces']);
|
||||
if (defined($tmp) && ($tmp) && $tmp->{otherinterfaces})
|
||||
{
|
||||
my $otherinterfaces = $tmp->{otherinterfaces};
|
||||
my @itf_pairs=split(/,/, $otherinterfaces);
|
||||
foreach (@itf_pairs) {
|
||||
my ($name,$vip)=split(/:/, $_);
|
||||
if(xCAT::NetworkUtils->ishostinsubnet($vip, $netmask, $subnet)) {
|
||||
$vlanip=$vip;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nic =~ /^vl([\d]+)$/) {
|
||||
$vlan=$1;
|
||||
my $nwtab=xCAT::Table->new("networks", -create =>0);
|
||||
if ($nwtab) {
|
||||
my $sent = $nwtab->getAttribs({vlanid=>"$vlan"},'net','mask');
|
||||
if ($sent and ($sent->{net})) {
|
||||
$subnet=$sent->{net};
|
||||
$netmask=$sent->{mask};
|
||||
}
|
||||
if (($subnet) && ($netmask)) {
|
||||
my $hoststab = xCAT::Table->new("hosts", -create => 0);
|
||||
if ($hoststab) {
|
||||
my $tmp = $hoststab->getNodeAttribs($hyp, ['otherinterfaces']);
|
||||
if (defined($tmp) && ($tmp) && $tmp->{otherinterfaces})
|
||||
{
|
||||
my $otherinterfaces = $tmp->{otherinterfaces};
|
||||
my @itf_pairs=split(/,/, $otherinterfaces);
|
||||
foreach (@itf_pairs) {
|
||||
my ($name,$vip)=split(/:/, $_);
|
||||
if(xCAT::NetworkUtils->ishostinsubnet($vip, $netmask, $subnet)) {
|
||||
$vlanip=$vip;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#get the vlan ip from nics table
|
||||
unless ($vlanip) {
|
||||
my $nicstable = xCAT::Table->new("nics", -create => 0);
|
||||
if ($nicstable) {
|
||||
my $tmp = $nicstable->getNodeAttribs($hyp, ['nicips']);
|
||||
if ($tmp && $tmp->{nicips}){
|
||||
$tmp =~ /vl${vlan}nic!([^,]*)/;
|
||||
$vlanip = $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#get the nic that vlan tagged
|
||||
my $swtab = xCAT::Table->new("switch", -create => 0);
|
||||
if ($swtab) {
|
||||
my $tmp_switch = $swtab->getNodesAttribs([$hyp], ['vlan','interface']);
|
||||
if (defined($tmp_switch) && (exists($tmp_switch->{$hyp}))) {
|
||||
my $tmp_node_array=$tmp_switch->{$hyp};
|
||||
foreach my $tmp (@$tmp_node_array) {
|
||||
if (exists($tmp->{vlan})) {
|
||||
my $vlans = $tmp->{vlan};
|
||||
foreach my $vlan_tmp (split(',',$vlans)) {
|
||||
if ($vlan_tmp == $vlan) {
|
||||
if (exists($tmp->{interface})) {
|
||||
$interface=$tmp->{interface};
|
||||
}
|
||||
last;
|
||||
my $tmp_switch = $swtab->getNodesAttribs([$hyp], ['vlan','interface']);
|
||||
if (defined($tmp_switch) && (exists($tmp_switch->{$hyp}))) {
|
||||
my $tmp_node_array=$tmp_switch->{$hyp};
|
||||
foreach my $tmp (@$tmp_node_array) {
|
||||
if (exists($tmp->{vlan})) {
|
||||
my $vlans = $tmp->{vlan};
|
||||
foreach my $vlan_tmp (split(',',$vlans)) {
|
||||
if ($vlan_tmp == $vlan) {
|
||||
if (exists($tmp->{interface})) {
|
||||
$interface=$tmp->{interface};
|
||||
}
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (($interface) || ($interface =~ /primary/)) {
|
||||
$interface =~ s/primary(:)?//g;
|
||||
}
|
||||
#print "interface=$interface nic=$nic vlanip=$vlanip netmask=$netmask\n";
|
||||
#print "interface=$interface nic=$nic vlanip=$vlanip netmask=$netmask\n";
|
||||
if ($interface) {
|
||||
$rc |=system("ssh $hyp xHRM bridgeprereq $interface:$nic $vlanip $netmask");
|
||||
$rc |=system("ssh $hyp xHRM bridgeprereq $interface:$nic $vlanip $netmask");
|
||||
} else {
|
||||
$rc |=system("ssh $hyp xHRM bridgeprereq $nic $vlanip $netmask");
|
||||
}
|
||||
@ -2785,8 +2796,6 @@ sub process_request {
|
||||
}
|
||||
}
|
||||
}
|
||||
#donot update node provision status (installing or netbooting) here
|
||||
xCAT::Utils->filter_nostatusupdate(\%newnodestatus);
|
||||
#print "newstatus" . Dumper(\%newnodestatus);
|
||||
xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1);
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ Usage:
|
||||
my %allfspips = %$recordsref;
|
||||
|
||||
# Get all switches name
|
||||
$recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('switches', 'switch');
|
||||
$recordsref = xCAT::ProfiledNodeUtils->get_db_switches();
|
||||
%allswitches = %$recordsref;
|
||||
|
||||
# Get all switches_switchport
|
||||
@ -385,6 +385,7 @@ Usage:
|
||||
$allmacs{$macstr} = 0;
|
||||
}
|
||||
}
|
||||
%allmacsupper = ();
|
||||
foreach (keys %allmacs){
|
||||
$allmacsupper{uc($_)} = 0;
|
||||
}
|
||||
@ -957,13 +958,13 @@ Usage:
|
||||
$chaintab->close();
|
||||
|
||||
# Remove all nodes information
|
||||
push(@kitcommands, "kitnoderemove");
|
||||
push(@kitcommands, "removenodes");
|
||||
# Add all nodes information back
|
||||
push(@kitcommands, "kitnodeadd");
|
||||
|
||||
} elsif ( $fsp_flag ) {
|
||||
# Remove all nodes information
|
||||
push(@kitcommands, "kitnoderemove");
|
||||
push(@kitcommands, "removenodes");
|
||||
# Add all nodes information back
|
||||
push(@kitcommands, "kitnodeadd");
|
||||
} else {
|
||||
@ -972,7 +973,17 @@ Usage:
|
||||
|
||||
#10. Call plugins.
|
||||
foreach my $command (@kitcommands) {
|
||||
my $retref = xCAT::Utils->runxcmd({command=>[$command], node=>$nodes, sequential=>[1]}, $request_command, 0, 2);
|
||||
my $retref;
|
||||
if ($command eq 'removenodes'){
|
||||
# Not run makedns -d as it costs too much time
|
||||
#setrsp_progress("Updating DNS entries");
|
||||
#$retref = xCAT::Utils->runxcmd({command=>["makedns"], node=>$nodes, arg=>['-d']}, $request_command, 0, 2);
|
||||
|
||||
#setrsp_progress("Updating hosts entries");
|
||||
$retref = xCAT::Utils->runxcmd({command=>["makehosts"], node=>$nodes, arg=>['-d']}, $request_command, 0, 2);
|
||||
next;
|
||||
}
|
||||
$retref = xCAT::Utils->runxcmd({command=>[$command], node=>$nodes, sequential=>[1]}, $request_command, 0, 2);
|
||||
my $retstrref = parse_runxcmd_ret($retref);
|
||||
if ($::RUNCMD_RC != 0){
|
||||
setrsp_progress("Warning: failed to call kit commands.");
|
||||
@ -1107,6 +1118,7 @@ Usage:
|
||||
$allmacs{$macstr} = 0;
|
||||
}
|
||||
}
|
||||
%allmacsupper = ();
|
||||
foreach (keys %allmacs){
|
||||
$allmacsupper{uc($_)} = 0;
|
||||
}
|
||||
@ -1508,6 +1520,7 @@ sub findme{
|
||||
$allmacs{$macstr} = 0;
|
||||
}
|
||||
}
|
||||
%allmacsupper = ();
|
||||
foreach (keys %allmacs){
|
||||
$allmacsupper{uc($_)} = 0;
|
||||
}
|
||||
|
@ -1851,6 +1851,15 @@ sub insert_dd () {
|
||||
# if the new kernel from update distro is not existed in initrd, create the path for it
|
||||
if (! -r "$dd_dir/initrd_img/lib/modules/$new_kernel_ver/") {
|
||||
mkpath ("$dd_dir/initrd_img/lib/modules/$new_kernel_ver/");
|
||||
# link the /modules to this new kernel dir
|
||||
unlink "$dd_dir/initrd_img/modules";
|
||||
$cmd = "/bin/ln -sf lib/modules/$new_kernel_ver/initrd $dd_dir/initrd_img/modules";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not create link to the new kernel dir.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
|
||||
# Copy the drivers to the rootimage
|
||||
|
@ -580,9 +580,10 @@ sub tabdump
|
||||
if ($args) {
|
||||
@ARGV = @{$args};
|
||||
}
|
||||
Getopt::Long::Configure("posix_default");
|
||||
Getopt::Long::Configure("no_gnu_compat");
|
||||
Getopt::Long::Configure("bundling");
|
||||
Getopt::Long::Configure("posix_default");
|
||||
Getopt::Long::Configure("no_gnu_compat");
|
||||
Getopt::Long::Configure("bundling");
|
||||
|
||||
|
||||
if (!GetOptions(
|
||||
'h|?|help' => \$HELP,
|
||||
@ -604,14 +605,15 @@ sub tabdump
|
||||
return;
|
||||
}
|
||||
if ($FILENAME and $FILENAME !~ /^\//) { $FILENAME =~ s/^/$request->{cwd}->[0]\//; }
|
||||
|
||||
|
||||
|
||||
if ($HELP) { $tabdump_usage->(0); return; }
|
||||
|
||||
if (($NUMBERENTRIES) && ($DESC)) {
|
||||
$cb->({error => "You cannot use the -n and -d flag together. ",errorcode=>1});
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (($NUMBERENTRIES) && ($OPTW)) {
|
||||
$cb->({error => "You cannot use the -n and -w flag together. ",errorcode=>1});
|
||||
return 1;
|
||||
@ -620,10 +622,8 @@ sub tabdump
|
||||
$cb->({error => "You cannot use the -n and -f flag together. ",errorcode=>1});
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (scalar(@ARGV)>1) { $tabdump_usage->(1); return; }
|
||||
|
||||
|
||||
my %rsp;
|
||||
# If no arguments given, we display a list of the tables
|
||||
if (!scalar(@ARGV)) {
|
||||
@ -647,15 +647,15 @@ sub tabdump
|
||||
}
|
||||
# get the table name
|
||||
$table = $ARGV[0];
|
||||
|
||||
|
||||
# if -n can only be the auditlog or eventlog
|
||||
if ($NUMBERENTRIES) {
|
||||
if (!( $table =~ /^auditlog/ ) && (!($table =~ /^eventlog/))){
|
||||
$cb->({error => "$table table is not supported in tabdump -n. You may only use this option on the auditlog or the eventlog.",errorcode=>1});
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# do not allow teal tables
|
||||
if ( $table =~ /^x_teal/ ) {
|
||||
$cb->({error => "$table table is not supported in tabdump. Use Teal maintenance commands. ",errorcode=>1});
|
||||
@ -703,7 +703,6 @@ sub tabdump
|
||||
return $rc;
|
||||
}
|
||||
|
||||
|
||||
my $recs;
|
||||
my @ents;
|
||||
my @attrarray;
|
||||
@ -758,12 +757,12 @@ sub tabdump
|
||||
}
|
||||
#
|
||||
# display input number of records for the table requested tabdump -n
|
||||
# note currently only supports auditlog and eventlog
|
||||
#
|
||||
sub tabdump_numberentries {
|
||||
my $table = shift;
|
||||
my $cb = shift;
|
||||
my $numberentries = shift; # either number of records to display
|
||||
my $attrrecid="recid";
|
||||
|
||||
my $VERBOSE = shift;
|
||||
my $rc=0;
|
||||
@ -772,38 +771,21 @@ sub tabdump_numberentries {
|
||||
$cb->({error => "Unable to open $table",errorcode=>4});
|
||||
return 1;
|
||||
}
|
||||
my $DBname = xCAT::Utils->get_DBName;
|
||||
my @attribs = ($attrrecid);
|
||||
my @ents=$tab->getAllAttribs(@attribs);
|
||||
if (@ents) { # anything to process
|
||||
# find smallest and largest recid, note table is not ordered by recid after
|
||||
# a while
|
||||
my $smallrid;
|
||||
my $largerid;
|
||||
foreach my $rid (@ents) {
|
||||
if (!(defined $smallrid)) {
|
||||
$smallrid=$rid;
|
||||
}
|
||||
if (!(defined $largerid)) {
|
||||
$largerid=$rid;
|
||||
}
|
||||
if ($rid->{$attrrecid} < $smallrid->{$attrrecid}) {
|
||||
$smallrid=$rid;
|
||||
}
|
||||
if ($rid->{$attrrecid} > $largerid->{$attrrecid}) {
|
||||
$largerid=$rid;
|
||||
}
|
||||
}
|
||||
my $RECID;
|
||||
#determine recid to show all records after
|
||||
$RECID= $largerid->{$attrrecid} - $numberentries ;
|
||||
$rc=tabdump_recid($table,$cb,$RECID, $attrrecid);
|
||||
} else {
|
||||
#determine recid to show all records after
|
||||
my $RECID;
|
||||
my $attrrecid="recid";
|
||||
my $values = $tab->getMAXMINEntries($attrrecid);
|
||||
my $max=$values->{"max"};
|
||||
if (defined($values->{"max"})){
|
||||
$RECID= $values->{"max"} - $numberentries ;
|
||||
$rc=tabdump_recid($table,$cb,$RECID, $attrrecid);
|
||||
|
||||
} else {
|
||||
my %rsp;
|
||||
push @{$rsp{data}}, "Nothing to display from $table.";
|
||||
$rsp{errorcode} = $rc;
|
||||
$cb->(\%rsp);
|
||||
}
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
# Display requested recored
|
||||
@ -831,6 +813,7 @@ sub tabdump_recid {
|
||||
output_table($table,$cb,$tab,\@recs);
|
||||
return $rc;
|
||||
}
|
||||
|
||||
# Display information from the daemon.
|
||||
#
|
||||
sub lsxcatd
|
||||
@ -1066,7 +1049,7 @@ sub tabprune
|
||||
if (($table eq "eventlog") || ($table eq "auditlog")) {
|
||||
$attrrecid="recid";
|
||||
} else {
|
||||
if ($table eq "isnm_perf") { # if ISNM These tables are really not supported in 2.8 or later
|
||||
if ($table eq "isnm_perf") { # if ISNM These tables are really not supported in 2.8 or later
|
||||
$attrrecid="perfid";
|
||||
} else {
|
||||
$attrrecid="period"; # isnm_perf_sum table
|
||||
@ -1134,51 +1117,34 @@ sub tabprune_numberentries {
|
||||
$cb->({error => "Unable to open $table",errorcode=>4});
|
||||
return 1;
|
||||
}
|
||||
my $DBname = xCAT::Utils->get_DBName;
|
||||
my @attribs = ("$attrrecid");
|
||||
my @ents=$tab->getAllAttribs(@attribs);
|
||||
if (@ents) { # anything to process
|
||||
# find smallest and largest recid, note table is not ordered by recid after
|
||||
# a while
|
||||
my $smallrid;
|
||||
my $largerid;
|
||||
foreach my $rid (@ents) {
|
||||
if (!(defined $smallrid)) {
|
||||
$smallrid=$rid;
|
||||
}
|
||||
if (!(defined $largerid)) {
|
||||
$largerid=$rid;
|
||||
}
|
||||
if ($rid->{$attrrecid} < $smallrid->{$attrrecid}) {
|
||||
$smallrid=$rid;
|
||||
}
|
||||
if ($rid->{$attrrecid} > $largerid->{$attrrecid}) {
|
||||
$largerid=$rid;
|
||||
}
|
||||
}
|
||||
my $RECID;
|
||||
my $RECID;
|
||||
my $values = $tab->getMAXMINEntries($attrrecid);
|
||||
if ((defined($values->{"max"})) && (defined($values->{"min"}))) {
|
||||
my $largerid = $values->{"max"};
|
||||
my $smallrid = $values->{"min"};
|
||||
if ($flag eq "n") { # deleting number of records
|
||||
#determine recid to delete all entries that come before like the -i flag
|
||||
$RECID= $smallrid->{$attrrecid} + $numberentries ;
|
||||
#get the smalled recid and add number to delete, that is where to start removing
|
||||
$RECID= $smallrid + $numberentries ;
|
||||
} else { # flag must be percentage
|
||||
#take largest and smallest recid and percentage and determine the recid
|
||||
# that will remove the requested percentage. If some are missing in the
|
||||
# middle due to tabedit, we are not worried about it.
|
||||
|
||||
my $totalnumberrids = $largerid->{$attrrecid} - $smallrid->{$attrrecid} +1;
|
||||
my $totalnumberrids = $largerid - $smallrid +1;
|
||||
my $percent = $numberentries / 100;
|
||||
my $percentage=$totalnumberrids * $percent ;
|
||||
my $cnt=sprintf( "%d", $percentage ); # round to whole number
|
||||
$RECID=$smallrid->{$attrrecid} + $cnt; # get recid to remove all before
|
||||
$RECID=$smallrid + $cnt; # get recid to remove all before
|
||||
}
|
||||
# Now prune starting at $RECID
|
||||
$rc=tabprune_recid($table,$cb,$RECID, $attrrecid,$VERBOSE);
|
||||
} else {
|
||||
} else {
|
||||
my %rsp;
|
||||
push @{$rsp{data}}, "Nothing to prune from $table.";
|
||||
$rsp{errorcode} = $rc;
|
||||
$cb->(\%rsp);
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
# prune all entries up to the record id input
|
||||
|
@ -218,6 +218,7 @@ sub preprocess_updatenode
|
||||
'v|version' => \$::VERSION,
|
||||
'V|verbose' => \$::VERBOSE,
|
||||
'F|sync' => \$::FILESYNC,
|
||||
'g|genmypost' => \$::GENMYPOST,
|
||||
'l|user:s' => \$::USER,
|
||||
'f|snsync' => \$::SNFILESYNC,
|
||||
'S|sw' => \$::SWMAINTENANCE,
|
||||
@ -249,6 +250,38 @@ sub preprocess_updatenode
|
||||
$callback->($rsp);
|
||||
return;
|
||||
}
|
||||
# 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";
|
||||
$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;
|
||||
}
|
||||
|
||||
# -c must work with -S for AIX node
|
||||
if ($::CMDLINE && !$::SWMAINTENANCE)
|
||||
@ -1267,6 +1300,7 @@ sub updatenoderunps
|
||||
# Note order of parameters to xcatdsklspost
|
||||
#is important and cannot be changed
|
||||
my $runpscmd;
|
||||
|
||||
if ($::SETSERVER){
|
||||
$runpscmd =
|
||||
"$installdir/postscripts/xcatdsklspost $mode -M $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
|
||||
@ -1274,6 +1308,11 @@ sub updatenoderunps
|
||||
$runpscmd =
|
||||
"$installdir/postscripts/xcatdsklspost $mode -m $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"
|
||||
}
|
||||
# add verbose flag
|
||||
if ($::VERBOSE){
|
||||
$runpscmd .= " -V";
|
||||
}
|
||||
|
||||
push @$args1,"--nodestatus"; # return nodestatus
|
||||
if (defined($::fanout)) { # fanout
|
||||
push @$args1,"-f" ;
|
||||
@ -1596,6 +1635,10 @@ sub updatenodesoftware
|
||||
$cmd =
|
||||
"$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs' --tftp $tftpdir";
|
||||
}
|
||||
# add verbose flag
|
||||
if ($::VERBOSE){
|
||||
$cmd .= " -V";
|
||||
}
|
||||
|
||||
# build xdsh command
|
||||
push @$args1,"--nodestatus"; # return nodestatus
|
||||
|
@ -296,7 +296,8 @@ sub setstate {
|
||||
my $pname = "yaboot.conf-" . $tmp;
|
||||
unlink($tftpdir."/".$pname);
|
||||
link($tftpdir."/etc/".$node,$tftpdir."/".$pname);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,9 +51,9 @@ import File::Basename;
|
||||
my $scriptname = $0;
|
||||
|
||||
my $cmdref={
|
||||
command=>"getcons",
|
||||
arg=>"text",
|
||||
noderange=>$ARGV[0]
|
||||
command=>["getcons"],
|
||||
arg=>["text"],
|
||||
noderange=>[$ARGV[0]]
|
||||
};
|
||||
use Data::Dumper;
|
||||
my $dsthost;
|
||||
|
@ -28,6 +28,8 @@ done >>/etc/resolv.conf
|
||||
#change the soft link /bin/sh to /bin/bash
|
||||
ln -sf /bin/bash /bin/sh
|
||||
#
|
||||
#delete the useless apt repo
|
||||
sed -i 's/^deb.*updates.*$/#&/g' /etc/apt/sources.list
|
||||
# Run xCAT post install
|
||||
#
|
||||
export MASTER_IP="#XCATVAR:XCATMASTER#"
|
||||
|
@ -538,6 +538,14 @@ if (-d "$rootimg_dir/usr/share/dracut") {
|
||||
print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n";
|
||||
}
|
||||
|
||||
|
||||
#-- for centos, disable the internet repository
|
||||
if( -e "$rootimg_dir/etc/yum.repos.d/CentOS-Base.repo" ) {
|
||||
my $repo_content=`sed -e '/enabled/d' $rootimg_dir/etc/yum.repos.d/CentOS-Base.repo | sed -e '/^gpgkey/i enabled=0'`;
|
||||
system("echo '$repo_content' > $rootimg_dir/etc/yum.repos.d/CentOS-Base.repo");
|
||||
}
|
||||
#
|
||||
|
||||
#-- run postinstall script
|
||||
unless ($imagename) {
|
||||
$postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall");
|
||||
|
@ -7,48 +7,109 @@ function get_def_interface {
|
||||
#we are, however, presuming ipv4 for the moment
|
||||
retval=$(ping -c 1 `hostname`|head -n 1|cut -d\( -f 2|cut -d\) -f 1)
|
||||
if [ -z "$retval" -o "127.0.0.1" = "$retval" ]; then #ok, that didn't pan out, now we grab the first address that looks sane
|
||||
retval=`ifconfig|grep inet" " |grep -v addr:127.0.0.1|grep -v 'addr:169.254'|head -n 1|cut -d: -f 2|cut -d' ' -f 1`
|
||||
retval=`ifconfig|grep inet" " |grep -v addr:127.0.0.1|grep -v 'addr:169.254'|head -n 1|cut -d: -f 2|cut -d' ' -f 1`
|
||||
fi
|
||||
if [ -z "$retval" ]; then
|
||||
echo "ERROR: Unable to reasonably guess the 'default' interface" >&2
|
||||
exit 1
|
||||
echo "ERROR: Unable to reasonably guess the 'default' interface" >&2
|
||||
exit 1
|
||||
fi
|
||||
iface=`ifconfig|grep -v inet6|egrep '(Link|inet)'|grep -B1 'addr:'$retval |head -n 1|awk '{print $1}'`
|
||||
if [ -z "$iface" ]; then
|
||||
echo "ERROR: Unable to reasonably guess the default interface" >&2
|
||||
exit 1
|
||||
echo "ERROR: Unable to reasonably guess the default interface" >&2
|
||||
exit 1
|
||||
fi
|
||||
if brctl show | grep ^$iface >& /dev/null; then #
|
||||
OIFS=$IFS
|
||||
IFS=$'\n'
|
||||
INMATCH=0
|
||||
for brline in $(brctl show); do
|
||||
IFS=$OIFS
|
||||
if [ $(expr match "$brline" $iface) == $(expr length $iface) ]; then
|
||||
INMATCH=1
|
||||
elif [ $(expr match "$brline" " ") != 1 ]; then
|
||||
INMATCH=0
|
||||
fi
|
||||
if [ "$INMATCH" == 1 ]; then
|
||||
if ! ethtool -i `echo $brline|awk '{print $NF}'`|grep "driver: tun" >& /dev/null; then
|
||||
iface=`echo $brline|awk '{print $NF}'`
|
||||
echo "$iface"
|
||||
IFS=$OFIS
|
||||
return
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS=$OFIS
|
||||
OIFS=$IFS
|
||||
IFS=$'\n'
|
||||
INMATCH=0
|
||||
for brline in $(brctl show); do
|
||||
IFS=$OIFS
|
||||
if [ $(expr match "$brline" $iface) == $(expr length $iface) ]; then
|
||||
INMATCH=1
|
||||
elif [ $(expr match "$brline" " ") != 1 ]; then
|
||||
INMATCH=0
|
||||
fi
|
||||
if [ "$INMATCH" == 1 ]; then
|
||||
if ! ethtool -i `echo $brline|awk '{print $NF}'`|grep "driver: tun" >& /dev/null; then
|
||||
iface=`echo $brline|awk '{print $NF}'`
|
||||
echo "$iface"
|
||||
IFS=$OFIS
|
||||
return
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS=$OFIS
|
||||
else
|
||||
echo "$iface"
|
||||
echo "$iface"
|
||||
fi
|
||||
}
|
||||
|
||||
#before modify the configuration on ubuntu/debian, should preparse the interface file
|
||||
#By default, All nics configuration are saved into /etc/network/interfaces, it is difficult for xcat to configure nic
|
||||
#So only use source /etc/network/interfaces.d/* in "/etc/network/interfaces"
|
||||
#create files under /etc/network/interfaces.d/ for each nic, then it is similar with the readhat and sles
|
||||
function debianpreconf(){
|
||||
#create the config sub dir
|
||||
if [ ! -d "/etc/network/interfaces.d" ];then
|
||||
mkdir -p "/etc/network/interfaces.d"
|
||||
fi
|
||||
#search xcat flag
|
||||
XCATFLAG=`grep "#XCAT_CONFIG" /etc/network/interfaces`
|
||||
if [ -n "$XCATFLAG" ];then
|
||||
return
|
||||
fi
|
||||
|
||||
#back up the old interface configure
|
||||
if [ ! -e "/etc/network/interfaces.bak" ];then
|
||||
mv /etc/network/interfaces /etc/network/interfaces.bak
|
||||
fi
|
||||
|
||||
#create the new config file
|
||||
echo "#XCAT_CONFIG" > /etc/network/interfaces
|
||||
echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces
|
||||
|
||||
CONFFILE=''
|
||||
|
||||
#read the backfile
|
||||
cat /etc/network/interfaces.bak | while read LINE
|
||||
do
|
||||
if [ ! "$LINE" ];then
|
||||
continue
|
||||
fi
|
||||
FIRSTCHAR=${LINE:0:1}
|
||||
if [ $FIRSTCHAR = '#' ];then
|
||||
continue
|
||||
fi
|
||||
|
||||
CONFTYPE=`echo $LINE | cut -d" " -f1`
|
||||
if [ $CONFTYPE = 'auto' -o $CONFTYPE = 'allow-hotplug' ];then
|
||||
LINE=${LINE#$CONFTYPE}
|
||||
for NICNAME in $LINE; do
|
||||
echo "$CONFTYPE $NICNAME" > "/etc/network/interfaces.d/$NICNAME"
|
||||
done
|
||||
elif [ $CONFTYPE = 'iface' -o $CONFTYPE = 'mapping' ];then
|
||||
#find out the nic name, should think about the eth0:1
|
||||
NICNAME=`echo $LINE | cut -d" " -f 2 | cut -d":" -f 1`
|
||||
CONFFILE="/etc/network/interfaces.d/$NICNAME"
|
||||
if [ ! -e $CONFFILE ];then
|
||||
echo "auto $NICNAME" > $CONFFILE
|
||||
fi
|
||||
|
||||
#write lines into the conffile
|
||||
echo $LINE >> $CONFFILE
|
||||
else
|
||||
echo $LINE >> $CONFFILE
|
||||
fi
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
if [ "storageprereq" = "$1" ]; then
|
||||
MOUNTURI="$2"
|
||||
DIRNAME=`echo $MOUNTURI|sed -e 's!nfs://!nfs_!'`
|
||||
MOUNTPATH=`echo $DIRNAME|sed -e 's!nfs_!!'|sed -e 's!/!:/!'`
|
||||
if mount|grep $MOUNTPATH > /dev/null; then
|
||||
exit 0;
|
||||
exit 0;
|
||||
fi
|
||||
mkdir -p /var/lib/xcat/vmnt/$DIRNAME
|
||||
mount $MOUNTPATH /var/lib/xcat/vmnt/$DIRNAME
|
||||
@ -67,29 +128,29 @@ elif [ "bridgeprereq" = "$1" ]; then
|
||||
if [ -n "$INSTALLNIC" ]; then
|
||||
NETDESC=$INSPORT:default
|
||||
else
|
||||
echo "Incorrect usage"
|
||||
exit 1
|
||||
echo "Incorrect usage"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if echo "$NETDESC"|grep ':'> /dev/null; then
|
||||
PORTS=`echo "$NETDESC"|cut -d: -f 1`
|
||||
BNAME=`echo "$NETDESC"|cut -d: -f 2`
|
||||
PORTS=`echo "$NETDESC"|cut -d: -f 1`
|
||||
BNAME=`echo "$NETDESC"|cut -d: -f 2`
|
||||
else
|
||||
if [ -n "$INSTALLNIC" ]; then
|
||||
PORTS=$INSPORT
|
||||
fi
|
||||
BNAME=$NETDESC
|
||||
BNAME=$NETDESC
|
||||
fi
|
||||
if brctl showstp "$BNAME" > /dev/null; then
|
||||
echo "$BNAME"
|
||||
exit 0
|
||||
echo "$BNAME"
|
||||
exit 0
|
||||
fi
|
||||
#Still here, that means we must build a bridge
|
||||
if [ -z "$PORTS" ]; then #No ports specified, default to whatever looks up
|
||||
PORTS=$(get_def_interface)
|
||||
PORTS=$(get_def_interface)
|
||||
fi
|
||||
if [ -z "$PORTS" ]; then #This has been checked many times before in theory, check again just in case
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
#For now, we only support bridge name==network name. This precludes
|
||||
#the config of the same vlan number on multiple fabrics, but
|
||||
@ -97,39 +158,40 @@ elif [ "bridgeprereq" = "$1" ]; then
|
||||
#I think it would be unwise to reuse them as it could confuse anyway)
|
||||
if echo "$PORTS"|grep '&'; then #we have bonding... fun to be had
|
||||
#To be slack, going to just support one bond for now..
|
||||
modprobe bonding miimon=100 mode=4
|
||||
PORTS=`echo $PORTS |sed -e 's/&/ /'`
|
||||
ip link set bond0 up
|
||||
for p in $PORTS; do
|
||||
#TODO: we are only going to manage the default
|
||||
#route for now
|
||||
saveroutes=`ip route | grep default| grep "dev $p"|grep via|sed -e 's/dev .*//'`
|
||||
OIFS=$IFS
|
||||
IFS=$'\n'
|
||||
saveip=`ip addr show dev $p scope global|grep inet|grep -v dynamic|sed -e 's/inet.//'|sed -e 's/[^ ]*$//'`
|
||||
if [ ! -z "$saveip" ]; then
|
||||
for line in $saveip; do
|
||||
ip addr add dev bond0 $line
|
||||
done
|
||||
fi
|
||||
IFS=$OIFS
|
||||
ifenslave bond0 $p
|
||||
if [ ! -z "$saveroutes" ]; then
|
||||
ip route add $saveroutes
|
||||
fi
|
||||
done
|
||||
PORTS=bond0
|
||||
modprobe bonding miimon=100 mode=4
|
||||
PORTS=`echo $PORTS |sed -e 's/&/ /'`
|
||||
ip link set bond0 up
|
||||
for p in $PORTS; do
|
||||
#TODO: we are only going to manage the default
|
||||
#route for now
|
||||
saveroutes=`ip route | grep default| grep "dev $p"|grep via|sed -e 's/dev .*//'`
|
||||
OIFS=$IFS
|
||||
IFS=$'\n'
|
||||
saveip=`ip addr show dev $p scope global|grep inet|grep -v dynamic|sed -e 's/inet.//'|sed -e 's/[^ ]*$//'`
|
||||
if [ ! -z "$saveip" ]; then
|
||||
for line in $saveip; do
|
||||
ip addr add dev bond0 $line
|
||||
done
|
||||
fi
|
||||
IFS=$OIFS
|
||||
ifenslave bond0 $p
|
||||
if [ ! -z "$saveroutes" ]; then
|
||||
ip route add $saveroutes
|
||||
fi
|
||||
done
|
||||
PORTS=bond0
|
||||
fi
|
||||
if echo "$BNAME"|egrep '^vl(an)?[0123456789]' > /dev/null; then
|
||||
vlan="yes"
|
||||
TNAME=${BNAME##vl}
|
||||
TNAME=${TNAME##an}
|
||||
#We have a vlan... more fun
|
||||
modprobe 8021q
|
||||
vconfig add $PORTS $TNAME
|
||||
vconfig set_flag $PORTS.$TNAME 2 1 #Turn on GVRP where supported
|
||||
ip link set $PORTS.$TNAME up
|
||||
PORTS=$PORTS.$TNAME
|
||||
vlan="yes"
|
||||
TNAME=${BNAME##vl}
|
||||
TNAME=${TNAME##an}
|
||||
#We have a vlan... more fun
|
||||
modprobe 8021q
|
||||
vconfig add $PORTS $TNAME
|
||||
vconfig set_flag $PORTS.$TNAME 2 1 #Turn on GVRP where supported
|
||||
ip link set $PORTS.$TNAME up
|
||||
PORTORG=$PORTS
|
||||
PORTS=$PORTS.$TNAME
|
||||
fi
|
||||
#Now, $PORTS is 'the' physical device to participate in a bridge
|
||||
#TODO: we are only going to manage the default
|
||||
@ -143,98 +205,131 @@ elif [ "bridgeprereq" = "$1" ]; then
|
||||
saveip=`ip addr show dev $PORTS scope global|grep inet|grep -v dynamic|sed -e 's/inet.//'|sed -e 's/[^ ]*$//'`
|
||||
#saveip=`ip addr show dev $PORTS scope global|grep inet|sed -e 's/inet.//'|sed -e 's/[^ ]*$//'`
|
||||
if [ ! -z "$saveip" ]; then
|
||||
for line in $saveip; do
|
||||
IFS=$OIFS
|
||||
ip addr add dev $BNAME $line
|
||||
done
|
||||
for line in $saveip; do
|
||||
IFS=$OIFS
|
||||
ip addr add dev $BNAME $line
|
||||
done
|
||||
else
|
||||
if [ ! -z "$3" ]; then
|
||||
ip addr add dev $BNAME $3
|
||||
fi
|
||||
ip addr add dev $BNAME $3
|
||||
fi
|
||||
fi
|
||||
brctl addif $BNAME $PORTS
|
||||
if [ ! -z "$saveip" ]; then
|
||||
OIFS=$IFS
|
||||
IFS=$'\n'
|
||||
for line in $saveip; do
|
||||
IFS=$OIFS
|
||||
ip addr del dev $PORTS $line
|
||||
done
|
||||
IFS=$OIFS
|
||||
OIFS=$IFS
|
||||
IFS=$'\n'
|
||||
for line in $saveip; do
|
||||
IFS=$OIFS
|
||||
ip addr del dev $PORTS $line
|
||||
done
|
||||
IFS=$OIFS
|
||||
fi
|
||||
IFS=$OIFS
|
||||
if [ ! -z "$saveroutes" ]; then
|
||||
ip route add $saveroutes
|
||||
ip route add $saveroutes
|
||||
fi
|
||||
|
||||
#now save the settings into the config files so that they will be persistent among reboots
|
||||
if [[ $OSVER = sles* ]] || [[ $OSVER = suse* ]] || [[ -f /etc/SuSE-release ]]; then
|
||||
nwdir="/etc/sysconfig/network"
|
||||
isSLES=1
|
||||
nwdir="/etc/sysconfig/network"
|
||||
isSLES=1
|
||||
elif [ -f "/etc/debian_version" ];then
|
||||
debianpreconf
|
||||
nwdir="/etc/network/interfaces.d"
|
||||
isDebian=1
|
||||
getcap /usr/bin/qemu-system-x86_64 | grep cap_net_admin
|
||||
if [ $? ne 0 ];then
|
||||
setcap cap_net_admin=ei /usr/bin/qemu-system-x86_64
|
||||
fi
|
||||
else
|
||||
nwdir="/etc/sysconfig/network-scripts"
|
||||
nwdir="/etc/sysconfig/network-scripts"
|
||||
fi
|
||||
|
||||
#write into the network configuration file
|
||||
if [[ $isSLES -eq 1 ]]; then
|
||||
cat >$nwdir/ifcfg-$PORTS <<EOF
|
||||
cat >$nwdir/ifcfg-$PORTS <<EOF
|
||||
DEVICE='$PORTS'
|
||||
ONBOOT='yes'
|
||||
BRIDGE='$BNAME'
|
||||
EOF
|
||||
mac=`ip addr show dev $PORTS scope global|grep link|sed -e 's/link\/ether//'|sed -e 's/brd.*$//'|sed -e 's/[ ]*//'`
|
||||
if [ ! -z "$mac" ]; then
|
||||
echo "HWADDR='$mac'" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
if [ ! -z "$vlan" ]; then
|
||||
echo "VLAN='yes'" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
cat >$nwdir/ifcfg-$BNAME <<EOF
|
||||
mac=`ip addr show dev $PORTS scope global|grep link|sed -e 's/link\/ether//'|sed -e 's/brd.*$//'|sed -e 's/[ ]*//'`
|
||||
if [ ! -z "$mac" ]; then
|
||||
echo "HWADDR='$mac'" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
if [ ! -z "$vlan" ]; then
|
||||
echo "VLAN='yes'" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
cat >$nwdir/ifcfg-$BNAME <<EOF
|
||||
DEVICE='$BNAME'
|
||||
TYPE='Bridge'
|
||||
ONBOOT='yes'
|
||||
PEERDNS='yes'
|
||||
DELAY='0'
|
||||
EOF
|
||||
if [ ! -z "$3" ]; then
|
||||
echo "IPADDR='$3'" >> $nwdir/ifcfg-$BNAME
|
||||
if [ ! -z "$4" ]; then
|
||||
echo "NETMASK='$4'" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
else
|
||||
echo "BOOTPROTO=dhcp" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
if [ ! -z "$3" ]; then
|
||||
echo "IPADDR='$3'" >> $nwdir/ifcfg-$BNAME
|
||||
if [ ! -z "$4" ]; then
|
||||
echo "NETMASK='$4'" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
else
|
||||
echo "BOOTPROTO=dhcp" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
elif [ $isDebian ];then
|
||||
#ubuntu/debian
|
||||
echo "auto $PORTS" >$nwdir/$PORTS
|
||||
echo "iface $PORTS inet manual" >> $nwdir/$PORTS
|
||||
|
||||
if [ ! -z "$vlan" ];then
|
||||
echo " vlan-raw-device $PORTORG"
|
||||
fi
|
||||
|
||||
echo "auto $BNAME" > $nwdir/$BNAME
|
||||
if [ ! -z "$3" ];then
|
||||
echo "iface $BNAME inet static" >> $nwdir/$BNAME
|
||||
echo " address $3" >> $nwdir/$BNAME
|
||||
if [ ! -z "$4" ];then
|
||||
echo " netmask $4" >> $nwdir/$BNAME
|
||||
else
|
||||
echo " netmask 255.255.255.0" >> $nwdir/$BNAME
|
||||
fi
|
||||
else
|
||||
echo "iface $BNAME inet dhcp" >> $nwdir/$BNAME
|
||||
fi
|
||||
echo " bridge_ports $PORTS" >> $nwdir/$BNAME
|
||||
echo " bridge_stp off" >> $nwdir/$BNAME
|
||||
echo " bridge_fd 0" >> $nwdir/$BNAME
|
||||
echo " bridge_maxwait 0" >> $nwdir/$BNAME
|
||||
else
|
||||
cat >$nwdir/ifcfg-$PORTS <<EOF
|
||||
cat >$nwdir/ifcfg-$PORTS <<EOF
|
||||
DEVICE=$PORTS
|
||||
ONBOOT=yes
|
||||
BRIDGE=$BNAME
|
||||
EOF
|
||||
mac=`ip addr show dev $PORTS scope global|grep link|sed -e 's/link\/ether//'|sed -e 's/brd.*$//'|sed -e 's/[ ]*//'`
|
||||
if [ ! -z "$mac" ]; then
|
||||
echo "HWADDR=$mac" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
if [ ! -z "$vlan" ]; then
|
||||
echo "VLAN=yes" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
cat >$nwdir/ifcfg-$BNAME <<EOF
|
||||
mac=`ip addr show dev $PORTS scope global|grep link|sed -e 's/link\/ether//'|sed -e 's/brd.*$//'|sed -e 's/[ ]*//'`
|
||||
if [ ! -z "$mac" ]; then
|
||||
echo "HWADDR=$mac" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
if [ ! -z "$vlan" ]; then
|
||||
echo "VLAN=yes" >> $nwdir/ifcfg-$PORTS
|
||||
fi
|
||||
cat >$nwdir/ifcfg-$BNAME <<EOF
|
||||
DEVICE=$BNAME
|
||||
TYPE=Bridge
|
||||
ONBOOT=yes
|
||||
PEERDNS=yes
|
||||
DELAY=0
|
||||
EOF
|
||||
if [ ! -z "$3" ]; then
|
||||
echo "IPADDR=$3" >> $nwdir/ifcfg-$BNAME
|
||||
if [ ! -z "$4" ]; then
|
||||
echo "NETMASK=$4" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
else
|
||||
echo "BOOTPROTO=dhcp" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
if [ ! -z "$3" ]; then
|
||||
echo "IPADDR=$3" >> $nwdir/ifcfg-$BNAME
|
||||
if [ ! -z "$4" ]; then
|
||||
echo "NETMASK=$4" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
else
|
||||
echo "BOOTPROTO=dhcp" >> $nwdir/ifcfg-$BNAME
|
||||
fi
|
||||
fi
|
||||
|
||||
ifup $BNAME
|
||||
fi #END bridge config.
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,532 +1,209 @@
|
||||
#!/usr/bin/perl
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#!/bin/bash
|
||||
|
||||
# confignics postscript for configuring additional ethernet and ib NIC adapters.
|
||||
# This module parses NIC environment variables containing data from the nics table
|
||||
# for the specific node i.e.:
|
||||
# NICNODE - the node name
|
||||
# NICIPS - comma separated list of ips per NIC
|
||||
# NICHOSTNAMESUFFIXES - comma spearated list of hostname suffixes per NIC
|
||||
# NICTYPES - ethernet or infiniband
|
||||
# NICCUSTOMSCRIPTS - script to configure nic, i.e. configeth or configib
|
||||
# NICNETWORKS - network and subnetmask for the adapter.
|
||||
str_dir_name=`dirname $0`
|
||||
. $str_dir_name/xcatlib.sh
|
||||
|
||||
use strict;
|
||||
use Socket;
|
||||
use Data::Dumper;
|
||||
|
||||
# Only three args are supported for confignics:
|
||||
# "-s" to allow the install nic to be configured. If not set
|
||||
# then the install nic will not be configured.
|
||||
# "--ibaports=x" to specify the number of ports for an ib adapter.
|
||||
# This value will set in an environment variable
|
||||
# prior to calling configib.
|
||||
# "-r" unconfigure/remove existing configured nics. This flag will
|
||||
# compare existing configured nics with nics in the nics table
|
||||
# if nic doesn't exist in nics table then ifdown and remove
|
||||
# config file (ifcfg-*)
|
||||
|
||||
|
||||
my $ibaports = 1; # default to one port per ib adapter.
|
||||
my $cfg_inst_nic = '';
|
||||
my $rem_eth_nics = ''; # ethernet nics to remove if -r is set
|
||||
my $rem_ib_nics = ''; # ib nics to remove if -r is set
|
||||
my $rem_nics = 0;
|
||||
my $arg ='';
|
||||
while ($arg = shift(@ARGV)) {
|
||||
if ( $arg eq "-s" ) {
|
||||
$cfg_inst_nic = 1;
|
||||
} elsif ( $arg =~ /--ibaports=(\d)$/) {
|
||||
$ibaports = $1;
|
||||
} elsif ( $arg eq "-r" ) {
|
||||
$rem_nics = 1;
|
||||
}
|
||||
}
|
||||
|
||||
my $ibnics = '';
|
||||
my $ethnics = '';
|
||||
my $bridgednics = '';
|
||||
my $nicips = $ENV{NICIPS};
|
||||
my $niccustomscripts = $ENV{NICCUSTOMSCRIPTS};
|
||||
my $nictypes = $ENV{NICTYPES};
|
||||
my $xcatpostdir = "/xcatpost";
|
||||
my %cust_script_nics = (); # hash to save nics specified in niccustomscripts
|
||||
my $type = '';
|
||||
my $nic = '';
|
||||
my $MAC = $ENV{MACADDRESS};
|
||||
my $inst_nic = '';
|
||||
my $thisnode = $ENV{NODE};
|
||||
|
||||
# After discussing with Bruce, getting install nic in following order:
|
||||
# 1) get NODE env var, resolve to ip and get related nic info, if not found:
|
||||
# 2) Check if INSTALLNIC is set to specific nic then use that nic, if set to "mac"
|
||||
# then use mac to get nic. If still not set then:
|
||||
# 3) check PRIMARYNIC in similar manor as INSTALLNIC.
|
||||
# If still not found then exit with error.
|
||||
|
||||
my $cfg_nic_ref_hash = {}; # set from get_install_nic
|
||||
my $nic_to_cfg_ref_hash = {}; # set from env variables in mypostscript
|
||||
|
||||
$cfg_nic_ref_hash = get_current_nics();
|
||||
|
||||
$inst_nic = get_install_nic();
|
||||
$bridgednics = get_bridged_nics();
|
||||
|
||||
|
||||
|
||||
# niccustomscripts specifies which NICS need to be configured.
|
||||
# and which script to use to configure it.
|
||||
# Strip NIC and customscript and then call the custom script with the NIC
|
||||
# it is up to the custom script to verify information passed in NIC env vars.
|
||||
# i.e. if customscript is "eth1:configeth eth1, eth2:configeth2"
|
||||
# then first get eth1 for the nic and "configeth eth1" for the command to run"
|
||||
# the do the same for eth2.
|
||||
|
||||
if ( defined $niccustomscripts && length $niccustomscripts > 0 ) {
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: processing custom scripts: $niccustomscripts '");
|
||||
|
||||
foreach my $customscript (split(/,/,$niccustomscripts)) {
|
||||
|
||||
my @script = ();
|
||||
if ( $customscript =~ /!/ ) {
|
||||
@script = split(/!/,$customscript);
|
||||
} else {
|
||||
@script = split(/:/,$customscript);
|
||||
}
|
||||
$cust_script_nics{$script[0]} = 1;
|
||||
my @s = split(/ /,$script[1]);
|
||||
|
||||
# if installnic then verify that "-s" flag was passed in.
|
||||
if (($inst_nic ne $script[0]) || (($inst_nic eq $script[0]) && $cfg_inst_nic)) {
|
||||
runcmd("$script[1]");
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: executed custom script: $script[1] '");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Get nic from nicips. If nic is in cust_script_nics hash then ignore this nic.
|
||||
# otherwise, get nictype if set or determine type from nic name, eth* or en*
|
||||
# implies ethernet, ib* implies infiniband.
|
||||
#
|
||||
# configib prefers to have ib adapters configured in one call for performance
|
||||
# reasons. So add ib nics to a list and call configib outside the loop.
|
||||
foreach my $nic_ips (split(/,/,$nicips)) {
|
||||
$type = '';
|
||||
my $type_found = 0;
|
||||
$nic = '';
|
||||
my @nic_and_ips = ();
|
||||
if ( $nic_ips =~ /!/ ) {
|
||||
@nic_and_ips = split(/!/,$nic_ips);
|
||||
} else {
|
||||
@nic_and_ips = split(/:/,$nic_ips);
|
||||
}
|
||||
$nic = $nic_and_ips[0];
|
||||
# do not configure if nic is in the customscript hash
|
||||
if ($cust_script_nics{$nic_and_ips[0]} == 1 ) {
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: nic $nic_and_ips[0] already configured through custom script '");
|
||||
#the nics' information contain:
|
||||
#1. ip address
|
||||
#2. nic network
|
||||
#3. nic type
|
||||
#4. custom scripts
|
||||
#all of them are saved by different variable
|
||||
#this function can split the varable for each nic, and svae the information for each nic
|
||||
#into an hash, the key is nic name, the value are all information, which joined by ','
|
||||
function splitconfig(){
|
||||
if [ ! "$1" ];then
|
||||
return
|
||||
fi
|
||||
old_ifs=$IFS
|
||||
IFS=$','
|
||||
array_conf_temp=($1)
|
||||
IFS=$old_ifs
|
||||
for i in ${array_conf_temp[@]}
|
||||
do
|
||||
D=
|
||||
if [ `echo $i | grep "!"` ];then
|
||||
D="!"
|
||||
else
|
||||
D=":"
|
||||
fi
|
||||
key=`echo $i | cut -d"$D" -f 1`
|
||||
str_temp_value=`echo $i | cut -d"$D" -f 2`
|
||||
|
||||
}
|
||||
else {
|
||||
# Find matching type for this nic
|
||||
foreach my $nic_type (split(/,/,$nictypes)) {
|
||||
my @nic_and_type = ();
|
||||
if ( $nic_type =~ /!/ ) {
|
||||
@nic_and_type = split(/!/,$nic_type);
|
||||
} else {
|
||||
@nic_and_type = split(/:/,$nic_type);
|
||||
}
|
||||
if ($nic_and_type[0] eq $nic ) {
|
||||
$type = $nic_and_type[1];
|
||||
# verify type is "ethernet" or "infiniband"
|
||||
if ($type =~ /ethernet|infiniband/i ) {
|
||||
$type_found = 1;
|
||||
}
|
||||
last;
|
||||
}
|
||||
}
|
||||
# if no matching nic type then derive nic type from nic
|
||||
if ( !$type_found ) {
|
||||
if ( $nic =~ /(eth|en)\d+/i ) {
|
||||
$type = "ethernet";
|
||||
} elsif ($nic =~ /ib\d+/i ) {
|
||||
$type = "infiniband";
|
||||
}
|
||||
}
|
||||
|
||||
if ("ethernet" eq lc($type)) {
|
||||
# Ensure to only configure the install nic if the "-s" flag was set.
|
||||
if (($inst_nic ne $nic) || (($inst_nic eq $nic) && $cfg_inst_nic)) {
|
||||
if ($ethnics) {
|
||||
$ethnics = $ethnics . "," . $nic;
|
||||
} else {
|
||||
$ethnics = $nic;
|
||||
}
|
||||
}
|
||||
else {
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: Not configuring install nic $nic '");
|
||||
}
|
||||
} elsif ("infiniband" eq lc($type)) {
|
||||
if ($ibnics) {
|
||||
$ibnics = $ibnics . "," . $nic;
|
||||
} else {
|
||||
$ibnics = $nic;
|
||||
}
|
||||
} else {
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: unknown type $type for NIC: $nic '");
|
||||
}
|
||||
}
|
||||
str_temp=$(hashget hash_defined_nics $key)
|
||||
if [ -n "$str_temp" ];then
|
||||
str_temp=$str_temp",${str_temp_value}"
|
||||
else
|
||||
str_temp="$str_temp_value"
|
||||
str_all_nics=$str_all_nics"$key "
|
||||
fi
|
||||
hashset hash_defined_nics $key $str_temp
|
||||
done
|
||||
}
|
||||
|
||||
# set_nics_to_remove will compare $rem_nics for install nic, and bonded or bridged nics
|
||||
# and set $rem_nics to only those $nics that should be unconfigured.
|
||||
if ( $rem_nics ) {
|
||||
set_nics_to_remove();
|
||||
}
|
||||
bool_cfg_inst_nic=0
|
||||
str_inst_nic=''
|
||||
str_ib_nics=''
|
||||
str_os_type=`uname | tr 'A-Z' 'a-z'`
|
||||
bool_remove=0
|
||||
num_iba_ports=
|
||||
str_all_nics=''
|
||||
for arg in "$@"
|
||||
do
|
||||
if [ "$arg" = "-s" ];then
|
||||
bool_cfg_inst_nic=1
|
||||
elif [ "$arg" = "-r" ];then
|
||||
bool_remove=1
|
||||
elif [ "${arg:0:10}" = "--ibaports" ];then
|
||||
num_iba_ports=${arg#--ibaports=}
|
||||
fi
|
||||
done
|
||||
|
||||
my $cmd = '';
|
||||
logger -t xcat -p local4.info "confignics is called: config install nic:$bool_cfg_inst_nic, remove: $bool_remove, iba ports: $num_iba_ports"
|
||||
echo "confignics on $NODE: config install nic:$bool_cfg_inst_nic, remove: $bool_remove, iba ports: $num_iba_ports"
|
||||
|
||||
# Call configeth now to configure all ethernet adapters in one call.
|
||||
if ($ethnics) {
|
||||
$cmd = "configeth -c $ethnics";
|
||||
}
|
||||
if ( $rem_eth_nics) {
|
||||
if ($cmd) {
|
||||
$cmd = $cmd . " -u $rem_eth_nics";
|
||||
}
|
||||
else {
|
||||
$cmd = "configeth -u $rem_eth_nics";
|
||||
}
|
||||
}
|
||||
if ($cmd) {
|
||||
runcmd("$cmd");
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: executed $cmd '");
|
||||
}
|
||||
else {
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode : no ethernet nics to configure'");
|
||||
}
|
||||
str_temp=''
|
||||
if [ ! $INSTALLNIC ];then
|
||||
str_temp="mac"
|
||||
else
|
||||
str_temp=$INSTALLNIC
|
||||
fi
|
||||
|
||||
# Call configib now to configure all ib adapters in one call.
|
||||
if ($ibnics) {
|
||||
runcmd("NIC_IBNICS=$ibnics NIC_IBAPORTS=$ibaports configib");
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: executed script: configib for nics $ibnics '");
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
sub runcmd {
|
||||
my $cmd = shift @_;
|
||||
$cmd .= ' 2>&1';
|
||||
my @output = `$cmd`;
|
||||
my $rc = $? >> 8;
|
||||
if ($rc) {
|
||||
system("logger -t xcat -p local4.err 'confignics $thisnode: command $cmd failed with rc $rc: " . join('',@output) . "'");
|
||||
my $errout= "confignics $thisnode: command $cmd failed with rc $rc.\n";
|
||||
print $errout;
|
||||
exit $rc;
|
||||
}
|
||||
print join("\n",@output),"\n";
|
||||
}
|
||||
if [ "$str_temp" = "mac" ];then
|
||||
if [ "$str_os_type" = "aix" ];then
|
||||
old_ifs=$IFS
|
||||
IFS=$' '
|
||||
str_temp=`ifconfig -l`
|
||||
array_nicnames_temp=($str_temp)
|
||||
IFS=$old_ifs
|
||||
for temp_nic in ${array_nicnames_temp[@]}
|
||||
do
|
||||
entstat -t $temp_nic | grep -i "$MACADDRESS"
|
||||
if [ $? -eq 0 ];then
|
||||
str_inst_nic=$temp_nic
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
str_inst_nic=`ifconfig -a | grep -i "$MACADDRESS" | awk '{print $1;}'`
|
||||
fi
|
||||
elif [ `echo $str_temp | grep -E "e(n|th)[0-9]+"` ];then
|
||||
str_inst_nic=$str_temp
|
||||
fi
|
||||
|
||||
|
||||
sub get_current_nics {
|
||||
my @ip_addr_array = `ip addr show`;
|
||||
|
||||
my $nic_name;
|
||||
my $nic_type;
|
||||
my $nic_state;
|
||||
my $nic_slave;
|
||||
my $nic_mac;
|
||||
my $a_len = scalar(@ip_addr_array);
|
||||
splitconfig $NICIPS
|
||||
splitconfig $NICTYPES
|
||||
splitconfig $NICNETWORKS
|
||||
splitconfig $NICCUSTOMSCRIPTS
|
||||
|
||||
my %nics;
|
||||
#get state of nic in "UP" status
|
||||
#If bonded redhat then "SLAVE" or "MASTER" will be in the first line of stanza
|
||||
#do not configure the loopback nic
|
||||
if [ $bool_remove -eq 1 ];then
|
||||
if [ "$str_os_type" = "aix" ];then
|
||||
str_temp=`ifconfig -a | grep flags | grep -vi loopback | grep -v SALVE | grep -v MASTER | awk -F: {'print $1'}`
|
||||
else
|
||||
str_temp=`ip link show | grep -v link | grep -vi loopback | grep -v SALVE | grep -v MASTER | awk {'print $2'} | sed s/://`
|
||||
fi
|
||||
old_ifs=$IFS
|
||||
IFS=$'\n'
|
||||
array_nics_temp=($str_temp)
|
||||
IFS=$old_ifs
|
||||
for str_temp_nic in ${array_nics_temp[@]}
|
||||
do
|
||||
#the nic type should be ethernet
|
||||
echo $str_temp_nic | grep -E "e(n|th)[0-9]+"
|
||||
if [ $? -ne 0 ];then
|
||||
continue
|
||||
fi
|
||||
if [ "$str_os_type" != "aix" ];then
|
||||
brctl show 2>/dev/null | grep $str_temp_nic
|
||||
#the nic belongs to a bridge, go to next
|
||||
if [ $? -eq 0 ];then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
#the nic is defined this time
|
||||
str_temp=$(hashget hash_defined_nics $str_temp_nic)
|
||||
if [ -n "$str_temp" ];then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$str_temp_nic" = "$str_inst_nic" -a $bool_cfg_inst_nic -eq 0 ];then
|
||||
continue
|
||||
fi
|
||||
|
||||
#ignore the vlan interface
|
||||
echo $str_temp_nic | grep "\."
|
||||
if [ $? -eq 0 ];then
|
||||
continue
|
||||
fi
|
||||
|
||||
my $i = 0;
|
||||
while ( $i < scalar(@ip_addr_array)) {
|
||||
#print "array index $i: @ip_addr_array[$i]\n";
|
||||
# check if line starts with "number: text:"
|
||||
# if so then it is the start of a nic stanza which looks like:
|
||||
# 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
|
||||
# link/ether 5c:f3:fc:a8:bb:93 brd ff:ff:ff:ff:ff:ff
|
||||
# inet 9.114.34.232/24 brd 9.114.34.255 scope global eth1
|
||||
# inet6 fd55:faaf:e1ab:336:5ef3:fcff:fea8:bb93/64 scope global dynamic
|
||||
# valid_lft 2591627sec preferred_lft 604427sec
|
||||
# inet6 fd56::214:5eff:fe15:849b/64 scope global
|
||||
# valid_lft forever preferred_lft forever
|
||||
# inet6 fe80::5ef3:fcff:fea8:bb93/64 scope link
|
||||
# valid_lft forever preferred_lft forever
|
||||
logger -t xcat -p local4.info "confignics: remove nic $str_temp_nic"
|
||||
echo "confignics on $NODE: remove nic $str_temp_nic"
|
||||
configeth -r $str_temp_nic
|
||||
done
|
||||
fi
|
||||
|
||||
if ( $ip_addr_array[$i] =~ /^(\d+): / ) {
|
||||
# get nic name
|
||||
$ip_addr_array[$i] =~ /^\d+: ([^:].*):/;
|
||||
$nic_name = $1;
|
||||
old_ifs=$IFS
|
||||
IFS=$' '
|
||||
array_nics_temp=($str_all_nics)
|
||||
IFS=$old_ifs
|
||||
for key in ${array_nics_temp[@]}
|
||||
do
|
||||
key=`echo $key | sed 's/^ \+//' | sed 's/ \+$//'`
|
||||
str_nic_type=
|
||||
str_value=$(hashget hash_defined_nics $key)
|
||||
if [ "$key" = "$str_inst_nic" -a $bool_cfg_inst_nic -eq 0 ];then
|
||||
continue
|
||||
fi
|
||||
old_ifs=$IFS
|
||||
IFS=$','
|
||||
array_temp=($str_value)
|
||||
IFS=$old_ifs
|
||||
|
||||
# get state of nic either "UP" if different, such as DOWN, not configured
|
||||
# then assume state is DOWN.
|
||||
if ($ip_addr_array[$i] =~ /,UP/ ) {
|
||||
$nic_state = "UP";
|
||||
}
|
||||
else {
|
||||
$nic_state = "DOWN";
|
||||
}
|
||||
if [ "${array_temp[3]}" ];then
|
||||
logger -t xcat -p local4.info "confignics: processing custom scripts: ${array_temp[3]} for interface $key"
|
||||
echo "confignics on $NODE: processing custom scripts: ${array_temp[3]} for interface $key"
|
||||
${array_temp[3]}
|
||||
else
|
||||
if [ "${array_temp[1]}" ];then
|
||||
str_nic_type=`echo ${array_temp[1]} | tr "[A-Z]" "[a-z]"`
|
||||
else
|
||||
if [ `echo $key | grep -E '(eth|en)[0-9]+'` ];then
|
||||
str_nic_type="ethernet"
|
||||
elif [ `echo $KEY | grep -E 'ib[0-9]+'` ];then
|
||||
str_nic_type="infiniband"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if this nic is part of a bridge or bonded interface. If bonded on
|
||||
# redhat then "SLAVE" or "MASTER" will be in the first line of stanza
|
||||
# inside <>.
|
||||
#
|
||||
# A bridged interface is a little different. The command, "brctl show", is used
|
||||
# to show information about bridged interfaces. The subroutine get_bridged_nics()
|
||||
# writes out $bridgednics which is a comma separated strings of bridged nics.
|
||||
# If $nic_name matches a bridgednic then set nic_slave=1 for now to lump them
|
||||
# with bonded nics for now since we will not unconfigure bridged or bonded nics.
|
||||
#
|
||||
$nic_slave = 0; # default to 0
|
||||
if ($ip_addr_array[$i] =~ /SLAVE/ ) {
|
||||
$nic_slave = 1;
|
||||
}
|
||||
if ($ip_addr_array[$i] =~ /MASTER/ ) {
|
||||
$nic_slave = 1;
|
||||
}
|
||||
if ($nic_name =~ /$bridgednics/) {
|
||||
$nic_slave = 1;
|
||||
}
|
||||
if [ $str_nic_type = "ethernet" ];then
|
||||
logger -t xcat -p local4.info "confignics: call 'configeth $key ${array_temp[0]} ${array_temp[2]}'"
|
||||
echo "confignics on $NODE: call 'configeth $key ${array_temp[0]} ${array_temp[2]}'"
|
||||
configeth $key ${array_temp[0]} ${array_temp[2]}
|
||||
elif [ $str_nic_type = "infiniband" ];then
|
||||
if [ $str_ib_nics ];then
|
||||
str_ib_nics=$str_ib_nics","$key
|
||||
else
|
||||
str_ib_nics=$key
|
||||
fi
|
||||
else
|
||||
logger -t xcat -p local4.info "confignics: unknown type $str_nic_type for NIC: $key"
|
||||
echo "confignics on $NODE: unknown type $str_nic_type for NIC: $key"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# example output shows type is "link/ether" for ethernet or
|
||||
# "link/infiniband" for ib. Look ahead to next line for this.
|
||||
$ip_addr_array[$i+1] =~ /^\s+link\/([a-z]+) /;
|
||||
$nic_type = $1;
|
||||
|
||||
$i++;
|
||||
|
||||
# CHECK: it looks like there could be a usb nic ethernet adapter. Need to investigate
|
||||
# if more needs to be done for that such as it is handled differently.
|
||||
# If value is not "ether" or "infiniband" then continue on to next stanza
|
||||
if ($nic_type ne "ether" && $nic_type ne "infiniband") {
|
||||
next;
|
||||
}
|
||||
|
||||
my @line = split(' ', $ip_addr_array[$i]);
|
||||
$nic_mac = $line[1];
|
||||
|
||||
# move on to next line and loop through all lines for additional information or
|
||||
# and until the line is the start of a new stanza.
|
||||
# This is where things get dicey and may need enhancements:
|
||||
# inet 70.0.0.182/24 brd 70.0.0.255 scope global eth5
|
||||
# indicates an ipv4 address with a netmask of /24, a broadcast address,
|
||||
# scope global nicname (eth5). If this was an aliased ip then nicname would be eth5:1 or such.
|
||||
# inet6 fd55:faaf:e1ab:336:3640:b5ff:fe89:66c4/64 scope global dynamic
|
||||
# it appears that valid ips have "scope global"
|
||||
|
||||
$i++;
|
||||
# print "NIC: $nic_name, TYPE: $nic_type, MAC: $nic_mac SLAVE: $nic_slave, STATE: $nic_state \n";
|
||||
$nics{$nic_name} = {};
|
||||
$nics{$nic_name}->{state} = $nic_state;
|
||||
$nics{$nic_name}->{mac} = $nic_mac;
|
||||
$nics{$nic_name}->{slave} = $nic_slave;
|
||||
$nics{$nic_name}->{type} = $nic_type;
|
||||
$nics{$nic_name}->{ips} = [];
|
||||
|
||||
while ($i < scalar(@ip_addr_array) && !($ip_addr_array[$i] =~ /^(\d+): / ) ) {
|
||||
# $ip_proto - is either inet or inet6
|
||||
# $ip_mask is "ipaddr or ipv6addr"/netmask and possibly "brd broadcastip"
|
||||
# $scope has the scope (global, link, site, host) if global or site then
|
||||
# only data after scope is the nic "label", i.e. eth0, eth5:1.
|
||||
# note that "tentative" may appear but is not a label.
|
||||
# On RH for an ip alias with same netmask/subnet then line will be:
|
||||
# inet 11.0.0.80/16 brd 11.0.255.255 scope global secondary eth2:1
|
||||
|
||||
my ($ip_proto, $ip_mask, $scope) =
|
||||
$ip_addr_array[$i]=~/\s+(inet|inet6)\s+(.+)\s+scope\s+(.+)$/;
|
||||
|
||||
if ( $ip_proto =~ /inet/ ) { # line contains inet or inet6. Process info
|
||||
my ($nic_ip_mask, $junk) = split(' ', $ip_mask);
|
||||
my ($nic_ip, $nic_mask) = split('\/', $nic_ip_mask);
|
||||
my ($sc, $label, $more_label) = split(' ', $scope);
|
||||
if ( $sc ne "link" ) { # this is a valid one to keep
|
||||
|
||||
if ($label eq "secondary") {
|
||||
$label = $more_label;
|
||||
}
|
||||
#print "\tPROTO: $ip_proto, IP: $nic_ip, MASK: $nic_mask, SCOPE: $sc, LABEL:$label\n";
|
||||
push @{$nics{$nic_name}->{ips}},{ip => $nic_ip, netmask => $nic_mask, label => $label };
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
next; # next nic stanza or end of file.
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return \%nics;
|
||||
}
|
||||
|
||||
sub get_install_nic {
|
||||
# get "NODE" from env, resolve to ip and determine which nic it belongs
|
||||
# to. This should be the "base" nic, i.e. eth0, eth1 - not eth1:1
|
||||
# To do: Need to find equivalent methods for an ipv6 address.
|
||||
|
||||
my $node = $ENV{NODE};
|
||||
my $installnic = $ENV{INSTALLNIC};
|
||||
my $primarynic = $ENV{PRIMARYNIC};
|
||||
my $i_p_nic = ''; # variable to hold installnic or primarynic value
|
||||
my @ip_info;
|
||||
my $inst_ip;
|
||||
my @addr_info;
|
||||
my %hash = $cfg_nic_ref_hash;
|
||||
|
||||
@addr_info = gethostbyname($node);
|
||||
@ip_info = unpack("C4", $addr_info[4]); # Is this only for ipv4 or does this include ipv6 as well?
|
||||
$inst_ip = join(".",@ip_info);
|
||||
|
||||
# get ip output, compare ip_addr and determine nic.
|
||||
|
||||
foreach my $k (keys %$cfg_nic_ref_hash) {
|
||||
my $nic = $cfg_nic_ref_hash->{$k};
|
||||
my $ips = $nic->{'ips'};
|
||||
if (defined($ips)) {
|
||||
foreach my $ip_info (@$ips) {
|
||||
my $ip = $ip_info->{'ip'};
|
||||
# print " IP:$ip";
|
||||
if ($ip eq $inst_ip) {
|
||||
return $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# install nic not found from configured nics. Try to get install nic from environment
|
||||
# variables.
|
||||
if ($installnic) {
|
||||
$i_p_nic = $installnic;
|
||||
}
|
||||
elsif ($primarynic) {
|
||||
$i_p_nic = $primarynic;
|
||||
}
|
||||
|
||||
if (!$i_p_nic) {
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: installnic and primarynic are not defined', use 'mac' by default.");
|
||||
$i_p_nic = "mac";
|
||||
}
|
||||
|
||||
if ($i_p_nic =~ /(e(n|th)\d+)$/ ) {
|
||||
$inst_nic = $1;
|
||||
} elsif ($i_p_nic eq "mac") {
|
||||
# determine nic from mac. Get all NICs and their mac addresses from ifconfig
|
||||
# and compare that with MACADDR.
|
||||
my @ifcfg_info = split(/\n/,`ifconfig -a | grep HWaddr | awk '{print \$1,\$5;}'`);
|
||||
foreach my $nic_mac (@ifcfg_info) {
|
||||
my @nicmac = split(/ /,$nic_mac);
|
||||
if (uc($nicmac[1]) eq uc($MAC)) {
|
||||
$inst_nic = $nicmac[0];
|
||||
last;
|
||||
}
|
||||
}
|
||||
} else { # INSTALLNIC not set or is not known
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: install nic $inst_nic not known '");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# subroutine compares configured nic hash with defined nics from nics table.
|
||||
# If configured nic is not in nics table and it is not the install nic then
|
||||
# set global variables $rem_eth_nics and $rem_ibnics.
|
||||
# This subroutine needs to be called after get_current_nics() and after parsing
|
||||
# custom scripts and nics to be configured.
|
||||
|
||||
sub set_nics_to_remove {
|
||||
my $do_not_remove;
|
||||
my %hash = $cfg_nic_ref_hash;
|
||||
foreach my $nic_key (keys %$cfg_nic_ref_hash) {
|
||||
my $nic = $cfg_nic_ref_hash->{$nic_key};
|
||||
# check if $nic is in $ethnics, $ibnics, $cust_script_nics or is $inst_nic.
|
||||
# if not then add to appropriate list to be removed.
|
||||
if ($nic_key eq $inst_nic) {
|
||||
}
|
||||
elsif ($ethnics =~ /$nic_key/ ) {
|
||||
}
|
||||
elsif ($ibnics =~ /$nic_key/) {
|
||||
}
|
||||
elsif ($cust_script_nics{$nic_key}) {
|
||||
}
|
||||
else {
|
||||
# now check if nic is part of bonded or bridged interface.
|
||||
#
|
||||
if ( $nic->{slave} ) {
|
||||
system("logger -t xcat -p local4.info 'confignics $thisnode: Not removing $nic_key. It is part of a bonded or bridged interface. '");
|
||||
}
|
||||
elsif ( $nic_key =~ /@/ ) {
|
||||
# For a vlan interface on redhat the nic name appears as
|
||||
# nic.vlan@nic, i.e. eth0.30@eth0 and in this case the label will be
|
||||
# eth0.30. So verify that there is no "@" in the nic name (should we
|
||||
# also check that the label contains a "."?)
|
||||
|
||||
my ($label, $base) = split(/@/,$nic_key);
|
||||
|
||||
# need to make sure that $base is not added to nics to be removed.
|
||||
# add both the label and base to $do_not_remove.
|
||||
if ($do_not_remove) {
|
||||
$do_not_remove = $label . "," . $base;
|
||||
}
|
||||
else {
|
||||
$do_not_remove = $do_not_remove . "," . $label . "," . $base;
|
||||
}
|
||||
}
|
||||
else {
|
||||
# finally have a nic to remove. Determine if it is ib or eth
|
||||
if ($nic->{type} eq "ether") {
|
||||
if ( $rem_eth_nics ) {
|
||||
$rem_eth_nics = $rem_eth_nics . "," . $nic_key;
|
||||
}
|
||||
else {
|
||||
$rem_eth_nics = $nic_key;
|
||||
}
|
||||
}
|
||||
if ($nic->{type} eq "infiniband") {
|
||||
if ( $rem_ib_nics ) {
|
||||
$rem_ib_nics = $rem_ib_nics . "," . $nic_key;
|
||||
}
|
||||
else {
|
||||
$rem_ib_nics = $nic_key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Bridged interfaces do not show differently than ethernet nics in
|
||||
# the "ip addr show" command. Therefore the command "brctl show" is
|
||||
# used to get the bridged nics.
|
||||
# This subroutine will set the global variable $bridgednics.
|
||||
# brctl show output is similar to:
|
||||
# bridge name bridge id STP enabled interfaces
|
||||
# virbr0 8000.5254004a3d54 yes virbr0-nic
|
||||
# first line is skipped as it is the heading. The values specified by
|
||||
# bridge name and interfaces show up as nics in the "ip addr show" output.
|
||||
# Therefore need to put both of these # in the $bridgednics string
|
||||
# because we don't want to remove either of those interfaces.
|
||||
|
||||
sub get_bridged_nics {
|
||||
# first, ensure that brctl is installed. If not then just exit since there will be no
|
||||
# bridged interfaces.
|
||||
my $i;
|
||||
if ( -e "/usr/sbin/bcrtl" ) {
|
||||
my @bridge_out = `brctl show`;
|
||||
my $lines = scalar(@bridge_out);
|
||||
for ($i=1; $i < $lines ; $i++) {
|
||||
|
||||
# brctl ouput puts half tabs '\cI' and line feed \cJ' chars in
|
||||
# the ouput. Need to convert these to spaces then split.
|
||||
# Get first and last values for nics.
|
||||
|
||||
$bridge_out[$i] =~ s/\cI/ /g;
|
||||
my @br = split(/ /,$bridge_out[$i]);
|
||||
if ( $bridgednics ) {
|
||||
$bridgednics = $bridgednics . "," . $br[0] . "," . $br[-1];
|
||||
}
|
||||
else {
|
||||
$bridgednics = $br[0] . "," . $br[-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if [ -n "$str_ib_nics" ];then
|
||||
logger -t xcat -p local4.info "confignics: executed script: configib for nics: $str_ib_nics, ports: $num_iba_ports"
|
||||
echo "confignics on $NODE: executed script: configib for nics: $str_ib_nics, ports: $num_iba_ports"
|
||||
NIC_IBNICS=$str_ib_nics NIC_IBAPORTS=$num_iba_ports configib
|
||||
else
|
||||
if [ $bool_remove -eq 1 ];then
|
||||
logger -t xcat -p local4.info "confignics: executed script: 'configib -u' to remove all ib nics and configuration files"
|
||||
echo "confignics on $NODE: executed script: 'configib -r' to remove all ib nics and configuration files"
|
||||
configib
|
||||
fi
|
||||
fi
|
||||
|
@ -23,21 +23,28 @@ if [ "$(uname -s)" = "AIX" ]; then
|
||||
fi
|
||||
if [ -r /etc/ssh/sshd_config ]
|
||||
then
|
||||
logger -t xcat -p local4.info "Install: setup /etc/ssh/sshd_config"
|
||||
logger -t xcat -p local4.info "remoteshell: setup /etc/ssh/sshd_config and ssh_config"
|
||||
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIG
|
||||
sed -i 's/^X11Forwarding .*$/X11Forwarding yes/' /etc/ssh/sshd_config
|
||||
sed -i 's/^KeyRegenerationInterval .*$/KeyRegenerationInterval 0/' /etc/ssh/sshd_config
|
||||
sed -i 's/\(.*MaxStartups.*\)/#\1/' /etc/ssh/sshd_config
|
||||
echo "MaxStartups 1024" >>/etc/ssh/sshd_config
|
||||
#delete all occurance of the attribute and then add xCAT settings
|
||||
sed -i '/X11Forwarding /'d /etc/ssh/sshd_config
|
||||
echo "X11Forwarding yes" >>/etc/ssh/sshd_config
|
||||
sed -i '/KeyRegenerationInterval /'d /etc/ssh/sshd_config
|
||||
echo "KeyRegenerationInterval 0" >>/etc/ssh/sshd_config
|
||||
sed -i '/MaxStartups /'d /etc/ssh/sshd_config
|
||||
echo "MaxStartups 1024" >>/etc/ssh/sshd_config
|
||||
|
||||
if [ "$SETUPFORPCM" = "1" ];then
|
||||
sed -i 's/\(.*PasswordAuthentication.*\)/#\1/' /etc/ssh/sshd_config
|
||||
echo "PasswordAuthentication yes" >>/etc/ssh/sshd_config
|
||||
sed -i '/PasswordAuthentication /'d /etc/ssh/sshd_config
|
||||
echo "PasswordAuthentication yes" >>/etc/ssh/sshd_config
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -r /etc/ssh/sshd_config ]
|
||||
then
|
||||
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config
|
||||
sed -i '/StrictHostKeyChecking /'d /etc/ssh/ssh_config
|
||||
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
|
||||
|
||||
fi
|
||||
|
||||
if [ -d /xcatpost/_ssh ]
|
||||
|
17
xCAT/postscripts/xcatlib.sh
Normal file
17
xCAT/postscripts/xcatlib.sh
Normal file
@ -0,0 +1,17 @@
|
||||
function hashencode(){
|
||||
local map="$1"
|
||||
echo `echo $map | sed 's/\./xDOTx/g' | sed 's/:/xCOLONx/g' | sed 's/,/:xCOMMAx/g'`
|
||||
}
|
||||
|
||||
function hashset(){
|
||||
local hashname="hash${1}${2}"
|
||||
local value=$3
|
||||
hashname=$(hashencode $hashname)
|
||||
eval "${hashname}='${value}'"
|
||||
}
|
||||
|
||||
function hashget(){
|
||||
local hashname="hash${1}${2}"
|
||||
hashname=$(hashencode $hashname)
|
||||
eval echo "\$${hashname}"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user