Merge branch 'master' of ssh://git.code.sf.net/p/xcat/xcat-core
modified softlayer sysclone for bonded nics
This commit is contained in:
commit
273e6f226b
@ -86,7 +86,7 @@ if [ "$c_flag" -a "$d_flag" ];then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
uploader="bp-sawyers"
|
||||
uploader="ligc"
|
||||
# Find where this script is located to set some build variables
|
||||
old_pwd=`pwd`
|
||||
cd `dirname $0`
|
||||
@ -279,7 +279,7 @@ __EOF__
|
||||
cat << '__EOF__' > mklocalrepo.sh
|
||||
. /etc/lsb-release
|
||||
cd `dirname $0`
|
||||
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
|
||||
echo deb [arch=amd64] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
|
||||
__EOF__
|
||||
|
||||
chmod 775 mklocalrepo.sh
|
||||
@ -380,7 +380,7 @@ __EOF__
|
||||
cat << '__EOF__' > mklocalrepo.sh
|
||||
. /etc/lsb-release
|
||||
cd `dirname $0`
|
||||
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
|
||||
echo deb [arch=amd64] file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
|
||||
__EOF__
|
||||
|
||||
chmod 775 mklocalrepo.sh
|
||||
|
@ -1020,6 +1020,7 @@ sub fork_fanout_dsh
|
||||
}
|
||||
}
|
||||
# save the original exports, we are going to add the unique node name below
|
||||
my $firstpass=0;
|
||||
while (@$targets_waiting
|
||||
&& (keys(%$targets_active) < $$options{'fanout'}))
|
||||
{
|
||||
@ -1046,6 +1047,7 @@ sub fork_fanout_dsh
|
||||
}
|
||||
if ($$options{'environment'})
|
||||
{
|
||||
if ($firstpass ==0) { # do the servicenode stuff only once
|
||||
# if we are on a servicenode need to get the environment file
|
||||
# from the SNsyncfiledir, not local
|
||||
if (xCAT::Utils->isServiceNode()) {
|
||||
@ -1068,8 +1070,10 @@ sub fork_fanout_dsh
|
||||
$rsp->{error}->[0] = "File $$options{'environment'} does not exist";
|
||||
xCAT::MsgUtils->message("E", $rsp, $::CALLBACK);
|
||||
}
|
||||
# build the xdsh command
|
||||
push @dsh_command,
|
||||
$firstpass=1;
|
||||
}
|
||||
# build the xdsh command
|
||||
push @dsh_command,
|
||||
"$exportnode$$options{'pre-command'} . $$options{'environment'} ; $$options{'command'}$$options{'post-command'}";
|
||||
}
|
||||
|
||||
|
@ -217,14 +217,13 @@ sub is_me
|
||||
#my ($b1, $b2, $b3, $b4) = split /\./, $nameIP;
|
||||
|
||||
# get all the possible IPs for the node I'm running on
|
||||
my $ifcmd = "ifconfig -a | grep 'inet'";
|
||||
my $result = xCAT::Utils->runcmd($ifcmd, -1, 1);
|
||||
my $ipcmd = "ip addr | grep 'inet'";
|
||||
my $result = xCAT::Utils->runcmd($ipcmd, -1, 1);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
my $rsp;
|
||||
# push @{$rsp->{data}}, "Could not run $ifcmd.\n";
|
||||
# xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
$::VERBOSE = $verb;
|
||||
my $str="Error running ipcmd";
|
||||
xCAT::MsgUtils->message("S", $str);
|
||||
$::VERBOSE = $verb;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -232,7 +231,6 @@ sub is_me
|
||||
{
|
||||
my ($inet, $myIP, $str) = split(" ", $int);
|
||||
chomp $myIP;
|
||||
$myIP =~ s/addr://;
|
||||
$myIP =~ s/\/.*//; # ipv6 address 4000::99/64
|
||||
$myIP =~ s/\%.*//; # ipv6 address ::1%1/128
|
||||
|
||||
@ -1135,8 +1133,8 @@ sub dolitesetup
|
||||
|
||||
if (!$file) {
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# ex. .../inst_root/foo/bar/ or .../inst_root/etc/lppcfg
|
||||
my $instrootfile = $instrootloc . $file;
|
||||
|
||||
|
@ -643,16 +643,11 @@ sub get_nic_ip
|
||||
{
|
||||
my $nic;
|
||||
my %iphash;
|
||||
my $cmd = "ifconfig -a";
|
||||
my $result = `$cmd`;
|
||||
my $mode = "MULTICAST";
|
||||
my $payingattention=0;
|
||||
my $interface;
|
||||
my $keepcurrentiface;
|
||||
|
||||
#############################################
|
||||
# Error running command
|
||||
#############################################
|
||||
if ( !$result ) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
if (xCAT::Utils->isAIX()) {
|
||||
##############################################################
|
||||
@ -664,6 +659,14 @@ sub get_nic_ip
|
||||
# en1: ...
|
||||
#
|
||||
##############################################################
|
||||
my $cmd = "ifconfig -a";
|
||||
my $result = `$cmd`;
|
||||
#############################################
|
||||
# Error running command
|
||||
#############################################
|
||||
if ( !$result ) {
|
||||
return undef;
|
||||
}
|
||||
my @adapter = split /(\w+\d+):\s+flags=/, $result;
|
||||
foreach ( @adapter ) {
|
||||
if ($_ =~ /^(en\d)/) {
|
||||
@ -683,44 +686,39 @@ sub get_nic_ip
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
##############################################################
|
||||
# Should look like this for Linux:
|
||||
# eth0 Link encap:Ethernet HWaddr 00:02:55:7B:06:30
|
||||
# inet addr:9.114.154.193 Bcast:9.114.154.223
|
||||
# inet6 addr: fe80::202:55ff:fe7b:630/64 Scope:Link
|
||||
# UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
|
||||
# RX packets:1280982 errors:0 dropped:0 overruns:0 frame:0
|
||||
# TX packets:3535776 errors:0 dropped:0 overruns:0 carrier:0
|
||||
# collisions:0 txqueuelen:1000
|
||||
# RX bytes:343489371 (327.5 MiB) TX bytes:870969610 (830.6 MiB)
|
||||
# Base address:0x2600 Memory:fbfe0000-fc0000080
|
||||
#
|
||||
# eth1 ...
|
||||
# Redhat7
|
||||
#eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
||||
# inet 10.1.0.178 netmask 255.255.0.0 broadcast 10.1.255.255
|
||||
#
|
||||
##############################################################
|
||||
my @adapter= split /\n{2,}/, $result;
|
||||
foreach ( @adapter ) {
|
||||
if ( !($_ =~ /LOOPBACK/ ) and
|
||||
$_ =~ /UP( |,|>)/ and
|
||||
$_ =~ /$mode/ ) {
|
||||
my @ip = split /\n/;
|
||||
for my $ent ( @ip ) {
|
||||
if ($ent =~ /^(eth\d|ib\d|hf\d)\s+/) {
|
||||
$nic = $1;
|
||||
}
|
||||
if ($ent =~ /^(eth\d:|ib\d:|hf\d:)\s+/) {
|
||||
$nic = $1;
|
||||
}
|
||||
$ent=~ s/addr://; # works for Redhat7 also
|
||||
if ( $ent =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) {
|
||||
$iphash{$nic} = $1;
|
||||
next;
|
||||
}
|
||||
else { # linux
|
||||
my @ipoutput = `ip addr`;
|
||||
#############################################
|
||||
# Error running command
|
||||
#############################################
|
||||
if ( !@ipoutput ) {
|
||||
return undef;
|
||||
}
|
||||
foreach my $line (@ipoutput) {
|
||||
if ($line =~ /^\d/) { # new interface, new context..
|
||||
if ($interface and not $keepcurrentiface) {
|
||||
#don't bother reporting unusable nics
|
||||
delete $iphash{$interface};
|
||||
}
|
||||
$keepcurrentiface=0;
|
||||
if ( !($line =~ /LOOPBACK/ ) and
|
||||
$line =~ /UP( |,|>)/ and
|
||||
$line =~ /$mode/ ) {
|
||||
|
||||
$payingattention=1;
|
||||
$line =~ /^([^:]*): ([^:]*):/;
|
||||
$interface=$2;
|
||||
} else {
|
||||
$payingattention=0;
|
||||
next;
|
||||
}
|
||||
}
|
||||
unless ($payingattention) { next; }
|
||||
if ($line =~ /inet/) {
|
||||
$keepcurrentiface=1;
|
||||
}
|
||||
if ( $line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) {
|
||||
$iphash{$interface} = $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1593,7 +1591,7 @@ sub thishostisnot
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 gethost_ips (AIX and Linux)
|
||||
Will use ifconfig to determine all possible ip addresses for the
|
||||
Will use ifconfig or ip addr to determine all possible ip addresses for the
|
||||
host it is running on and then gethostbyaddr to get all possible hostnames
|
||||
|
||||
input:
|
||||
@ -1608,52 +1606,57 @@ sub gethost_ips
|
||||
my ($class) = @_;
|
||||
my $cmd;
|
||||
my @ipaddress;
|
||||
$cmd = "ifconfig" . " -a";
|
||||
$cmd = $cmd . "| grep \"inet\"";
|
||||
if (xCAT::Utils->isLinux()) {
|
||||
$cmd = "ip addr ";
|
||||
$cmd = $cmd . "| grep \"inet\"";
|
||||
} else { # AIX
|
||||
$cmd = "ifconfig" . " -a";
|
||||
$cmd = $cmd . "| grep \"inet\"";
|
||||
}
|
||||
my @result = xCAT::Utils->runcmd($cmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
xCAT::MsgUtils->message("S", "Error from $cmd\n");
|
||||
exit $::RUNCMD_RC;
|
||||
}
|
||||
foreach my $addr (@result)
|
||||
{
|
||||
if (xCAT::Utils->isLinux()) {
|
||||
foreach (@result)
|
||||
{
|
||||
my @ip;
|
||||
if (xCAT::Utils->isLinux())
|
||||
if (/inet6/)
|
||||
{
|
||||
if ($addr =~ /inet6/)
|
||||
#TODO, Linux ipv6
|
||||
}
|
||||
else
|
||||
{
|
||||
my @ents = split(/\s+/);
|
||||
my $ip = $ents[2];
|
||||
$ip =~ s/\/.*//;
|
||||
$ip =~ s/\%.*//;
|
||||
push @ipaddress, $ip;
|
||||
}
|
||||
}
|
||||
} else { #AIX
|
||||
foreach my $addr (@result)
|
||||
{
|
||||
if ($addr =~ /inet6/)
|
||||
{
|
||||
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
|
||||
my $v6ip = $1;
|
||||
my $v6mask = $2;
|
||||
if ($v6ip)
|
||||
{
|
||||
#TODO, Linux ipv6
|
||||
}
|
||||
else
|
||||
{
|
||||
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
|
||||
#@ip = split(":", $addr1);
|
||||
#push @ipaddress, $ip[1];
|
||||
$addr1 =~ s/.*://;
|
||||
push @ipaddress, $addr1;
|
||||
push @ipaddress, $v6ip;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ #AIX
|
||||
if ($addr =~ /inet6/)
|
||||
{
|
||||
$addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/;
|
||||
my $v6ip = $1;
|
||||
my $v6mask = $2;
|
||||
if ($v6ip)
|
||||
{
|
||||
push @ipaddress, $v6ip;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
|
||||
split(" ", $addr);
|
||||
push @ipaddress, $addr1;
|
||||
}
|
||||
|
||||
{
|
||||
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
|
||||
split(" ", $addr);
|
||||
push @ipaddress, $addr1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
my @names = @ipaddress;
|
||||
foreach my $ipaddr (@names)
|
||||
@ -1844,100 +1847,6 @@ sub validate_ip
|
||||
return([0]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 getFacingIP
|
||||
Gets the ip address of the adapter of the localhost that is facing the
|
||||
the given node.
|
||||
Assume it is the same as my_ip_facing...
|
||||
Arguments:
|
||||
The name of the node that is facing the localhost.
|
||||
Returns:
|
||||
The ip address of the adapter that faces the node.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub getFacingIP
|
||||
{
|
||||
my ($class, $node) = @_;
|
||||
my $ip;
|
||||
my $cmd;
|
||||
my @ipaddress;
|
||||
|
||||
my $nodeip = inet_ntoa(inet_aton($node));
|
||||
unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/)
|
||||
{
|
||||
return 0; #Not supporting IPv6 here IPV6TODO
|
||||
}
|
||||
|
||||
$cmd = "ifconfig" . " -a";
|
||||
$cmd = $cmd . "| grep \"inet \"";
|
||||
my @result = xCAT::Utils->runcmd($cmd, 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
xCAT::MsgUtils->message("S", "Error from $cmd\n");
|
||||
exit $::RUNCMD_RC;
|
||||
}
|
||||
|
||||
# split node address
|
||||
my ($n1, $n2, $n3, $n4) = split('\.', $nodeip);
|
||||
|
||||
foreach my $addr (@result)
|
||||
{
|
||||
my $ip;
|
||||
my $mask;
|
||||
if (xCAT::Utils->isLinux())
|
||||
{
|
||||
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
|
||||
if ((!$addr1) || (!$Mask)) { next; }
|
||||
my @ips = split(":", $addr1);
|
||||
my @masks = split(":", $Mask);
|
||||
$ip = $ips[1];
|
||||
$mask = $masks[1];
|
||||
}
|
||||
else
|
||||
{ #AIX
|
||||
my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) =
|
||||
split(" ", $addr);
|
||||
if ((!$addr1) && (!$mask1)) { next; }
|
||||
$ip = $addr1;
|
||||
$mask1 =~ s/0x//;
|
||||
$mask =
|
||||
`printf "%d.%d.%d.%d" \$(echo "$mask1" | sed 's/../0x& /g')`;
|
||||
}
|
||||
|
||||
if ($ip && $mask)
|
||||
{
|
||||
|
||||
# split interface IP
|
||||
my ($h1, $h2, $h3, $h4) = split('\.', $ip);
|
||||
|
||||
# split mask
|
||||
my ($m1, $m2, $m3, $m4) = split('\.', $mask);
|
||||
|
||||
# AND this interface IP with the netmask of the network
|
||||
my $a1 = ((int $h1) & (int $m1));
|
||||
my $a2 = ((int $h2) & (int $m2));
|
||||
my $a3 = ((int $h3) & (int $m3));
|
||||
my $a4 = ((int $h4) & (int $m4));
|
||||
|
||||
# AND node IP with the netmask of the network
|
||||
my $b1 = ((int $n1) & (int $m1));
|
||||
my $b2 = ((int $n2) & (int $m2));
|
||||
my $b3 = ((int $n3) & (int $m3));
|
||||
my $b4 = ((int $n4) & (int $m4));
|
||||
|
||||
if (($b1 == $a1) && ($b2 == $a2) && ($b3 == $a3) && ($b4 == $a4))
|
||||
{
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xCAT::MsgUtils->message("S", "Cannot find master for the node $node\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -115,7 +115,11 @@ else
|
||||
length=`expr $index2 - $index1`
|
||||
length=`expr $length - 1`
|
||||
cons_ip=`expr substr "$result" $pos $length`
|
||||
ifconfig |grep "$cons_ip"
|
||||
if [ "$os" == "AIX" ]; then
|
||||
ifconfig |grep "$cons_ip"
|
||||
else
|
||||
ip addr |grep "$cons_ip"
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
CONSERVER=""
|
||||
fi
|
||||
|
@ -105,11 +105,6 @@ sub subvars {
|
||||
}
|
||||
|
||||
|
||||
my @managedaddressmode = xCAT::TableUtils->get_site_attribute("managedaddressmode");
|
||||
my $tmp=$managedaddressmode[0];
|
||||
if( defined($tmp) ){
|
||||
$ENV{MANAGEDADDRESSMODE}=$tmp;
|
||||
}
|
||||
|
||||
#replace the env with the right value so that correct include files can be found
|
||||
$inc =~ s/#ENV:([^#]+)#/envvar($1)/eg;
|
||||
@ -249,6 +244,7 @@ sub subvars {
|
||||
$inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg;
|
||||
$inc =~ s/#MANAGEDADDRESSMODE#/managed_address_mode()/eg;
|
||||
$inc =~ s/#HOSTNAME#/$node/g;
|
||||
$inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg;
|
||||
|
||||
my $nrtab = xCAT::Table->new("noderes");
|
||||
my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']);
|
||||
@ -638,6 +634,22 @@ sub get_win_prodkey {
|
||||
sub managed_address_mode {
|
||||
return $::XCATSITEVALS{managedaddressmode};
|
||||
}
|
||||
|
||||
|
||||
sub get_node_domain {
|
||||
my $lcnode=shift;
|
||||
if ( $lcnode eq 'THISNODE' ){
|
||||
$lcnode=$node;
|
||||
}
|
||||
|
||||
my $nd = xCAT::NetworkUtils->getNodeDomains([$lcnode]);
|
||||
my %nodedomains = %$nd;
|
||||
my $domain=$nodedomains{$lcnode};
|
||||
|
||||
return $domain;
|
||||
|
||||
}
|
||||
|
||||
sub esxipv6setup {
|
||||
if (not $::XCATSITEVALS{managedaddressmode} or $::XCATSITEVALS{managedaddressmode} =~ /v4/) { return ""; } # blank line for ipv4 schemes
|
||||
my $v6addr;
|
||||
@ -705,7 +717,7 @@ sub kickstartnetwork {
|
||||
push @nameserversIP, $ip;
|
||||
|
||||
}
|
||||
|
||||
#there is no network option to set dns search domain in kickstart, it will be set in %post
|
||||
if (scalar @nameserversIP) {
|
||||
$line .=" --nameserver=". join(",",@nameserversIP);
|
||||
}
|
||||
|
@ -884,10 +884,15 @@ sub check_options
|
||||
# if not help and not -n, dhcpd needs to be running
|
||||
if (!($opt->{h})&& (!($opt->{n}))) {
|
||||
if (xCAT::Utils->isLinux()) {
|
||||
my @output = xCAT::Utils->runcmd("service dhcpd status", -1);
|
||||
my $DHCPSERVER="dhcpd";
|
||||
if( -e "/etc/init.d/isc-dhcp-server" ){
|
||||
$DHCPSERVER="isc-dhcp-server";
|
||||
}
|
||||
|
||||
my @output = xCAT::Utils->runcmd("service $DHCPSERVER status", -1);
|
||||
if ($::RUNCMD_RC != 0) { # not running
|
||||
my $rsp = {};
|
||||
$rsp->{data}->[0] = "dhcpd is not running. Run service dhcpd start and rerun your command.";
|
||||
$rsp->{data}->[0] = "$DHCPSERVER is not running. Run service $DHCPSERVER start and rerun your command.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1182,11 +1182,19 @@ sub mkinstall
|
||||
}
|
||||
|
||||
if(scalar @nameserversIP){
|
||||
$kcmdline .=" dns=".join(",",@nameserversIP);
|
||||
$kcmdline .=" Nameserver=".join(",",@nameserversIP);
|
||||
}
|
||||
|
||||
my $nd = xCAT::NetworkUtils->getNodeDomains([$node]);
|
||||
my %nodedomains = %$nd;
|
||||
my $domain=$nodedomains{$node};
|
||||
|
||||
$kcmdline .=" Domain=$domain ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (defined $sent->{serialport})
|
||||
{
|
||||
|
@ -742,6 +742,12 @@ sub copycd
|
||||
$darch = "x86_64";
|
||||
} elsif (/BuildBranch=win7_rtm/){
|
||||
$distname = "win7";
|
||||
} elsif (/BuildBranch=winblue_rtm/){
|
||||
if (-r $mntpath . "/sources/background_svr.bmp") {
|
||||
if (! -r $mntpath . "/sources/EI.CFG") {
|
||||
$distname = "win2012r2";
|
||||
}
|
||||
}
|
||||
} elsif (/BuildBranch=win8_rtm/){
|
||||
if (-r $mntpath . "/sources/background_cli.bmp") {
|
||||
$distname = "win8";
|
||||
|
@ -2,6 +2,7 @@
|
||||
#cmdline
|
||||
|
||||
lang en_US
|
||||
#KICKSTARTNET#
|
||||
|
||||
#
|
||||
# Where's the source?
|
||||
|
@ -3,6 +3,7 @@
|
||||
#cmdline
|
||||
|
||||
lang en_US
|
||||
#KICKSTARTNET#
|
||||
|
||||
#
|
||||
# Where's the source?
|
||||
|
@ -2,6 +2,8 @@
|
||||
# Setup hostname
|
||||
#
|
||||
echo "post scripts" >/root/post.log
|
||||
|
||||
|
||||
export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic#
|
||||
if [ "$PRINIC" == "mac" ]
|
||||
then
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
export MANAGEDADDRESSMODE="#XCATVAR:MANAGEDADDRESSMODE#"
|
||||
export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE#
|
||||
|
||||
cd /etc/sysconfig/network
|
||||
|
||||
|
@ -14,6 +14,17 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then
|
||||
fi
|
||||
|
||||
|
||||
#there is no boot option to set dns search domain in kickstart file,
|
||||
#the search domain in /etc/resolv.conf is set in the pre installation script
|
||||
export MANAGEDADDRESSMODE=#MANAGEDADDRESSMODE#
|
||||
export SEARCHDOMAIN=#GETNODEDOMAIN:THISNODE#
|
||||
|
||||
if [ "$MANAGEDADDRESSMODE" == "static" ]; then
|
||||
echo "#appended by %pre " >> /etc/resolv.conf
|
||||
echo "search $SEARCHDOMAIN" >> /etc/resolv.conf
|
||||
fi
|
||||
|
||||
|
||||
|
||||
cat >/tmp/baz.py <<EOF
|
||||
#!/usr/bin/python
|
||||
|
@ -1,138 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# stateless
|
||||
#
|
||||
# chkconfig: 345 11 99
|
||||
# description: action stateless
|
||||
#
|
||||
# Source the library functions
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
|
||||
ZONE="US/Mountain"
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting stateless configuration: "
|
||||
|
||||
if [ -r /etc/stateless_done ]
|
||||
then
|
||||
echo_failure
|
||||
echo
|
||||
echo " already run!"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#initrd=xcat/netboot/fedora8/x86_64/compute/initrd.gz imgurl=nfs://rro000/install/netboot/fedora8/x86_64/compute/rootimg console=ttyS1,19200n8r BOOT_IMAGE=xcat/netboot/fedora8/x86_64/compute/kernel
|
||||
cat /proc/cmdline | grep imgurl >/dev/null 2>&1
|
||||
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
echo_failure
|
||||
echo
|
||||
echo " imgurl missing from /proc/cmdline, i.e. stateful!"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
for i in $(cat /proc/cmdline)
|
||||
do
|
||||
KEY=$(echo $i | awk -F= '{print $1}')
|
||||
VALUE=$(echo $i | awk -F= '{print $2}')
|
||||
|
||||
if [ "$KEY" = "imgurl" ]
|
||||
then
|
||||
SERVER=$(echo $VALUE | awk -F/ '{print $3}')
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$SERVER" ]
|
||||
then
|
||||
echo_failure
|
||||
echo
|
||||
echo "bogus server in imgurl"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo
|
||||
echo " Universal Server: $SERVER"
|
||||
|
||||
echo -n " Syslog: "
|
||||
echo "*.* @$SERVER" >/etc/rsyslog.conf
|
||||
echo_success
|
||||
echo
|
||||
|
||||
if [ -r /etc/rc.d/init.d/ntpd ]
|
||||
then
|
||||
echo -n " NTP: "
|
||||
if [ ! -r /etc/sysconfig/clock ]
|
||||
then
|
||||
echo "ZONE=\"$ZONE\"
|
||||
UTC=true
|
||||
ARC=false" >/etc/sysconfig/clock
|
||||
fi
|
||||
|
||||
echo "server $SERVER
|
||||
driftfile /etc/ntp/drift
|
||||
multicastclient
|
||||
broadcastdelay 0.008
|
||||
disable auth
|
||||
keys /etc/ntp/keys
|
||||
trustedkey 65535
|
||||
requestkey 65535
|
||||
controlkey 65535" >/etc/ntp.conf
|
||||
|
||||
echo "$SERVER" >/etc/ntp/step-tickers
|
||||
|
||||
echo_success
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ -r /etc/ldap.conf -a -r /etc/resolv.conf ]
|
||||
then
|
||||
echo -n " LDAP: "
|
||||
|
||||
DC=$(
|
||||
cat /etc/resolv.conf | \
|
||||
egrep '(domain|search)' | \
|
||||
head -1 | \
|
||||
awk '{print $2}' | \
|
||||
sed 's/\./,dc=/g' | \
|
||||
sed 's/^/dc=/'
|
||||
)
|
||||
|
||||
echo "host $SERVER
|
||||
base $DC
|
||||
nss_base_passwd ou=People,$DC
|
||||
nss_base_shadow ou=People,$DC
|
||||
nss_base_group ou=Group,$DC
|
||||
timelimit 120
|
||||
bind_timelimit 120
|
||||
idle_timelimit 3600
|
||||
nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat,radiusd,news,mailman,nscd
|
||||
ssl no
|
||||
tls_cacertdir /etc/openldap/cacerts
|
||||
pam_password md5" >/etc/ldap.conf
|
||||
|
||||
echo "URI ldap://$SERVER
|
||||
BASE $DC
|
||||
TLS_CACERTDIR /etc/openldap/cacerts" >/etc/openldap/ldap.conf
|
||||
|
||||
cd /etc
|
||||
cp nsswitch.conf nsswitch.conf.ORIG
|
||||
sed -r 's/^((passwd|shadow|group):.*)/\1 ldap/' <nsswitch.conf.ORIG >nsswitch.conf
|
||||
|
||||
cd /etc/pam.d
|
||||
cp system-auth system-auth.ORIG
|
||||
sed -r 's/(account\s+required\s+pam_unix.so)/account sufficient pam_ldap.so\n\1/' <system-auth.ORIG >system-auth
|
||||
|
||||
echo_success
|
||||
echo
|
||||
fi
|
||||
touch /etc/stateless_done
|
||||
;;
|
||||
stop)
|
||||
;;
|
||||
*)
|
||||
echo "Usage: stateless {start|stop}"
|
||||
exit 1
|
||||
esac
|
@ -1,170 +0,0 @@
|
||||
################################################################################
|
||||
# Create a generic HPC image
|
||||
# This script is an example of how to create an HPC image with xCAT stateless.
|
||||
# in this example you may need to change some of the parameters. In the future
|
||||
# we should probably place this in the database...
|
||||
# All good sys admins can reproduce their environments. Creating a stateless
|
||||
# image should be reproducable. Doing this with a script is a good idea.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
|
||||
# specify the OS stuff. You'll probably want to change this. If you do then you'll
|
||||
# need to make sure there is a *.pkglist and *.exlist
|
||||
PROFILE=compute
|
||||
ARCH=x86_64
|
||||
OS=centos5.3
|
||||
|
||||
# this is where the OS image will reside
|
||||
IMGROOT=/install/netboot/$OS/$ARCH/$PROFILE/rootimg
|
||||
|
||||
# remove the old image if it exists.
|
||||
rm -rf /install/netboot/$OS/$ARCH/$PROFILE
|
||||
|
||||
# generate the base image
|
||||
# for IBM: tg3 in older blades, bnx in newer stuff, and igb in the nehalem based products.
|
||||
/opt/xcat/share/xcat/netboot/centos/genimage -i eth0 -n libphy,tg3,bnx2,igb -o $OS -p $PROFILE
|
||||
|
||||
# update the yum database in the image
|
||||
rm -rf $IMGROOT/etc/yum.repos.d
|
||||
yum --installroot=$IMGROOT clean all
|
||||
cp -a /etc/yum.repos.d/ $IMGROOT/etc/
|
||||
rm -rf $IMGROOT/etc/yum.repos.d/xCAT-*
|
||||
|
||||
# no selinux!!
|
||||
echo SELINUX=disabled > $IMGROOT/etc/sysconfig/selinux
|
||||
|
||||
# fix respawns
|
||||
cp $IMGROOT/etc/inittab $IMGROOT/etc/inittab.ORIG
|
||||
grep -v 38400 $IMGROOT/etc/inittab.ORIG > $IMGROOT/etc/inittab
|
||||
|
||||
# filesystem setup, you'll want to customize this. We have swap and scratch
|
||||
# configured here. But if you don't have disks then this may not help.
|
||||
# we name our / partition the image name (compute by default) plus a timestamp.
|
||||
|
||||
TIME=`date +%s`
|
||||
cp $IMGROOT/etc/fstab $IMGROOT/etc/fstab.ORIG
|
||||
echo "proc /proc proc rw 0 0
|
||||
sysfs /sys sysfs rw 0 0
|
||||
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
|
||||
$PROFILE-$TIME / tmpfs rw 0 1
|
||||
#/dev/sda1 swap swap defaults 0 0
|
||||
#/dev/sda2 /scratch ext3 defaults 0 0
|
||||
" > $IMGROOT/etc/fstab
|
||||
mkdir $IMGROOT/scratch
|
||||
|
||||
### get ntp to start on boot
|
||||
chroot $IMGROOT chkconfig --level 345 ntpd on
|
||||
|
||||
#### user stuff so that we can do some work ####
|
||||
cp /etc/shadow $IMGROOT/etc/
|
||||
cp /etc/group $IMGROOT/etc/
|
||||
cp /etc/passwd $IMGROOT/etc/
|
||||
cp /etc/hosts $IMGROOT/etc/
|
||||
|
||||
### scaling fixes #####
|
||||
echo "# increase TCP max buffer size
|
||||
net.core.rmem_max = 33554432
|
||||
net.core.wmem_max = 33554432
|
||||
net.core.rmem_default = 65536
|
||||
net.core.wmem_default = 65536
|
||||
# increase Linux autotuning TCP buffer limits
|
||||
# min, default, and max number of bytes to use
|
||||
net.ipv4.tcp_rmem = 4096 33554432 33554432
|
||||
net.ipv4.tcp_wmem = 4096 33554432 33554432
|
||||
net.ipv4.tcp_mem= 33554432 33554432 33554432
|
||||
net.ipv4.route.flush=1
|
||||
net.core.netdev_max_backlog=1500
|
||||
|
||||
#GPFS / NFS Tuning
|
||||
net.ipv4.conf.all.arp_filter = 1
|
||||
net.ipv4.conf.all.rp_filter = 1
|
||||
net.ipv4.neigh.default.gc_thresh1 = 1024
|
||||
net.ipv4.neigh.default.gc_thresh2 = 4096
|
||||
net.ipv4.neigh.default.gc_thresh3 = 8192
|
||||
net.ipv4.neigh.default.gc_stale_time = 24" >> $IMGROOT/etc/sysctl.conf
|
||||
|
||||
## Limits: need to make sure users can have unlimited memory (ulimit -l unlimited)
|
||||
cp /etc/security/limits.conf $IMGROOT/etc/security/
|
||||
|
||||
### add torque ###
|
||||
/opt/xcat/share/xcat/netboot/add-on/torque/add_torque $IMGROOT mgt /opt/torque / local
|
||||
|
||||
# update the limit on pegged memory limit and if they have old xCAT then make sure
|
||||
# it says torque instead of pbs in the paths of the config file.
|
||||
perl -pi -e 's/ulimit -n 20000/ulimit -n 20000; ulimit -l unlimited/g' $IMGROOT/etc/init.d/pbs_mom
|
||||
perl -pi -e 's/spool\/pbs/spool\/torque/g' $IMGROOT/etc/init.d/pbs_mom
|
||||
perl -pi -e 's/spool\/pbs/spool\/torque/g' $IMGROOT/etc/init.d/pbs_mom
|
||||
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/epilogue
|
||||
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/prologue
|
||||
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/takedownnode
|
||||
|
||||
### stateless init script does NTP, syslog, etc. ####
|
||||
cp /etc/localtime $IMGROOT/etc/
|
||||
cp /opt/xcat/share/xcat/netboot/add-on/stateless/stateless $IMGROOT/etc/init.d/
|
||||
perl -pi -e 's!Mountain!Mexico/General!g' $IMGROOT/etc/init.d/stateless
|
||||
perl -pi -e 's/driftfile \/etc\/ntp/driftfile \/var\/lib\/ntp/g' $IMGROOT/etc/init.d/stateless
|
||||
perl -pi -e 's/keys \/etc\/ntp/keys \/var\/lib\/ntp/g' $IMGROOT/etc/init.d/stateless
|
||||
rm -rf $IMGROOT/etc/sysconfig/clock
|
||||
chroot $IMGROOT chkconfig --level 345 stateless on
|
||||
chroot $IMGROOT chkconfig --level 345 rsyslog on
|
||||
|
||||
### make sure dhcp boot protocol is set to none ###
|
||||
perl -pi -e 's/dhcp/none/g' $IMGROOT/etc/sysconfig/network-scripts/ifcfg-eth0
|
||||
|
||||
#### add GPFS stuff ###
|
||||
# this is an example of a stateless GPFS implementation. Uncomment the below if you
|
||||
# want GPFS. Make sure you have the GPFS RPMs to do this.
|
||||
#GPFSSRCDIR=/install/GPFS
|
||||
#yum --installroot=$IMGROOT -y install glibc ksh compat-libstdc++-33 binutils rsh
|
||||
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.base*rpm
|
||||
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.gpl*rpm
|
||||
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.msg*rpm
|
||||
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.base*rpm
|
||||
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.gpl*rpm
|
||||
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.msg*rpm
|
||||
##
|
||||
#AUTOGPFSDIR=/opt/xcat/share/xcat/netboot/add-on/autogpfs
|
||||
#cp $AUTOGPFSDIR/autogpfsc.pl $IMGROOT/usr/sbin
|
||||
#cp $AUTOGPFSDIR/autogpfsc $IMGROOT/etc/init.d/
|
||||
#echo "SERVERS=mgt
|
||||
#PORT=3003
|
||||
#BLOCK=no" >> $IMGROOT/etc/sysconfig/autogpfsc
|
||||
#
|
||||
#chroot $IMGROOT chkconfig --level 345 autogpfsc on
|
||||
#cp $GPFSSRCDIR/2.6.18-128.el5/* $IMGROOT/usr/lpp/mmfs/bin/
|
||||
#cp /etc/profile.d/gpfs.sh $IMGROOT/etc/profile.d/
|
||||
### End GPFS Stuff ####
|
||||
|
||||
|
||||
### IB Stuff ####
|
||||
# if you have InfiniBand on your machines then you probably have an OFED distribution you
|
||||
# need to add. Here is an example of how to add it.
|
||||
#echo "Adding InfiniBand"
|
||||
#yum --installroot=$IMGROOT -y install bind-utils which rpm tcl tk glibc-devel.i386 pciutils expat libgfortran.x86_64 libgomp.x86_64 tcsh
|
||||
#
|
||||
#IBROOT=/install/voltaire/VoltaireOFED-1.4.2_2-k2.6.18-128.el5-x86_64
|
||||
#mount -o bind /proc $IMGROOT/proc
|
||||
#mount -o bind /sys $IMGROOT/sys
|
||||
#mount -o bind $IBROOT $IMGROOT/mnt
|
||||
#chroot $IMGROOT /mnt/install.sh --without-mpi
|
||||
#umount $IMGROOT/mnt
|
||||
#umount $IMGROOT/sys
|
||||
#umount $IMGROOT/proc
|
||||
# configure IB IP address
|
||||
#echo "IP=\`host \$HOSTNAME-ib0 | awk '{ print \$4 }' | head -1\`" >> $IMGROOT/etc/rc.d/rc.local
|
||||
#echo "ifconfig ib0 \$IP" >> $IMGROOT/etc/rc.d/rc.local
|
||||
#echo "ifconfig ib0 netmask 255.255.0.0" >> $IMGROOT/etc/rc.d/rc.local
|
||||
### End IB Stuff ####
|
||||
|
||||
# configure name resolution
|
||||
# change this to what you want it to be. (this is in site.tab as the domain and nameservers)
|
||||
echo "search cluster.foo
|
||||
nameserver 172.20.0.1" >$IMGROOT/etc/resolv.conf
|
||||
|
||||
|
||||
### uniq-i-fy Torque OS name
|
||||
echo "opsys compute_centos5.3" >> $IMGROOT/var/spool/torque/mom_priv/config
|
||||
|
||||
packimage -p $PROFILE -a $ARCH -o $OS
|
||||
echo "Image $PROFILE-$TIME created"
|
3
xCAT-server/share/xcat/netboot/rh/dracut_033/check
Executable file
3
xCAT-server/share/xcat/netboot/rh/dracut_033/check
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
[ "$1" = "-d" ] && echo network
|
||||
exit 0
|
9
xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot
Executable file
9
xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
echo $drivers
|
||||
dracut_install wget cpio gzip modprobe touch echo cut wc
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install mount.nfs
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
|
||||
inst "$moddir/xcatroot" "/sbin/xcatroot"
|
||||
inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"
|
8
xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite
Executable file
8
xCAT-server/share/xcat/netboot/rh/dracut_033/install.statelite
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
echo $drivers
|
||||
dracut_install wget cpio gzip modprobe wc touch echo cut
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
|
||||
inst_hook pre-mount 5 "$moddir/xcat-premount.sh"
|
||||
inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh"
|
2
xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel
Executable file
2
xCAT-server/share/xcat/netboot/rh/dracut_033/installkernel
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
instmods nfs sunrpc
|
@ -0,0 +1,4 @@
|
||||
root=1
|
||||
rootok=1
|
||||
netroot=xcat
|
||||
echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/xcatroot.sh
|
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
#script to update nodelist.nodestatus during provision
|
||||
|
||||
MASTER=`echo $XCAT |awk -F: '{print $1}'`
|
||||
|
||||
getarg nonodestatus
|
||||
NODESTATUS=$?
|
||||
|
||||
XCATIPORT="$(getarg XCATIPORT=)"
|
||||
if [ $? -ne 0 ]; then
|
||||
XCATIPORT="3002"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ $NODESTATUS -ne 0 ];then
|
||||
/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting"
|
||||
fi
|
126
xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh
Executable file
126
xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-prepivot.sh
Executable file
@ -0,0 +1,126 @@
|
||||
#!/bin/sh
|
||||
NEWROOT=/sysroot
|
||||
SERVER=${SERVER%%/*}
|
||||
SERVER=${SERVER%:}
|
||||
RWDIR=.statelite
|
||||
if [ ! -z $STATEMNT ]; then #btw, uri style might have left future options other than nfs open, will u se // to detect uri in the future I guess
|
||||
SNAPSHOTSERVER=${STATEMNT%:*}
|
||||
SNAPSHOTROOT=${STATEMNT#*/}
|
||||
#echo $SNAPSHOTROOT
|
||||
#echo $SNAPSHOTSERVER
|
||||
# may be that there is not server and just a directory.
|
||||
if [ -z $SNAPSHOTROOT ]; then
|
||||
SNAPSHOTROOT=$SNAPSHOTSERVER
|
||||
SNAPSHOTSERVER=
|
||||
fi
|
||||
fi
|
||||
|
||||
echo Setting up Statelite
|
||||
mkdir -p $NEWROOT
|
||||
|
||||
# now we need to mount the rest of the system. This is the read/write portions
|
||||
# echo Mounting snapshot directories
|
||||
|
||||
MAXTRIES=7
|
||||
ITER=0
|
||||
if [ ! -e "$NEWROOT/$RWDIR" ]; then
|
||||
echo ""
|
||||
echo "This NFS root directory doesn't have a /$RWDIR directory for me to mount a rw filesystem. You'd better create it... "
|
||||
echo ""
|
||||
/bin/sh
|
||||
fi
|
||||
|
||||
if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then
|
||||
echo ""
|
||||
echo "$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with th e -m statelite mode"
|
||||
echo ""
|
||||
/bin/sh
|
||||
fi
|
||||
|
||||
mount -t tmpfs rw $NEWROOT/$RWDIR
|
||||
mkdir -p $NEWROOT/$RWDIR/tmpfs
|
||||
ME=`hostname`
|
||||
if [ ! -z $NODE ]; then
|
||||
ME=$NODE
|
||||
fi
|
||||
|
||||
# mount the SNAPSHOT directory here for persistent use.
|
||||
if [ ! -z $SNAPSHOTSERVER ]; then
|
||||
mkdir -p $NEWROOT/$RWDIR/persistent
|
||||
MAXTRIES=5
|
||||
ITER=0
|
||||
if [ -z $MNTOPTS ]; then
|
||||
MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14"
|
||||
else
|
||||
MNT_OPTIONS=$MNTOPTS
|
||||
fi
|
||||
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
|
||||
ITER=$(( ITER + 1 ))
|
||||
if [ "$ITER" == "$MAXTRIES" ]; then
|
||||
echo "Your are dead, rpower $ME boot to play again."
|
||||
echo "Possible problems:
|
||||
1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ?
|
||||
2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER."
|
||||
/bin/sh
|
||||
exit
|
||||
fi
|
||||
RS= $(( $RANDOM % 20 ))
|
||||
echo "Trying again in $RS seconds..."
|
||||
sleep $RS
|
||||
done
|
||||
|
||||
# create directory which is named after my node name
|
||||
mkdir -p $NEWROOT/$RWDIR/persistent/$ME
|
||||
ITER=0
|
||||
# umount current persistent mount
|
||||
while ! umount -l $NEWROOT/$RWDIR/persistent; do
|
||||
ITER=$(( ITER + 1 ))
|
||||
if [ "$ITER" == "$MAXTRIES" ]; then
|
||||
echo "Your are dead, rpower $ME boot to play again."
|
||||
echo "Cannot umount $NEWROOT/$RWDIR/persistent."
|
||||
/bin/sh
|
||||
exit
|
||||
fi
|
||||
RS= $(( $RANDOM % 20 ))
|
||||
echo "Trying again in $RS seconds..."
|
||||
sleep $RS
|
||||
done
|
||||
|
||||
# mount persistent to server:/rootpath/nodename
|
||||
ITER=0
|
||||
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
|
||||
ITER=$(( ITER + 1 ))
|
||||
if [ "$ITER" == "$MAXTRIES" ]; then
|
||||
echo "Your are dead, rpower $ME boot to play again."
|
||||
echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME."
|
||||
/bin/sh
|
||||
exit
|
||||
fi
|
||||
RS= $(( $RANDOM % 20 ))
|
||||
echo "Trying again in $RS seconds..."
|
||||
sleep $RS
|
||||
done
|
||||
fi
|
||||
|
||||
# TODO: handle the dhclient/resolv.conf/ntp, etc
|
||||
echo "Get to enable localdisk"
|
||||
$NEWROOT/etc/init.d/localdisk
|
||||
$NEWROOT/etc/init.d/statelite
|
||||
READONLY=yes
|
||||
export READONLY
|
||||
fastboot=yes
|
||||
export fastboot
|
||||
keep_old_ip=yes
|
||||
export keep_old_ip
|
||||
mount -n --bind /dev $NEWROOT/dev
|
||||
mount -n --bind /proc $NEWROOT/proc
|
||||
mount -n --bind /sys $NEWROOT/sys
|
||||
|
||||
if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then
|
||||
echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux"
|
||||
fi
|
||||
|
||||
# inject new exit_if_exists
|
||||
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh
|
||||
# force udevsettle to break
|
||||
> $hookdir/initqueue/work
|
24
xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag
Executable file
24
xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/awk -f
|
||||
#script to feedback the node provision status to xcatd
|
||||
BEGIN {
|
||||
|
||||
xcatdhost = ARGV[1]
|
||||
xcatiport = ARGV[2]
|
||||
|
||||
|
||||
ns = "/inet/tcp/0/" xcatdhost "/" xcatiport
|
||||
print "xCAT_xcatd" |& ns
|
||||
|
||||
while(1) {
|
||||
ns |& getline
|
||||
|
||||
if($0 == "ready")
|
||||
print ARGV[3] |& ns
|
||||
if($0 == "done")
|
||||
break
|
||||
}
|
||||
|
||||
close(ns)
|
||||
|
||||
exit 0
|
||||
}
|
259
xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot
Executable file
259
xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot
Executable file
@ -0,0 +1,259 @@
|
||||
#!/bin/sh
|
||||
NEWROOT=$3
|
||||
RWDIR=.statelite
|
||||
XCATMASTER=$XCAT
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
rootlimit="$(getarg rootlimit=)"
|
||||
|
||||
|
||||
getarg nonodestatus
|
||||
NODESTATUS=$?
|
||||
|
||||
MASTER=`echo $XCATMASTER |awk -F: '{print $1}'`
|
||||
XCATIPORT="$(getarg XCATIPORT=)"
|
||||
if [ $? -ne 0 ]; then
|
||||
XCATIPORT="3002"
|
||||
fi
|
||||
|
||||
|
||||
if [ $NODESTATUS -ne 0 ];then
|
||||
/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting"
|
||||
fi
|
||||
|
||||
if [ ! -z "$imgurl" ]; then
|
||||
if [ xhttp = x${imgurl%%:*} ]; then
|
||||
NFS=0
|
||||
FILENAME=${imgurl##*/}
|
||||
while [ ! -r "$FILENAME" ]; do
|
||||
echo Getting $imgurl...
|
||||
if ! wget $imgurl; then
|
||||
rm -f $FILENAME
|
||||
sleep 27
|
||||
fi
|
||||
done
|
||||
elif [ xnfs = x${imgurl%%:*} ]; then
|
||||
NFS=1
|
||||
SERVER=${imgurl#nfs:}
|
||||
SERVER=${SERVER#/}
|
||||
SERVER=${SERVER#/}
|
||||
ROOTDIR=$SERVER
|
||||
SERVER=${SERVER%%/*}
|
||||
SERVER=${SERVER%:}
|
||||
ROOTDIR=/${ROOTDIR#*/}
|
||||
fi
|
||||
fi
|
||||
#echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug
|
||||
|
||||
if [ -r /rootimg.sfs ]; then
|
||||
echo Setting up squashfs with ram overlay.
|
||||
mknod /dev/loop0 b 7 0
|
||||
mkdir -p /ro
|
||||
mkdir -p /rw
|
||||
mount -t squashfs /rootimg.sfs /ro
|
||||
mount -t tmpfs rw /rw
|
||||
mount -t aufs -o dirs=/rw:/ro mergedroot $NEWROOT
|
||||
mkdir -p $NEWROOT/ro
|
||||
mkdir -p $NEWROOT/rw
|
||||
mount --move /ro $NEWROOT/ro
|
||||
mount --move /rw $NEWROOT/rw
|
||||
elif [ -r /rootimg.gz ]; then
|
||||
echo Setting up RAM-root tmpfs.
|
||||
if [ -z $rootlimit ];then
|
||||
mount -t tmpfs -o mode=755 rootfs $NEWROOT
|
||||
else
|
||||
mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT
|
||||
fi
|
||||
|
||||
cd $NEWROOT
|
||||
echo -n "Extracting root filesystem:"
|
||||
if [ -x /bin/cpio ]; then
|
||||
gzip -cd /rootimg.gz |/bin/cpio -idum
|
||||
else
|
||||
gzip -cd /rootimg.gz |cpio -idum
|
||||
fi
|
||||
$NEWROOT/etc/init.d/localdisk
|
||||
echo Done
|
||||
elif [ -r /rootimg-statelite.gz ]; then
|
||||
echo Setting up RAM-root tmpfs for statelite mode.
|
||||
|
||||
if [ -z $rootlimit];then
|
||||
mount -t tmpfs -o mode=755 rootfs $NEWROOT
|
||||
else
|
||||
mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT
|
||||
fi
|
||||
|
||||
cd $NEWROOT
|
||||
echo -n "Extracting root filesystem:"
|
||||
if [ -x /bin/cpio ]; then
|
||||
gzip -cd /rootimg-statelite.gz |/bin/cpio -idum
|
||||
else
|
||||
gzip -cd /rootimg-statelite.gz |cpio -idum
|
||||
fi
|
||||
echo Done
|
||||
# then, the statelite staffs will be processed
|
||||
echo Setting up Statelite
|
||||
modprobe nfs
|
||||
MAXTRIES=7
|
||||
ITER=0
|
||||
if [ ! -e "$NEWROOT/$RWDIR" ]; then
|
||||
echo ""
|
||||
echo "The /$RWDIR directory doesn't exist in the rootimg... "
|
||||
echo ""
|
||||
/bin/sh
|
||||
fi
|
||||
|
||||
if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then
|
||||
echo ""
|
||||
echo "$NEWROOT/etc/init.d/statelite doesn't exist... "
|
||||
echo ""
|
||||
/bin/sh
|
||||
fi
|
||||
|
||||
mount -t tmpfs rw $NEWROOT/$RWDIR
|
||||
mkdir -p $NEWROOT/$RWDIR/tmpfs
|
||||
ME=`hostname`
|
||||
if [ ! -z $NODE ]; then
|
||||
ME=$NODE
|
||||
fi
|
||||
|
||||
|
||||
# mount the SNAPSHOT directory here for persistent use.
|
||||
if [ ! -z $STATEMNT ]; then
|
||||
SNAPSHOTSERVER=${STATEMNT%:*}
|
||||
SNAPSHOTROOT=${STATEMNT#*/}
|
||||
if [ -z $SNAPSHOTROOT ]; then
|
||||
SNAPSHOTROOT=$SNAPSHOTSERVER
|
||||
SNAPSHOTSERVER=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z $SNAPSHOTSERVER ]; then
|
||||
mkdir -p $NEWROOT/$RWDIR/persistent
|
||||
MAXTRIES=5
|
||||
ITER=0
|
||||
if [ -z $MNTOPTS ]; then
|
||||
MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14"
|
||||
else
|
||||
MNT_OPTIONS=$MNTOPTS
|
||||
fi
|
||||
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
|
||||
ITER=$(( ITER + 1 ))
|
||||
if [ "$ITER" == "$MAXTRIES" ]; then
|
||||
echo "You are dead, rpower $ME boot to play again."
|
||||
echo "Possible problems:
|
||||
1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ?
|
||||
2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER."
|
||||
/bin/sh
|
||||
exit
|
||||
fi
|
||||
RS=$(( $RANDOM % 20 ))
|
||||
echo "Trying again in $RS seconds ..."
|
||||
sleep $RS
|
||||
done
|
||||
|
||||
# create directory which is named after my node name
|
||||
mkdir -p $NEWROOT/$RWDIR/persistent/$ME
|
||||
ITER=0
|
||||
# umount current persistent mount
|
||||
while ! umount -l $NEWROOT/$RWDIR/persistent; do
|
||||
ITER=$(( ITER + 1 ))
|
||||
if [ "$ITER" == "$MAXTRIES" ]; then
|
||||
echo "Your are dead, rpower $ME boot to play again."
|
||||
echo "Cannot umount $NEWROOT/$RWDIR/persistent."
|
||||
/bin/sh
|
||||
exit
|
||||
fi
|
||||
RS= $(( $RANDOM % 20 ))
|
||||
echo "Trying again in $RS seconds..."
|
||||
sleep $RS
|
||||
done
|
||||
|
||||
# mount persistent to server:/rootpath/nodename
|
||||
ITER=0
|
||||
while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
|
||||
ITER=$(( ITER + 1 ))
|
||||
if [ "$ITER" == "$MAXTRIES" ]; then
|
||||
echo "Your are dead, rpower $ME boot to play again."
|
||||
echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME."
|
||||
/bin/sh
|
||||
exit
|
||||
fi
|
||||
RS= $(( $RANDOM % 20 ))
|
||||
echo "Trying again in $RS seconds..."
|
||||
sleep $RS
|
||||
done
|
||||
fi
|
||||
|
||||
$NEWROOT/etc/init.d/localdisk
|
||||
$NEWROOT/etc/init.d/statelite
|
||||
fastboot=yes
|
||||
export fastboot
|
||||
keep_old_ip=yes
|
||||
export keep_old_ip
|
||||
|
||||
mount -n --bind /dev $NEWROOT/dev
|
||||
mount -n --bind /proc $NEWROOT/proc
|
||||
mount -n --bind /sys $NEWROOT/sys
|
||||
|
||||
else
|
||||
echo -n Failed to download image, panicing in 5...
|
||||
for i in 4 3 2 1 0; do
|
||||
/bin/sleep 1
|
||||
echo -n $i...
|
||||
done
|
||||
echo
|
||||
echo "You're dead. rpower nodename reset to play again.
|
||||
|
||||
* Did you packimage with -m cpio, -m squashfs, or -m nfs?
|
||||
* If using -m squashfs did you include aufs.ko with geninitrd?
|
||||
e.g.: -n tg3,squashfs,aufs,loop
|
||||
* If using -m nfs did you export NFS and sync rootimg? And
|
||||
did you include the aufs and nfs modules in the proper order:
|
||||
e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs
|
||||
|
||||
"
|
||||
/bin/dash
|
||||
exit
|
||||
fi
|
||||
cd /
|
||||
|
||||
if [ -z $STATEMNT ]; then
|
||||
for lf in /tmp/dhclient.*.lease; do
|
||||
netif=${lf#*.}
|
||||
netif=${netif%.*}
|
||||
cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases"
|
||||
done
|
||||
|
||||
if [ ! -z "$ifname" ]; then
|
||||
MACX=${ifname#*:}
|
||||
ETHX=${ifname%:$MACX*}
|
||||
elif [ ! -z "$netdev" ]; then
|
||||
ETHX=$netdev
|
||||
MACX=`ip link show $netdev | grep ether | awk '{print $2}'`
|
||||
elif [ ! -z "$BOOTIF" ]; then
|
||||
MACX=$BOOTIF
|
||||
ETHX=`ifconfig |grep -i $BOOTIF | awk '{print $1}'`
|
||||
fi
|
||||
|
||||
if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then
|
||||
if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then
|
||||
touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
|
||||
fi
|
||||
echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
|
||||
echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
|
||||
echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
|
||||
echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX
|
||||
fi
|
||||
fi
|
||||
|
||||
cp /etc/resolv.conf "$NEWROOT/etc/"
|
||||
|
||||
if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then
|
||||
echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux"
|
||||
fi
|
||||
|
||||
# inject new exit_if_exists
|
||||
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh
|
||||
# force udevsettle to break
|
||||
> $hookdir/initqueue/work
|
@ -583,8 +583,8 @@ if ( (-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")
|
||||
my $dracutver = `rpm --root $rootimg_dir -qi dracut | grep Version | awk -F' ' '{print \$3}'`;
|
||||
chomp($dracutver);
|
||||
if ($dracutver =~ /^\d\d\d$/) {
|
||||
if (($dracutver >= "009") and ($dracutver < "033")) {
|
||||
$dracutdir = "dracut_009";
|
||||
if ($dracutver >= "033") {
|
||||
$dracutdir = "dracut_033";
|
||||
} else {
|
||||
$dracutdir = "dracut"; # The default directory
|
||||
}
|
||||
@ -924,7 +924,11 @@ sub mkinitrd_dracut {
|
||||
$additional_options= qq{--include /tmp/cmdline /etc/cmdline};
|
||||
}
|
||||
|
||||
system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver");
|
||||
# force the dracut run in non-hostonly mode for dracut higher than version 033
|
||||
if ($dracutver > "033") {
|
||||
$additional_options .= " -N";
|
||||
}
|
||||
system("chroot $rootimg_dir dracut -N $additional_options -f /tmp/initrd.$$.gz $kernelver");
|
||||
print "the initial ramdisk for $mode is generated successfully.\n";
|
||||
move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz");
|
||||
}
|
||||
@ -1665,7 +1669,11 @@ sub using_systemd {
|
||||
my $os = shift;
|
||||
if ($os =~ /fedora(\d+)/) {
|
||||
if ($1 >= 15) {
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
}elsif ($os =~ /rhels(\d+)/) {
|
||||
if ($1 >= 7) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
503
xCAT-test/restapitest
Executable file
503
xCAT-test/restapitest
Executable file
@ -0,0 +1,503 @@
|
||||
#!/usr/bin/env perl
|
||||
###############################################################################
|
||||
# This script is used for rest-api automation test
|
||||
# Flags are used for test input:
|
||||
# -m method. Should be GET, POST, PUT, DELETE
|
||||
# -r resource
|
||||
# -t token
|
||||
# -h host
|
||||
# -u user
|
||||
# -p passwd
|
||||
# -P port (BC)
|
||||
# -d data
|
||||
# -c cert
|
||||
# -n hostname
|
||||
# Flags are used for check output:
|
||||
# -o expected output
|
||||
# -l logical operator
|
||||
#
|
||||
# Expected result format is '{ANY:{ANY:content}}'
|
||||
# These steps are used to explain how to scan result
|
||||
# step 1. go through to see if content can be found
|
||||
# step 2. compare content if found
|
||||
# options are used as followed:
|
||||
# == returns 0 if found and equal, returns 1 if not found or found but not equal
|
||||
# != returns 0 if found, returns 1 if not found
|
||||
# =~ returns 0 if match, returns 1 if not match
|
||||
# !=~ returns 0 if not match, returns 1 if match
|
||||
################################################################################
|
||||
BEGIN
|
||||
{
|
||||
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
||||
}
|
||||
use Getopt::Long;
|
||||
use Data::Dumper;
|
||||
use strict;
|
||||
my $help;
|
||||
my $method;
|
||||
my $token;
|
||||
my $resource;
|
||||
my $host;
|
||||
my $user;
|
||||
my $passwd;
|
||||
my $port;
|
||||
my $data;
|
||||
my $cert;
|
||||
my $hostname;
|
||||
my $output;
|
||||
my $loperator;
|
||||
my $debug;
|
||||
my $defaulthash;
|
||||
my $defaulthttpresult = 0;
|
||||
my $outputfile = "/tmp/testrestapiresult";
|
||||
|
||||
if (
|
||||
!GetOptions("h|?" => \$help,
|
||||
"m=s" => \$method,
|
||||
"t=s" => \$token,
|
||||
"r=s" => \$resource,
|
||||
"h=s" => \$host,
|
||||
"u=s" => \$user,
|
||||
"p=s" => \$passwd,
|
||||
"P=s" => \$port,
|
||||
"d=s" => \$data,
|
||||
"c=s" => \$cert,
|
||||
"n=s" => \$hostname,
|
||||
"o=s" => \$output,
|
||||
"l=s" => \$loperator,
|
||||
"debug" => \$debug,
|
||||
)
|
||||
) {
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
##############################################################
|
||||
# check result
|
||||
##############################################################
|
||||
if ($output) {
|
||||
if ($method or $resource) {
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $res = check_result($output,$loperator,$outputfile);
|
||||
print_debug( "check result runs with $output and $loperator, result is $res\n" );
|
||||
exit $res;
|
||||
}
|
||||
##############################################################
|
||||
# return help
|
||||
##############################################################
|
||||
if ($help) {
|
||||
&usage;
|
||||
exit 0;
|
||||
}
|
||||
##############################################################
|
||||
# Give default values for optional vars.
|
||||
###############################################################
|
||||
my $rootdir = "$::XCATROOT/share/xcat/tools/autotest";
|
||||
my $resultdir = "$rootdir/result";
|
||||
my $logfile = "$rootdir/result/restapitest.log"; #/opt/xcat/share/xcat/tools/autotest/result/restapitest.log
|
||||
my $cert1 = "/root/ca-cert.pem";
|
||||
# get token
|
||||
my $gettoken = `curl -X POST -k 'https://127.0.0.1/xcatws/tokens?userName=root&password=cluster' -H Content-Type:application/json --data '{"userName":"root","password":"cluster"}' 2>/dev/null`;
|
||||
my $reshash = parse_json($gettoken);
|
||||
my $token1 = $$reshash{token}{id};
|
||||
|
||||
|
||||
# get hostname
|
||||
unless ($hostname) {
|
||||
$hostname = `hostname`;
|
||||
chomp($hostname);
|
||||
|
||||
}
|
||||
|
||||
# keey default test result for save
|
||||
my $res = run_restapi($method, $resource, $data, "", $port, "127.0.0.1", "root", "cluster");
|
||||
$defaulthash = parse_json($res);
|
||||
$defaulthttpresult = check_errcode();
|
||||
|
||||
# debug info
|
||||
print_debug( "get token $token1. \n" );
|
||||
print_debug( "get hostname $hostname.\n");
|
||||
print_debug( "default result is $res. \n" );
|
||||
print_debug( "default resulthash is: \n" );
|
||||
print_debug($defaulthash);
|
||||
print_debug( "default errcode is $defaulthttpresult \n" );
|
||||
|
||||
|
||||
####################################################
|
||||
# Begin to run test cases
|
||||
####################################################
|
||||
my @users = ("root","wsuser", $user);
|
||||
my @passwds = ("cluster","cluster", $passwd);
|
||||
my @tokens = ("", $token1, $token);
|
||||
my @certs = ("", $cert1, $cert);
|
||||
unless ($host) {
|
||||
$host = "127.0.0.1";
|
||||
}
|
||||
log_me("**************begin restapi test***************");
|
||||
my $i = 0;
|
||||
for my $u (@users) {
|
||||
next unless($u);
|
||||
my $p = $passwds[$i];
|
||||
$i++;
|
||||
for my $t (@tokens) {
|
||||
for my $c (@certs){
|
||||
my $res = run_restapi($method, $resource, $data, $c, $port, $host, $u, $p, $t);
|
||||
if($res){
|
||||
my $reshash = parse_json($res);
|
||||
print_debug("parse curl result and got:\n");
|
||||
print_debug($reshash);
|
||||
if (%$reshash != %$defaulthash) {
|
||||
log_me("restapi test cases run different result");
|
||||
print_debug( "restapi test cases run different result with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" );
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
my $errcode = check_errcode();
|
||||
print_debug("get curl error code: $errcode\n");
|
||||
if ($errcode != $defaulthttpresult) {
|
||||
log_me("restapi test cases run different errcode");
|
||||
print_debug( "restapi test cases run different error code with $method, $resource, $data, $c, $port, $host, $u, $p, $t\n" );
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit $defaulthttpresult;
|
||||
|
||||
################################################
|
||||
# begin subroutine
|
||||
################################################
|
||||
|
||||
##########
|
||||
# usage #
|
||||
##########
|
||||
sub usage
|
||||
{
|
||||
print "Usage:testrestapi - Run xcat test cases.\n";
|
||||
print " testrestapi [-?|-h]\n";
|
||||
print " testrestapi [-m method] [-r resource] [-t tocken]\n";
|
||||
print " [-h host] [-P port][-u user] [-p passwd]\n";
|
||||
print " [-d data] [-c cert] [-n hostname]\n";
|
||||
print " [-o expect_output] [-l logical_operator] [-debug]\n";
|
||||
print " [-debug]\n";
|
||||
print "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
###############
|
||||
# record log #
|
||||
###############
|
||||
sub log_me
|
||||
{
|
||||
my $msg = shift;
|
||||
open (LOG, ">>$logfile")
|
||||
or return 1;
|
||||
my $date = `date`;
|
||||
print LOG "$date\: $msg\n";
|
||||
}
|
||||
|
||||
#####################
|
||||
# print debug infor #
|
||||
#####################
|
||||
sub print_debug
|
||||
{
|
||||
my $msg = shift;
|
||||
return 0 unless($debug);
|
||||
if(ref($msg) eq 'HASH') {
|
||||
print Dumper($msg);
|
||||
} elsif( ref($msg) eq 'ARRAY') {
|
||||
print Dumper($msg);
|
||||
} else {
|
||||
print "$msg";
|
||||
}
|
||||
}
|
||||
#########################
|
||||
# run rest-api command #
|
||||
#########################
|
||||
sub run_restapi
|
||||
{
|
||||
my ($m,$r,$d,$c,$p,$h,$u,$a,$t) = @_;
|
||||
my $cmd = "curl";
|
||||
$cmd .= " -X $m";
|
||||
unless ($c) {
|
||||
$cmd .= " -k ";
|
||||
}else {
|
||||
$cmd .= " --cacert $c";
|
||||
}
|
||||
if($t){
|
||||
$cmd .= " -H X-Auth-Token:$t ";
|
||||
}
|
||||
if($t or $c){
|
||||
$cmd .= " 'https://$hostname";
|
||||
} else {
|
||||
$cmd .= " 'https://$h";
|
||||
}
|
||||
if ($p) {
|
||||
$cmd .= ":$p";
|
||||
}
|
||||
$cmd .= "/xcatws";
|
||||
$cmd .= "$r?";
|
||||
unless($t){
|
||||
$cmd .= "userName=$u&password=$a'";
|
||||
}else {
|
||||
$cmd .= "'";
|
||||
}
|
||||
if($d) {
|
||||
$cmd .= " -H Content-Type:application/json --data '$d'";
|
||||
}
|
||||
$cmd .= " -D /tmp/err.log";
|
||||
log_me("Begin to run restapi test with $cmd");
|
||||
my $res = `$cmd 2>/dev/null`;
|
||||
print_debug("run curl: $cmd\n");
|
||||
print_debug("result is $res\n");
|
||||
if (!open (RESULT, ">$outputfile")) {
|
||||
log_me("wirte outputfile error");
|
||||
}
|
||||
print RESULT $res;
|
||||
close RESULT;
|
||||
return $res;
|
||||
}
|
||||
|
||||
############################
|
||||
# transfer json into hash #
|
||||
############################
|
||||
sub parse_json
|
||||
{
|
||||
my $input = shift;
|
||||
my %hash;
|
||||
if ($input =~ /:/) {
|
||||
# for those who look like:
|
||||
# {"networks":[{"mgtifname":"eth1","mask":"255.255.255.0"},{"mgtifname":"eth1","mask":"255.255.255.0"}]}
|
||||
if ($input =~ /^\[(.*)\]$/s) {
|
||||
my $content = $1;
|
||||
print "[:] content is $content \n" if($debug);
|
||||
parse_json($content);
|
||||
}
|
||||
# for those who look like
|
||||
# {"clustersite":{"domain":"cluster.com","master":"192.168.1.15"}}
|
||||
elsif ($input =~ /^\s*{(.*)}\s*$/s) {
|
||||
my $content = $1;
|
||||
print "{} content is $content \n" if($debug);
|
||||
parse_json($content);
|
||||
}
|
||||
# for those who look like
|
||||
# "domain":"cluster.com","master":"192.168.1.15"
|
||||
elsif ($input =~ /,/ and !($input =~ /}/)) {
|
||||
my @contents = split /,/, $input;
|
||||
my @reval;
|
||||
# record result
|
||||
foreach my $t (@contents) {
|
||||
print ", content is $t \n" if($debug);
|
||||
my $re = parse_json($t);
|
||||
push @reval, $re;
|
||||
}
|
||||
# merge hash
|
||||
foreach my $t (@reval) {
|
||||
if(ref($t) =~ "HASH") {
|
||||
foreach my $k (keys %$t){
|
||||
$hash{$k} = $$t{$k};
|
||||
}
|
||||
}
|
||||
}
|
||||
return \%hash;
|
||||
|
||||
}
|
||||
# for those who look like:
|
||||
# "clustersite":{"domain":"cluster.com","master":"192.168.1.15"}
|
||||
# "domain":"cluster.com"
|
||||
elsif ($input =~ /\"(\S+?)\":(.+)/s) {
|
||||
my $key = $1;
|
||||
my $value = $2;
|
||||
if ($value =~ /{/) {
|
||||
# "clustersite":{"domain":"cluster.com","master":"192.168.1.15"}
|
||||
print "{ content is $value \n" if($debug);
|
||||
$hash{$key} = parse_json($value, $key);
|
||||
return \%hash;
|
||||
} else {
|
||||
# "domain":"cluster.com"
|
||||
$value =~ /\"(\S+)\"/;
|
||||
$hash{$key} = $1;
|
||||
return \%hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
# for those who look like
|
||||
# ["10.1.255.250","192.168.200.16","192.168.200.19","192.168.200.22"]
|
||||
else {
|
||||
if ($input =~ /^\[(.*)\]/s) {
|
||||
my $content = $1;
|
||||
print "[] content is $content \n" if($debug);
|
||||
my @all = split /,/, $content;
|
||||
foreach my $n (@all) {
|
||||
$n =~ /\"(.*)\"/;
|
||||
$hash{$1} = 1;
|
||||
}
|
||||
return \%hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
############################
|
||||
# check curl running code #
|
||||
############################
|
||||
sub check_errcode
|
||||
{
|
||||
if(!open (ERRLOG, "</tmp/err.log")) {
|
||||
log_me("can't open err.log in tmp");
|
||||
return 1;
|
||||
}
|
||||
my $num;
|
||||
while (<ERRLOG>){
|
||||
if (/HTTP\/\w*\.*\w* (\w+) (\w+)/) {
|
||||
$num = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close ERRLOG;
|
||||
print_debug("can't get errorcode\n") unless($num);
|
||||
return $num;
|
||||
}
|
||||
|
||||
############################
|
||||
# check curl return result #
|
||||
############################
|
||||
sub check_result
|
||||
{
|
||||
my $data = shift;
|
||||
my $opterator = shift;
|
||||
my $output = shift;
|
||||
if ( !open (OUTPUT, "<$output")) {
|
||||
log_me("can't read output file");
|
||||
return 1;
|
||||
}
|
||||
my $res;
|
||||
while (<OUTPUT>) {
|
||||
$res .= $_;
|
||||
}
|
||||
close OUTPUT;
|
||||
|
||||
|
||||
my $expects = transf_hash(parse_json($data)); # one entry
|
||||
my $actuals = transf_hash(parse_json($res)); # serval entries
|
||||
|
||||
print_debug("expected result is:\n");
|
||||
print_debug($expects);
|
||||
print_debug("testcase run result is \n");
|
||||
print_debug($actuals);
|
||||
|
||||
my $flag = 0;
|
||||
my %flaghash;
|
||||
my $expect = $$expects[0]; # $expect = ANY:ANY:x86_64
|
||||
|
||||
my @expectvalue = split /:/, $expect; #@expectvalue = ANY, ANY, x86_64
|
||||
$flag = 0;
|
||||
foreach my $expval (@expectvalue) { # $expval = ANY
|
||||
foreach my $actual (@$actuals) { # $actual = nodetype:arch:x86_64
|
||||
if($flaghash{$actual} eq "none"){
|
||||
next;
|
||||
}
|
||||
my @actualvalue = split /:/, $actual; # @actualvalue = nodetype, arch, x86_64
|
||||
print_debug("begin to compare $expval and $actualvalue[$flag]");
|
||||
|
||||
if(($expval eq $actualvalue[$flag]) or ($expval eq "ANY")) { #ANY =~ nodetype
|
||||
$flaghash{$actual} = "eq";
|
||||
} elsif (($expval =~ $actualvalue[$flag]) or ($expval eq "ANY")) {
|
||||
$flaghash{$actual} = "match";
|
||||
} else {
|
||||
$flaghash{$actual} = "none";
|
||||
}
|
||||
print_debug(", compare result is $flaghash{$actual}\n");
|
||||
}
|
||||
$flag++;
|
||||
}
|
||||
print_debug("search result is \n");
|
||||
print_debug(\%flaghash);
|
||||
|
||||
if ($opterator eq "!="){
|
||||
foreach my $val (keys %flaghash) {
|
||||
if ($flaghash{$val} eq "eq") {
|
||||
print_debug("compare result: failed\n");
|
||||
return 1; # fail
|
||||
}
|
||||
}
|
||||
print_debug("compare result: succeed\n");
|
||||
return 0; #succeed
|
||||
}
|
||||
if ($opterator eq "=="){
|
||||
foreach my $val (keys %flaghash) {
|
||||
if ($flaghash{$val} eq "eq") {
|
||||
print_debug("compare result: succeed\n");
|
||||
return 0; # succeed
|
||||
}
|
||||
}
|
||||
print_debug("compare result: failed\n");
|
||||
return 1; #fail
|
||||
}
|
||||
|
||||
if ($opterator eq "=~"){
|
||||
foreach my $val (keys %flaghash) {
|
||||
if ($flaghash{$val} eq "match") {
|
||||
print_debug("compare result: succeed\n");
|
||||
return 0; # succeed
|
||||
}
|
||||
}
|
||||
print_debug("compare result: failed\n");
|
||||
return 1; #fail
|
||||
}
|
||||
if ($opterator eq "!=~"){
|
||||
foreach my $val (keys %flaghash) {
|
||||
if ($flaghash{$val} eq "match") {
|
||||
print_debug("compare result: failed\n");
|
||||
return 1; # fail
|
||||
}
|
||||
}
|
||||
print_debug("compare result: succeed\n");
|
||||
return 0; #succeed
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
####################################
|
||||
# help to transfer hash into array #
|
||||
####################################
|
||||
sub find_key
|
||||
{
|
||||
my $input = shift;
|
||||
my $en = shift;
|
||||
my $ou = shift;
|
||||
if( ref($input) =~ "HASH") {
|
||||
foreach my $val (keys %$input) {
|
||||
my $tmp = $$en; # keey head
|
||||
$$en .= "$val:";
|
||||
my $t1 = find_key($$input{$val}, $en, $ou);
|
||||
if ($$en == ""){
|
||||
$$en = $tmp; #restore head
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$$en .= $input;
|
||||
push @$ou, $$en;
|
||||
$$en = ""; # clear entry;
|
||||
}
|
||||
}
|
||||
|
||||
############################
|
||||
# transfer hash into array #
|
||||
############################
|
||||
sub transf_hash
|
||||
{
|
||||
my $input = shift;
|
||||
my $entry;
|
||||
my @array;
|
||||
find_key($input, \$entry, \@array);
|
||||
return \@array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ pod2html pods/man1/xcattest.1.pod > share/doc/man1/xcattest.1.html
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/sbin
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools/autotest
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
|
||||
@ -46,6 +47,9 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
|
||||
cp xcattest $RPM_BUILD_ROOT/%{prefix}/bin
|
||||
chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
|
||||
|
||||
cp restapitest $RPM_BUILD_ROOT/%{prefix}/sbin
|
||||
chmod 755 $RPM_BUILD_ROOT/%{prefix}/sbin/*
|
||||
|
||||
# These were built dynamically in the build phase
|
||||
cp share/man/man1/* $RPM_BUILD_ROOT/%{prefix}/share/man/man1
|
||||
chmod 444 $RPM_BUILD_ROOT/%{prefix}/share/man/man1/*
|
||||
|
@ -25,10 +25,10 @@ my $string1 = undef;
|
||||
if (
|
||||
!GetOptions("h|?" => \$needhelp,
|
||||
"f=s" => \$configfile,
|
||||
"b=s" => \$bundle_list,
|
||||
"t=s" => \$case_list,
|
||||
"c=s" => \$cmd_list,
|
||||
"l" => \$needshow,
|
||||
"b=s" => \$bundle_list,
|
||||
"t=s" => \$case_list,
|
||||
"c=s" => \$cmd_list,
|
||||
"l" => \$needshow,
|
||||
"restore"=>\$restore)
|
||||
)
|
||||
{
|
||||
@ -221,7 +221,7 @@ sub getConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(exists $config{object}){
|
||||
foreach my $type (keys %{$config{object}}){
|
||||
foreach my $name (keys %{$config{object}{$type}}){
|
||||
@ -344,7 +344,7 @@ sub init
|
||||
log_this("No compute node defined,can't get ARCH of compute node");
|
||||
} else {
|
||||
$config{var}{ARCH} = getnodeattr($config{var}{CN},"arch");
|
||||
if($config{var}{ARCH} =~ /ppc/){
|
||||
if($config{var}{ARCH} =~ /ppc/){
|
||||
$config{var}{ARCH} = 'ppc';
|
||||
}elsif($config{var}{ARCH}=~/86/){
|
||||
$config{var}{ARCH} = 'x86';
|
||||
@ -432,7 +432,7 @@ sub loadcase
|
||||
my $j = -1;
|
||||
my $z = 0;
|
||||
my $skip = 0;
|
||||
|
||||
|
||||
my @caserange = ();
|
||||
my @rightcase = ();
|
||||
my @notrightcase = ();
|
||||
@ -452,7 +452,7 @@ sub loadcase
|
||||
}
|
||||
}
|
||||
if($case_list){
|
||||
@caserange = split /,/, $case_list;
|
||||
@caserange = split /,/, $case_list;
|
||||
}
|
||||
foreach $file (@files){
|
||||
if(!open(FILE, "<$file")){
|
||||
@ -498,13 +498,13 @@ sub loadcase
|
||||
$cases[$i]->{os}=$string1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($cases[$i]->{os} !~ /$config{var}{OS}/){
|
||||
push(@notrightcase, $cases[$i]->{name});
|
||||
pop(@rightcase);
|
||||
$skip = 1;
|
||||
}
|
||||
|
||||
|
||||
}elsif($line =~ /^arch\s*:\s*(\w[\w\,]+)/){
|
||||
next if $skip;
|
||||
$cases[$i]->{arch}=$1;
|
||||
@ -631,7 +631,7 @@ sub getfunc
|
||||
$func = $1;
|
||||
$parameter = $2;
|
||||
@para = split /\s*,\s*/, trim($parameter);
|
||||
if($func eq "GETNODEATTR"){
|
||||
if($func eq "GETNODEATTR"){
|
||||
$value= getnodeattr(@para);
|
||||
if($value eq "Unknown"){
|
||||
$value = '';
|
||||
@ -669,9 +669,9 @@ sub runcase
|
||||
my $time1=gmtime $now1;
|
||||
log_this("------START:$$case{name}::Time:$time1------");
|
||||
push @record, "------START:$$case{name}::Time:$time1------";
|
||||
push @record, "FILENAME:$$case{filename}";
|
||||
push @record, "FILENAME:$$case{filename}";
|
||||
foreach my $cmd (@{$$case{cmd}}){
|
||||
$cmd = getfunc($cmd);
|
||||
$cmd = getfunc($cmd);
|
||||
|
||||
#by
|
||||
my $runstart=timelocal(localtime());
|
||||
@ -684,10 +684,10 @@ sub runcase
|
||||
my $diffduration=$runstop-$runstart;
|
||||
log_this("\n[$cmd] Running Time:$diffduration sec");
|
||||
push(@record,("\n[$cmd] Running Time:$diffduration sec"));
|
||||
|
||||
|
||||
log_this("RETURN: rc = $rc","OUTPUT:",@output);
|
||||
push(@record,("RETURN rc = $rc","OUTPUT:",@output));
|
||||
|
||||
|
||||
|
||||
foreach my $check (@{$$case{check}->[$j]}){
|
||||
if($failed){
|
||||
@ -766,7 +766,17 @@ sub runcase
|
||||
}
|
||||
}
|
||||
foreach my $cmdcheck (@{$$case{cmdcheck}->[$j]}){
|
||||
&runcmd($cmdcheck);
|
||||
if($cmdcheck) {
|
||||
&runcmd($cmdcheck);
|
||||
$rc = $::RUNCMD_RC;
|
||||
if($rc == 1) {
|
||||
log_this("CMDCHECK:output $cmdcheck\t[Failed]");
|
||||
push(@record, "CHECK:output $cmdcheck\t[Failed]");
|
||||
} elsif ($rc == 0) {
|
||||
log_this("CMDCHECK:output $cmdcheck\t[Pass]");
|
||||
push(@record, "CHECK:output $cmdcheck\t[Pass]");
|
||||
}
|
||||
}
|
||||
}
|
||||
$j = $j + 1;
|
||||
}
|
||||
@ -798,6 +808,7 @@ sub runcmd
|
||||
if ($?)
|
||||
{
|
||||
$rc = $? ;
|
||||
$rc = $rc >> 8;
|
||||
$::RUNCMD_RC = $rc;
|
||||
}
|
||||
chomp(@$outref);
|
||||
@ -835,3 +846,5 @@ sub getreport
|
||||
close(FD);
|
||||
close(STDOUT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,4 +5,5 @@ install/prescripts
|
||||
install/kdump
|
||||
opt/xcat/share/xcat
|
||||
etc/apache2/conf.d
|
||||
etc/apache2/conf-enabled
|
||||
opt/xcat/share/doc/packages/xCAT
|
||||
|
@ -1,5 +1,5 @@
|
||||
xcat.conf etc/apache2/conf.d/
|
||||
xcat.conf.apach24 etc/apache2/conf.d/
|
||||
xcat.conf.apach24 etc/apache2/conf-enabled
|
||||
LICENSE.html opt/xcat/share/doc/packages/xCAT
|
||||
postscripts/* install/postscripts/
|
||||
prescripts/* install/prescripts/
|
||||
|
@ -40,12 +40,9 @@ case "$1" in
|
||||
else
|
||||
xcatconfig -i -d -s
|
||||
fi
|
||||
ver=$(cat /etc/issue |awk '{print $2}')
|
||||
num=${ver%.*}
|
||||
file="xcat.conf.apach24"
|
||||
if [ $num -gt 12 ];then
|
||||
mv /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf-enabled/
|
||||
fi
|
||||
|
||||
# [ -e /etc/apache2/conf-enabled/xcat.conf ] && rm /etc/apache2/conf-enabled/xcat.conf
|
||||
# mv /etc/apache2/conf-enabled/xcat.conf.apach24 /etc/apache2/conf-enabled/xcat.conf
|
||||
|
||||
/etc/init.d/apache2 restart
|
||||
;;
|
||||
|
@ -335,7 +335,8 @@ elif [ "$1" = "-s" ];then
|
||||
if [ -n "$MACADDRESS" ];then
|
||||
str_inst_mac=$MACADDRESS
|
||||
else
|
||||
str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'`
|
||||
#str_inst_mac=`ifconfig $str_inst_nic | grep HWaddr | awk -F'HWaddr' '{print $2}' | sed 's/\s*//'`
|
||||
str_inst_mac=`ip link show $netdev | grep ether | awk '{print $2}'`
|
||||
fi
|
||||
|
||||
if [ -z "$str_inst_ip" -o -z "$str_inst_mask" ];then
|
||||
|
@ -180,7 +180,7 @@ if [ "$str_temp" = "mac" ];then
|
||||
fi
|
||||
done
|
||||
else
|
||||
str_inst_nic=`ifconfig -a | grep -i "$MACADDRESS" | awk '{print $1;}'`
|
||||
str_inst_nic=`ip -o link | grep -i "$MACADDRESS" | awk '{print $2;}' | sed s/://`
|
||||
fi
|
||||
elif [ `echo $str_temp | grep -E "e(n|th)[0-9]+"` ];then
|
||||
str_inst_nic=$str_temp
|
||||
|
@ -43,9 +43,9 @@ cat >/tmp/esxcfg.sh <<EOF1
|
||||
# Configure ESX Server. You'll need to put your own IP address
|
||||
# in here. We assume eth0 is your nic. Change if needed.
|
||||
NIC=eth0
|
||||
IPADDR=`ifconfig $NIC |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}' | head -1`
|
||||
NETMASK=`ifconfig $NIC |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'`
|
||||
|
||||
IPADDRMASK=`ip addr show dev $NIC | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1`
|
||||
IPADDR=`echo $IPADDRMASK | awk -F'/' '{print $1}'`
|
||||
NETMASK=`echo $IPADDRMASK | awk -F'/' '{print $2}'`
|
||||
#esxcfg-vswitch -U vmnic0 vSwitch0
|
||||
esxcfg-vswitch -L vmnic0 vSwitch0
|
||||
esxcfg-vswif -i \$IPADDR -n \$NETMASK vswif0
|
||||
|
Loading…
Reference in New Issue
Block a user