Compare commits

..

5 Commits

88 changed files with 7999 additions and 7401 deletions
-1
View File
@@ -243,7 +243,6 @@ for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xC
#if [ "$EMBED" = "zvm" -a "$rpmname" != "xCAT-server" -a "$rpmname" != "xCAT-UI" ]; then continue; fi # for zvm embedded env only need to build server and UI
if [[ " $EMBEDBUILD " != *\ $rpmname\ * ]]; then continue; fi
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi # do not build xCAT-buildkit on aix
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-SoftLayer" ]; then continue; fi # do not build xCAT-softlayer on aix
if $GREP $rpmname $GITUP || [ "$BUILDALL" == 1 ]; then
UPLOAD=1
maker $rpmname
+8 -31
View File
@@ -23,13 +23,6 @@ echo "CURDIR is $CURDIR"
echo "OSNAME is $OSNAME!"
echo "NAMEALL is $NAMEALL"
grep -i 'SUSE' /etc/issue
if [ $? -eq 0 ]; then
echo "This is a SUSE system!"
OS="SUSE";
fi
ls $CURDIR/makerpm
if [ $? -gt 0 ]; then
@@ -85,16 +78,9 @@ else
#This is not an Ubuntu system
echo "This is an $OSNAME system"
if [ "$OS" = "SUSE" ]; then
rm -rf /usr/src/packages/RPMS/noarch/*
rm -rf /usr/src/packages/RPMS/x86_64/*
rm -rf /usr/src/packages/RPMS/ppc64/*
else
rm -rf /root/rpmbuild/RPMS/noarch/*
rm -rf /root/rpmbuild/RPMS/x86_64/*
rm -rf /root/rpmbuild/RPMS/ppc64/*
fi
rm -rf /root/rpmbuild/RPMS/noarch/*
rm -rf /root/rpmbuild/RPMS/x86_64/*
rm -rf /root/rpmbuild/RPMS/ppc64/*
mkdir -p $CURDIR/build/
#always build perl-xCAT
@@ -127,20 +113,13 @@ echo "This is an $OSNAME system"
fi
done
if [ "$OS" = "SUSE" ]; then
cp /usr/src/packages/RPMS/noarch/* $CURDIR/build/
cp /usr/src/packages/RPMS/x86_64/* $CURDIR/build/
cp /usr/src/packages/RPMS/ppc64/* $CURDIR/build/
else
cp /root/rpmbuild/RPMS/noarch/* $CURDIR/build/
cp /root/rpmbuild/RPMS/x86_64/* $CURDIR/build/
cp /root/rpmbuild/RPMS/ppc64/* $CURDIR/build/
fi
cp /root/rpmbuild/RPMS/noarch/* $CURDIR/build/
cp /root/rpmbuild/RPMS/x86_64/* $CURDIR/build/
cp /root/rpmbuild/RPMS/ppc64/* $CURDIR/build/
#begin to create repo for redhat platform
grep -i 'Red' /etc/issue;
if [ "$OSNAME" != "AIX" -a $? -eq 0 ]; then
if [ "$OSNAME" != "AIX" ]; then
cat >$CURDIR/build/xCAT-core.repo << EOF
[xcat-2-core]
name=xCAT 2 Core packages
@@ -150,9 +129,7 @@ gpgcheck=0
EOF
cp $CURDIR/build/xCAT-core.repo /etc/yum.repos.d/
else
rm -f /etc/zypp/repos.d/xCAT-core.repo
zypper ar file://$CURDIR/build xCAT-core
fi
fi
+24 -34
View File
@@ -598,7 +598,7 @@ sub _execute_dsh
}
else
{
# HERE: This is where the output shows up
# LKV: This is where the output shows up
#print STDOUT @{$output_buffers{$user_target}};
#print STDERR @{$error_buffers{$user_target}};
chomp(@{$output_buffers{$user_target}});
@@ -3993,7 +3993,8 @@ sub parse_and_run_dsh
{
$options{'user'} = $ENV{'DSH_TO_USERID'};
}
if ((!(defined($nodes))) && (!(defined($options{'rootimg'}))))
if ((!(defined(@$nodes))) && (!(defined($options{'rootimg'}))))
{ # no nodes and not -i option, error
my $rsp = ();
$rsp->{error}->[0] = "Unless using -i option, noderange is required.";
@@ -4032,7 +4033,7 @@ sub parse_and_run_dsh
{ # from sinv, discard this name
undef @$nodes;
}
if (@$nodes)
if (defined(@$nodes))
{
my $rsp = {};
$rsp->{error}->[0] =
@@ -4404,7 +4405,7 @@ sub parse_and_run_dcp
return;
}
}
if ((!(defined($nodes))) && (!(defined($options{'rootimg'}))))
if ((!(defined(@$nodes))) && (!(defined($options{'rootimg'}))))
{ # no nodes and not -i option, error
my $rsp = {};
$rsp->{error}->[0] = "Unless using -i option, noderange is required.";
@@ -4501,7 +4502,7 @@ sub parse_and_run_dcp
#
# build list of nodes
my @nodelist;
if (@$nodes)
if (defined(@$nodes))
{ # there are nodes
@nodelist = @$nodes;
$options{'nodes'} = join(',', @nodelist);
@@ -4971,8 +4972,7 @@ sub parse_rsync_input_file_on_MN
$::process_line = 0;
my $destfileisdir;
my $clause=0;
my $addmergescript =0;
my $addappendscript =0;
open(INPUTFILE, "< $input_file") || die "File $input_file does not exist\n";
while (my $line = <INPUTFILE>)
{
@@ -5013,16 +5013,12 @@ sub parse_rsync_input_file_on_MN
# this triggers the running of the appendscript
$::appendscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
}
# add the append script to the sync
if ($addappendscript == 0) { # only add once
my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
my $appendscriptline = "$appscript -> $appscript";
$syncappendscript=1; # syncing the xdcpappend.sh script
&build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript);
$addappendscript=1;
}
} # end APPEND clause
my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh";
my $appendscriptline = "$appscript -> $appscript";
$syncappendscript=1; # syncing the xdcpappend.sh script
&build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript);
}
if ($clause =~ /MERGE:/) {
# location of the base merge script
# for MERGE we have to sync the mergescript and the
@@ -5034,16 +5030,12 @@ sub parse_rsync_input_file_on_MN
# this triggers the running of the mergescript
$::mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
}
# add the merge script to the sync
if ($addmergescript == 0) { # only add once
my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
my $mergescriptline = "$mergescript -> $mergescript";
$syncmergescript=1; # syncing the xdcpmerge.sh script
&build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript);
$addmergescript=1;
}
} # end MERGE clause
my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh";
my $mergescriptline = "$mergescript -> $mergescript";
$syncmergescript=1; # syncing the xdcpmerge.sh script
&build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript);
}
}
} else { # not processing EXECUTE, EXECUTEALWAYS or APPEND
@@ -5207,7 +5199,6 @@ sub build_append_rsync
push @::appendlines,$line;
}
my $src_file = $1; # append file left of arror
my $orig_src_file = $1; # append file left of arror
# it will be sync'd to $nodesyncfiledir/$append_file
my $dest_file = $nodesyncfiledir;
$dest_file .= $src_file;
@@ -5236,7 +5227,7 @@ sub build_append_rsync
# to pick up files from /var/xcat/syncfiles...
if ($onServiceNode == 1) {
my $newsrcfile = $syncdir; # add SN syndir on front
$newsrcfile .= $orig_src_file;
$newsrcfile .= $src_file;
$src_file=$newsrcfile;
}
# destination file name
@@ -5319,8 +5310,7 @@ sub build_merge_rsync
if ($syncmergescript == 0) { # don't add the xdcpmerge.sh line
push @::mergelines,$line;
}
my $src_file = $1; # merge file left of arrow
my $orig_src_file = $1;
my $src_file = $1; # merge file left of arror
# it will be sync'd to $nodesyncfiledir/$merge_file
my $dest_file = $nodesyncfiledir;
$dest_file .= $src_file;
@@ -5349,7 +5339,7 @@ sub build_merge_rsync
# to pick up files from /var/xcat/syncfiles...
if ($onServiceNode == 1) {
my $newsrcfile = $syncdir; # add SN syndir on front
$newsrcfile .= $orig_src_file;
$newsrcfile .= $src_file;
$src_file=$newsrcfile;
}
# destination file name
@@ -6039,11 +6029,11 @@ sub run_always_rsync_postscripts
# if on the service node need to add the $syncdir directory
# to the path
if (xCAT::Utils->isServiceNode()) {
my $tmps=$syncdir . $ps;
push @args, $tmps;
} else{
push @args, $ps;
my $tmpp=$syncdir . $ps;
$ps=$tmpp;
}
push @args, $ps;
push (@nodes, @{$$dshparms{'postscripts'}{$ps}});
$out=xCAT::Utils->runxcmd( { command => ['xdsh'],
+58
View File
@@ -253,6 +253,64 @@ use strict;
#---------------------------------------------------------------------------
=head3
ifconfig_inet
Builds a list of all IP Addresses bound to the local host and
stores them in a global list
Arguments:
None
Returns:
None
Globals:
@local_inet
Error:
None
Example:
xCAT::DSHCore->ifconfig_inet;
Comments:
Internal routine only
=cut
#---------------------------------------------------------------------------
sub ifconfig_inet
{
my @local_inet = ();
if ($^O eq 'aix')
{
my @ip_address = ();
my @output = `/usr/sbin/ifconfig -a`;
foreach my $line (@output)
{
($line =~ /inet ((\d{1,3}?\.){3}(\d){1,3})\s/o)
&& (push @local_inet, $1);
}
}
elsif ($^O eq 'linux')
{
my @ip_address = ();
my @output = `/sbin/ifconfig -a`;
foreach my $line (@output)
{
($line =~ /inet addr:((\d{1,3}?\.){3}(\d){1,3})\s/o)
&& (push @local_inet, $1);
}
}
}
#---------------------------------------------------------------------------
+31 -199
View File
@@ -16,7 +16,7 @@ use xCAT::Usage;
use xCAT::NodeRange;
use xCAT::FSPUtils;
use xCAT::VMCommon;
use Data::Dumper;
#use Data::Dumper;
use xCAT::MsgUtils qw(verbose_message);
##############################################
# Globals
@@ -48,15 +48,6 @@ sub parse_args {
##########################################################################
# Parse the chvm command line for options and operands
##########################################################################
my @query_array = ();
my %param_list_map = (
'vmcpus' => 'part_get_lpar_processing',
'vmmemory' => 'part_get_lpar_memory',
'vmphyslots' => 'part_get_all_io_bus_info',
'vmnics' => 'part_get_all_vio_info',
'vmstorage' => 'part_get_all_vio_info',
'del_vadapter' => 'part_get_all_vio_info'
);
sub chvm_parse_extra_options {
my $args = shift;
@@ -66,7 +57,6 @@ sub chvm_parse_extra_options {
if (ref($args) ne 'ARRAY') {
return "$args";
}
my %tmp_hash = ();
foreach (@$args) {
my ($cmd, $value) = split (/\=/, $_);
if (!defined($value)) {
@@ -85,24 +75,14 @@ sub chvm_parse_extra_options {
# return "'$value' invalid";
# }
} elsif (grep(/^$cmd$/, @support_ops)) {
if (exists($param_list_map{$cmd})) {
$tmp_hash{$param_list_map{$cmd}} = 1;
}
if (exists($opt->{p775})) {
return "'$cmd' doesn't work for Power 775 machines.";
} elsif ($cmd eq "del_vadapter") {
if ($value !~ /^\d+$/) {
return "Invalid param '$value', only one slot id can be specified";
}
} elsif ($cmd eq "vmothersetting") {
if ($value =~ /hugepage:\s*(\d+)/i) {
$opt->{huge_page} = $1;
$tmp_hash{'get_huge_page'} = 1;
}
if ($value =~ /bsr:\s*(\d+)/i) {
$opt->{bsr} = $1;
$tmp_hash{'get_cec_bsr'} = 1;
}
next;
} elsif ($cmd eq "vmstorage") {
@@ -177,7 +157,6 @@ sub chvm_parse_extra_options {
}
$opt->{$cmd} = $value;
}
@query_array = keys(%tmp_hash);
return undef;
}
@@ -740,7 +719,7 @@ sub lsvm_parse_args {
$Getopt::Long::ignorecase = 0;
Getopt::Long::Configure( "bundling" );
if ( !GetOptions( \%opt, qw(V|verbose l|long p775 updatedb) )) {
if ( !GetOptions( \%opt, qw(V|verbose l|long p775) )) {
return( usage() );
}
if (exists($opt{l}) && !exists($opt{p775})) {
@@ -779,12 +758,11 @@ sub modify {
return op_extra_cmds ($request, $hash) if ($request->{opt}->{lparname} || $request->{opt}->{huge_page});
return ([["Error", "Miss argument\n".$usage_string, 1]]);
}
sub do_op_extra_cmds {
my $request = shift;
my $hash = shift;
my @values = ();
my %lpar_hash = ();
while (my ($mtms, $h) = each(%$hash)) {
my $memhash;
while (my($name, $d) = each(%$h)) {
@@ -849,17 +827,17 @@ sub do_op_extra_cmds {
if ($2 == "G" or $2 == '') {
$min = $min * 1024;
}
$min = int($min/$memsize);
$min = $min/$memsize;
my $cur = $3;
if ($4 == "G" or $4 == '') {
$cur = $cur * 1024;
}
$cur = int($cur/$memsize);
$cur = $cur/$memsize;
my $max = $5;
if ($6 == "G" or $6 == '') {
$max = $max * 1024;
}
$max = int($max/$memsize);
$max = $max/$memsize;
$request->{opt}->{$op} ="$min/$cur/$max";
$param = $request->{opt}->{$op};
} else {
@@ -892,15 +870,8 @@ sub do_op_extra_cmds {
push @values, [$name, "Success", '0'];
}
}
my $rethash = query_cec_info_actions($request, $name, $d, 1, \@query_array);
# need to add update db here
$lpar_hash{$name} = $rethash;
$lpar_hash{$name}->{parent} = @$d[3];
}
}
if (%lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@values;
}
sub check_node_info {
@@ -1681,7 +1652,6 @@ my @partition_query_actions = qw(part_get_partition_cap part_get_hyp_process_and
sub parse_part_get_info {
my $hash = shift;
my $data = shift;
my $lparid = shift;
my @array = split /\n/, $data;
foreach my $line (@array) {
chomp($line);
@@ -1702,12 +1672,9 @@ sub parse_part_get_info {
$hash->{bus}->{$3}->{cur_lparid} = $1;
$hash->{bus}->{$3}->{bus_slot} = $2;
$hash->{bus}->{$3}->{des} = $4;
if ($lparid and $lparid eq $1) {
push @{$hash->{lpar_phy_bus}}, $3;
}
} elsif ($line =~ /Phy drc_index:(\w+), Port group: (\w+), Phy port id: (\w+)/) {
$hash->{phy_drc_group_port}->{$1}->{$2}->{$3} = '1';
#} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) {
} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) {
if (($2 == -1) && ($4 == 255)) {
$hash->{logic_drc_phydrc}->{$3}->{$5} = $1;
#$hash->{logic_drc_phydrc}->{$5}->{$1} = [$2,$3,$4];
@@ -1720,49 +1687,12 @@ sub parse_part_get_info {
$hash->{lpar0_used_mem} = $2;
$hash->{phy_min_mem_req} = $3;
#print "===>lpar0_used_mem:$hash->{lpar0_used_mem}.\n";
} elsif ($line =~ /Curr Memory (Min|Req|Max):\s*([\d]*)[^\(]*\((\d+)\s*regions\)/) {
if ($1 eq 'Min') {
$hash->{lpar_mem_min} = $2
} elsif ($1 eq 'Max') {
$hash->{lpar_mem_max} = $2;
} else {
$hash->{lpar_mem_req} = $2;
$hash->{lpar_used_regions} = $3;
}
} elsif ($line =~ /Curr Processor (Min|Req|Max):\s*(\d+)/) {
if ($1 eq 'Min') {
$hash->{lpar_cpu_min} = $2;
} elsif ($1 eq 'Max') {
$hash->{lpar_cpu_max} = $2;
} else {
$hash->{lpar_cpu_req} = $2;
}
} elsif ($line =~ /\s*lpar_id=(\d+),type=vSCSI,slot=(\d+),attr=(\d+).*remote_lpar_id=0x(\w+),remote_slot_num=0x(\w+)/) {
if ($3 eq '0') {
my $lparid = hex($4);
my $slotid = hex($5);
push @{$hash->{lpar_vmstorage_client}}, "$lparid:$slotid";
} else {
if (exists($hash->{lpar_vmstorage_server})) {
$hash->{lpar_vmstorage_server}++;
} else {
$hash->{lpar_vmstorage_server} = 1;
}
}
} elsif ($line =~ /\s*lpar_id=(\d+),type=(vEth),slot=(\d+).*port_vlan_id=(\d+),mac_addr=(\w+)/) {
push @{$hash->{lpar_vmnics}}, "vlan$4";
} elsif ($line =~ /Curr Memory Req:[^\(]*\((\d+)\s*regions\)/) {
$hash->{lpar_used_regions} = $1;
} elsif ($line =~ /Available huge page memory\(in pages\):\s*(\d+)/) {
$hash->{huge_page_avail} = $1;
} elsif ($line =~ /Available BSR array:\s*(\d+)/) {
$hash->{cec_bsr_avail} = $1;
} elsif ($line =~ /^\d+\/(\d+)\/\d+$/) {
if ($1 ne 0) {
push @{$hash->{lpar_othersetting}}, "hugepage:$1";
}
} elsif ($line =~ /^(\d+)\.$/) {
if ($1 ne 0) {
push @{$hash->{lpar_othersetting}}, "bsr:$1";
}
}
}
}
@@ -1773,7 +1703,6 @@ sub query_cec_info_actions {
my $td = shift;
my $usage = shift;
my $action_array = shift;
my $lpar_hash = shift;
my $lparid = @$td[0];
my $data;
my @array = ();
@@ -1788,16 +1717,12 @@ sub query_cec_info_actions {
chomp(@$values[1]);
#if ($action eq "part_get_partition_cap" and (@$values[1] =~ /Error:/i or @$values[2] ne 0)) {
if (@$values[1] =~ /Error:/i or @$values[2] ne 0) {
next; #return ([[@$values]]);
return ([[@$values]]);
}
if (@$values[1] =~ /^$/) {
next;
}
if ($usage eq 1 or $usage eq 2) {
&parse_part_get_info(\%hash, @$values[1], $lparid);
}
if ($usage eq 0 or $usage eq 2) {
if ($usage eq 0) {
if ($lparid) {
if ($action eq "lpar_lhea_mac") {
my @output = split /\n/,@$values[1];
@@ -1852,72 +1777,18 @@ sub query_cec_info_actions {
}
#$data .= "@$values[1]\n\n";
push @array, [$name, @$values[1], @$values[2]];
}
}
if ($usage eq 0 or $usage eq 2) {
#return $data;
if ($usage eq 2) {
%$lpar_hash = %hash;
} else {
&parse_part_get_info(\%hash, @$values[1]);
}
}
if ($usage eq 0) {
#return $data;
return \@array;
} else {
return \%hash;
}
}
sub update_vm_db {
my $request = shift;
my $lpar_hash = shift;
my $vm_hd = xCAT::Table->new('vm');
my %name_id_map = ();
my $commit = 0;
foreach (keys (%$lpar_hash)) {
my %db_update = ();
my $node_hash = $lpar_hash->{$_};
if (exists($node_hash->{lpar_cpu_min})) {
$db_update{cpus} = "$node_hash->{lpar_cpu_min}/$node_hash->{lpar_cpu_req}/$node_hash->{lpar_cpu_max}";
}
if (exists($node_hash->{lpar_mem_min})) {
$db_update{memory} = "$node_hash->{lpar_mem_min}/$node_hash->{lpar_mem_req}/$node_hash->{lpar_mem_max}";
}
if (exists($node_hash->{lpar_vmstorage_server})) {
$db_update{storage} = $node_hash->{lpar_vmstorage_server};
} elsif (exists($node_hash->{lpar_vmstorage_client})) {
my @tmp_array = ();
foreach (@{$node_hash->{lpar_vmstorage_client}}) {
if (/(\d+):(\d+)/) {
if (exists($name_id_map{$1})) {
push @tmp_array, "$name_id_map{$1}:$2";
} else {
my $vios_name = &find_lpar_name($request, $node_hash->{parent}, $1);
if (defined($vios_name)) {
$name_id_map{$1} = $vios_name;
push @tmp_array, "$vios_name:$2";
}
}
}
}
$db_update{storage} = join(",",@tmp_array);
}
if (exists($node_hash->{lpar_vmnics})) {
$db_update{nics} = join(",",@{$node_hash->{lpar_vmnics}});
}
if (exists($node_hash->{lpar_phy_bus})) {
$db_update{physlots} = join(",",@{$node_hash->{lpar_phy_bus}});
}
if (exists($node_hash->{lpar_othersetting})) {
$db_update{othersettings} = join(",",@{$node_hash->{lpar_othersetting}});
}
if (%db_update) {
$vm_hd->setNodeAttribs($_,\%db_update);
$commit = 1;
}
}
if ($commit) {
$vm_hd->commit;
}
}
#my @partition_query_actions = qw(part_get_partition_cap part_get_num_of_lpar_slots part_get_hyp_config_process_and_mem part_get_hyp_avail_process_and_mem part_get_service_authority_lpar_id part_get_shared_processing_resource part_get_all_vio_info lpar_lhea_mac part_get_all_io_bus_info part_get_lpar_processing part_get_lpar_memory get_huge_page get_cec_bsr);
sub query_cec_info {
my $request = shift;
@@ -1925,36 +1796,25 @@ sub query_cec_info {
my $args = $request->{opt};
my @td = ();
my @result = ();
my $usage = 0;
my %lpar_hash = ();
#print Dumper($request);
#print Dumper($hash);
while (my ($mtms,$h) = each(%$hash) ) {
while (my ($name, $d) = each (%$h)) {
my %tmp_hash = ();
@td = @$d;
if (@$d[0] == 0 && @$d[4] !~ /lpar|vios/) {
last;
}
#my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","lpar_lhea_mac","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]);
if ($args->{updatedb}) {
$usage = 2;
}
my $rethash = query_cec_info_actions($request, $name, $d, $usage, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"], \%tmp_hash);
my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"]);
#push @result, [$name, $rethash, 0];
push @result, @$rethash;
$lpar_hash{$name} = \%tmp_hash;
$lpar_hash{$name}->{parent} = @$d[3];
}
if (@td[0] == 0) {
my $rethash = query_cec_info_actions($request, @td[3],\@td, $usage);
my $rethash = query_cec_info_actions($request, @td[3],\@td, 0);
#push @result, [@td[3], $rethash, 0];
push @result, @$rethash;
}
}
if ($args->{updatedb} and %lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@result;
}
@@ -2071,19 +1931,6 @@ sub find_lpar_id {
return undef;
}
sub find_lpar_name {
my $request = shift;
my $parent = shift;
my $id = shift;
my %mapping = %{$request->{ppc}->{$parent}->{mapping}};
foreach (keys %mapping) {
if ($mapping{$_} eq $id) {
return $_;
}
}
return undef;
}
sub create_lpar {
my $request = shift;
my $name = shift;
@@ -2207,7 +2054,6 @@ sub mkspeclpar {
my $opt = $request->{opt};
my $values;
my @result = ();
my %lpar_hash = ();
my $vmtab = xCAT::Table->new( 'vm');
unless($vmtab) {
return([["Error","Cannot open vm table", 1]]);
@@ -2280,9 +2126,9 @@ sub mkspeclpar {
return([[$name, "Parameter for 'vmmemory' is invalid", 1]]);
}
my $memsize = $memhash->{mem_region_size};
$mmin = int(($mmin + $memsize - 1) / $memsize);
$mcur = int(($mcur + $memsize - 1) / $memsize);
$mmax = int(($mmax + $memsize - 1) / $memsize);
$mmin = ($mmin + $memsize) / $memsize;
$mcur = ($mcur + $memsize) / $memsize;
$mmax = ($mmax + $memsize) / $memsize;
$tmp_ent->{memory} = "$mmin/$mcur/$mmax";
$tmp_ent->{mem_region_size} = $memsize;
} else {
@@ -2332,27 +2178,21 @@ sub mkspeclpar {
$tmp_ent->{storage} = \@array;
}
} else {
if (exists($tmp_ent->{storage})) {
my @tmp_array = split ",",$tmp_ent->{storage};
my $storage_array = undef;
foreach (@tmp_array) {
if (/([\w_-]*):(\d+)/) {
my $vios = &find_lpar_id($request, @$d[3], $1);
my $r_slotid = $2;
if (defined($vios)) {
push @$storage_array, "0,$vios,$r_slotid";
} else {
return ([[$name, "Cannot find lparid for Server lpar:$1"]]);
}
} else {
return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]);
if (exists($tmp_ent->{storage}) and $tmp_ent->{storage} !~ /^[\w_-]*:\d+$/) {
return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]);
} elsif (exists($tmp_ent->{storage})) {
if ($tmp_ent->{storage} =~ /([\w_-]*):(\d+)/) {
my $vios = &find_lpar_id($request, @$d[3], $1);
my $r_slotid = $2;
if (!defined($vios)) {
return ([[$name, "Cannot find lparid for Server lpar:$1"]]);
}
$tmp_ent->{storage} = ["0,$vios,$r_slotid"];
}
$tmp_ent->{storage} = $storage_array;
}
}
$tmp_ent->{hyp_config_mem} = $memhash->{hyp_config_mem};
$tmp_ent->{hyp_avail_mem} = $memhash->{hyp_avail_mem};
if (exists($tmp_ent->{othersettings})) {
@@ -2373,18 +2213,10 @@ sub mkspeclpar {
$tmp_ent->{logic_drc_phydrc} = $memhash->{logic_drc_phydrc};
$values = &create_lpar($request, $name, $d, $tmp_ent);
push @result, $values;
#need to add update db here
my $rethash = query_cec_info_actions($request, $name, $d, 1, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]);
$lpar_hash{$name} = $rethash;
$lpar_hash{$name}->{parent} = @$d[3];
$name = undef;
$d = undef;
}
}
if (%lpar_hash) {
update_vm_db($request, \%lpar_hash);
}
return \@result;
}
+1 -1
View File
@@ -1023,7 +1023,7 @@ sub dolitesetup
$nrange = join(',',@nodel);
}
@flist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $nrange", -1);
my @flist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $nrange", -1);
if (scalar(@flist) > 0) {
foreach my $l (@flist) {
my ($j1, $j2, $file) = split /\s+/, $l;
+9 -128
View File
@@ -19,7 +19,6 @@ use File::Path;
use Math::BigInt;
use Socket;
use xCAT::GlobalDef;
use Data::Dumper;
use strict;
use warnings "all";
my $socket6support = eval { require Socket6 };
@@ -697,26 +696,19 @@ sub get_nic_ip
# Base address:0x2600 Memory:fbfe0000-fc0000080
#
# eth1 ...
# Redhat7
#eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
# inet 10.1.0.178 netmask 255.255.0.0 broadcast 10.1.255.255
#
##############################################################
my @adapter= split /\n{2,}/, $result;
foreach ( @adapter ) {
if ( !($_ =~ /LOOPBACK/ ) and
$_ =~ /UP( |,|>)/ and
$_ =~ /$mode/ ) {
if ( !($_ =~ /LOOPBACK / ) and
$_ =~ /UP / and
$_ =~ /$mode / ) {
my @ip = split /\n/;
for my $ent ( @ip ) {
if ($ent =~ /^(eth\d|ib\d|hf\d)\s+/) {
$nic = $1;
}
if ($ent =~ /^(eth\d:|ib\d:|hf\d:)\s+/) {
$nic = $1;
}
$ent=~ s/addr://; # works for Redhat7 also
if ( $ent =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) {
}
if ( $ent =~ /^\s*inet addr:\s*(\d+\.\d+\.\d+\.\d+)/ ) {
$iphash{$nic} = $1;
next;
}
@@ -1628,10 +1620,8 @@ sub gethost_ips
else
{
my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr);
#@ip = split(":", $addr1);
#push @ipaddress, $ip[1];
$addr1 =~ s/.*://;
push @ipaddress, $addr1;
@ip = split(":", $addr1);
push @ipaddress, $ip[1];
}
}
else
@@ -1991,108 +1981,6 @@ sub isIpaddr
}
}
#-------------------------------------------------------------------------------
=head3 getSubnetGateway
Description:
Get gateway from the networks table of the specified net.
Arguments:
net: the net, ie. the "net" field of the networks table
Returns:
Return a string, of the gateway
undef - Failed to get the gateway
Globals:
none
Error:
none
Example:
my $gateway = xCAT::NetworkUtils::getSubnetGateway('192.168.1.0');
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub getSubnetGateway
{
my $netname=shift;
if( $netname =~ /xCAT::NetworkUtils/)
{
$netname=shift;
}
my $gateway=undef;
my $nettab = xCAT::Table->new("networks");
unless($nettab) { die "No entry defined in networks"; }
my @nets = $nettab->getAllAttribs('net','gateway');
foreach(@nets)
{
if("$_->{net}" eq "$netname")
{
$gateway = $_->{gateway};
last;
}
}
return $gateway;
}
#-------------------------------------------------------------------------------
=head3 getNodeNameservers
Description:
Get nameservers of specified nodes.
The priority: noderes.nameservers > networks.nameservers > site.nameservers
Arguments:
node: node name list
Returns:
Return a hash ref, of the $nameservers{$node}
undef - Failed to get the nameservers
Globals:
none
Error:
none
Example:
my $nameservers = xCAT::NetworkUtils::getNodeNameservers(\@node);
Comments:
none
=cut
#-------------------------------------------------------------------------------
sub getNodeNameservers{
my $nodes=shift;
if( $nodes =~ /xCAT::NetworkUtils/)
{
$nodes=shift;
}
my @nodelist = @$nodes;
my %nodenameservers;
my $nrtab = xCAT::Table->new('noderes',-create=>0);
my %nrhash = %{$nrtab->getNodesAttribs(\@nodelist,['nameservers'])};
my $nettab = xCAT::Table->new("networks");
my %nethash = xCAT::DBobjUtils->getNetwkInfo( \@nodelist );
my @nameservers = xCAT::TableUtils->get_site_attribute("nameservers");
my $sitenameservers=$nameservers[0];
foreach my $node (@nodelist){
if ($nrhash{$node} and $nrhash{$node}->[0] and $nrhash{$node}->[0]->{nameservers})
{
$nodenameservers{$node}=$nrhash{$node}->[0]->{nameservers};
}elsif($nethash{$node}{nameservers})
{
$nodenameservers{$node}=$nethash{$node}{nameservers};
}elsif($sitenameservers)
{
$nodenameservers{$node}=$sitenameservers;
}
}
return \%nodenameservers;
}
#-------------------------------------------------------------------------------
=head3 getNodeNetworkCfg
@@ -2119,23 +2007,17 @@ sub getNodeNameservers{
sub getNodeNetworkCfg
{
my $node = shift;
if( $node =~ /xCAT::NetworkUtils/)
{
$node =shift;
}
my $nets = xCAT::NetworkUtils::my_nets();
my $ip = xCAT::NetworkUtils->getipaddr($node);
my $mask = undef;
my $gateway = undef;
for my $net (keys %$nets)
{
my $netname;
($netname,$mask) = split /\//, $net;
$gateway=xCAT::NetworkUtils::getSubnetGateway($netname);
last if ( xCAT::NetworkUtils::isInSameSubnet( $netname, $ip, $mask, 1));
}
return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask,1,0));
return ($ip, $node, undef, xCAT::NetworkUtils::formatNetmask($mask,1,0));
}
#-------------------------------------------------------------------------------
@@ -2313,7 +2195,6 @@ sub isValidHostname
return 0;
}
#-------------------------------------------------------------------------------
=head3 isValidFQDN
+1 -1
View File
@@ -156,7 +156,7 @@ sub connect {
# Shell prompt regexp based on HW Type
##################################################
my %prompt = (
hmc => "~>\\s*\$",
hmc => "~> \$",
ivm => "\\\$ \$"
);
##################################################
-15
View File
@@ -921,11 +921,6 @@ site => {
" '0' value means include all the nodes in the subnet.\n\n".
" pruneservices: Whether to enable service pruning when noderm is run (i.e.\n".
" removing DHCP entries when noderm is executed)\n\n".
" managedaddressmode: The mode of networking configuration during node provision.\n".
" If set to 'static', the network configuration will be configured \n".
" in static mode based on the node and network definition on MN.\n".
" If set to 'dhcp', the network will be configured with dhcp protocol.\n".
" The default is 'dhcp'.\n\n".
" ------------\n".
"DNS ATTRIBUTES\n".
" ------------\n".
@@ -946,12 +941,6 @@ site => {
" \"<xcatmaster>\" to mean the DNS server for each node should be the\n".
" node that is managing it (either its service node or the management\n".
" node).\n\n".
" externaldns: To specify that external dns is used. If externaldns is set to any value\n".
" then, makedns command will not start the local nameserver on xCAT MN. \n".
" Default is to start the local nameserver.\n\n".
" dnsupdaters: The value are \',\' separated string which will be added to the zone config\n".
" section. This is an interface for user to add configuration entries to\n".
" the zone sections in named.conf.\n\n".
" -------------------------\n".
"HARDWARE CONTROL ATTRIBUTES\n".
" -------------------------\n".
@@ -1107,10 +1096,6 @@ site => {
" will not interfere.\n\n".
" vmwarereconfigonpower: When set to no, the VMWare plugin will make no effort to\n".
" push vm.cpus/vm.memory updates from xCAT to VMWare.\n\n".
" persistkvmguests: Keep the kvm definition on the kvm hypervisor when you power off\n".
" the kvm guest node. This is useful for you to manually change the \n".
" kvm xml definition file in virsh for debugging. Set anything means\n".
" enable.\n\n".
" --------------------\n".
"XCAT DAEMON ATTRIBUTES\n".
" --------------------\n".
Executable → Regular
+3 -4
View File
@@ -429,6 +429,7 @@ rmdir \"/tmp/$to_userid\" \n";
# Need to check if nodes are in a zone.
my @zones;
my $tab = xCAT::Table->new("zone");
my @zones;
if ($tab)
{
# if we have zones, need to send the zone keys to each node in the zone
@@ -622,7 +623,7 @@ sub sendkeysTOzones
my ($class, $ref_nodes,$expecttimeout) = @_;
my @nodes=$ref_nodes;
my $n_str = $nodes[0];
@nodes= split(",", $n_str);
my @nodes= split(",", $n_str);
my $rsp = ();
my $cmd;
my $roothome = xCAT::Utils->getHomeDir("root");
@@ -1177,9 +1178,7 @@ sub getAppStatus
my ($class, $nodes_ref, $application) = @_;
my @nodes = @$nodes_ref;
# FIXME: why autocommit matters for a read-only subroutine getNodesAttribs?
# but could not get the appstatus without the autocommit=0
my $nltab = xCAT::Table->new('nodelist', -autocommit => 0);
my $nltab = xCAT::Table->new('nodelist');
my $nodeappstat = $nltab->getNodesAttribs(\@nodes,['appstatus']);
my $ret_nodeappstat;
+1 -1
View File
@@ -222,7 +222,7 @@ my %usage = (
lsvm <noderange> [-a|--all]
PPC (using Direct FSP Management) specific:
lsvm <noderange> [-l|--long] --p775
lsvm <noderange>
lsvm <noderange>
zVM specific:
lsvm noderange
lsvm noderange --getnetworknames
-56
View File
@@ -3487,60 +3487,4 @@ sub fullpathbin
return $fullpath;
}
#--------------------------------------------------------------------------------
=head3 gettimezone
returns the name of the timezone defined on the Linux distro.
This routine was written to replace the use of /etc/sysconfig/clock which in no
longer supported on future Linux releases such as RHEL7. It is suppose to be a routine
that can find the timezone on any Linux OS or AIX.
Arguments:
none
Returns:
Name of timezone, for example US/Eastern
Globals:
none
Error:
None
Example:
my $timezone = xCAT::Utils->gettimezone();
Comments:
none
=cut
#--------------------------------------------------------------------------------
sub gettimezone
{
my ($class) = @_;
my $tz;
if (xCAT::Utils->isAIX()) {
$tz= $ENV{'TZ'};
} else { # all linux
my $localtime = "/etc/localtime";
my $zoneinfo = "/usr/share/zoneinfo";
my $cmd = "find $zoneinfo -type f -exec cmp -s $localtime {} \\; -print | grep -v posix | grep -v SystemV";
my $zone_result = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
$tz="Could not determine timezone checksum";
return $tz;
}
my @zones = split /\n/, $zone_result;
$zones[0] =~ s/$zoneinfo\///;
if (!$zones[0]) { # if we still did not get one, then default
$tz = `cat /etc/timezone`;
chomp $tz;
} else {
$tz=$zones[0];
}
}
return $tz;
}
1;
-2
View File
@@ -29,7 +29,6 @@ require Exporter;
"1272326751.405938" => "centos5.5",
"1330913492.861127" => "centos5.8",#x86_64
"1357930415.252042" => "centos5.9",#x86_64
"1381776971.473332" => "centos5.10",#x86_64
"1195488871.805863" => "centos4.6",
"1195487524.127458" => "centos4.6",
"1301444731.448392" => "centos5.6",
@@ -71,7 +70,6 @@ require Exporter;
"1321545261.599847" => "rhelhpc6.2",#x86_64
"1339640148.070971" => "rhelhpc6.3",#x86_64
"1359576195.413831" => "rhelhpc6.4",#x86_64, RHEL ComputeNode
"1384196516.465862" => "rhelhpc6.5",#x86_64, RHEL ComputeNode
"1194015916.783841" => "fedora8",
"1194015385.299901" => "fedora8",
"1210112435.291709" => "fedora9",
File diff suppressed because it is too large Load Diff
@@ -41,8 +41,8 @@ if [ $OS != "AIX" ]; then
mkdir -p /tmp/gpfs_updates
rm -f -R /tmp/gpfs_updates/*
cd /tmp/gpfs_updates
# wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=3 ftp://$MASTER/$UPDATES_DIR/*.rpm 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=4 --reject "index.html*" --no-parent http://$MASTER$INSTALL_DIR/$UPDATES_DIR/ 2> /tmp/wget.log
# wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=3 ftp://$SITEMASTER/$UPDATES_DIR/*.rpm 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 10 -T 60 -nH --cut-dirs=4 --reject "index.html*" --no-parent http://$SITEMASTER$INSTALL_DIR/$UPDATES_DIR/ 2> /tmp/wget.log
if [ -n "`ls *.rpm 2> /dev/null`" ] ; then
rpm -Uvh *.rpm
fi
+4 -13
View File
@@ -38,6 +38,8 @@ if (scalar(@ARGV)>1) { $usage->(1); }
my $hnmatch = $ARGV[0]; # if they specified a hostname match, only show svrs that start with that
readconf("$ENV{HOME}/.slconfig"); # get the userid and api key from the config file
#my $api_username = 'SL276540';
#my $api_key = '799d5d9267a927a330ec016f00bfe17e6fc532d203cf68b3b0d997b2d27a3ce1';
my $slinstalled = eval { push @INC, $CONFIG{apidir}; require SoftLayer::API::SOAP; };
if (!$slinstalled) { die "Error: the SoftLayer::API::SOAP perl module is not installed. Download it using 'git clone https://github.com/softlayer/softlayer-api-perl-client' and put the directory in ~/.slconfig ."; }
@@ -62,23 +64,12 @@ foreach my $server (@$servers) {
print "\tbmc=".$server->{remoteManagementComponent}->{ipmiIpAddress}."\n";
print "\tbmcusername=".$server->{remoteManagementAccounts}->[0]->{username}."\n";
print "\tbmcpassword=".$server->{remoteManagementAccounts}->[0]->{password}."\n";
# find the 1st active private nic that is not the bmc
foreach my $nic (@{$server->{backendNetworkComponents}}) {
#print "nic:\n"; foreach my $key (keys(%$nic)) { print " $key = ", $nic->{$key}, "\n"; }
if ($nic->{status} eq 'ACTIVE' && $nic->{name} eq 'eth' && $nic->{macAddress} && $nic->{primaryIpAddress}) {
# found it
print "\tmac=".$nic->{macAddress}."\n";
print "\tip=".$nic->{primaryIpAddress}."\n";
}
}
#print "\tip=".$server->{privateIpAddress}."\n"; # getting this from the backendNetworkComponents instead
print "\tserial=".$server->{manufacturerSerialNumber}."\n";
print "\tmac=".$server->{backendNetworkComponents}->[0]->{macAddress}."\n";
print "\tip=".$server->{privateIpAddress}."\n";
print "\tnetboot=xnba\n";
print "\tarch=x86_64\n";
print "\tusercomment=hostname:".$server->{fullyQualifiedDomainName}.", user:".$server->{operatingSystem}->{passwords}->[0]->{username}.", pw:".$server->{operatingSystem}->{passwords}->[0]->{password}."\n";
verbose('SoftLayer API bare metal server entry: ' . Dumper($server));
#print Dumper($server->{remoteManagementAccounts});
#print "#Softlayer_account_info_for ".$server->{fullyQualifiedDomainName} . " Username: ";
#print $server->{operatingSystem}->{passwords}->[0]->{username} . " Password: ";
+15 -57
View File
@@ -13,12 +13,11 @@ use Socket;
my $HELP;
my $VERBOSE;
my $WAITTIME;
my $PROVMETHOD;
my $XCATNETBOOTTITLE = 'xCAT network boot kernel and initrd';
my $usage = sub {
my $exitcode = shift @_;
print "Usage: modifygrub [-?|-h|--help] [-v|--verbose] [-w <waittime>] [-p <provmethod] <kernel-path> <initrd-path> <kernel-parms> <mn-ip>\n\n";
print "Usage: modifygrub [-?|-h|--help] [-v|--verbose] [-w <waittime>] <kernel-path> <initrd-path> <kernel-parms> <mn-ip>\n\n";
if (!$exitcode) {
print "Modify the grub config file on the node to boot the specified kernel and initrd.\n";
}
@@ -31,7 +30,7 @@ if (-f '/etc/os-release') { die "This script doesn't support ubuntu yet.\n"; }
Getopt::Long::Configure("bundling");
#Getopt::Long::Configure("pass_through");
Getopt::Long::Configure("no_pass_through");
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME, 'p|provmethod=s' => \$PROVMETHOD)) { $usage->(1); }
if (!GetOptions('h|?|help' => \$HELP, 'v|verbose' => \$VERBOSE, 'w|waittime=s' => \$WAITTIME)) { $usage->(1); }
if ($HELP) { $usage->(0); }
if (scalar(@ARGV) != 4) { $usage->(1); }
@@ -61,29 +60,13 @@ sub addKernelParms {
$args->{kernelparms} =~ s/<nodename>/$nodename/g;
# get node ip and add it to the kernel parms
my ($nic, $ip, $netmask, $network, $broadcast, $gateway, $mac) = getNodeIpInfo($args);
my ($nic, $ip, $netmask, $gateway) = getNodeIpInfo($args);
if (!$ip) { die "Error: could not find the NIC that would connect to the xCAT mgmt node's IP (".$args->{mnip}.").\n"; }
# if we are booting genesis, need to add the BOOTIF parm
my $bootif;
if ($args->{kernelpath} =~ m/genesis\.kernel\.x86_64/) {
$bootif = $mac;
$bootif =~ s/:/-/g;
$bootif = "BOOTIF=01-$bootif";
}
if (defined($PROVMETHOD) && $PROVMETHOD eq 'sysclone') {
# add additional parms for sysclone
# DEVICE=eth0 IPADDR=10.0.0.99 NETMASK=255.255.255.0 NETWORK=10.0.0.0 BROADCAST=10.0.0.255 GATEWAY=10.0.0.1 GATEWAYDEV=eth0
#todo: should we also add ETHER_SLEEP=$WAITTIME textmode=1 dns=$mnip ?
$args->{kernelparms} .= " $bootif IPADDR=$ip NETMASK=$netmask NETWORK=$network BROADCAST=$broadcast GATEWAY=$gateway HOSTNAME=$nodename DEVICE=$nic GATEWAYDEV=$nic";
}
else { # scripted install or genesis shell
$args->{kernelparms} .= " $bootif hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1";
}
$args->{kernelparms} .= " hostip=$ip netmask=$netmask gateway=$gateway dns=$mnip hostname=$nodename netdevice=$nic netwait=$WAITTIME textmode=1";
}
# get this nodes nic, ip, netmask, gateway, and mac. Returns them in a 5 element array.
# get this nodes nic, ip, netmask, and gateway. Returns them in a 4 element array.
sub getNodeIpInfo {
my $args = shift @_;
my ($ipprefix) = $args->{mnip}=~m/^(\d+\.\d+)\./; #todo: this is a hack, just using the 1st 2 octets of the mn ip addr
@@ -91,14 +74,13 @@ sub getNodeIpInfo {
# parse ip addr show output, looking for ipprefix, to determine nic and ip
my @output = runcmd("ip addr show");
my ($nic, $mac, $ipandmask);
my ($nic, $ipandmask);
foreach my $line (@output) {
my ($nictmp, $mactmp, $iptmp);
my ($nictmp, $iptmp);
if (($nictmp) = $line=~m/^\d+:\s+(\S+): /) { $nic = $nictmp; } # new stanza, remember it
if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) |) { $mac = $mactmp; } # got mac, remember it
if (($iptmp) = $line=~m/^\s+inet\s+($ipprefix\S+) /) { $ipandmask = $iptmp; last; } # got ip, we are done
}
my ($ip, $netmask, $network, $broadcast) = convertIpAndMask($ipandmask);
my ($ip, $netmask) = convertIpAndMask($ipandmask);
# if the nic is a bonded nic (common on sl), then find the 1st real nic that is part of it
my $realnic = $nic;
@@ -106,12 +88,6 @@ sub getNodeIpInfo {
my @nics = grep(m/\s+master\s+$nic\s+/, @output);
if (!scalar(@nics)) { die "Error: can't find the NICs that are part of $nic.\n"; }
($realnic) = $nics[0]=~m/^\d+:\s+(\S+): /;
# go back thru the ip add show output and find the mac of this nic
foreach my $line (@output) {
my ($nictmp, $mactmp, $foundnic);
if (($nictmp) = $line=~m/^\d+:\s+(\S+): / && $nictmp eq $realnic) { $foundnic = 1; }
if (($mactmp) = $line=~m|^\s+link/ether\s+(\S+) | && $foundnic) { $mac = $mactmp; last; } # got mac, we are done
}
}
# finally, find the gateway
@@ -126,37 +102,19 @@ sub getNodeIpInfo {
verbose("using xCAT mgmt node IP as the fall back gateway.");
}
verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway, mac=$mac");
return ($realnic, $ip, $netmask, $network, $broadcast, $gateway, $mac);
verbose("IP info: realnic=$realnic, ip=$ip, netmask=$netmask, gateway=$gateway");
return ($realnic, $ip, $netmask, $gateway);
}
# Convert an ip/mask in slash notation (like 10.1.1.1/26) to separate ip, netmask, network, and broadcast values,
# like: 10.1.1.1, 255.255.255.192, 10.1.1.0, 10.1.1.63
# Convert an ip/mask in slash notation (like 10.0.0.1/26) to separate ip and netmask like 10.0.0.1 and 255.255.255.192
sub convertIpAndMask {
my $ipandmask = shift @_;
my ($ip, $masknum) = split('/', $ipandmask);
# build the netmask
my $nmbin = oct("0b" . '1' x $masknum . '0' x (32-$masknum)); # create a str like '1111100', then convert to binary
my @nmarr=unpack('C4',pack('N',$nmbin)); # separate into the 4 octets
my $netmask=join('.',@nmarr); # put them together into the normal looking netmask
# create binary form of ip
my @iparr=split(/\./,$ip);
my ( $ipbin ) = unpack('N', pack('C4',@iparr ) );
# Calculate network address by logical AND operation of ip & netmask and convert network address to IP address format
my $netbin = ( $ipbin & $nmbin );
my @netarr=unpack('C4', pack('N',$netbin ) );
my $network=join(".",@netarr);
# Calculate broadcast address by inverting the netmask and adding it to the network address
my $bcbin = ( $ipbin & $nmbin ) + ( ~ $nmbin );
my @bcarr=unpack('C4', pack('N',$bcbin ) ) ;
my $broadcast=join(".",@bcarr);
return ($ip, $netmask, $network, $broadcast);
my $netbin = oct("0b" . '1' x $masknum . '0' x (32-$masknum)); # create a str like '1111100', then convert to binary
my @netarr=unpack('C4',pack('N',$netbin)); # separate into the 4 octets
my $netmask=join('.',@netarr); # put them together into the normal looking netmask
return ($ip, $netmask);
}
+12 -68
View File
@@ -45,9 +45,7 @@ copyFilesToNodes($noderange, \%bootparms);
updateGrubOnNodes($noderange, \%bootparms);
if ($bootparms{osimageprovmethod} eq 'install' && !$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); }
if ($bootparms{osimageprovmethod} eq 'sysclone') { copySyscloneFiles(); }
if (!$NOAUTOINST) { modifyAutoinstFiles($noderange, \%bootparms); }
exit(0);
@@ -56,28 +54,23 @@ exit(0);
sub getBootParms {
my $nr = shift @_;
my %bootparms;
my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod");
my @output = runcmd("nodels $nr bootparams.kernel bootparams.initrd bootparams.kcmdline");
# the attributes can be displayed in a different order than requested, so need to grep for them
foreach my $attr (qw(bootparams.kernel bootparams.initrd bootparams.kcmdline nodetype.provmethod)) {
my ($a) = $attr =~ m/\.(.*)$/;
my @gresults = grep(/^\S+:\s+$attr:/, @output);
my @gresults;
foreach my $a (qw(kernel initrd kcmdline)) {
my $attr = "bootparams.$a";
@gresults = grep(/^\S+:\s+$attr:/, @output);
if (!scalar(@gresults)) { die "Error: attribute $attr not defined for the noderange. Did you run 'nodeset <noderange> osimage=<osimage>' ?\n"; }
# for now just pick the 1st one. They should all be the same, except for the node name in kcmdline
chomp($gresults[0]);
$gresults[0] =~ s/^\S+:\s+$attr:\s*//;
$bootparms{$a} = $gresults[0];
if ($a eq 'kcmdline') { $bootparms{$a} =~ s|/install/autoinst/\S+|/install/autoinst/<nodename>|; }
}
$bootparms{kcmdline} =~ s|/install/autoinst/\S+|/install/autoinst/<nodename>|;
# from the nodes provmethod, get the osimage provmethod, so we know the type of install
@output = runcmd("lsdef -t osimage $bootparms{provmethod} -ci provmethod");
chomp($output[0]);
my ($junk, $provmethod) = split(/=/, $output[0]);
$bootparms{osimageprovmethod} = $provmethod;
# get the mgmt node cluster-facing ip addr
@output = runcmd('lsdef -t site -ci master');
@output = runcmd('lsdef -t site -i master -c');
chomp($output[0]);
my ($junk, $ip) = split(/=/, $output[0]);
$bootparms{mnip} = $ip;
@@ -106,7 +99,7 @@ sub copyFilesToNodes {
# Form the remote file name, using the last 2 parts of the path, separated by "-"
sub remoteFilename {
my $f = shift @_;
$f =~ s|^.*?([^/]+)/([^/]+)$|$1-$2|;
$f =~ s|^.*/([^/]+)/([^/]+)$|$1-$2|;
return $f;
}
@@ -120,7 +113,7 @@ sub updateGrubOnNodes {
my @output = runcmd('which modifygrub');
my $modifygrub = $output[0];
chomp($modifygrub);
my $cmd = "xdsh $nr -e $modifygrub $vtxt -w $WAITTIME -p " . $bootparms->{osimageprovmethod} . ' ' . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' ';
my $cmd = "xdsh $nr -e $modifygrub $vtxt -w $WAITTIME " . remoteFilename($bootparms->{kernel}) . ' ' . remoteFilename($bootparms->{initrd}) . ' ';
# we need to quote the kernel parms, both here when passing it to xdsh, and on the node
# when xdsh is passing it to modifygrub. The way to get single quotes inside single quotes
# is to quote each of the outer single quotes with double quotes.
@@ -145,55 +138,15 @@ sub modifyAutoinstFiles {
# Edit each file to have chroot.sles insert a wait at the end of /etc/init.d/network
# this finds the end of boot.sh script (which is chroot.sles)
my $search = '\n\]\]>\s*</source>\s*</script>\s*</chroot-scripts>';
# hack the /etc/init.d/network script to put a wait in it
my $file = '/mnt/etc/init.d/network'; # at this point in the installation, the permanent file system is just mounted
#my $waitstring = 'echo Sleeping for 55s;sleep 55';
# this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escaped for sed
my $waitstring = 'echo -n Waiting to reach xCAT mgmt node ' . $bootparms->{mnip} . '.;xcatretries=60;while \[ \$\(\(xcati+=1\)\) -le \$xcatretries \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .' \>\/dev\/null 2\>\&1; do echo -n .; done; if \[ \$xcati -le \$xcatretries \]; then echo success; else echo failed; fi; sleep 3';
# this is the string to insert in the nodes /etc/init.d/network script. It is a while loop pinging the mn, but some of the chars need to be escape for sed
my $waitstring = 'echo Waiting to reach xCAT mgmt node...;while \[ \$\(\(xcati+=1\)\) -le 60 \] \&\& ! ping -c2 -w3 ' . $bootparms->{mnip} .'; do echo i=\$xcati ; done; sleep 10';
# this crazy sed string is from google. It gathers up the whole file into the hold buffer, and then the substitution is done on the whole file
my $sedstring = q|sed -n '1h;1!H;${;g;s/\(\t\treload_firewall\n\)\n/\1\t\t| . $waitstring . q(\n\n/g;p;}') . " $file > $file.new";
# finally create the perl replace string that will be used to modify the autoinst file
my $replace = "$sedstring\nchmod 755 $file.new; mv -f $file.new $file";
# Now instead we add a script that gets invoked by the OS after the nic is brought up
# these are specific to SLES
#my $netdir = '/etc/sysconfig/network';
#my $filename = '/etc/sysconfig/network/if-up.d/xcat-sl-wait';
#my $mnip = $bootparms->{mnip};
#todo: to support rhel, use these values instead
#my $netdir='/etc/sysconfig/network-scripts';
#my $filename='/sbin/ifup-local';
# this does not work, because midway thru the autoyast process, the if-up.d scripts do not seem to get invoked
# so autoyast fails to get he media
#my $replace = qq(
#FILENAME=$filename
#NETDIR=$netdir
#MNIP=$mnip
#);
# $replace .= q(
#cat >$FILENAME << EOF1
#MNIP=$MNIP
#NETDIR=$NETDIR
#EOF1
#
# this part of the file we do NOT want to expand the variables in the content
#cat >>$FILENAME << 'EOF2'
#NIC="$1"
# look in this ifcfg script to get the nics ip to see if this is the one we should be waiting on
#NICIP=`awk -F= '/^IPADDR/ {print $2}' $NETDIR/ifcfg-$NIC | tr -d \' `
#if [ "${NICIP%.*.*}" != "${MNIP%.*.*}" ]; then exit; fi # hack: compare the 1st 2 octets
#echo -n Waiting to reach xCAT mgmt node $MNIP.
#xcatretries=60
#while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $MNIP >/dev/null 2>&1; do echo -n .; done
#if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi
#sleep 3
#EOF2
#
#chmod +x $FILENAME
#);
# now actually update the file
print "Updating /install/autoinst files.\n";
foreach my $n (@nodes) {
@@ -204,15 +157,6 @@ sub modifyAutoinstFiles {
}
# Copy softlayer specific systemimager post-install scripts to the systemimager location.
# These cause si to use static ip and insert a wait into the bring up of the network.
sub copySyscloneFiles {
my $cmd = "cp -f /opt/xcat/share/xcat/sysclone/post-install/* /install/sysclone/scripts/post-install";
print "Copying SoftLayer-specific post scripts to the SystemImager post-install directory.\n";
runcmd($cmd);
}
# this is like multi-line sed replace function
# Args: filename, search-string, replace-string
sub sed {
@@ -1,43 +0,0 @@
#!/bin/bash
# Add a script that will run when the network is brought up to wait until the
# xcat mn can be pinged.
. /tmp/post-install/variables.txt
if [ -d "/etc/sysconfig/network-scripts/" ];then
#redhat
NETDIR=/etc/sysconfig/network-scripts
filename=/sbin/ifup-local
elif [ -d "/etc/sysconfig/network/" ];then
#suse
NETDIR=/etc/sysconfig/network
filename=/etc/sysconfig/network/if-up.d/xcat-sl-wait
else
#ubuntu
echo "Does not support ubuntu."
exit 1
fi
# Create the wait script, overwriting a copy that may have come from the golden client
# (in case the mn/image server is different).
# this part of the file we want to expand the variables in the content
cat >$filename << EOF1
MNIP=$IMAGESERVER
NETDIR=$NETDIR
EOF1
# this part of the file we do NOT want to expand the variables in the content
cat >>$filename << 'EOF2'
NIC="$1"
# look in this ifcfg script to get the nics ip to see if this is the one we should be waiting on
NICIP=`awk -F= '/^IPADDR/ {print $2}' $NETDIR/ifcfg-$NIC | tr -d \' `
if [ "${NICIP%.*.*}" != "${MNIP%.*.*}" ]; then exit; fi # hack: compare the 1st 2 octets
echo -n Waiting to reach xCAT mgmt node $MNIP.
xcatretries=60
while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $MNIP >/dev/null 2>&1; do echo -n .; done
if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi
sleep 3
EOF2
chmod +x $filename
@@ -1,101 +0,0 @@
#!/bin/bash
# Configure network settings after SI has installed the OS
. /tmp/post-install/variables.txt
# determine if we should be using a static ip or dhcp
staticIP () {
# Eventually we should use the SI variable IP_ASSIGNMENT_METHOD below to determine this.
# But this requires a patch in both xcat/sysclone (to set si_getimage -ip-assignment method)
# and SI (to set IP_ASSIGNMENT_METHOD as a result of that). Until both of those patches
# are in the main releases, assume that if we have set the IPADDR kernel parm for the boot
# kernel to use static ip, that the final OS should use static ip too.
# Note: the IPADDR environment variable will be set by SI, even if it got it thru dhcp, so
# that is not a reliable way to decide.
str=`cat /proc/cmdline`
#str='netmask=255.255.255.192 IPADDR=10.54.51.11 GATEWAY=10.54.51.1 dns=10.54.51.2 hostname=sap64-4 DEVICE=eth0'
for parm in $str; do
key=`echo $parm|awk -F= '{print $1}'`
value=`echo $parm|awk -F= '{print $2}'`
if [[ $key == "IPADDR" || $key == "ipaddr" ]]; then
return 0 # yes, we should use static ip
fi
done
if [[ -n $IP_ASSIGNMENT_METHOD && ${IP_ASSIGNMENT_METHOD,,} == "static" ]]; then
return 0 # this means yes/true
fi
return 1
}
#delete the udev rule in the image
rule_file=`ls /etc/udev/rules.d/*net_persistent_names.rules 2>/dev/null`
if [ -n "$rule_file" ];then
rm -f $rule_file
fi
hostname $HOSTNAME
device_names=`ifconfig -a | grep -i hwaddr | grep -i 'Ethernet' | grep -v usb| awk '{print $1}'`
str_cfg_file=''
if [ -d "/etc/sysconfig/network-scripts/" ];then
#redhat
grep -i HOSTNAME /etc/sysconfig/network
if [ $? -eq 0 ];then
sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network
else
echo "HOSTNAME=$HOSTNAME" >> /etc/sysconfig/network
fi
if staticIP; then
# set static ip from variables in variables.txt
i="$DEVICE"
str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=static" >> $str_cfg_file
echo "ONBOOT=yes" >> $str_cfg_file
echo "IPADDR=$IPADDR" >> $str_cfg_file
echo "NETMASK=$NETMASK" >> $str_cfg_file
echo "NETWORK=$NETWORK" >> $str_cfg_file
echo "BROADCAST=$BROADCAST" >> $str_cfg_file
#todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway
else
# use dhcp for all nics
for i in $device_names;do
str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "NM_CONTROLLED=yes" >> $str_cfg_file
echo "ONBOOT=yes" >> $str_cfg_file
done
fi
elif [ -d "/etc/sysconfig/network/" ];then
#suse
echo "$HOSTNAME" > /etc/HOSTNAME
if staticIP; then
# set static ip from variables in variables.txt
i="$DEVICE"
str_cfg_file="/etc/sysconfig/network/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=static" >> $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
echo "IPADDR=$IPADDR" >> $str_cfg_file
echo "NETMASK=$NETMASK" >> $str_cfg_file
echo "NETWORK=$NETWORK" >> $str_cfg_file
echo "BROADCAST=$BROADCAST" >> $str_cfg_file
#todo: add gateway config? Not sure, because the boot kernels gateway might not be the final OS gateway
else
# use dhcp for all nics
for i in $device_names;do
str_cfg_file="/etc/sysconfig/network/ifcfg-$i"
echo "DEVICE=$i" > $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
echo "DHCLIENT_PRIMARY_DEVICE=yes" >> $str_cfg_file
done
fi
else
#ubuntu
echo "Does not support ubuntu."
exit 1
fi
-4
View File
@@ -47,7 +47,6 @@ mkdir -p $RPM_BUILD_ROOT/install/postscripts
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/man/man1
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/man1
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install
cp -p -R share/xcat/install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/install/
@@ -57,9 +56,6 @@ chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/*
cp -d postscripts/* $RPM_BUILD_ROOT/install/postscripts
chmod 755 $RPM_BUILD_ROOT/install/postscripts/*
cp -d si-post-install/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install
chmod 755 $RPM_BUILD_ROOT/%{prefix}/share/xcat/sysclone/post-install/*
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer
chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-SoftLayer/*
+28 -59
View File
@@ -8,9 +8,10 @@
This script automates the setup of the MySQL/MariaDB server and creates the xCAT database to run
xCAT on MySQL/MariaDB.
Note: it will setup an xcat database (xcatdb),a xcatadmin id , and a MySQL root password.
This is script is called after the installation or upgrade of MySQL
on xCAT. It will automate the setup of the MySQL and xCAT to run
xCAT on the MySQL DB.
Note: if will setup an xcatdb,a xcatadmin, and a MySQL root password.
It will interact for the
password to assign, unless the XCATMYSQLADMIN_PW and the XCATMYSQLROOT_PW
env variables are set to the admin and mysql root password, resp.
@@ -149,8 +150,8 @@ $::linuxos = xCAT::Utils->osver();
#
# check to see if mysql is installed
#
my $cmd = "rpm -qa | grep -i perl-DBD-mysql";
#
my $cmd = "rpm -qa | grep mysql";
if ( $::debianflag ){
$cmd = "dpkg -l | grep mysql-server";
}
@@ -158,17 +159,10 @@ xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
my $message =
"\nMySQL perl DBD is not installed. If on AIX, it should be first obtained from the xcat dependency tarballs and installed before running this command.\n If on Linux, install from the OS CDs.";
"\nMySQL is not installed. If on AIX, it should be first obtained from the xcat dependency tarballs and installed before running this command.\n If on Linux, install from the OS CDs.";
xCAT::MsgUtils->message("E", " $cmd failed. $message");
exit(1);
}
# is this MariaDB or MySQL
$::MariaDB=0;
$cmd = "rpm -qa | grep -i mariadb"; # check this is MariaDB not MySQL
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC == 0) {
$::MariaDB=1;
}
# check to see if MySQL is running
$::mysqlrunning = 0;
@@ -334,6 +328,7 @@ if (($::INIT) && ($::xcatrunningmysql == 0))
# MySQL not running, then initialize the database
if ($::mysqlrunning == 0)
{
# Add mysql user and group for AIX
# Correct directory permissions
#
@@ -441,7 +436,7 @@ sub usage
{
xCAT::MsgUtils->message(
'I',
"Usage:\nmysqlsetup - Performs the setup of MySQL or MariaDB for xCAT to use as its database. See man mysqlsetup for more information."
"Usage:\nmysqlsetup - Performs the setup of MySQL for xCAT to use as its database. See man mysqlsetup for more information."
);
my $msg =
"mysqlsetup <-h|--help>\n <-v|--version>\n <-i|--init> [-f|hostfile] [-o|--odbc] [-L|--LL] [-V|--verbose]\n <-u|--update> <-f|hostfile> [-o|--odbc] [-L|--LL] [-V|--verbose]\n <-o|--odbc> [-V|--verbose]\n <-L|--LL> [-V|--verbose]";
@@ -875,20 +870,14 @@ sub mysqlstart
}
else
{
if ($::MariaDB==1) { # running MariaDB
$cmd = "service mariadb start";
} else { # it is mysql
if ($::linuxos =~ /rh.*/)
{
if ($::linuxos =~ /rh.*/)
{
$cmd = "service mysqld start";
}
else
{ # sles
}
else
{ # sles
$cmd = "service mysql start";
}
}
}
}
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
@@ -984,21 +973,16 @@ sub mysqlreboot
}
else # linux
{
if ($::MariaDB==1 ) { # MariaDB not MySQL
$cmd = "chkconfig mariadb on";
} else { # mysql
if ($::linuxos =~ /rh.*/)
{
$cmd = "chkconfig mysqld on";
}
else
{ # sles
$cmd = "chkconfig mysql on";
if ( $::debianflag ){
$cmd = "update-rc.d mysql defaults";
}
}
if ($::linuxos =~ /rh.*/)
{
$cmd = "chkconfig mysqld on";
}
else
{ # sles
$cmd = "chkconfig mysql on";
if ( $::debianflag ){
$cmd = "update-rc.d mysql defaults";
}
}
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
@@ -1074,12 +1058,7 @@ sub setupxcatdb
my $timeout = 10; # sets Expect default timeout, 0 accepts immediately
my $pwd_sent = 0;
my $pwd_prompt = 'Enter password: ';
my $mysql_prompt;
if ($::MariaDB == 1) { # setup MariaDB
$mysql_prompt = 'MariaDB \[\(none\)\]> ';
} else {
$mysql_prompt = 'mysql> ';
}
my $mysql_prompt = 'mysql> ';
my $expect_log = undef;
my $debug = 0;
#if ($::VERBOSE)
@@ -1199,12 +1178,7 @@ sub setupLL
my $timeout = 10; # sets Expect default timeout, 0 accepts immediately
my $pwd_sent = 0;
my $pwd_prompt = 'Enter password: ';
my $mysql_prompt;
if ($::MariaDB == 1) { # setup MariaDB
$mysql_prompt = 'MariaDB \[\(none\)\]> ';
} else {
$mysql_prompt = 'mysql> ';
}
my $mysql_prompt = 'mysql> ';
my $expect_log = undef;
my $debug = 0;
#if ($::VERBOSE)
@@ -1334,12 +1308,7 @@ sub addhosts
my $timeout = 10; # sets Expect default timeout, 0 accepts immediately
my $pwd_sent = 0;
my $pwd_prompt = 'Enter password: ';
my $mysql_prompt;
if ($::MariaDB == 1) { # setup MariaDB
$mysql_prompt = 'MariaDB \[\(none\)\]> ';
} else {
$mysql_prompt = 'mysql> ';
}
my $mysql_prompt = 'mysql> ';
my $expect_log = undef;
foreach my $host (@hosts)
+1 -1
View File
@@ -65,7 +65,7 @@ else { # the normal case of the user running the cmd - expand the noderange us
SSL_cert_file=> xCAT::Utils->getHomeDir()."/.xcat/client-cred.pem",
SSL_ca_file => xCAT::Utils->getHomeDir()."/.xcat/ca.pem",
SSL_use_cert => 1,
SSL_verify_mode => 1,
#SSL_verify_mode => 1,
);
die "Connection failure: $!\n" unless ($client);
my %cmdref = (command => 'noderange', noderange => $noderange);
-74
View File
@@ -1,74 +0,0 @@
=head1 Name
B<mkvlan> - Create vlan on switches
=head1 B<Synopsis>
B<mkvlan> [B<-h>|B<--help>|B<?>|B<-v>|B<--version>]
B<mkvlan> {Ivlanid} -n I<noderange> {B-i <interface>|B-m <netmask> |B-t <subnet>}
=head1 B<Description>
B<mkvlan> creates tagged vlan on the switches corresponding to the attributes defined in the B<switch> table
=head1 B<Options>
=over 7
=item B<vlanid>
The vlan to tag on the switch.
=item B<interface>
List all buses for each I/O slot.
=item B<netmask>
Retrieves number of processors, speed, total memory, and DIMM
locations.
=item B<subnet>
Retrieves model number.
=item B<-h>|B<--help>|B<?>
Print help.
=item B<-v>|B<--version>
Print version.
=back
=back
=head1 B<Examples>
=over 4
=item *
To make a private vlan for stand-alone nodes for the management network, enter:
mkvlan -n node1,node2,node3
=item *
You can specify vlan id, subnet and netmask etc, enter:
mkvlan 3 -n node1,node2,node3 -t 10.3.2.0 -m 255.255.255.0
=item *
To create a tagged vlan on an interface, enter:
mkvlan -n node1,node2,node3 -i eth1
=back
=head1 SEE ALSO
L<noderange(3)|noderange.3>, L<lsvlan(1)|lsvlan.1>
+4 -5
View File
@@ -1,6 +1,6 @@
=head1 NAME
B<mysqlsetup> - Sets up the MySQL or MariaDB database for xCAT to use.
B<mysqlsetup> - Sets up the MySQL database for xCAT to use.
=head1 SYNOPSIS
@@ -19,10 +19,9 @@ B<mysqlsetup> {B<-L>|B<--LL>} [-V|--verbose]
=head1 DESCRIPTION
B<mysqlsetup> - Sets up the MySQL or MariaDB database (linux only for MariaDB) for xCAT to use. The mysqlsetup script is run on the Management Node as root after the MySQL code or MariaDB code has been installed. Before running the init option, the MySQL server should be stopped, if it is running. The xCAT daemon, xcatd, must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL or MariaDB and restarting the xcatd daemon as well as the MySQL daemon. For full information on all the steps that will be done, read the "Configure MySQL and Migrate xCAT Data to MySQL" sections in
B<mysqlsetup> - Sets up the MySQL database for xCAT to use. The mysqlsetup script is run on the Management Node as root after the MySQL code has been installed. Before running the init option, the MySQL server should be stopped. The xCAT daemon, xcatd, must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL and restarting the xcatd daemon as well as the MySQL daemon. For full information on all the steps that will be done, read the "Configure MySQL and Migrate xCAT Data to MySQL" sections in
https://sourceforge.net/apps/mediawiki/xcat/index.php?title=Setting_Up_MySQL_as_the_xCAT_DB
Two passwords must be supplied for the setup, a password for the xcatadmin id and a password for the root id in the MySQL database. These will be prompted for interactively, unless the environment variables XCATMYSQLADMIN_PW and XCATMYSQLROOT_PW are set to the passwords for the xcatadmin id and root id in the database,resp.
Note below we refer to MySQL but it works the same for MariaDB.
=head1 OPTIONS
@@ -42,8 +41,8 @@ Displays verbose messages.
=item B<-i|--init>
The init option is used to setup a xCAT database on an installed MySQL or MariaDB server for xCAT to use. The mysqlsetup script will check for the installed MariaDB server rpm first and will use MariaDB if it is installed. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the my.cnf configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the /etc/xcat/cfgloc file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database.
On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL or MariaDB rpms shipped with the OS. You can chose the -f and/or the -o option, to run after the init.
The init option is used to setup an installed MySQL database so that xCAT can use the database. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the my.cnf configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the /etc/xcat/cfgloc file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database.
On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL rpms shipped with the OS. You can chose the -f and/or the -o option, to run after the init.
=item B<-u|--update>
-22
View File
@@ -123,28 +123,6 @@ Wake up the target nodes which is in B<suspend> state.
Don't try to run B<wake> against the 'on' state node, it would cause the node gets to 'off' state.
For some of xCAT hardware such as NeXtScale, it may need to enable S3 before using B<wake>. The following steps can be used to enable S3. Please reference L<pasu(1)|pasu.1> for "pasu" usage.
[root@xcatmn home]# echo "set Power.S3Enable Enable" > power-setting
[root@xcatmn home]# pasu -b power-setting node01
node01: Batch mode start.
node01: [set Power.S3Enable Enable]
node01: Power.S3Enable=Enable
node01:
node01: Beginning intermediate batch update.
node01: Waiting for command completion status.
node01: Command completed successfully.
node01: Completed intermediate batch update.
node01: Batch mode completed successfully.
[root@xcatmn home]# pasu node01 show all|grep -i s3
node01: IMM.Community_HostIPAddress3.1=
node01: IMM.Community_HostIPAddress3.2=
node01: IMM.Community_HostIPAddress3.3=
node01: IMM.DNS_IP_Address3=0.0.0.0
node01: IMM.IPv6DNS_IP_Address3=::
node01: Power.S3Enable=Enable
=item B<stat>|B<state>
Print the current power state/status.
-2
View File
@@ -49,8 +49,6 @@ Remove the DNS records.
Update DNS records to the external DNS server listed in /etc/resolv.conf.
Enabling the site attribute I<externaldns> means use 'external' DNS by default. If setting I<externaldns> to 1, you need NOT use B<-e> flag in every makedns call.
=item B<noderange>
A set of comma delimited node names and/or group names. See the "noderange" man page for details on additional supported formats.
+6
View File
@@ -253,6 +253,9 @@ dracut_install /usr/share/zoneinfo/posix/America/Knox_IN
dracut_install /usr/share/zoneinfo/posix/America/Goose_Bay
dracut_install /usr/share/zoneinfo/posix/EET
dracut_install /usr/share/zoneinfo/posix/EST5EDT
dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh89
dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh88
dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh87
dracut_install /usr/share/zoneinfo/posix/MST
dracut_install /usr/share/zoneinfo/posix/Iceland
dracut_install /usr/share/zoneinfo/posix/Atlantic/Faeroe
@@ -393,6 +396,7 @@ dracut_install /usr/share/zoneinfo/posix/NZ-CHAT
dracut_install /usr/share/zoneinfo/posix/Asia/Istanbul
dracut_install /usr/share/zoneinfo/posix/Asia/Kuwait
dracut_install /usr/share/zoneinfo/posix/Asia/Saigon
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh89
dracut_install /usr/share/zoneinfo/posix/Asia/Urumqi
dracut_install /usr/share/zoneinfo/posix/Asia/Brunei
dracut_install /usr/share/zoneinfo/posix/Asia/Ujung_Pandang
@@ -434,6 +438,7 @@ dracut_install /usr/share/zoneinfo/posix/Asia/Tokyo
dracut_install /usr/share/zoneinfo/posix/Asia/Macao
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh
dracut_install /usr/share/zoneinfo/posix/Asia/Rangoon
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh88
dracut_install /usr/share/zoneinfo/posix/Asia/Jakarta
dracut_install /usr/share/zoneinfo/posix/Asia/Aden
dracut_install /usr/share/zoneinfo/posix/Asia/Calcutta
@@ -471,6 +476,7 @@ dracut_install /usr/share/zoneinfo/posix/Asia/Tel_Aviv
dracut_install /usr/share/zoneinfo/posix/Asia/Taipei
dracut_install /usr/share/zoneinfo/posix/Asia/Kabul
dracut_install /usr/share/zoneinfo/posix/Asia/Macau
dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh87
dracut_install /usr/share/zoneinfo/posix/Asia/Choibalsan
dracut_install /usr/share/zoneinfo/posix/Asia/Vientiane
dracut_install /usr/share/zoneinfo/posix/Asia/Dacca
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
instmods nfs sunrpc
instmods e1000 e1000e virtio_net igb ines sfc mlx4_en cxgb3 cxgb4 tg3 bnx2 bnx2x bna ixgb ixgbe qlge mptsas mpt2sas mpt3sas ata_piix megaraid_sas virtio_blk ahci ibmaem xhci-hcd sd_mod pmcraid be2net vfat ext3 ext4 btrfs reiserfs usb_storage scsi_wait_scan kvm kvm-intel kvm-amd ipmi_si ipmi_devintf
instmods e1000 e1000e virtio_net igb ines sfc mlx4_en cxgb3 cxgb4 tg3 bnx2 bnx2x bna ixgb ixgbe qlge mptsas mpt2sas ata_piix megaraid_sas virtio_blk ahci ibmaem xhci-hcd sd_mod pmcraid be2net vfat ext3 ext4 btrfs reiserfs usb_storage scsi_wait_scan kvm kvm-intel kvm-amd ipmi_si ipmi_devintf
instmods macvlan macvtap 8021q bridge bonding vmxnet3 cpufreq_ondemand acpi-cpufreq powernow-k8 cdc_ether
instmods mptctl #LSI firmware management requires this
instmods mlx4_ib ib_umad #make the mellanox ib available enough to examine /sys
-1
View File
@@ -5,7 +5,6 @@ clear
echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bashrc
echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bash_profile
mkdir -p /etc/ssh
mkdir -p /var/tmp/
mkdir -p /var/empty/sshd
echo root:x:0:0::/:/bin/bash >> /etc/passwd
echo sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin >> /etc/passwd
+2 -2
View File
@@ -204,7 +204,7 @@ for bmcu in $BMCUS; do
if [ "$bmcu" = "" ]; then continue; fi
DISABLEUSERS="1 2 3 4"
if [ ! -z "$LOCKEDUSERS" ]; then
USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep -w "$BMCUS"|awk '{print $1}'`
USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep " $BMCUS"|awk '{print $1}'`
if [ -z "$USERSLOT" ]; then
USERSLOT=4
fi
@@ -239,7 +239,7 @@ done
TRIES=0
# Last param in ipmitool user priv is the channel to set it on.
# Penguin boxes are all channel 2
CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'`
CURRPRIV=`ipmitool -d $idev user list 1|grep ^$USERSLOT|awk '{print $6}'`
if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then
while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do
sleep 1
+17 -88
View File
@@ -4,13 +4,11 @@
# Bug reported by Jeff Lang <jrlang@uwyo.edu>. Thanks, Jeff!
#
modprobe acpi_cpufreq 2>/dev/null # on some machines this fails
modprobe acpi_cpufreq
modprobe cpufreq_ondemand
if ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &>/dev/null; then
for gov in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo -n ondemand > $gov
done
fi
for gov in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo -n ondemand > $gov
done
if [ ! -z "$BOOTIF" ]; then
BOOTIF=`echo $BOOTIF|sed -e s/01-// -e s/-/:/g`
echo -n "Waiting for device with address $BOOTIF to appear.."
@@ -76,91 +74,22 @@ echo '};' >> /var/lib/lldpad/lldpad.conf
done
echo '};' >> /var/lib/lldpad/lldpad.conf
lldpad -d
# Caclulate the broadcast address of a given IP address and mask.
bcastcalc(){
read oct1 oct2 oct3 oct4 << HERE
$(echo "$1" | sed -e 's/\./ /g')
HERE
read msk1 msk2 msk3 msk4 << HERE
$(echo "$2" | sed -e 's/\./ /g')
HERE
ipa=$(($oct1+(255-($oct1 | $msk1))))
ipb=$(($oct2+(255-($oct2 | $msk2))))
ipc=$(($oct3+(255-($oct3 | $msk3))))
ipd=$(($oct4+(255-($oct4 | $msk4))))
echo "$ipa.$ipb.$ipc.$ipd"
}
# Calculates the number of bits in a netmask for converting something like 255.255.255.192 to 26 so
# you can use the notation 10.0.0.1/26
mask2prefix() {
nbits=0
old_ifs=$IFS
IFS=.
for dec in $1 ; do
case $dec in
255) let nbits+=8;;
254) let nbits+=7;;
252) let nbits+=6;;
248) let nbits+=5;;
240) let nbits+=4;;
224) let nbits+=3;;
192) let nbits+=2;;
128) let nbits+=1;;
0);;
*) echo "Error: $dec is not recognised"; exit 1
esac
done
IFS=$old_ifs
echo "$nbits"
}
# see if they specified static ip info, otherwise use dhcp
for parm in `cat /proc/cmdline`; do
key=`echo $parm|awk -F= '{print $1}'`
value=`echo $parm|awk -F= '{print $2}'`
if [[ ${key,,} == "hostip" || ${key,,} == "ipaddr" ]]; then
hostip=$value
elif [[ ${key,,} == "netmask" ]]; then
netmask=$value
elif [[ ${key,,} == "gateway" ]]; then
gateway=$value
elif [[ ${key,,} == "netdevice" || ${key,,} == "device" ]]; then
netdevice=$value
fi
dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic &
#we'll kick of IPv6 and IPv4 on all nics, but not wait for them to come up unless doing discovery, to reduce
#chances that we'll perform a partial discovery
#in other scenarios where downed non-bootnics cause issues, will rely on retries to fix things up
dhclient -6 -pf /var/run/dhclient6.$bootnic.pid $bootnic -lf /var/lib/dhclient/dhclient6.leases &
NICSTOBRINGUP=`ip link|grep mtu|grep -v LOOPBACK|grep -v $bootnic|grep -v usb|grep -v ,UP|awk -F: '{print $2}'`
export NICSTOBRINGUP
for nic in $NICSTOBRINGUP; do
(while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$nic.pid $nic ) &
(while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -6 -pf /var/run/dhclient6.$nic.pid -lf /var/lib/dhclient/dhclient6.leases $nic ) &
done
if [[ -n $hostip && -n $netmask && -n $gateway && -n $netdevice ]]; then
# doing static ip
numbits=$(mask2prefix $netmask)
broadcast=$(bcastcalc $hostip $netmask)
echo "Setting static IP=$hostip/$numbits broadcast=$broadcast gateway=$gateway netdevice=$netdevice ..."
ip addr add $hostip/$numbits broadcast $broadcast dev $netdevice scope global label $netdevice
ip link set $netdevice up
ip route replace to default via $gateway dev $netdevice
# in softlayer it takes up to 60 seconds for the nic to actually be able to communicate
echo -n Waiting to reach xCAT mgmt node $gateway.
xcatretries=60
while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $gateway >/dev/null 2>&1; do echo -n .; done
if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi
sleep 3
else
echo "Setting IP via DHCP..."
dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic &
#we'll kick of IPv6 and IPv4 on all nics, but not wait for them to come up unless doing discovery, to reduce
#chances that we'll perform a partial discovery
#in other scenarios where downed non-bootnics cause issues, will rely on retries to fix things up
dhclient -6 -pf /var/run/dhclient6.$bootnic.pid $bootnic -lf /var/lib/dhclient/dhclient6.leases &
NICSTOBRINGUP=`ip link|grep mtu|grep -v LOOPBACK|grep -v $bootnic|grep -v usb|grep -v ,UP|awk -F: '{print $2}'`
export NICSTOBRINGUP
for nic in $NICSTOBRINGUP; do
(while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$nic.pid $nic ) &
(while ! ethtool $nic | grep Link\ detected|grep yes > /dev/null; do sleep 5; done; dhclient -cf /etc/dhclient.conf -6 -pf /var/run/dhclient6.$nic.pid -lf /var/lib/dhclient/dhclient6.leases $nic ) &
done
fi
openssl genrsa -out /etc/xcat/certkey.pem 4096 > /dev/null 2>&1 &
gripeiter=101
echo -n "Acquiring network addresses.."
while ! ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet > /dev/null; do
+1 -1
View File
@@ -7,6 +7,6 @@ Standards-Version: 3.7.2
Package: xcat-server
Architecture: all
Depends: ${perl:Depends}, grub2-xcat, perl-xcat (>= 2.5.0-1), xcat-client (>= 2.5.0-1), libsys-syslog-perl, libio-socket-ssl-perl, libxml-simple-perl, make, libdbd-sqlite3-perl, libexpect-perl, libnet-dns-perl, libsoap-lite-perl, libxml-libxml-perl, libsnmp-perl, debootstrap, libdigest-sha-perl,libcrypt-rijndael-perl,libcrypt-cbc-perl
Depends: ${perl:Depends}, grub2-xcat, perl-xcat (>= 2.5.0-1), xcat-client (>= 2.5.0-1), libsys-syslog-perl, libio-socket-ssl-perl, libxml-simple-perl, make, libdbd-sqlite3-perl, libexpect-perl, libnet-dns-perl, libsoap-lite-perl, libxml-libxml-perl, libsnmp-perl, debootstrap, libdigest-sha-perl
Description: Server and configuration utilities of the xCAT management project
xCAT-server provides the core server and configuration management components of xCAT. This package should be installed on your management server
+5 -13
View File
@@ -122,7 +122,6 @@ sub new {
unless ($ipmi2support) {
$self->{ipmi15only} = 1;
}
$self->{privlevel} = 4;
unless ($args{'bmc'} and defined $args{'userid'} and defined $args{'password'}) {
$self->{error}="bmc, userid, and password must be specified";
return $self;
@@ -310,7 +309,7 @@ sub session_activated {
sub set_admin_level {
my $self= shift;
$self->subcmd(netfn=>0x6,command=>0x3b,data=>[$self->{privlevel}],callback=>\&admin_level_set,callback_args=>$self);
$self->subcmd(netfn=>0x6,command=>0x3b,data=>[4],callback=>\&admin_level_set,callback_args=>$self);
}
sub admin_level_set {
my $rsp = shift;
@@ -688,7 +687,7 @@ sub send_rakp3 {
$self->{rmcptag}+=1;
my @payload = ($self->{rmcptag},0,0,0,@{$self->{pendingsessionid}});
my @user = unpack("C*",$self->{userid});
push @payload,unpack("C*",hmac_sha1(pack("C*",@{$self->{remoterandomnumber}},@{$self->{sidm}},$self->{privlevel},scalar @user,@user),$self->{password}));
push @payload,unpack("C*",hmac_sha1(pack("C*",@{$self->{remoterandomnumber}},@{$self->{sidm}},4,scalar @user,@user),$self->{password}));
$self->sendpayload(payload=>\@payload,type=>$payload_types{'rakp3'});
}
@@ -702,7 +701,7 @@ sub send_rakp1 {
push @{$self->{randomnumber}},$randomnumber;
}
push @payload, @{$self->{randomnumber}};
push @payload,($self->{privlevel},0,0); # request priv
push @payload,(4,0,0); # request admin
my @user = unpack("C*",$self->{userid});
push @payload,scalar @user;
push @payload,@user;
@@ -818,13 +817,6 @@ sub got_rakp2 {
}
$byte = shift @data;
unless ($byte == 0x00) {
if ($byte == 0x9 and $self->{privlevel} == 4) {
# this is probably an environment that wants to give us only operator
# try to connect again at 3.
$self->{privlevel} = 3;
$self->relog();
return;
}
if ($byte == 0x02) { #invalid session id is almost certainly because a retry on rmcp+ open session response rendered our session id invalid, ignore this in the hope that we'll get an answer for our retry that invalidated us..
#$self->relog();
#TODO: probably should disable RAKP1 retry here... high likelihood that we'll just spew a bad RAKP1 and Open Session Request retry would be more appropriate to try to discern a valid session id
@@ -849,7 +841,7 @@ sub got_rakp2 {
#Data now represents authcode.. sha1 only..
my @user = unpack("C*",$self->{userid});
my $ulength = scalar @user;
my $hmacdata = pack("C*",(@{$self->{sidm}},@{$self->{pendingsessionid}},@{$self->{randomnumber}},@{$self->{remoterandomnumber}},@{$self->{remoteguid}},$self->{privlevel},$ulength,@user));
my $hmacdata = pack("C*",(@{$self->{sidm}},@{$self->{pendingsessionid}},@{$self->{randomnumber}},@{$self->{remoterandomnumber}},@{$self->{remoteguid}},4,$ulength,@user));
my @expectedhash = (unpack("C*",hmac_sha1($hmacdata,$self->{password})));
foreach (0..(scalar(@expectedhash)-1)) {
if ($expectedhash[$_] != $data[$_]) {
@@ -858,7 +850,7 @@ sub got_rakp2 {
return 9;
}
}
$self->{sik} = hmac_sha1(pack("C*",@{$self->{randomnumber}},@{$self->{remoterandomnumber}},$self->{privlevel},$ulength,@user),$self->{password});
$self->{sik} = hmac_sha1(pack("C*",@{$self->{randomnumber}},@{$self->{remoterandomnumber}},4,$ulength,@user),$self->{password});
$self->{k1} = hmac_sha1(pack("C*",1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),$self->{sik});
$self->{k2} = hmac_sha1(pack("C*",2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2),$self->{sik});
my @aeskey = unpack("C*",$self->{k2});
+1 -3
View File
@@ -1392,9 +1392,7 @@ sub collect_all_attribs_for_tables_in_template
$::GLOBAL_TAB_HASH{$tabname}{$node}{$attrib} = $ent->{$node}->[0]->{$attrib};
#for noderes.xcatmaster
if ($tabname =~ /^noderes$/ && $attrib =~ /^xcatmaster$/ &&
( ! exists($::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster}) ||
$::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster} == "" ) )
if ($tabname =~ /^noderes$/ && $attrib =~ /^xcatmaster$/ && ! exists($::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster}))
{
my $value;
$value = xCAT::NetworkUtils->my_ip_facing($node);
-1
View File
@@ -115,7 +115,6 @@ sub run_remote_shell_api {
my $rc=1;
if ($t) {
#Wait for command prompt
$t->print("\t");
my ($prematch, $match) = $t->waitfor(Match => '/login[: ]*$/i',
Match => '/username[: ]*$/i',
Match => '/password[: ]*$/i',
+5 -266
View File
@@ -14,7 +14,6 @@ use xCAT::ADUtils; #to allow setting of one-time machine passwords
use xCAT::Utils;
use xCAT::TableUtils;
use xCAT::NetworkUtils;
use XML::Simple;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
@@ -104,13 +103,6 @@ sub subvars {
$ENV{NODESTATUS}=$tmp;
}
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;
@@ -237,7 +229,6 @@ sub subvars {
$inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg;
$inc =~ s/#COMMAND:([^#]+)#/command($1)/eg;
$inc =~ s/#KICKSTARTNET#/kickstartnetwork()/eg;
$inc =~ s/#YAST2NET#/yast2network()/eg;
$inc =~ s/#ESXIPV6SETUP#/esxipv6setup()/eg;
$inc =~ s/#WINTIMEZONE#/xCAT::TZUtils::get_wintimezone()/eg;
$inc =~ s/#WINPRODKEY:([^#]+)#/get_win_prodkey($1)/eg;
@@ -281,9 +272,7 @@ sub subvars {
my $tempstr = "%include /tmp/partitionfile\n";
$inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/;
#modify the content in the file, and write into %pre part
#$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n";
$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent .= "chmod 755 /tmp/partscript\n";
$partcontent .= "/tmp/partscript\n";
#replace the #XCA_PARTITION_SCRIPT#
@@ -293,8 +282,7 @@ sub subvars {
elsif ($inc =~ /<!-- XCAT-PARTITION-START -->/){
my $tempstr = "<drive><device>XCATPARTITIONTEMP</device></drive>";
$inc =~ s/<!-- XCAT-PARTITION-START -->[\s\S]*<!-- XCAT-PARTITION-END -->/$tempstr/;
#$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent = "echo " . "'". $partcontent . "'" . ">/tmp/partscript\n";
$partcontent = "cat > /tmp/partscript << EOFEOF\n" . $partcontent . "\nEOFEOF\n";
$partcontent .= "chmod 755 /tmp/partscript\n";
$partcontent .= "/tmp/partscript\n";
$inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/;
@@ -663,12 +651,9 @@ sub esxipv6setup {
return 'esxcfg-vmknic -i '.$v6addr.'/64 "Management Network"'." #ESXISTATICV6\n";
}
sub kickstartnetwork {
my $line = "network --onboot=yes --bootproto=";
my $hoststab;
my $line = "network --onboot=yes --bootproto=";
my $hoststab;
my $mactab = xCAT::Table->new('mac',-create=>0);
unless ($mactab) { die "mac table should always exist prior to template processing when doing autoula"; }
my $ent = $mactab->getNodeAttribs($node,['mac'],prefetchcache=>1);
@@ -682,258 +667,12 @@ sub kickstartnetwork {
$hoststab->setNodeAttribs($node,{ip=>$ulaaddr});
$line .= $ulaaddr;
} elsif ($::XCATSITEVALS{managedaddressmode} =~ /static/) {
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) { die "cannot resolve the network configuration of $node"; }
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
$line .="static --device=$suffix --ip=$ipaddr --netmask=$netmask --gateway=$gateway --hostname=$hostname ";
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
if (scalar @nameserversIP) {
$line .=" --nameserver=". join(",",@nameserversIP);
}
#return "#KSNET static unsupported";
return "#KSNET static unsupported";
} else {
$line .= "dhcp --device=$suffix";
}
return $line;
}
sub yast2network {
my $line;
my $hoststab;
my $mactab = xCAT::Table->new('mac',-create=>0);
unless ($mactab) { die "mac table should always exist prior to template processing when doing autoula"; }
my $ent = $mactab->getNodeAttribs($node,['mac'],prefetchcache=>1);
unless ($ent and $ent->{mac}) { die "missing mac data for $node"; }
my $suffix = $ent->{mac};
$suffix = lc($suffix);
if ($::XCATSITEVALS{managedaddressmode} eq "autoula") {
#TODO
return "#YAST2NET autoula unsupported"
} elsif ($::XCATSITEVALS{managedaddressmode} =~ /static/) {
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) { die "cannot resolve the network configuration of $node"; }
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
# get the domains for each node - one call for all nodes in hosts file
my $nd = xCAT::NetworkUtils->getNodeDomains([$node]);
my %nodedomains = %$nd;
my $domain=$nodedomains{$node};
my $networkhash={
'networking' => [
{
'dns' => [
{
'domain' => [
"$domain"
],
'dhcp_hostname' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'dhcp_resolv' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'nameservers' => [
{
'config:type' => 'list',
'nameserver' => [@nameserversIP]
}
],
'hostname' => [
$hostname
],
'searchlist' => [
{
'search' => [
$domain
],
'config:type' => 'list'
}
]
}
],
'interfaces' => [
{
'interface' => [
{
'bootproto' => [
'static'
],
'startmode' => [
'onboot'
],
'netmask' => [
$netmask
],
'device' => [
'eth0'
],
'ipaddr' => [
$ipaddr
]
}
],
'config:type' => 'list'
}
],
'routing' => [
{
'ip_forward' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'routes' => [
{
'route' => [
{
'destination' => [
'default'
],
'gateway' => [
$gateway
],
'netmask' => [
'-'
],
'device' => [
'-'
]
}
],
'config:type' => 'list'
}
]
}
]
}
]
};
my $xml = new XML::Simple(KeepRoot => 1);
$line=$xml->XMLout($networkhash);
#return "#KSNET static unsupported";
} else {
my $networkhash={
'networking' => [
{
'dns' => [
{
'domain' => [
'local'
],
'dhcp_hostname' => [
{
'content' => 'true',
'config:type' => 'boolean'
}
],
'hostname' => [
'linux'
],
'dhcp_resolv' => [
{
'content' => 'true',
'config:type' => 'boolean'
}
]
}
],
'interfaces' => [
{
'interface' => [
{
'startmode' => [
'onboot'
],
'bootproto' => [
'dhcp'
],
'device' => [
'eth0'
]
}
],
'config:type' => 'list'
}
],
'routing' => [
{
'ip_forward' => [
{
'content' => 'false',
'config:type' => 'boolean'
}
],
'routes' => [
{
'config:type' => 'list'
}
]
}
]
}
]
};
my $xml = new XML::Simple(KeepRoot => 1);
$line=$xml->XMLout($networkhash);
}
return $line;
}
sub autoulaaddress {
my $suffix = shift;
my $prefix = $::XCATSITEVALS{autoulaprefix};
+14 -29
View File
@@ -379,7 +379,8 @@ sub parse_attr_for_osimage{
sub processArgs
{
my $gotattrs = 0;
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
} else {
if ($::command eq "lsdef") {
@@ -390,9 +391,8 @@ sub processArgs
return 2;
}
}
if ( defined ($::args) && @{$::args} ) {
if ( scalar(@{$::args}) eq 1 and $::args->[0] eq '-S')
{
if ( scalar(@{$::args}) eq 1 and $::args->[0] eq '-S')
{
if ($::command eq "lsdef") {
push @ARGV, "-t";
push @ARGV, "node";
@@ -400,7 +400,6 @@ sub processArgs
} else {
return 2;
}
}
}
if ($::command eq "lsdef") {
@@ -2464,21 +2463,15 @@ sub defch
# give results
my $rsp;
my $nodenum = scalar(keys %::FINALATTRS);
if ($nodenum) {
$rsp->{data}->[0] =
"The database was updated for the following objects:";
xCAT::MsgUtils->message("I", $rsp, $::callback);
$rsp->{data}->[0] =
"The database was updated for the following objects:";
xCAT::MsgUtils->message("I", $rsp, $::callback);
my $n = 1;
foreach my $o (sort(keys %::FINALATTRS))
{
$rsp->{data}->[$n] = "$o\n";
$n++;
}
} else {
$rsp->{data}->[0] =
"No database was updated";
my $n = 1;
foreach my $o (sort(keys %::FINALATTRS))
{
$rsp->{data}->[$n] = "$o\n";
$n++;
}
xCAT::MsgUtils->message("I", $rsp, $::callback);
}
@@ -2486,13 +2479,8 @@ sub defch
{
my $rsp;
my $nodenum = scalar(keys %::FINALATTRS);
if ($nodenum) {
$rsp->{data}->[0] =
"$nodenum object definitions have been created or modified.";
} else {
$rsp->{data}->[0] =
"No object definitions have been created or modified.";
}
$rsp->{data}->[0] =
"$nodenum object definitions have been created or modified.";
xCAT::MsgUtils->message("I", $rsp, $::callback);
if (scalar(keys %newobjects) > 0)
{
@@ -2640,9 +2628,6 @@ sub setFINALattrs
{
# special case for the nic* attributes
# merge nic*.eth0, nic*.eth1
unless(exists($::CLIATTRS{$objname})) {
next;
}
if ($::CLIATTRS{$objname}{objtype} eq 'node')
{
# Even if only the nicips.eth0 is specified with CLI,
+2 -1
View File
@@ -232,7 +232,8 @@ sub parse_args
my $args = $request->{arg};
my $gotattrs = 0;
my %opt =();
if ( defined ($args) && @{$args}) {
if (defined(@{$args})) {
@ARGV = @{$args};
} else {
return 2;
+14 -21
View File
@@ -154,13 +154,6 @@ sub preprocess_request
# - either the NIMprime attr of the site table or the management node
my $nimprime = xCAT::InstUtils->getnimprime();
chomp $nimprime;
if (!defined($nimprime))
{
my $rsp={};
$rsp->{error}->[0] = "Could not determine nimprime. Check if nimprime defined in site table or site table master is not resolvable to the MN name.";
xCAT::MsgUtils->message("E", $rsp, $cb,1);
return undef;
}
my $nimprimeip = xCAT::NetworkUtils->getipaddr($nimprime);
if ($nimprimeip =~ /:/) #IPv6
{
@@ -624,7 +617,7 @@ sub nimnodeset
my $Sname = xCAT::InstUtils->myxCATname();
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -1800,7 +1793,7 @@ sub chkosimage
my $image_name;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -2267,7 +2260,7 @@ sub mknimimage
my $dump_name;
my $install_dir = xCAT::TableUtils->getInstallDir();
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -4240,7 +4233,7 @@ sub mk_spot
if ($::RUNCMD_RC != 0)
{
my $rsp;
push @{$rsp->{data}}, " The cpcosi command failed. \n$output\n";
push @{$rsp->{data}}, " The cpcosi command failed. \n$output\n";
push @{$rsp->{data}},
"Could not create a NIM definition for \'$spot_name\'.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
@@ -5705,7 +5698,7 @@ sub prermnimimage
my @servicenodes = (); # pass back list of service nodes
my %imagedef; # pass back image def hash
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -6215,7 +6208,7 @@ sub rmnimimage
%allsn = %{$nodehash};
}
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -7822,7 +7815,7 @@ sub prenimnodecust
@nodelist = @$nodes;
}
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -8060,7 +8053,7 @@ sub nimnodecust
@nodelist = @$nodes;
}
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -8217,7 +8210,7 @@ sub prenimnodeset
my $subreq = shift;
my $error = 0;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -9944,7 +9937,7 @@ sub define_SN_resource
}
my %attrs;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -10983,7 +10976,7 @@ sub mkdsklsnode
# - just set global for now
$::callback = $callback;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -12993,7 +12986,7 @@ sub make_SN_resource
}
my %attrs;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -13653,7 +13646,7 @@ sub prermdsklsnode
{
my $callback = shift;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
@@ -13763,7 +13756,7 @@ sub rmdsklsnode
# - just set global for now
$::callback = $callback;
if ( defined ($::args) && @{$::args} )
if (defined(@{$::args}))
{
@ARGV = @{$::args};
}
+2 -50
View File
@@ -1381,24 +1381,18 @@ sub mkinstall
$instserver=$ent->{nfsserver};
}
if ($::XCATSITEVALS{managedaddressmode} =~ /static/){
unless($instserver eq '!myipfn!'){
my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($instserver);
$instserver=$ip;
}
}
my $httpprefix=$pkgdir;
if ($installroot =~ /\/$/) {
$httpprefix =~ s/^$installroot/\/install\//;
} else {
$httpprefix =~ s/^$installroot/\/install/;
}
my $kcmdline;
if ($pkvm) {
$kcmdline = "ksdevice=bootif kssendmac text selinux=0 rd.dm=0 rd.md=0 repo=$httpmethod://$instserver:$httpport$httpprefix/packages/ kvmp.inst.auto=$httpmethod://$instserver:$httpport/install/autoinst/$node root=live:$httpmethod://$instserver:$httpport$httpprefix/LiveOS/squashfs.img";
} else {
$kcmdline ="quiet repo=$httpmethod://$instserver:$httpport$httpprefix ks=$httpmethod://"
$kcmdline =
"quiet repo=$httpmethod://$instserver:$httpport$httpprefix ks=$httpmethod://"
. $instserver . ":". $httpport
. "/install/autoinst/"
. $node;
@@ -1452,48 +1446,6 @@ sub mkinstall
unless ($ksdev eq "bootif" and $os =~ /7/) {
$kcmdline .= " ksdevice=" . $ksdev;
}
#if site.managedaddressmode=static, specify the network configuration as kernel options
#to avoid multicast dhcp
if($::XCATSITEVALS{managedaddressmode} =~ /static/){
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) {
$callback->(
{
error => [
"cannot resolve the ip address of $node"
],
errorcode => [1]
}
);
}
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
$kcmdline .=" ip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname ";
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
if(scalar @nameserversIP){
$kcmdline .=" dns=".join(",",@nameserversIP);
}
}
#TODO: dd=<url> for driver disks
if (defined($sent->{serialport}))
+187 -188
View File
@@ -51,7 +51,7 @@ sub getzonesfornet {
die "Not supporting having a mask like $mask on an ipv6 network like $net";
}
my $netnum= getipaddr($net,GetNumber=>1);
unless ($netnum) { return (); }
unless ($netnum) { return (); }
$netnum->brsft(128-$maskbits);
my $prefix=$netnum->as_hex();
my $nibbs=$maskbits/4;
@@ -229,7 +229,7 @@ sub process_request {
}
}
if ($::XCATSITEVALS{externaldns}) {
$external=1;
$external=1;
}
if ($help)
@@ -325,73 +325,73 @@ sub process_request {
if ($allnodes) {
#read all nodelist specified nodes
} else {
if (not $request->{node} and $deletemode) {
#when this was permitted, it really ruined peoples' days
xCAT::SvrUtils::sendmsg([1,"makedns -d without noderange or -a is not supported"],$callback);
umask($oldmask);
return;
}
my @contents;
my $domain;
if ($request->{node}) { #leverage makehosts code to flesh out the options
require xCAT_plugin::hosts;
my @content1;
my @content2;
xCAT_plugin::hosts::add_hosts_content(nodelist=>$request->{node},callback=>$callback,hostsref=>\@content1);
xCAT_plugin::hosts::donics(nodes=>$request->{node},callback=>$callback,hostsref=>\@content2);
if (not $request->{node} and $deletemode) {
#when this was permitted, it really ruined peoples' days
xCAT::SvrUtils::sendmsg([1,"makedns -d without noderange or -a is not supported"],$callback);
umask($oldmask);
return;
}
my @contents;
my $domain;
if ($request->{node}) { #leverage makehosts code to flesh out the options
require xCAT_plugin::hosts;
my @content1;
my @content2;
xCAT_plugin::hosts::add_hosts_content(nodelist=>$request->{node},callback=>$callback,hostsref=>\@content1);
xCAT_plugin::hosts::donics(nodes=>$request->{node},callback=>$callback,hostsref=>\@content2);
@contents = (@content1, @content2);
} else {
#legacy behavior, read from /etc/hosts
my $hostsfile;
open($hostsfile,"<","/etc/hosts");
flock($hostsfile,LOCK_SH);
@contents = <$hostsfile>;
flock($hostsfile,LOCK_UN);
close($hostsfile);
}
} else {
#legacy behavior, read from /etc/hosts
my $hostsfile;
open($hostsfile,"<","/etc/hosts");
flock($hostsfile,LOCK_SH);
@contents = <$hostsfile>;
flock($hostsfile,LOCK_UN);
close($hostsfile);
}
my $addr;
my $name;
my $canonical;
my $aliasstr;
my @aliases;
my $names;
my @hosts;
my %nodehash;
foreach (@contents) {
chomp; #no newline
s/#.*//; #strip comments;
s/^[ \t\n]*//; #remove leading whitespace
next unless ($_); #skip empty lines
($addr,$names) = split /[ \t]+/,$_,2;
if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/ and $addr !~ /^[abcdef0123456789:]+$/) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, address seems malformed.", $callback);
next;
}
unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback);
next;
}
my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr);
push @hosts, $host;
$nodehash{$addr}{names}=$names;
$nodehash{$addr}{host}=$host;
}
my @hosts;
my %nodehash;
# get the domains for each node - one call for all nodes in hosts file
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
foreach my $n (keys %nodehash) {
$addr=$n;
$names=$nodehash{$n}{names};
# - need domain for this node
my $host = $nodehash{$n}{host};
$domain=$nodedomains{$host};
# remove the first . at domain name since it's not accepted by high dns parser
if ($domain =~ /^\./) { $domain =~ s/^\.//;; }
foreach (@contents) {
chomp; #no newline
s/#.*//; #strip comments;
s/^[ \t\n]*//; #remove leading whitespace
next unless ($_); #skip empty lines
($addr,$names) = split /[ \t]+/,$_,2;
if ($addr !~ /^\d+\.\d+\.\d+\.\d+$/ and $addr !~ /^[abcdef0123456789:]+$/) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, address seems malformed.", $callback);
next;
}
unless ($names =~ /^[a-z0-9\. \t\n-]+$/i) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback);
next;
}
my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr);
push @hosts, $host;
$nodehash{$addr}{names}=$names;
$nodehash{$addr}{host}=$host;
}
# get the domains for each node - one call for all nodes in hosts file
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
foreach my $n (keys %nodehash) {
$addr=$n;
$names=$nodehash{$n}{names};
# - need domain for this node
my $host = $nodehash{$n}{host};
$domain=$nodedomains{$host};
# remove the first . at domain name since it's not accepted by high dns parser
if ($domain =~ /^\./) { $domain =~ s/^\.//;; }
($canonical,$aliasstr) = split /[ \t]+/,$names,2;
if ($aliasstr) {
@@ -407,7 +407,7 @@ sub process_request {
unless ($canonical =~ /$domain/) {
$canonical.=".".$domain;
}
# for only the sake of comparison, ensure consistant dot suffix
# for only the sake of comparison, ensure consistant dot suffix
unless ($canonical =~ /\.\z/) { $canonical .= '.' }
foreach my $alias (@aliases) {
unless ($alias =~ /$domain/) {
@@ -419,13 +419,13 @@ sub process_request {
if ($alias eq $canonical) {
next;
}
# remember alias for CNAM records later
# remember alias for CNAM records later
$ctx->{aliases}->{$node}->{$alias}=1;
}
# exclude the nodes not belong to any nets defined in networks table
# because only the nets defined in networks table will be add
# zones later.
# zones later.
my $found = 0;
foreach (@networks)
{
@@ -508,13 +508,13 @@ sub process_request {
$ctx->{domain} =~ s/^\.//; # remove . if it's the first char of domain name
$ctx->{zonestotouch}->{$ctx->{domain}}=1;
foreach (@networks) {
if ($_->{domain}) {
$_->{domain} =~ s/^\.//; # remove . if it's the first char of domain name
$ctx->{zonestotouch}->{$_->{domain}}=1;
}
}
foreach (@networks) {
if ($_->{domain}) {
$_->{domain} =~ s/^\.//; # remove . if it's the first char of domain name
$ctx->{zonestotouch}->{$_->{domain}}=1;
}
}
xCAT::SvrUtils::sendmsg("Getting reverse zones, this may take several minutes for a large cluster.", $callback);
foreach (@nodes) {
@@ -528,10 +528,10 @@ sub process_request {
xCAT::SvrUtils::sendmsg("Completed getting reverse zones.", $callback);
if (1) {
#TODO: function to detect and return 1 if the master server is
# DNS SOA for all the zones we care about here, we are examining
#TODO: function to detect and return 1 if the master server is
# DNS SOA for all the zones we care about here, we are examining
# files to assure that our key is in named.conf, the zones we
# care about are there, and that if active directory is in use,
# care about are there, and that if active directory is in use,
# allow the domain controllers to update specific zones
@entries = xCAT::TableUtils->get_site_attribute("directoryprovider");
$site_entry = $entries[0];
@@ -541,13 +541,13 @@ sub process_request {
if ( defined($site_entry)) {
my @dservers = split /[ ,]/,$site_entry;
$ctx->{adservers} = \@dservers;
############################
# - should this include all domains?
# - multi-domains not supported with activedirectory
# - TODO in future release
###################
############################
# - should this include all domains?
# - multi-domains not supported with activedirectory
# - TODO in future release
###################
$ctx->{adzones} = {
"_msdcs.". $ctx->{domain} => 1,
"_sites.". $ctx->{domain} => 1,
@@ -556,51 +556,51 @@ sub process_request {
};
}
}
@entries = xCAT::TableUtils->get_site_attribute("dnsupdaters");
$site_entry = $entries[0];
if ( defined($site_entry) ) {
my @nservers = split /[ ,]/,$site_entry;
$ctx->{dnsupdaters} = \@nservers;
my @nservers = split /[ ,]/,$site_entry;
$ctx->{dnsupdaters} = \@nservers;
}
unless ($external) { # only generate the named.conf and zone files for xCAT dns when NOT using external dns
if ($zapfiles || $slave) { #here, we unlink all the existing files to start fresh
if (xCAT::Utils->isAIX())
unless ($external) {
if ($zapfiles || $slave) { #here, we unlink all the existing files to start fresh
if (xCAT::Utils->isAIX())
{
system("/usr/bin/stopsrc -s $service");
}
else
{
system("service $service stop"); #named may otherwise hold on to stale journal filehandles
}
my $conf = get_conf();
unlink $conf;
my $DBDir = get_dbdir();
foreach (<$DBDir/db.*>) {
unlink $_;
}
}
#We manipulate local namedconf
$ctx->{dbdir} = get_dbdir();
$ctx->{zonesdir} = get_zonesdir();
chmod 0775, $ctx->{dbdir}; # assure dynamic dns can actually execute against the directory
update_namedconf($ctx, $slave);
unless ($slave)
{
system("/usr/bin/stopsrc -s $service");
update_zones($ctx);
}
else
{
system("service $service stop"); #named may otherwise hold on to stale journal filehandles
}
my $conf = get_conf();
unlink $conf;
my $DBDir = get_dbdir();
foreach (<$DBDir/db.*>) {
unlink $_;
}
}
#We manipulate local namedconf
$ctx->{dbdir} = get_dbdir();
$ctx->{zonesdir} = get_zonesdir();
chmod 0775, $ctx->{dbdir}; # assure dynamic dns can actually execute against the directory
update_namedconf($ctx, $slave);
unless ($slave)
{
update_zones($ctx);
}
if ($ctx->{restartneeded}) {
xCAT::SvrUtils::sendmsg("Restarting $service", $callback);
if ($ctx->{restartneeded}) {
xCAT::SvrUtils::sendmsg("Restarting $service", $callback);
if (xCAT::Utils->isAIX())
{
#try to stop named
my $cmd = "/usr/bin/stopsrc -s $service";
my @output=xCAT::Utils->runcmd($cmd, 0);
$cmd = "/usr/bin/startsrc -s $service";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
@@ -624,7 +624,7 @@ sub process_request {
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
$cmd = "service $service start";
@output=xCAT::Utils->runcmd($cmd, 0);
$outp = join('', @output);
@@ -636,57 +636,56 @@ sub process_request {
return;
}
}
xCAT::SvrUtils::sendmsg("Restarting named complete", $callback);
}
}
xCAT::SvrUtils::sendmsg("Restarting named complete", $callback);
}
}
} else {
unless ($ctx->{privkey}) {
xCAT::SvrUtils::sendmsg([1,"Unable to update DNS due to lack of credentials in passwd to communicate with remote server"], $callback);
}
}
if ($slave)
{
return;
}
# check if named is active before update dns records.
unless ($external) { # only start xCAT local dns when NOT using external dns
if (xCAT::Utils->isAIX())
if (xCAT::Utils->isAIX())
{
my $cmd = "/usr/bin/lssrc -s $service |grep active";
my @output=xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
my $cmd = "/usr/bin/lssrc -s $service |grep active";
my @output=xCAT::Utils->runcmd($cmd, 0);
$cmd = "/usr/bin/startsrc -s $service";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
$cmd = "/usr/bin/startsrc -s $service";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
}
else
}
else
{
my $cmd = "service $service status|grep running";
my @output=xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC != 0)
{
my $cmd = "service $service status|grep running";
my @output=xCAT::Utils->runcmd($cmd, 0);
$cmd = "service $service start";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
$cmd = "service $service start";
@output=xCAT::Utils->runcmd($cmd, 0);
my $outp = join('', @output);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
my $rsp = {};
$rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return;
}
}
}
@@ -694,12 +693,12 @@ sub process_request {
#now we stick to Net::DNS style updates, with TSIG if possible. TODO: kerberized (i.e. Windows) DNS server support, maybe needing to use nsupdate -g....
if ($external)
{
# based on /etc/resolv.conf
# based on /etc/resolv.conf
$ctx->{resolver} = Net::DNS::Resolver->new();
}
else
{
# default to localhost
# default to localhost
$ctx->{resolver} = Net::DNS::Resolver->new(nameservers=>['127.0.0.1']);
}
@@ -717,9 +716,9 @@ sub get_zonesdir {
my @entries = xCAT::TableUtils->get_site_attribute("bindzones");
my $site_entry = $entries[0];
if ( defined($site_entry) ) {
$ZonesDir= $site_entry;
}
if ( defined($site_entry) ) {
$ZonesDir= $site_entry;
}
return "$ZonesDir";
}
@@ -728,16 +727,16 @@ sub get_conf {
my $conf="/etc/named.conf";
# is this ubuntu ?
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
$conf="/etc/bind/named.conf";
}
my @entries = xCAT::TableUtils->get_site_attribute("bindconf");
my $site_entry = $entries[0];
if ( defined($site_entry) ) {
$conf= $site_entry;
}
if ( defined($site_entry) ) {
$conf= $site_entry;
}
return "$conf";
}
@@ -747,9 +746,9 @@ sub get_dbdir {
my @entries = xCAT::TableUtils->get_site_attribute("binddir");
my $site_entry = $entries[0];
if ( defined($site_entry) ) {
$DBDir = $site_entry;
}
if ( defined($site_entry) ) {
$DBDir = $site_entry;
}
if ( -d "$DBDir" ) {
return "$DBDir"
@@ -790,13 +789,13 @@ sub update_zones {
my $name = hostname;
my $node = $name;
# get the domain for the node - which is the local hostname
my ($host, $nip) = xCAT::NetworkUtils->gethostnameandip($node);
my @hosts;
push (@hosts, $host);
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
my $domain = $nodedomains{$host};
# get the domain for the node - which is the local hostname
my ($host, $nip) = xCAT::NetworkUtils->gethostnameandip($node);
my @hosts;
push (@hosts, $host);
my $nd = xCAT::NetworkUtils->getNodeDomains(\@hosts);
my %nodedomains = %$nd;
my $domain = $nodedomains{$host};
xCAT::SvrUtils::sendmsg("Updating zones.", $callback);
@@ -830,7 +829,7 @@ sub update_zones {
my $serial = ($mday * 100) + (($mon + 1) * 10000) + (($year + 1900) * 1000000);
foreach $currzone (@neededzones) {
my $zonefilename = $currzone;
my $zonefilename = $currzone;
if ($currzone =~ /IN-ADDR\.ARPA/) {
$currzone =~ s/\.IN-ADDR\.ARPA.*//;
my @octets = split/\./,$currzone;
@@ -854,7 +853,7 @@ sub update_zones {
}
flock($zonehdl,LOCK_UN);
close($zonehdl);
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
chown(scalar(getpwnam('root')),scalar(getgrnam('bind')),$dbdir."/db.$zonefilename");
}
else{
@@ -890,7 +889,7 @@ sub update_namedconf {
$gotoptions=1;
my $skip=0;
do {
#push @newnamed,"\t\t//listen-on-v6 { any; };\n";
#push @newnamed,"\t\t//listen-on-v6 { any; };\n";
if ($ctx->{forwarders} and $line =~ /forwarders {/) {
push @newnamed,"\tforwarders \{\n";
$skip=1;
@@ -1006,11 +1005,11 @@ sub update_namedconf {
}
}
unless ($gotoptions) {
push @newnamed,"options {\n";
push @newnamed,"options {\n";
unless ($slave && xCAT::Utils->isLinux()) {
push @newnamed,"\tdirectory \"".$ctx->{zonesdir}."\";\n";
}
push @newnamed,"\t\t//listen-on-v6 { any; };\n";
push @newnamed,"\t\t//listen-on-v6 { any; };\n";
if ($ctx->{forwarders}) {
push @newnamed,"\tforwarders {\n";
foreach (@{$ctx->{forwarders}}) {
@@ -1129,7 +1128,7 @@ sub update_namedconf {
for my $l (@newnamed) { print $newnameconf $l; }
flock($newnameconf,LOCK_UN);
close($newnameconf);
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
if ( $distro =~ /ubuntu.*/i || $distro =~ /debian.*/i ){
chown (scalar(getpwnam('root')),scalar(getgrnam('bind')),$namedlocation);
}
else{
@@ -1157,9 +1156,9 @@ sub add_or_delete_records {
$ctx->{nsmap} = {}; #will store a map to known NS records to avoid needless redundant queries to sort nodes into domains
$ctx->{updatesbyzone}={}; #sort all updates into their respective zones for bulk update for fewer DNS transactions
# get node domains
my $nd = xCAT::NetworkUtils->getNodeDomains(\@{$ctx->{nodes}});
my %nodedomains = %{$nd};
# get node domains
my $nd = xCAT::NetworkUtils->getNodeDomains(\@{$ctx->{nodes}});
my %nodedomains = %{$nd};
foreach $node (@{$ctx->{nodes}}) {
my $name = $node;
@@ -1169,8 +1168,8 @@ sub add_or_delete_records {
next;
}
my $domain = $nodedomains{$node};
if ($domain =~ /^\./) { $domain =~ s/^\.//; } # remove . if it's the first char of domain name
my $domain = $nodedomains{$node};
if ($domain =~ /^\./) { $domain =~ s/^\.//; } # remove . if it's the first char of domain name
unless ($name =~ /$domain/) { $name .= ".".$domain } # $name needs to represent fqdn, but must preserve $node as a nodename for cfg lookup
@@ -1178,9 +1177,9 @@ sub add_or_delete_records {
@ips = ($ctx->{hoststab}->{$node}->[0]->{ip});
} else {
@ips = getipaddr($node,GetAllAddresses=>1);
if (not @ips and keys %{$ctx->{nodeips}->{$node}}) {
@ips = keys %{$ctx->{nodeips}->{$node}};
}
if (not @ips and keys %{$ctx->{nodeips}->{$node}}) {
@ips = keys %{$ctx->{nodeips}->{$node}};
}
if (!defined($ips[0])) {
xCAT::SvrUtils::sendmsg([1,"Unable to find an IP for $node in hosts table or via system lookup (i.e. /etc/hosts)"], $callback);
next;
@@ -1215,7 +1214,7 @@ sub add_or_delete_records {
}
my $zone;
foreach $zone (keys %{$ctx->{updatesbyzone}}) {
my $ip = xCAT::NetworkUtils->getipaddr($ctx->{nsmap}->{$zone});
my $ip = xCAT::NetworkUtils->getipaddr($ctx->{nsmap}->{$zone});
if( !defined $ip) {
xCAT::SvrUtils::sendmsg([1,"Please make sure $ctx->{nsmap}->{$zone} exist either in /etc/hosts or DNS."], $callback);
return 1;
@@ -1297,9 +1296,9 @@ sub find_nameserver_for_dns {
}
if (defined $ctx->{aliases}->{$node}) {
foreach (keys %{$ctx->{aliases}->{$node}}) {
push @rrcontent, "$_ IN CNAME $name";
}
foreach (keys %{$ctx->{aliases}->{$node}}) {
push @rrcontent, "$_ IN CNAME $name";
}
}
if ($ctx->{deletemode}) {
push @rrcontent,"$name TXT";
@@ -1312,7 +1311,7 @@ sub find_nameserver_for_dns {
unless (defined $ctx->{nsmap}->{$zone}) { #ok, we already thought about this zone and made a decision
if ($zone =~ /^\.*192.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*172.IN-ADDR.ARPA\.*/ or $zone =~ /127.IN-ADDR.ARPA\.*/ or $zone =~ /^\.*IN-ADDR.ARPA\.*/ or $zone =~ /^\.*ARPA\.*/) {
$ctx->{nsmap}->{$zone} = 0; #ignore zones that are likely to appear, but probably not ours
} elsif ($::XCATSITEVALS{ddnsserver}) {
} elsif ($::XCATSITEVALS{ddnsserver}) {
$ctx->{nsmap}->{$zone} = $::XCATSITEVALS{ddnsserver};
} else {
my $reply = $ctx->{resolver}->query($zone,'NS');
@@ -1393,9 +1392,9 @@ sub get_dns_slave
foreach my $sn (@ents)
{
if ($sn->{'nameserver'} == 2)
{
{
push @sns, $sn->{'node'};
}
}
}
@slaves = xCAT::NodeRange::noderange(join(',',@sns));
-1
View File
@@ -2647,7 +2647,6 @@ sub newconfig
push @dhcpconf, "#xCAT generated dhcp configuration\n";
push @dhcpconf, "\n";
push @dhcpconf, "authoritative;\n";
push @dhcpconf, "option conf-file code 209 = text;\n";
push @dhcpconf, "option space isan;\n";
push @dhcpconf, "option isan-encap-opts code 43 = encapsulate isan;\n";
push @dhcpconf, "option isan.iqn code 203 = string;\n";
+3 -4
View File
@@ -1332,7 +1332,7 @@ sub fpc_firmxfer_watch {
return;
}
my $percent = 0;
if ($rsp->{data} and (scalar(@{$rsp->{data}}) > 0)) {
if ($rsp->{data} and (length(@{$rsp->{data}}) > 0)) {
$percent = $rsp->{data}->[0];
}
#$callback->({sinfo=>"$percent%"});
@@ -2971,13 +2971,12 @@ sub parsefru {
my $currsize;
if ($bytes->[$curridx] <= 5) { #don't even try to parse unknown stuff
#some records don't comply to any SPEC
while (not $last and $curridx < (scalar @$bytes)) {
while (not $last) {
if ($bytes->[$curridx+1] & 128) {
$last=1;
}
$currsize=$bytes->[$curridx+2];
push @{$fruhash->{extra}},@{$bytes}[$curridx..$curridx+4+$currsize-1];
$curridx += 5 + $currsize;
push @{$fruhash->{extra}},$bytes->[$curridx..$curridx+4+$currsize-1];
}
}
}
+4 -3
View File
@@ -3563,7 +3563,8 @@ sub create_error_response {
#-----------------------------------------------------------------------------
sub lskit_processargs {
if ( defined ($::args) && @{$::args} ){
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
@@ -3664,7 +3665,7 @@ sub lskit_processargs {
#-----------------------------------------------------------------------------
sub lskitcomp_processargs {
if ( defined ($::args) && @{$::args} ){
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
@@ -3757,7 +3758,7 @@ sub lskitcomp_processargs {
#-----------------------------------------------------------------------------
sub lskitdeployparam_processargs {
if ( defined ($::args) && @{$::args} ){
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
+1 -1
View File
@@ -192,7 +192,7 @@ sub lskmodules_usage {
#-----------------------------------------------------------------------------
sub processArgs {
if ( defined ($::args) && @{$::args} ) {
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
+23 -52
View File
@@ -470,7 +470,26 @@ sub build_diskstruct {
my $currdev;
my @suffixes=('a','b','d'..'zzz');
my $suffidx=0;
my $storagemodel = $confdata->{vm}->{$node}->[0]->{storagemodel};
if ($cdloc) {
my $cdhash;
$cdhash->{device}='cdrom';
if ($cdloc =~ /^\/dev/) {
$cdhash->{type}='block';
} else {
$cdhash->{type}='file';
}
$cdhash->{source}->{file}=$cdloc;
$cdhash->{readonly};
$cdhash->{target}->{dev}='hdc';
push @returns,$cdhash;
} else { #give the VM an empty optical drive, to allow chvm live attach/remove
my $cdhash;
$cdhash->{device}='cdrom';
$cdhash->{type}='file';
$cdhash->{readonly};
$cdhash->{target}->{dev}='hdc';
push @returns,$cdhash;
}
my $cachemethod = "none";
if ( $confdata->{vm}->{$node}->[0]->{storagecache}) {
$cachemethod = $confdata->{vm}->{$node}->[0]->{storagecache};
@@ -487,7 +506,7 @@ sub build_diskstruct {
my $model = $1;
unless ($model) {
#if not defined, model will stay undefined like above
$model = $storagemodel;
$model = $confdata->{vm}->{$node}->[0]->{storagemodel};
unless ($model) { $model = 'ide'; } #if still not defined, ide
}
my $prefix='hd';
@@ -555,34 +574,6 @@ sub build_diskstruct {
push @returns,$diskhash;
}
}
my $cdprefix='hd';
if ($storagemodel eq 'virtio') {
$cdprefix='vd';
} elsif ($storagemodel eq 'scsi') {
$cdprefix='sd';
}
$suffidx += 1;
if ($cdloc) {
my $cdhash;
$cdhash->{device}='cdrom';
if ($cdloc =~ /^\/dev/) {
$cdhash->{type}='block';
} else {
$cdhash->{type}='file';
}
$cdhash->{source}->{file}=$cdloc;
$cdhash->{readonly};
$cdhash->{target}->{dev}=$cdprefix.$suffixes[$suffidx];
push @returns,$cdhash;
} else { #give the VM an empty optical drive, to allow chvm live attach/remove
my $cdhash;
$cdhash->{device}='cdrom';
$cdhash->{type}='file';
$cdhash->{readonly};
$cdhash->{target}->{dev}=$cdprefix.$suffixes[$suffidx];
push @returns,$cdhash;
}
return \@returns;
}
sub getNodeUUID {
@@ -663,16 +654,10 @@ sub build_xmldesc {
my %args=@_;
my $cdloc=$args{cd};
my %xtree=();
my $hypcpumodel = $confdata->{$confdata->{vm}->{$node}->[0]->{host}}->{cpumodel};
$xtree{type}='kvm';
$xtree{name}->{content}=$node;
$xtree{uuid}->{content}=getNodeUUID($node);
$xtree{os} = build_oshash();
if (defined($hypcpumodel) and $hypcpumodel eq "ppc64") {
$xtree{os}->{type}->{arch} = "ppc64";
$xtree{os}->{type}->{machine} = "pseries";
delete $xtree{os}->{bios};
}
if ($args{memory}) {
$xtree{memory}->{content}=getUnits($args{memory},"M",1024);
if ($confdata->{vm}->{$node}->[0]->{memory}) {
@@ -738,12 +723,8 @@ sub build_xmldesc {
} else {
$xtree{devices}->{graphics}->{password}=genpassword(20);
}
if (defined($hypcpumodel) and $hypcpumodel eq 'ppc64') {
$xtree{devices}->{emulator}->{content} = "/usr/bin/qemu-system-ppc64";
} else {
$xtree{devices}->{sound}->{model}='ac97';
}
$xtree{devices}->{sound}->{model}='ac97';
$xtree{devices}->{console}->{type}='pty';
$xtree{devices}->{console}->{target}->{port}='1';
return XMLout(\%xtree,RootName=>"domain");
@@ -3007,17 +2988,7 @@ sub dohyp {
return 1,"General error establishing libvirt communication";
}
}
if (($command eq 'mkvm' or $command eq 'chvm') and $hypconn) {
my $nodeinfo = $hypconn->get_node_info();
if (exists($nodeinfo->{model})) {
$confdata->{$hyp}->{cpumodel} = $nodeinfo->{model};
}
}
foreach $node (sort (keys %{$hyphash{$hyp}->{nodes}})) {
if ($confdata->{$hyp}->{cpumodel} and $confdata->{$hyp}->{cpumodel} =~ /ppc64/i) {
$confdata->{vm}->{$node}->[0]->{storagemodel} = "scsi";
}
my ($rc,@output) = guestcmd($hyp,$node,$command,@$args);
foreach(@output) {
+3 -2
View File
@@ -26,7 +26,8 @@ sub preprocess_request
my @requests = ({%$req}); #first element is local instance
$::args = $req->{arg};
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
}
@@ -87,7 +88,7 @@ sub process_request
$::args = $request->{arg};
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
}
+2 -2
View File
@@ -412,13 +412,13 @@ sub create_imgconf_file {
my $rootpw = undef;
my $passwdtab = xCAT::Table->new('passwd');
if ($passwdtab) {
my $et = $passwdtab->getAttribs({key => 'vios', username => 'padmin'}, 'password');
my $et = $passwdtab->getAttribs({key => 'system', username => 'root'}, 'password');
if ($et and defined ($et->{'password'})) {
$rootpw = $et->{'password'};
}
}
unless (defined($rootpw)) {
return "Unable to find requested password from passwd, with key=vios,username=padmin";
return "Unable to find requested password from passwd, with key=system,username=root";
}
unless (-e $bootimg_root."/viobootimg") {
return "Unable to find VIOS bootimg file";
+13 -15
View File
@@ -447,22 +447,20 @@ sub process_request {
if ($do_dhcpsetup) {
foreach my $node (@normalnodeset) {
my $server = xCAT::TableUtils->GetMasterNodeName($node);
my $ipfn = xCAT::NetworkUtils->my_ip_facing($server);
if(($server != 1) and defined($ipfn)) {
my $fpath = "http://$ipfn/tftpboot/petitboot/$node";
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=> [$node],
arg=>['-l','-s','option conf-file \"'.$fpath.'\";']},$callback);
} else {
$sub_req->({command=>['makedhcp'],
node=> [$node],
arg=>['-s','option conf-file \"'.$fpath.'\";']},$callback);
}
}
my $fpath = "http://9.3.190.175/tftpboot/petitboot/$node";
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=> [$node],
arg=>['-l','-s','conf-file = \"'.$fpath.'\";']},$callback);
} else {
$sub_req->({command=>['makedhcp'],
node=> [$node],
arg=>['-s','conf-file = \"'.$fpath.'\";']},$callback);
}
}
}
}
}
#now run the end part of the prescripts
+48 -62
View File
@@ -54,7 +54,6 @@ my $command;
my $args;
# Put arguments in a hash.
my %args_dict;
my %general_arg;
#-------------------------------------------------------
@@ -101,8 +100,6 @@ sub process_request {
$command = $request->{command}->[0];
$args = $request->{arg};
my $gereral_arg = get_general_args();
# There is no need to acquire lock for command nodediscoverstatus, nodediscoverls and noderegenips.
if ($command eq "nodediscoverstatus"){
nodediscoverstatus();
@@ -115,11 +112,7 @@ sub process_request {
return;
}
my $non_block = 1;
if ( $general_arg{'blockmode'} == 1) {
$non_block = 0;
}
my $lock = xCAT::Utils->acquire_lock("nodemgmt", $non_block);
my $lock = xCAT::Utils->acquire_lock("nodemgmt", 1);
if (! $lock){
setrsp_errormsg("Cannot acquire lock, another process is already running.");
return;
@@ -138,7 +131,7 @@ sub process_request {
);
setrsp_errormsg("Cannot $errormsg_dict{$command} while node discovery is running.");
xCAT::Utils->release_lock($lock, $non_block);
xCAT::Utils->release_lock($lock, 1);
return;
}
}
@@ -163,32 +156,7 @@ sub process_request {
nodechmac();
}
xCAT::Utils->release_lock($lock, $non_block);
}
sub get_general_args
{
my ($help, $ver, $blockmode);
%general_arg = ();
@ARGV = ();
if($args) {
@ARGV = @$args;
}
GetOptions(
'h|help' => \$help,
'v|version' => \$ver,
'b|block' => \$blockmode,
);
if($help){
$general_arg{'help'} = 1;
}
if($ver){
$general_arg{'version'} = 1;
}
if ($blockmode) {
$general_arg{'blockmode'} = 1;
}
xCAT::Utils->release_lock($lock, 1);
}
#-------------------------------------------------------
@@ -234,21 +202,37 @@ sub validate_args{
my $enabledparamsref = shift;
my $mandatoryparamsref = shift;
if ($general_arg{'help'} == 1){
my %process_help_commands = (
'nodediscoverstart' => 1,
'nodediscoverstop' => 1,
'nodediscoverls' => 1,
'nodediscoverstatus' => 1,
);
# The -h -v are handled by seqdiscovery.pm
# -t -u -l only works for nodediscoverls, and them only handled by seqdiscovery.pm
my ($help, $ver, $type, $uuid, $long);
# do not process help message for these noddiscover* commands, cover them in seqdiscovery.pm
unless ($process_help_commands{$command} == 1) {
setrsp_infostr($helpmsg);
return 0;
}
@ARGV = ();
if($args) {
@ARGV = @$args;
}
GetOptions(
'h|help' => \$help,
'v|version' => \$ver,
't=s' => \$type,
'u=s' => \$uuid,
'l' => \$long,
);
if($help){
# just return to make sequential discovery to handle it
return 0;
}
if($ver){
# just return to make sequential discovery to handle it
return 0;
}
if ($type || $uuid || $long) {
# these args for general discovery, return directly
return 0;
}
my $parseret = parse_args();
if ($parseret){
setrsp_errormsg($parseret);
@@ -498,8 +482,6 @@ Usage:
$warnstr = "Warning: failed to import some nodes.";
setrsp_progress($warnstr);
}
# setup node provisioning status.
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>\@nodelist, arg=>['defined']}, $request_command, -1, 2);
setrsp_progress("Configuring nodes...");
my $retref = xCAT::Utils->runxcmd({command=>["kitnodeadd"], node=>\@nodelist, sequential=>[1], macflag=>[$mac_addr_mode]}, $request_command, 0, 2);
@@ -744,6 +726,9 @@ Usage:
# Update nodes' attributes
foreach (@$nodes) {
$updatenodeshash{$_}{'groups'} .= $profile_groups;
if ($profile_status){
$updatenodeshash{$_}{'status'} = $profile_status;
}
}
#update DataBase.
@@ -752,11 +737,6 @@ Usage:
$nodetab->setNodesAttribs(\%updatenodeshash);
$nodetab->close();
#update node's status:
if($profile_status eq "defined"){
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>$nodes, arg=>['defined']}, $request_command, -1, 2);
}
my $retref;
my $retstrref;
# Call update plugins first.
@@ -1174,7 +1154,17 @@ Usage:
# Update node's status.
setrsp_progress("Updating node status...");
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>[$hostname], arg=>['defined']}, $request_command, -1, 2);
my $nodelisttab = xCAT::Table->new('nodelist',-create=>1);
my (
$sec, $min, $hour, $mday, $mon,
$year, $wday, $yday, $isdst
) = localtime(time);
my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d",
$mon + 1, $mday, $year + 1900,
$hour, $min, $sec);
$nodelisttab->setNodeAttribs($hostname, {status=>'defined', statustime=>$currtime});
$nodelisttab->close();
setrsp_progress("Updated MAC address.");
}
@@ -1450,9 +1440,7 @@ Usage:
my $mactab = xCAT::Table->new("mac");
my $macsref = $mactab->getNodesAttribs(\@nodes, ['mac']);
my $nodelisttab = xCAT::Table->new("nodelist");
# Get node current provisioning status.
my $provisionapp = "provision";
my $provision_status = xCAT::TableUtils->getAppStatus(\@nodes,$provisionapp);
my $statusref = $nodelisttab->getNodesAttribs(\@nodes, ['status']);
my $rspentry;
my $i = 0;
@@ -1473,8 +1461,8 @@ Usage:
}
}
if ($provision_status->{$_}){
$rspentry->{node}->[$i]->{"status"} = $provision_status->{$_};
if ($statusref->{$_}->[0]){
$rspentry->{node}->[$i]->{"status"} = $statusref->{$_}->[0]->{status};
} else{
$rspentry->{node}->[$i]->{"status"} = "defined";
}
@@ -1638,8 +1626,6 @@ sub findme{
}
my @nodelist = keys %hostinfo_dict;
# setup node provisioning status.
xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>\@nodelist, arg=>['defined']}, $request_command, -1, 2);
# call makehosts to get the IP by resolving the name
my $retref = xCAT::Utils->runxcmd({command=>["makehosts"], node=>\@nodelist, sequential=>[1]}, $request_command, 0, 2);
+1 -1
View File
@@ -250,7 +250,7 @@ sub runrollupdate_usage {
sub processArgs {
my $gotattrs = 0;
if ( defined ($::args) && @{$::args} ) {
if ( defined( @{$::args} ) ) {
@ARGV = @{$::args};
}
else {
-52
View File
@@ -956,8 +956,6 @@ sub mkinstall
my $tmppkgdir=$pkgdir;
my @srcdirs = split(",", $pkgdir);
$pkgdir = $srcdirs[0];
# trim the "/" in /install/sles11.3/x86_64/
$pkgdir =~ s/\/$//;
if( $pkgdir =~/^($installroot\/$os\/$arch)$/) {
$srcdirs[0]="$pkgdir/1";
$tmppkgdir=join(",", @srcdirs);
@@ -1074,14 +1072,6 @@ sub mkinstall
{
$netserver = $ent->{nfsserver};
}
if ($::XCATSITEVALS{managedaddressmode} =~ /static/){
unless($netserver eq '!myipfn!'){
my($host,$ip)=xCAT::NetworkUtils->gethostnameandip($netserver);
$netserver=$ip;
}
}
my $httpprefix = $pkgdir;
if ($installroot =~ /\/$/) { #must prepend /install/
$httpprefix =~ s/^$installroot/\/install\//;
@@ -1146,48 +1136,6 @@ sub mkinstall
$kcmdline .= " dud=file:/cus_driverdisk/$_";
}
#if site.managedaddressmode=static, specify the network configuration as kernel options
#to avoid multicast dhcp
if($::XCATSITEVALS{managedaddressmode} =~ /static/){
my ($ipaddr,$hostname,$gateway,$netmask)=xCAT::NetworkUtils->getNodeNetworkCfg($node);
unless($ipaddr) {
$callback->(
{
error => [
"cannot resolve the ip address of $node"
],
errorcode => [1]
}
);
}
if($gateway eq '<xcatmaster>'){
$gateway = xCAT::NetworkUtils->my_ip_facing($ipaddr);
}
$kcmdline .=" hostip=$ipaddr netmask=$netmask gateway=$gateway hostname=$hostname ";
my %nameservers=%{xCAT::NetworkUtils->getNodeNameservers([$node])};
my @nameserverARR=split (",",$nameservers{$node});
my @nameserversIP;
foreach (@nameserverARR)
{
my $ip;
if($_ eq '<xcatmaster>'){
$ip = xCAT::NetworkUtils->my_ip_facing($gateway);
}else{
(undef,$ip) = xCAT::NetworkUtils->gethostnameandip($_);
}
push @nameserversIP, $ip;
}
if(scalar @nameserversIP){
$kcmdline .=" dns=".join(",",@nameserversIP);
}
}
if (defined $sent->{serialport})
{
unless ($sent->{serialspeed})
-15
View File
@@ -2975,21 +2975,6 @@ sub getAttribs
# <comments>This is a comment</comments>
#</xcatrequest>
#
#
#<xcatrequest>
#<clienttype>PCM</clienttype>
#<command>setAttribs</command>
#<table>networks</table>
#<keys>
# <net>10.0.1.0</net>
# <mask>255.255.255.0</mask>
#</keys>
#<attr>
# <netname>mynet</netname>
# <gateway>10.0.1.254</gateway>
#</attr>
#</xcatrequest>
sub setAttribs
{
my $request = shift;
+32 -89
View File
@@ -14,7 +14,6 @@ use xCAT::Schema;
use Data::Dumper;
use xCAT::Utils;
use xCAT::SvrUtils;
use xCAT::Scope;
use xCAT::Usage;
use Storable qw(dclone);
use xCAT::TableUtils;
@@ -189,7 +188,6 @@ sub preprocess_updatenode
my @requests = ();
my $installdir = xCAT::TableUtils->getInstallDir();
my $localhost = hostname();
# subroutine to display the usage
sub updatenode_usage
@@ -253,40 +251,20 @@ sub preprocess_updatenode
$callback->($rsp);
return;
}
# preprocess generate mypostscripts files (-g) for hierarchy
# if no sharedtftp then we need to broadcast this updatenode -g to all service nodes inorder
# to be able to support service node pools
#
# Just generate mypostscripts file and get out
if ($::GENMYPOST)
{
# precreatemypostscript has to be yes/1 or do nothing
my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts");
if ($entries[0] ) {
$entries[0] =~ tr/a-z/A-Z/;
if ($entries[0] =~ /^(1|YES)$/ ) {
# now check if sharedtftp = 0, if it is we need to broadcast to all the servicenode
# if there are service nodes
my @entries = xCAT::TableUtils->get_site_attribute("sharedtftp");
my $t_entry = $entries[0];
if ( defined($t_entry) and ($t_entry eq "0" or $t_entry eq "no" or $t_entry eq "NO")) {
# see if there are any servicenodes. If so then run updatenode -g on all of them
my @SN;
my @CN;
my $nodes = $request->{node};
xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN);
if (@CN >0 ) { # if compute nodes broadcast to all servicenodes
return xCAT::Scope->get_broadcast_scope($request,@_);
}
} else { # sharedtftp=yes, just run on MN
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files on $localhost";
$callback->($rsp);
return 0;
}
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files";
$callback->($rsp);
} else { # not valid unless precreatemypostscripts enabled
my $rsp = {};
$rsp->{error}->[0] =
@@ -295,7 +273,7 @@ sub preprocess_updatenode
$callback->($rsp);
return ;
}
} else { # precreatemypostscripts not in the site table
} else { # not in the site table
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
@@ -303,9 +281,8 @@ sub preprocess_updatenode
$callback->($rsp);
return ;
}
} # end GENMYPOST
return 0;
}
# -c must work with -S for AIX node
if ($::CMDLINE && !$::SWMAINTENANCE)
@@ -1033,6 +1010,27 @@ sub updatenode
}
#create each /tftpboot/mypostscript/mypostscript.<nodename> for each node
# This first removes the old one if precreatemypostscripts =0 or undefined
# call create files but no tmp files
my $notmpfiles=1;
my $nofiles=0;
#my $nofiles=1;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
# convert the hashes back to the way they were passed in
my $flatreq = xCAT::InstUtils->restore_request($request, $callback);
my $imgdefs;
my $updates;
if ($flatreq->{imagedef})
{
$imgdefs = $flatreq->{imagedef};
}
if ($flatreq->{updateinfo})
{
$updates = $flatreq->{updateinfo};
}
# get the NIM primary server name
my $nimprime = xCAT::InstUtils->getnimprime();
chomp $nimprime;
@@ -1045,7 +1043,6 @@ sub updatenode
'A|updateallsw' => \$::ALLSW,
'c|cmdlineonly' => \$::CMDLINE,
'd=s' => \$::ALTSRC,
'g|genmypost' => \$::GENMYPOST,
'h|help' => \$::HELP,
'v|version' => \$::VERSION,
'V|verbose' => \$::VERBOSE,
@@ -1088,60 +1085,6 @@ sub updatenode
$::attrres{$attr} = $value;
}
}
# Just generate mypostscripts file and get out
if ($::GENMYPOST)
{
my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts");
if ($entries[0] ) {
$entries[0] =~ tr/a-z/A-Z/;
if ($entries[0] =~ /^(1|YES)$/ ) {
my $notmpfiles=1;
my $nofiles=0;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my $rsp = {};
$rsp->{data}->[0] = "Generated new mypostscript files on $localhostname";
$callback->($rsp);
} else { # not valid unless precreatemypostscripts enabled
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
$rsp->{errorcode}->[0] =1;
$callback->($rsp);
return ;
}
} else { # not in the site table
my $rsp = {};
$rsp->{error}->[0] =
"This option is only valid if site table precreatemypostscripts attribute is 1 or YES";
$rsp->{errorcode}->[0] =1;
$callback->($rsp);
return ;
}
return 0;
}
#create each /tftpboot/mypostscript/mypostscript.<nodename> for each node
# This first removes the old one if precreatemypostscripts =0 or undefined
# call create files but no tmp files
my $notmpfiles=1;
my $nofiles=0;
#my $nofiles=1;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
# convert the hashes back to the way they were passed in
my $flatreq = xCAT::InstUtils->restore_request($request, $callback);
my $imgdefs;
my $updates;
if ($flatreq->{imagedef})
{
$imgdefs = $flatreq->{imagedef};
}
if ($flatreq->{updateinfo})
{
$updates = $flatreq->{updateinfo};
}
# if not just using the -k flag, then set all nodes to syncing in
# nodelist updatestatus for the other updatenode options
if (!($::SECURITY)) {
File diff suppressed because it is too large Load Diff
-183
View File
@@ -1,183 +0,0 @@
#!/usr/bin/perl
package xCAT_plugin::vlan;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
use strict;
use warnings "all";
use xCAT::GlobalDef;
use xCAT::Utils;
use xCAT::TableUtils;
use xCAT::SvrUtils;
use xCAT::Usage;
use xCAT::NodeRange;
sub handled_commands {
return {
mkvlan => 'switch:vlan,port,switch', # in progress
chvlan => 'switch:vlan,port,switch', # in progress
lsvlan => 'switch:vlan,port,switch', # in progress
rmvlan => 'switch:vlan,port,switch', # in progress
}
}
use POSIX "WNOHANG";
use IO::Handle;
use IO::Socket;
use IO::Select;
#local to module
my $callback;
my $timeout;
my $port;
my $debug;
my $ndebug = 0;
my $sock;
my $noclose;
my %sessiondata; #hold per session variables, in preparation for single-process strategy
my %pendingtransactions; #list of peers with callbacks, callback arguments, and timer expiry data
my $enable_cache="yes";
my $cache_dir = "/var/cache/xcat";
my $vlanid;
sub process_request
{
my $req = shift;
my $callback = shift;
my $reqcmd = shift;
if ($command eq 'mkvlan')
{
return mkvlan($req, $callback, $reqcmd);
}
elsif ($command eq 'chvlan')
{
return chvlan($req, $callback, $reqcmd);
}
elsif ($command eq 'lsvlan')
{
return lsvlan($req, $callback, $reqcmd);
}
elsif ($command eq 'rmvlan')
{
return rmvlan($req, $callback, $reqcmd);
}
}
sub mkvlan
{
my $request = shift;
my $callback = shift;
my $reqcmd = shift;
# Variables for this function
my $vlanid;
# A quick function for usage information for the command
my $mkvlan_usage = sub {
my $exitcode = shift @_;
my %rsp;
push @{$rsp{data}}, "Usage: mkvlan [vlanid] -n noderange [-t subnet | -m netmask | -i interface]";
push @{$rsp{data}}, " mkvlan [-?|-h|--help]";
if ($exitcode) { $rsp{errorcode} = $exitcode; }
$callback->(\%rsp);
};
# Go through the arguments, and get the relevant information
@ARGV = @{$req->{arg}};
#Detect if the first variable is a number or not, as it may be the vlanid
if ($ARGV[0] !~ /\D/) {$vlanid=$ARGV[0];}
GetOptions(
't=s' => \$subnet,
'm=s' => \$mask,
'n=s' => \$noderange,
'i=s' => \$interface,
'h|?|help' => \$help,
'v|version' => \$VERSION,
);
# Show usage info if help is defined
if ($help) { $mkvlan_usage->(0); return;}
# Node range must be defined
if (!defined($noderange)) { $mkvlan_usage->(1); return;}
# Display the version of the code
if ($VERSION) {
my %rsp;
my $version = xCAT::Utils->Version();
$rsp{data}->[0] = "$version";
$cb->(\%rsp);
return;
}
# put the nodes in an array
my @nodes = split(/,/,$noderange);
my $swtab = xCAT::Table->new('switch');
my $swhash = $swtab->getNodesAttribs(\@nodes,['switch','vlan','port','interface']);
foreach (@nodes)
{
my $node = $_;
foreach (@$swhash->{$node})
{
my $nswhash = $_;
my $switch = $nswhash->{'switch'};
my $vlan = $nswhash->{'vlan'};
my $port = $nswhash->{'port'};
my $swinterface = $nswhash->{'interface'};
if ($vlanid == "" || !defined($vlanid)) {$vlanid = $vlan;}
if ($interface == "" || !defined($interface)) { $interface = $swinterface;}
}
}
sub lsvlan
{
my $request = shift;
my $callback = shift;
my $reqcmd = shift;
my @args = @{$req->{arg}} if(exists($req->{arg}));
# A quick function for usage information for the command
my $lsvlan_usage = sub {
my $exitcode = shift @_;
my %rsp;
push @{$rsp{data}}, "Usage: mkvlan vlanid";
push @{$rsp{data}}, " mkvlan [-?|-h|--help]";
if ($exitcode) { $rsp{errorcode} = $exitcode; }
$callback->(\%rsp);
};
# Go through the arguments, and get the relevant information
@ARGV = @{$req->{arg}};
#Detect if the first variable is a number or not, as it may be the vlanid
if ($ARGV[0] !~ /\D/) {$vlanid=$ARGV[0];}
GetOptions(
'h|?|help' => \$help,
);
# Show usage info if help is defined
if ($help) { $lsvlan_usage->(0); return; }
# Show usage if we have less then 2 arguments, or the vlan option is not defined
if (scalar(@ARGV)<1 || !defined($vlanid)) { $lsvlan_usage->(1); return; }
}
1;
+2 -2
View File
@@ -199,7 +199,7 @@ sub prexcat2nim
my @nodelist=(); # pass back list of nodes - if applicable
my @servicenodes=(); # pass back list of service nodes - if applicable
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
} else {
&xcat2nim_usage($callback);
@@ -359,7 +359,7 @@ sub processArgs
my $gotattrs = 0;
if ( defined ($::args) && @{$::args} ) {
if (defined(@{$::args})) {
@ARGV = @{$::args};
} else {
return 3;
-36
View File
@@ -131,16 +131,6 @@ sub process_request
&usage($callback,$command);
exit 1;
}
# if the ARGS still have data we have invalid input
if (@ARGV) {
my $args=join(',', @ARGV);
my $rsp = {};
$rsp->{error}->[0] =
"The input to the command: $command contained invalid arguments: $args.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
exit 1;
}
if ($options{'help'})
{
&usage($callback,$command);
@@ -180,14 +170,6 @@ sub process_request
}
}
}
# cannot enter -K and -k
if (($options{'sshkeypath'}) && ($options{'gensshkeys'})) {
my $rsp = {};
$rsp->{error}->[0] =
"The input of -k and -K is not valid on the command : $command.";
xCAT::MsgUtils->message("E", $rsp, $callback);
exit 1;
}
# check for site.sshbetweennodes attribute, put out a warning it will not be used as long
# as zones are defined in the zone table.
@@ -491,18 +473,6 @@ sub rmzone
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# see if they input invalid flags
if (($$options{'sshkeypath'}) || ($$options{'gensshkeys'}) ||
( $$options{'addnoderange'}) || ( $$options{'rmnoderange'}) ||
( $$options{'defaultzone'}) ||
($$options{'sshbetweennodes'})) {
my $rsp = {};
$rsp->{error}->[0] =
"The following flags are not valid input for the rmzone command: -k,-K,-a,-r,-f,-s ";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# check to see if the input zone already exists
# cannot remove it if it is not defined
my $zonename=$request->{zonename};
@@ -735,9 +705,6 @@ sub addtozonetable
my $curdefaultzone = xCAT::Zone->getdefaultzone($callback);
if (!(defined ($curdefaultzone))) { # no default defined
$tb_cols{defaultzone} ="yes";
$tab->setAttribs({zonename => $zonename}, \%tb_cols);
$tab->commit();
$tab->close();
} else { # already a default
if ($$options{'force'}) { # force the default
$tb_cols{defaultzone} ="yes";
@@ -813,9 +780,6 @@ sub updatezonetable
my $curdefaultzone = xCAT::Zone->getdefaultzone($callback);
if (!(defined ($curdefaultzone))) { # no default defined
$tb_cols{defaultzone} ="yes";
$tab->setAttribs({zonename => $zonename}, \%tb_cols);
$tab->commit();
$tab->close();
} else { # already a default
if ($$options{'force'}) { # force the default
$tb_cols{defaultzone} ="yes";
-1
View File
@@ -12,7 +12,6 @@ use Getopt::Long;
use strict;
#This or something like this must always be available and not depend on server
#Otherwise, can't set things to let server run in the first place
#
sub usage {
print "Usage:\n";
+93 -5
View File
@@ -1020,6 +1020,44 @@ sub genSSHNodeHostKey
}
# is_lsb_ubuntu return value indicates whether system appears to be Ubuntu.
# Using required /etc/lsb-release file, instead of optional lsb_release command.
sub is_lsb_ubuntu
{
if (open(my $relfile, "<", "/etc/lsb-release")) {
my @text = <$relfile>;
close($relfile);
chomp(@text);
my $distrib_id = '';
foreach (@text) {
if ( $_ =~ /^\s*DISTRIB_ID=(.*)$/ ) {
$distrib_id = $1; # last DISTRIB_ID value in file used
}
}
if ( $distrib_id =~ /^(Ubuntu|"Ubuntu")\s*$/ ) {
return 1; # return "true"
}
}
return 0; # return "false"
}
sub is_debian
{
if ( -e "/etc/debian_version" && -e "/etc/issue"){
open(my $relfile, "<", "/etc/issue");
my $line = <$relfile>;
close($relfile);
if ( $line =~ /debian.*/i ){
return 1;
}
}
return 0;
}
sub is_redhat6sp4
{
if( -e "/etc/redhat-release" ){
@@ -1034,6 +1072,21 @@ sub is_redhat6sp4
}
# on Ubuntu need to painstakingly compare /etc/localtime with files under
# /usr/share/zoneinfo since /etc/localtime # isn't always a symbolic link
sub discover_timezone_ubuntu
{
my $localtime = "/etc/localtime";
my $zoneinfo = "/usr/share/zoneinfo";
my $zone_result = `find $zoneinfo -type f -exec cmp -s $localtime {} \\; -print | grep -v posix | grep -v SystemV`;
my @zones = split /\n/, $zone_result;
$zones[0] =~ s/$zoneinfo\///;
return $zones[0];
}
#-----------------------------------------------------------------------------
@@ -1105,7 +1158,6 @@ sub initDB
# set value based on OS
my ($domain, $timezone);
my $timezone = xCAT::Utils->gettimezone();
if ($::osname eq 'AIX')
{
my ($name, $rest) = split('\.', $hname);
@@ -1118,10 +1170,35 @@ sub initDB
$domain = "";
}
$timezone = $ENV{'TZ'};
}
else # linux
{
$domain = `hostname -d`;
my $tz;
if (-f "/etc/redhat-release")
{
# on Redhat look for "ZONE"
$tz =
`grep ^ZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`;
}
elsif ( is_lsb_ubuntu() || is_debian() )
{
$tz = discover_timezone_ubuntu;
if (!$tz){
$tz = `cat /etc/timezone`;
chomp $tz;
}
}
else
{
# on SuSE look for "TIMEZONE"
$tz =
`grep ^TIMEZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`;
}
$timezone = $tz;
}
chomp $timezone;
@@ -1896,7 +1973,6 @@ sub setuphttp
{
my $cmd;
my $distro = xCAT::Utils->osver();
# restart httpd
if (-e "/etc/init.d/apache2")
{ #for sles/ubuntu
@@ -1924,7 +2000,8 @@ sub setuphttp
# enable httpd
if (-e "/etc/init.d/apache2")
{
if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) {
if (is_lsb_ubuntu() || is_debian() )
{ # for ubuntu
$cmd = "/usr/sbin/update-rc.d apache2 enable";
}
else
@@ -1932,6 +2009,18 @@ sub setuphttp
$cmd = "/sbin/chkconfig apache2 on";
}
}
# elsif (-e "/sbin/chkconfig")
# {
# $cmd = "/sbin/chkconfig httpd on";
# }
# elsif (-e "/usr/sbin/chkconfig")
# {
# $cmd = "/usr/sbin/chkconfig httpd on";
# }
# else
# {
# $cmd = "chkconfig httpd on";
# }
else
{
my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig");
@@ -2164,7 +2253,6 @@ sub setupMNinDB
sub startnamedonboot
{
# start named on boot
my $distro = xCAT::Utils->osver();
if (xCAT::Utils->isAIX())
{
#/etc/inittab
@@ -2184,7 +2272,7 @@ sub startnamedonboot
#chkconfig
my $serv = "named";
my $cmd = "/sbin/chkconfig $serv on";
if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) {
if ( is_lsb_ubuntu() || is_debian() ){
$serv = "bind9";
$cmd = "update-rc.d $serv enable";
}
+2 -1
View File
@@ -67,7 +67,7 @@ cert_opt = ca_default # Certificate field options
default_days = 7300 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = sha1 # which md to use.
default_md = sha256 # which md to use.
preserve = no # keep passed DN ordering
# A few difference way of specifying how similar the request should look
@@ -98,6 +98,7 @@ emailAddress = optional
####################################################################
[ req ]
default_md = sha256
default_bits = 2048
default_keyfile = private/ca-key.pem
distinguished_name = req_distinguished_name
+2 -2
View File
@@ -72,12 +72,12 @@ release_lock();
my ($user,$pass);
if ($username) {
$user = "-U '$username'";
$user = "-U $username";
} else {
$user = '';
}
if ($password) {
$pass = "-P '$password'";
$pass = "-P $password";
} else {
$pass = '';
}
@@ -27,7 +27,7 @@ rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password#
#partition / --ondisk=/dev/mapper/ibmpkvm_vg_root-ibmpkvm_lv_root
partition / --ondisk=/dev/sda
network --bootproto dhcp
network --device eth0 --bootproto dhcp
%post
touch "/startpost"
@@ -1,8 +1,7 @@
#
lang en_US
#network --bootproto dhcp
#KICKSTARTNET#
network --bootproto dhcp
#
# Where's the source?
@@ -1,10 +1,6 @@
#!/bin/sh
export MANAGEDADDRESSMODE="#XCATVAR:MANAGEDADDRESSMODE#"
cd /etc/sysconfig/network
if [ "$MANAGEDADDRESSMODE" != "static" ]
then
rm -f ifcfg-eth-id*
rm -f ifcfg-myri*
cat >ifcfg-eth0 <<EOF
@@ -12,7 +8,7 @@ DEVICE=eth0
BOOTPROTO=dhcp
STARTMODE=onboot
EOF
fi
. /tmp/prinicsetting
rm /tmp/prinicsetting
if [ "$PRINIC" != "eth0" ]
@@ -26,12 +22,7 @@ then
# echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC
fi
fi
if [ "$MANAGEDADDRESSMODE" != "static" ]
then
echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC
fi
perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config
/etc/init.d/network restart
@@ -182,10 +182,9 @@ addsiteyum
/xcatpost/mypostscript
sed -i 's/^serial/#serial/' /boot/grub/grub.conf
sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
#the following command should always be run to prevent infinite installation loops
updateflag.awk $MASTER 3002
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
updateflag.awk $MASTER 3002
fi
cd /
#rm -Rf /xcatpost
#rm -f /xcatpost/mypostscript
@@ -184,7 +184,7 @@ if [ -z "$instdisk" ]; then
"ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
"mptsas"|"mpt2sas"|"mpt3sas") #*PROBABLY* not SAN, but SAS SAN is possible
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
*)
@@ -219,10 +219,7 @@ if [ `uname -m` = "ppc64" ]; then
echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning
fi
if [ -d /sys/firmware/efi ]; then
echo 'bootloader --driveorder='$instdisk >> /tmp/partitioning
echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype vfat' >> /tmp/partitioning
else
echo 'bootloader' >> /tmp/partitioning
fi
#TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen...
@@ -159,7 +159,7 @@ if [ -z "$instdisk" ]; then
"ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
"mptsas"|"mpt2sas"|"mpt3sas") #*PROBABLY* not SAN, but SAS SAN is possible
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
*)
@@ -145,7 +145,7 @@ if [ -z "$instdisk" ]; then
"ata_piix4"|"PMC MaxRAID"|"ahci"|"megaraid_sas") #certainly direct
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
"mptsas"|"mpt2sas"|"mpt3sas") #*PROBABLY* not SAN, but SAS SAN is possible
"mptsas"|"mpt2sas") #*PROBABLY* not SAN, but SAS SAN is possible
if [ -z "$probablyfirstdirectdisk" ]; then probablyfirstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
;;
*)
@@ -63,7 +63,25 @@
<surname/>
</user>
</users>
#YAST2NET#
<networking>
<dns>
<dhcp_hostname config:type="boolean">true</dhcp_hostname>
<dhcp_resolv config:type="boolean">true</dhcp_resolv>
<domain>local</domain>
<hostname>linux</hostname>
</dns>
<interfaces config:type="list">
<interface>
<bootproto>dhcp</bootproto>
<device>eth0</device>
<startmode>onboot</startmode>
</interface>
</interfaces>
<routing>
<ip_forward config:type="boolean">false</ip_forward>
<routes config:type="list"/>
</routing>
</networking>
<scripts>
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles#
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles#
+138
View File
@@ -0,0 +1,138 @@
#!/bin/sh
#
# stateless
#
# chkconfig: 345 11 99
# description: action stateless
#
# Source the library functions
. /etc/rc.d/init.d/functions
ZONE="US/Mountain"
case "$1" in
start)
echo -n "Starting stateless configuration: "
if [ -r /etc/stateless_done ]
then
echo_failure
echo
echo " already run!"
exit $?
fi
#initrd=xcat/netboot/fedora8/x86_64/compute/initrd.gz imgurl=nfs://rro000/install/netboot/fedora8/x86_64/compute/rootimg console=ttyS1,19200n8r BOOT_IMAGE=xcat/netboot/fedora8/x86_64/compute/kernel
cat /proc/cmdline | grep imgurl >/dev/null 2>&1
if [ "$?" != "0" ]
then
echo_failure
echo
echo " imgurl missing from /proc/cmdline, i.e. stateful!"
exit $?
fi
for i in $(cat /proc/cmdline)
do
KEY=$(echo $i | awk -F= '{print $1}')
VALUE=$(echo $i | awk -F= '{print $2}')
if [ "$KEY" = "imgurl" ]
then
SERVER=$(echo $VALUE | awk -F/ '{print $3}')
fi
done
if [ -z "$SERVER" ]
then
echo_failure
echo
echo "bogus server in imgurl"
exit $?
fi
echo
echo " Universal Server: $SERVER"
echo -n " Syslog: "
echo "*.* @$SERVER" >/etc/rsyslog.conf
echo_success
echo
if [ -r /etc/rc.d/init.d/ntpd ]
then
echo -n " NTP: "
if [ ! -r /etc/sysconfig/clock ]
then
echo "ZONE=\"$ZONE\"
UTC=true
ARC=false" >/etc/sysconfig/clock
fi
echo "server $SERVER
driftfile /etc/ntp/drift
multicastclient
broadcastdelay 0.008
disable auth
keys /etc/ntp/keys
trustedkey 65535
requestkey 65535
controlkey 65535" >/etc/ntp.conf
echo "$SERVER" >/etc/ntp/step-tickers
echo_success
echo
fi
if [ -r /etc/ldap.conf -a -r /etc/resolv.conf ]
then
echo -n " LDAP: "
DC=$(
cat /etc/resolv.conf | \
egrep '(domain|search)' | \
head -1 | \
awk '{print $2}' | \
sed 's/\./,dc=/g' | \
sed 's/^/dc=/'
)
echo "host $SERVER
base $DC
nss_base_passwd ou=People,$DC
nss_base_shadow ou=People,$DC
nss_base_group ou=Group,$DC
timelimit 120
bind_timelimit 120
idle_timelimit 3600
nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat,radiusd,news,mailman,nscd
ssl no
tls_cacertdir /etc/openldap/cacerts
pam_password md5" >/etc/ldap.conf
echo "URI ldap://$SERVER
BASE $DC
TLS_CACERTDIR /etc/openldap/cacerts" >/etc/openldap/ldap.conf
cd /etc
cp nsswitch.conf nsswitch.conf.ORIG
sed -r 's/^((passwd|shadow|group):.*)/\1 ldap/' <nsswitch.conf.ORIG >nsswitch.conf
cd /etc/pam.d
cp system-auth system-auth.ORIG
sed -r 's/(account\s+required\s+pam_unix.so)/account sufficient pam_ldap.so\n\1/' <system-auth.ORIG >system-auth
echo_success
echo
fi
touch /etc/stateless_done
;;
stop)
;;
*)
echo "Usage: stateless {start|stop}"
exit 1
esac
+170
View File
@@ -0,0 +1,170 @@
################################################################################
# Create a generic HPC image
# This script is an example of how to create an HPC image with xCAT stateless.
# in this example you may need to change some of the parameters. In the future
# we should probably place this in the database...
# All good sys admins can reproduce their environments. Creating a stateless
# image should be reproducable. Doing this with a script is a good idea.
#
################################################################################
# specify the OS stuff. You'll probably want to change this. If you do then you'll
# need to make sure there is a *.pkglist and *.exlist
PROFILE=compute
ARCH=x86_64
OS=centos5.3
# this is where the OS image will reside
IMGROOT=/install/netboot/$OS/$ARCH/$PROFILE/rootimg
# remove the old image if it exists.
rm -rf /install/netboot/$OS/$ARCH/$PROFILE
# generate the base image
# for IBM: tg3 in older blades, bnx in newer stuff, and igb in the nehalem based products.
/opt/xcat/share/xcat/netboot/centos/genimage -i eth0 -n libphy,tg3,bnx2,igb -o $OS -p $PROFILE
# update the yum database in the image
rm -rf $IMGROOT/etc/yum.repos.d
yum --installroot=$IMGROOT clean all
cp -a /etc/yum.repos.d/ $IMGROOT/etc/
rm -rf $IMGROOT/etc/yum.repos.d/xCAT-*
# no selinux!!
echo SELINUX=disabled > $IMGROOT/etc/sysconfig/selinux
# fix respawns
cp $IMGROOT/etc/inittab $IMGROOT/etc/inittab.ORIG
grep -v 38400 $IMGROOT/etc/inittab.ORIG > $IMGROOT/etc/inittab
# filesystem setup, you'll want to customize this. We have swap and scratch
# configured here. But if you don't have disks then this may not help.
# we name our / partition the image name (compute by default) plus a timestamp.
TIME=`date +%s`
cp $IMGROOT/etc/fstab $IMGROOT/etc/fstab.ORIG
echo "proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
$PROFILE-$TIME / tmpfs rw 0 1
#/dev/sda1 swap swap defaults 0 0
#/dev/sda2 /scratch ext3 defaults 0 0
" > $IMGROOT/etc/fstab
mkdir $IMGROOT/scratch
### get ntp to start on boot
chroot $IMGROOT chkconfig --level 345 ntpd on
#### user stuff so that we can do some work ####
cp /etc/shadow $IMGROOT/etc/
cp /etc/group $IMGROOT/etc/
cp /etc/passwd $IMGROOT/etc/
cp /etc/hosts $IMGROOT/etc/
### scaling fixes #####
echo "# increase TCP max buffer size
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.core.rmem_default = 65536
net.core.wmem_default = 65536
# increase Linux autotuning TCP buffer limits
# min, default, and max number of bytes to use
net.ipv4.tcp_rmem = 4096 33554432 33554432
net.ipv4.tcp_wmem = 4096 33554432 33554432
net.ipv4.tcp_mem= 33554432 33554432 33554432
net.ipv4.route.flush=1
net.core.netdev_max_backlog=1500
#GPFS / NFS Tuning
net.ipv4.conf.all.arp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.neigh.default.gc_thresh1 = 1024
net.ipv4.neigh.default.gc_thresh2 = 4096
net.ipv4.neigh.default.gc_thresh3 = 8192
net.ipv4.neigh.default.gc_stale_time = 24" >> $IMGROOT/etc/sysctl.conf
## Limits: need to make sure users can have unlimited memory (ulimit -l unlimited)
cp /etc/security/limits.conf $IMGROOT/etc/security/
### add torque ###
/opt/xcat/share/xcat/netboot/add-on/torque/add_torque $IMGROOT mgt /opt/torque / local
# update the limit on pegged memory limit and if they have old xCAT then make sure
# it says torque instead of pbs in the paths of the config file.
perl -pi -e 's/ulimit -n 20000/ulimit -n 20000; ulimit -l unlimited/g' $IMGROOT/etc/init.d/pbs_mom
perl -pi -e 's/spool\/pbs/spool\/torque/g' $IMGROOT/etc/init.d/pbs_mom
perl -pi -e 's/spool\/pbs/spool\/torque/g' $IMGROOT/etc/init.d/pbs_mom
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/epilogue
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/prologue
perl -pi -e 's/PBS_HOME=\/var\/spool\/pbs/PBS_HOME=\/var\/spool\/torque/g' $IMGROOT/var/spool/torque/mom_priv/takedownnode
### stateless init script does NTP, syslog, etc. ####
cp /etc/localtime $IMGROOT/etc/
cp /opt/xcat/share/xcat/netboot/add-on/stateless/stateless $IMGROOT/etc/init.d/
perl -pi -e 's!Mountain!Mexico/General!g' $IMGROOT/etc/init.d/stateless
perl -pi -e 's/driftfile \/etc\/ntp/driftfile \/var\/lib\/ntp/g' $IMGROOT/etc/init.d/stateless
perl -pi -e 's/keys \/etc\/ntp/keys \/var\/lib\/ntp/g' $IMGROOT/etc/init.d/stateless
rm -rf $IMGROOT/etc/sysconfig/clock
chroot $IMGROOT chkconfig --level 345 stateless on
chroot $IMGROOT chkconfig --level 345 rsyslog on
### make sure dhcp boot protocol is set to none ###
perl -pi -e 's/dhcp/none/g' $IMGROOT/etc/sysconfig/network-scripts/ifcfg-eth0
#### add GPFS stuff ###
# this is an example of a stateless GPFS implementation. Uncomment the below if you
# want GPFS. Make sure you have the GPFS RPMs to do this.
#GPFSSRCDIR=/install/GPFS
#yum --installroot=$IMGROOT -y install glibc ksh compat-libstdc++-33 binutils rsh
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.base*rpm
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.gpl*rpm
#rpm -ivh --root=$IMGROOT $GPFSSRCDIR/gpfs.msg*rpm
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.base*rpm
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.gpl*rpm
#rpm -Uivh --root=$IMGROOT $GPFSSRCDIR/updates/gpfs.msg*rpm
##
#AUTOGPFSDIR=/opt/xcat/share/xcat/netboot/add-on/autogpfs
#cp $AUTOGPFSDIR/autogpfsc.pl $IMGROOT/usr/sbin
#cp $AUTOGPFSDIR/autogpfsc $IMGROOT/etc/init.d/
#echo "SERVERS=mgt
#PORT=3003
#BLOCK=no" >> $IMGROOT/etc/sysconfig/autogpfsc
#
#chroot $IMGROOT chkconfig --level 345 autogpfsc on
#cp $GPFSSRCDIR/2.6.18-128.el5/* $IMGROOT/usr/lpp/mmfs/bin/
#cp /etc/profile.d/gpfs.sh $IMGROOT/etc/profile.d/
### End GPFS Stuff ####
### IB Stuff ####
# if you have InfiniBand on your machines then you probably have an OFED distribution you
# need to add. Here is an example of how to add it.
#echo "Adding InfiniBand"
#yum --installroot=$IMGROOT -y install bind-utils which rpm tcl tk glibc-devel.i386 pciutils expat libgfortran.x86_64 libgomp.x86_64 tcsh
#
#IBROOT=/install/voltaire/VoltaireOFED-1.4.2_2-k2.6.18-128.el5-x86_64
#mount -o bind /proc $IMGROOT/proc
#mount -o bind /sys $IMGROOT/sys
#mount -o bind $IBROOT $IMGROOT/mnt
#chroot $IMGROOT /mnt/install.sh --without-mpi
#umount $IMGROOT/mnt
#umount $IMGROOT/sys
#umount $IMGROOT/proc
# configure IB IP address
#echo "IP=\`host \$HOSTNAME-ib0 | awk '{ print \$4 }' | head -1\`" >> $IMGROOT/etc/rc.d/rc.local
#echo "ifconfig ib0 \$IP" >> $IMGROOT/etc/rc.d/rc.local
#echo "ifconfig ib0 netmask 255.255.0.0" >> $IMGROOT/etc/rc.d/rc.local
### End IB Stuff ####
# configure name resolution
# change this to what you want it to be. (this is in site.tab as the domain and nameservers)
echo "search cluster.foo
nameserver 172.20.0.1" >$IMGROOT/etc/resolv.conf
### uniq-i-fy Torque OS name
echo "opsys compute_centos5.3" >> $IMGROOT/var/spool/torque/mom_priv/config
packimage -p $PROFILE -a $ARCH -o $OS
echo "Image $PROFILE-$TIME created"
+1 -1
View File
@@ -177,7 +177,7 @@ if ($netdriver) {
# Add the default driver list
if ($arch eq 'x86' or $arch eq 'x86_64') {
push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx_en be2net/;
push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e igb mlx_en be2net/;
} elsif ($arch eq 'ppc64') {
push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/;
} elsif ($arch eq "s390x") {
@@ -46,7 +46,7 @@ fi
# remove user from index
index=`grep $CNA /etc/xcat/ca/index | cut -f4 2>&1`
for id in $index; do
openssl ca -startdate 19600101010101Z -config /etc/xcat/ca/openssl.cnf -revoke /etc/xcat/ca/certs/$id.pem
openssl ca -config /etc/xcat/ca/openssl.cnf -revoke /etc/xcat/ca/certs/$id.pem
done
mkdir -p $USERHOME/.xcat
cd $USERHOME/.xcat
@@ -60,7 +60,7 @@ cd $XCATDIR/ca
# - seems to be a problem with the use of the wildcard in the Makefile
# - calling cmds directly instead - should be safe
# make sign
openssl ca -startdate 600101010101Z -config openssl.cnf -in root.csr -out root.cert
openssl ca -config openssl.cnf -in root.csr -out root.cert
if [ -f root.cert ]; then
rm root.csr
fi
@@ -33,7 +33,7 @@ cd $XCATDIR/ca
# - call cmds directly instead - seems safe
# make sign
openssl ca -startdate 600101010101Z -config openssl.cnf -in `hostname`.csr -out `hostname`.cert -extensions server
openssl ca -config openssl.cnf -in `hostname`.csr -out `hostname`.cert -extensions server
if [ -f `hostname`.cert ]; then
rm `hostname`.csr
fi
@@ -30,9 +30,5 @@ sed -e "s@##XCATCADIR##@$XCATCADIR@" $XCATROOT/share/xcat/ca/openssl.cnf.tmpl >
cp $XCATROOT/share/xcat/ca/Makefile $XCATCADIR/
cd $XCATCADIR
make init
#openssl req -nodes -config openssl.cnf -days 7300 -x509 -newkey rsa:2048 -out ca-cert.pem -extensions v3_ca -outform PEM -subj /CN="$CNA"
openssl genrsa -out private/ca-key.pem 2048
chmod 600 private/ca-key.pem
openssl req -new -key private/ca-key.pem -config openssl.cnf -out ca-req.csr -subj /CN="$CNA" -outform PEM
openssl ca -selfsign -keyfile private/ca-key.pem -in ca-req.csr -startdate 700101010101Z -days 7305 -extensions v3_ca -config openssl.cnf -out ca-cert.pem
openssl req -nodes -config openssl.cnf -days 7300 -x509 -newkey rsa:2048 -out ca-cert.pem -extensions v3_ca -outform PEM -subj /CN="$CNA"
cd -
File diff suppressed because it is too large Load Diff
Regular → Executable
+2 -8
View File
@@ -29,15 +29,9 @@ Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser
Obsoletes: atftp-xcat
%endif
# The aix rpm cmd forces us to do this outside of ifos type stmts
%if %notpcm
%ifos linux
%ifnarch s390x
# PCM does not use or ship grub2-xcat
Requires: grub2-xcat
%endif
%endif
%endif
%if %fsm
# nothing needed here
@@ -167,7 +161,7 @@ rm $RPM_BUILD_ROOT/%{prefix}/sbin/stopstartxcatd
#rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/blade.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/hpblade.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/hpilo.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/ipmi.pm
#rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/ipmi.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/nodediscover.pm
#rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/switch.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/xen.pm
@@ -389,7 +383,7 @@ fi
%post
%ifos linux
ln -sf $RPM_INSTALL_PREFIX0/sbin/xcatd /usr/sbin/xcatd
if [ "$1" = "1" ]; then #Only if installing for the first time..
if [ -x /usr/lib/lsb/install_initd ]; then
/usr/lib/lsb/install_initd /etc/init.d/xcatd
+63 -88
View File
@@ -20,17 +20,17 @@ my @apigroups = (
]
},
{
groupname => 'osimages',
header => "Osimage resources",
desc => "URI list which can be used to query, create osimage resources.",
resources => ['osimage', 'osimage_allattr', 'osimage_attr', 'osimage_op']
groupname => 'groups',
header => "Group Resources",
desc => "The URI list which can be used to create, query, change and manage group objects.",
resources => ['all_groups','group_allattr','group_attr',
]
},
{
groupname => 'networks',
header => "Network Resources",
desc => "The URI list which can be used to create, query, change and manage network objects.",
resources => ['allnetwork', 'network_allattr','network_attr']
groupname => 'services',
header => "Services Resources",
desc => "The URI list which can be used to manage the dns and dhcp services on xCAT MN.",
resources => ['dns','dhcp','host', 'slpnodes', 'specific_slpnodes',]
},
{
groupname => 'policy',
@@ -38,13 +38,6 @@ my @apigroups = (
desc => "The URI list which can be used to create, query, change and manage policy entries.",
resources => ['policy', 'policy_allattr', 'policy_attr']
},
{
groupname => 'groups',
header => "Group Resources",
desc => "The URI list which can be used to create, query, change and manage group objects.",
resources => ['all_groups','group_allattr','group_attr',
]
},
{
groupname => 'globalconf',
header => "Global Configuration Resources",
@@ -52,16 +45,20 @@ my @apigroups = (
resources => ['all_site', 'site']
},
{
groupname => 'services',
header => "Service Resources",
desc => "The URI list which can be used to manage the host, dns and dhcp services on xCAT MN.",
resources => ['dns','dhcp','host', 'slpnodes', 'specific_slpnodes',]
groupname => 'table',
header => "Table Resources",
desc => "URI list which can be used to create, query, change global configuration.",
resources => ['table_nodes', 'table_rows']
},
{
groupname => 'tables',
header => "Table Resources",
desc => "URI list which can be used to create, query, change table entries.",
resources => ['table_nodes', 'table_nodes_attrs', 'table_all_rows', 'table_rows', 'table_rows_attrs']
groupname => 'osimage',
header => "Osimage resources",
desc => "URI list which can be used to query, create osimage resources.",
resources => ['osimage', 'osimage_allattr']
},
{
# groupname => 'network',
resources => ['network', 'network_allattr']
},
);
@@ -110,41 +107,31 @@ sub outtext {
print " Returns: $parts[2]\n";
}
}
my @example_array = ();
if (defined($def->{example})) {
push @example_array, $def->{example};
} else {
foreach (1..10) {
if (defined($def->{'example'.$_})) {
push @example_array, $def->{'example'.$_};
}
}
}
if (@example_array) {
foreach my $line (@example_array) {
my @parts = split ('\|', $line);
print " Example:\n";
if ($parts[1]) {
print " $parts[1]\n";
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
if ($parts[2] && $parts[3] && ($parts[4] || $opt ne "GET")) {
my ($uri, $data);
if ($parts[3] =~ /\s+/) {
($uri, $data) = split(/ /, $parts[3]);
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$uri$postfix\' -H Content-Type:application/json --data \'$data\'\n";
} else {
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$parts[3]$postfix\'\n";
}
$parts[4] =~ s/\n/\n /g;
print " $parts[4]\n";
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
if (defined ($def->{example})) {
my @parts = split ('\|', $def->{example});
print " Example:\n";
if ($parts[1]) {
print " $parts[1]\n";
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
if ($parts[2] && $parts[3] && ($parts[4] || $opt ne "GET")) {
my ($uri, $data);
if ($parts[3] =~ /\s+/) {
($uri, $data) = split(/ /, $parts[3]);
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$uri$postfix\' -H Content-Type:application/json --data \'$data\'\n";
} else {
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$parts[3]$postfix\'\n";
}
$parts[4] =~ s/\n/\n /g;
print " $parts[4]\n";
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
} else {
push @errmsg, "Error format in:[".$def->{desc}."]\n";
}
@@ -198,42 +185,30 @@ sub outwiki {
}
}
my @example_array = ();
if (defined($def->{example})) {
push @example_array, $def->{example};
} else {
foreach (1..10) {
if (defined($def->{'example'.$_})) {
push @example_array, $def->{'example'.$_};
}
if (defined ($def->{example})) {
my @parts = split ('\|', $def->{example});
print "'''Example:'''\n\n";
if ($parts[1]) {
print "$parts[1]\n";
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
}
}
if (@example_array) {
foreach my $line (@example_array) {
my @parts = split ('\|', $line);
print "'''Example:'''\n\n";
if ($parts[1]) {
print "$parts[1]\n";
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
}
if ($parts[2] && $parts[3] && ($parts[4] || $opt ne "GET")) {
my ($uri, $data);
if ($parts[3] =~ /\s+/) {
($uri, $data) = split(/ /, $parts[3]);
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$uri$postfix\' -H Content-Type:application/json --data \'$data\'\n";
} else {
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$parts[3]$postfix\'\n";
}
$parts[4] =~ s/\n/\n /g;
print " $parts[4]\n";
if ($parts[2] && $parts[3] && ($parts[4] || $opt ne "GET")) {
my ($uri, $data);
if ($parts[3] =~ /\s+/) {
($uri, $data) = split(/ /, $parts[3]);
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$uri$postfix\' -H Content-Type:application/json --data \'$data\'\n";
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
print " #curl -X $parts[2] -k \'https://127.0.0.1/xcatws$parts[3]$postfix\'\n";
}
$parts[4] =~ s/\n/\n /g;
print " $parts[4]\n";
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
}
} else {
push @errmsg, "Error format for:[".$def->{desc}."]\n";
}
+148 -370
View File
@@ -9,8 +9,8 @@ use Data::Dumper;
use Socket;
use IO::Socket::INET;
use IO::Socket::SSL;
#use lib "/opt/xcat/lib/perl";
#use xCAT::Table;
use lib "/opt/xcat/lib/perl";
use xCAT::Table;
# The hash %URIdef defines all the xCAT resources which can be access from Web Service.
# This script will be called when a https request with the URI started with /xcatws/ is sent to xCAT Web Service
@@ -45,7 +45,7 @@ use IO::Socket::SSL;
my %usagemsg = (
objreturn => "Json format: An object which includes multiple \'<name> : {att:value, attr:value ...}\' pairs.",
objchparam => "Json format: An object which includes multiple \'att:value\' pairs.",
non_getreturn => "No output when execution is successfull. Otherwise output the error information in the Standard Error Format: {error:[msg1,msg2...],errocode:errornum}."
non_getreturn => "No output for succeeded execution. Otherwise output the error information in the Standard Error Format: {error:[msg1,msg2...],errocode:errornum}."
);
my %URIdef = (
@@ -356,7 +356,7 @@ my %URIdef = (
},
},
inventoryattr => {
desc => "[URI:/nodes/{nodename}/inventory/{pci|model...}] - The specific inventory attributes for the node {nodename}",
desc => "[URI:/nodes/{nodename}/inventory/{pci;model...}] - The specific inventory attributes for the node {nodename}",
matcher => '^/nodes/[^/]*/inventory/\S+$',
GET => {
desc => "Get the specific inventory attibutes.",
@@ -664,188 +664,149 @@ my %URIdef = (
},
#### definition for network resources
networks => {
allnetwork => {
desc => "[URI:/networks] - The network list resource.",
desc1 => "This resource can be used to display all the networks which have been defined in the xCAT database.",
matcher => '^\/networks$',
network => {
network => {
desc => "[URI:/network] - The network resource.",
matcher => '^\/network$',
GET => {
desc => "Get all the networks in xCAT.",
desc1 => "The attributes details for the networks will not be displayed.",
usage => "||Json format: An array of networks names.|",
example => "|Get all the networks names from xCAT database.|GET|/networks|[\n \"network1\",\n \"network2\",\n \"network3\",\n]|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout_remove_appended_type,
},
POST => {
desc => "Create the networks resources base on the network configuration on xCAT MN.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Create the networks resources base on the network configuration on xCAT MN.|POST|/networks||",
desc => "Create the network resources base on the network configuration on xCAT MN.",
cmd => "makenetworks",
fhandler => \&actionhdl,
fhandler => \&defhdl,
},
},
network_allattr => {
desc => "[URI:/networks/{netname}] - The network resource",
matcher => '^\/networks\/[^\/]*$',
desc => "[URI:/network/{netname}] - The network resource",
matcher => '^\/network\/[^\/]*$',
GET => {
desc => "Get all the attibutes for the network {netname}.",
usage => "||$usagemsg{objreturn}|",
example => "|Get all the attibutes for network \'network1\'.|GET|/networks/network1|{\n \"network1\":{\n \"gateway\":\"<xcatmaster>\",\n \"mask\":\"255.255.255.0\",\n \"mgtifname\":\"eth2\",\n \"net\":\"10.0.0.0\",\n \"tftpserver\":\"10.0.0.119\",\n ...\n }\n}|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout,
},
PUT => {
desc => "Change the attibutes for the network {netname}.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Change the attributes mgtifname=eth0 and net=10.1.0.0.|PUT|/networks/network1 {\"mgtifname\":\"eth0\",\"net\":\"10.1.0.0\"}||",
cmd => "chdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
POST => {
desc => "Create the network {netname}. DataBody: {attr1:v1,att2:v2...}.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Create a network with attributes gateway=10.1.0.1, mask=255.255.0.0 |POST|/networks/network1 {\"gateway\":\"10.1.0.1\",\"mask\":\"255.255.0.0\"}||",
cmd => "mkdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
DELETE => {
desc => "Remove the network {netname}.",
usage => "||$usagemsg{non_getreturn}|",
example => "|Delete the network network1|DELETE|/networks/network1||",
cmd => "rmdef",
fhandler => \&defhdl,
outhdler => \&noout
},
},
network_attr => {
desc => "[URI:/networks/{netname}/attrs/attr1,attr2,...] - The attributes resource for the network {netname}",
matcher => '^\/networks\/[^\/]*/attrs/\S+$',
desc => "[URI:/network/{netname}/attrs/attr1;attr2;attr3 ...] - The attributes resource for the network {netname}",
matcher => '^\/network\/[^\/]*/attrs/\S+$',
GET => {
desc => "Get the specific attributes for the network {netname}.",
usage => "||$usagemsg{objreturn}|",
example => "|Get the attributes {groups,mgt,netboot} for network network1|GET|/networks/network1/attrs/gateway,mask,mgtifname,net,tftpserver|{\n \"network1\":{\n \"gateway\":\"9.114.34.254\",\n \"mask\":\"255.255.255.0\",\n }\n}|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout,
},
PUT__backup => {
PUT => {
desc => "Change attributes for the network {netname}. DataBody: {attr1:v1,att2:v2,att3:v3 ...}.",
usage => "||An array of network objects.|",
example => "|Get the attributes {gateway,mask,mgtifname,net,tftpserver} for networks network1|GET|/networks/network1/attrs/gateway;mask;net||",
cmd => "chdef",
fhandler => \&noout,
fhandler => \&defhdl,
}
},
},
#### definition for osimage resources
osimages => {
osimage => {
osimage => {
desc => "[URI:/osimages] - The osimage resource.",
matcher => '^\/osimages$',
desc => "[URI:/osimage] - The osimage resource.",
matcher => '^\/osimage$',
GET => {
desc => "Get all the osimage in xCAT.",
usage => "||Json format: An array of osimage names.|",
example => "|Get all the osimage names.|GET|/osimages|[\n \"sles11.2-x86_64-install-compute\",\n \"sles11.2-x86_64-install-iscsi\",\n \"sles11.2-x86_64-install-iscsiibft\",\n \"sles11.2-x86_64-install-service\"\n]|",
desc => "Get all the osimage in xCAT.", usage => "||Json format: An array of osimage names.|",
example => "|Get all the osimage names.|GET|/osimage|[\n \"sles11.2-x86_64-install-compute\",\n \"sles11.2-x86_64-install-iscsi\",\n \"sles11.2-x86_64-install-iscsiibft\",\n \"sles11.2-x86_64-install-service\"\n]|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout_remove_appended_type,
},
POST => {
desc => "Create the osimage resources base on the parameters specified in the Data body.",
#usage => "|$usagemsg{objchparam} DataBody: {iso:isoname\\file:filename\\node:nodename,params:[{attr1:value1,attr2:value2}]}|$usagemsg{non_getreturn}|",
usage => "|$usagemsg{objchparam} DataBody: {iso:isoname\\file:filename,params:[{attr1:value1,attr2:value2}]}|$usagemsg{non_getreturn}|",
example1 => "|Create osimage resources based on the ISO specified|POST|/osimages {\"iso\":\"/iso/RHEL6.4-20130130.0-Server-ppc64-DVD1.iso\"}||",
example2 => "|Create osimage resources based on an xCAT image or configuration file|POST|/osimages {\"file\":\"/tmp/sles11.2-x86_64-install-compute.tgz\"}||",
# TD: the imgcapture need to be moved to nodes/.*/osimages
# example3 => "|Create a image based on the specified Linux diskful node|POST|/osimages {\"node\":\"rhcn1\"}||",
desc => "Create the osimage resources base on the parameters specified in the Data body. DataBody: {iso:isoname|file:filename|node:nodename,params:[{attr1:value,attr2:value2}]}",
usage => "|$usagemsg{objchparam} DataBody: {iso:isoname\\file:filename\\node:nodename,params:[{attr1:value,attr2:value2}]}|$usagemsg{non_getreturn}|",
example => "|Create osimage resouces based on the ISO specified|POST|/osimage {\"iso\":\"/iso/RHEL6.4-20130130.0-Server-ppc64-DVD1.iso\"}||",
cmd => "copycds",
fhandler => \&imgophdl,
outhdler => \&noout,
},
},
osimage_allattr => {
desc => "[URI:/osimages/{imgname}] - The osimage resource",
matcher => '^\/osimages\/[^\/]*$',
desc => "[URI:/osimage/{imgname}] - The osimage resource",
matcher => '^\/osimage\/[^\/]*$',
GET => {
desc => "Get all the attibutes for the osimage {imgname}.",
usage => "||$usagemsg{objreturn}|",
example => "|Get the attributes for the specified osimage.|GET|/osimages/sles11.2-x86_64-install-compute|{\n \"sles11.2-x86_64-install-compute\":{\n \"provmethod\":\"install\",\n \"profile\":\"compute\",\n \"template\":\"/opt/xcat/share/xcat/install/sles/compute.sles11.tmpl\",\n \"pkglist\":\"/opt/xcat/share/xcat/install/sles/compute.sles11.pkglist\",\n \"osvers\":\"sles11.2\",\n \"osarch\":\"x86_64\",\n \"osname\":\"Linux\",\n \"imagetype\":\"linux\",\n \"otherpkgdir\":\"/install/post/otherpkgs/sles11.2/x86_64\",\n \"osdistroname\":\"sles11.2-x86_64\",\n \"pkgdir\":\"/install/sles11.2/x86_64\"\n }\n}|",
usage => "|$usagemsg{objchparam}|$usagemsg{non_getreturn}|",
example => "|Get the attributes for the specified osimage.|GET|/osimage/sles11.2-x86_64-install-compute|{\n \"sles11.2-x86_64-install-compute\":{\n \"provmethod\":\"install\",\n \"profile\":\"compute\",\n \"template\":\"/opt/xcat/share/xcat/install/sles/compute.sles11.tmpl\",\n \"pkglist\":\"/opt/xcat/share/xcat/install/sles/compute.sles11.pkglist\",\n \"osvers\":\"sles11.2\",\n \"osarch\":\"x86_64\",\n \"osname\":\"Linux\",\n \"imagetype\":\"linux\",\n \"otherpkgdir\":\"/install/post/otherpkgs/sles11.2/x86_64\",\n \"osdistroname\":\"sles11.2-x86_64\",\n \"pkgdir\":\"/install/sles11.2/x86_64\"\n }\n}|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout,
},
POST => {
desc => "Create the osimage {imgname}.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,attr2:v2]|$usagemsg{non_getreturn}|",
example => "|Create a osimage obj with the specified parameters.|POST|/osimages/sles11.3-ppc64-install-compute {\"osvers\":\"sles11.3\",\"osarch\":\"ppc64\",\"osname\":\"Linux\",\"provmethod\":\"install\",\"profile\":\"compute\"}||",
cmd => "mkdef",
PUT => {
desc => "Change the attibutes for the osimage {imgname}.",
usage => "|$usagemsg{objchparam}|$usagemsg{non_getreturn}|",
example => "|Change the 'osvers' and 'osarch' attributes for the osiamge.|PUT|/osimage/sles11.2-x86_64-install-compute/ {\"osvers\":\"sles11.3\",\"osarch\":\"ppc64\"}||",
cmd => "chdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
PUT => {
desc => "Change the attibutes for the osimage {imgname}.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,attr2:v2...}|$usagemsg{non_getreturn}|",
example => "|Change the 'osvers' and 'osarch' attributes for the osiamge.|PUT|/osimages/sles11.2-ppc64-install-compute/ {\"osvers\":\"sles11.3\",\"osarch\":\"x86_64\"}||",
cmd => "chdef",
POST => {
desc => "Create the osimage {imgname}. DataBody: {attr1:v1,att2:v2...}.",
usage => "|$usagemsg{objchparam}|$usagemsg{non_getreturn}|",
example => "|Create a osimage obj with the specified parameters.|POST|/osimage/mysles/ {\"osvers\":\"sles11.3\",\"osarch\":\"ppc64\",\"osname\":\"Linux\",\"provmethod\":\"install\",\"profile\":\"compute\"}||",
cmd => "mkdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
DELETE => {
desc => "Remove the osimage {imgname}.",
usage => "||$usagemsg{non_getreturn}|",
example => "|Delete the specified osimage.|DELETE|/osimages/sles11.3-ppc64-install-compute||",
usage => "|$usagemsg{objchparam}|$usagemsg{non_getreturn}|",
example => "|Delete the specified osimage.|DELETE|/osimage/mysles||",
cmd => "rmdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
},
osimage_attr => {
desc => "[URI:/osimages/{imgname}/attrs/attr1,attr2,attr3 ...] - The attributes resource for the osimage {imgname}",
matcher => '^\/osimages\/[^\/]*/attrs/\S+$',
desc => "[URI:/osimage/{imgname}/attrs/attr1;attr2;attr3 ...] - The attributes resource for the osimage {imgname}",
matcher => '^\/osimage\/[^\/]*/attrs/\S+$',
GET => {
desc => "Get the specific attributes for the osimage {imgname}.",
usage => "||Json format: An array of attr:value pairs for the specified osimage.|",
example => "|Get the specified attributes.|GET|/osimages/sles11.2-ppc64-install-compute/attrs/imagetype,osarch,osname,provmethod|{\n \"sles11.2-ppc64-install-compute\":{\n \"provmethod\":\"install\",\n \"osname\":\"Linux\",\n \"osarch\":\"ppc64\",\n \"imagetype\":\"linux\"\n }\n}|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout,
},
# TD, the implementation may need to be change.
PUT_backup => {
desc => "Change the attibutes for the osimage {imgname}.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,attr2:v2...}|$usagemsg{non_getreturn}|",
example => "|Change the 'osvers' and 'osarch' attributes for the osiamge.|PUT|/osimages/sles11.2-ppc64-install-compute/attrs/osvers;osarch {\"osvers\":\"sles11.3\",\"osarch\":\"x86_64\"}||",
PUT => {
desc => "Change attributes for the osimage {imgname}. DataBody: {attr1:v1,att2:v2,att3:v3 ...}.",
cmd => "chdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
}
},
osimage_op => {
desc => "[URI:/osimages/{imgname}/instance] - The instance for the osimage {imgname}",
matcher => '^\/osimages\/[^\/]*/instance$',
desc => "[URI:/osimage/{imgname}/instance] - The instance for the osimage {imgname}",
matcher => '^\/osimage\/[^\/]*/instance$',
POST => {
desc => "Operate the instance of the osimage {imgname}.",
usage => "|$usagemsg{objchparam} DataBody: {action:gen\\pack\\export,params:[{attr1:value1,attr2:value2...}]}|$usagemsg{non_getreturn}|",
example1 => "|Generates a stateless image based on the specified osimage|POST|/osimages/sles11.2-x86_64-install-compute/instance {\"action\":\"gen\"}||",
example2 => "|Packs the stateless image from the chroot file system based on the specified osimage|POST|/osimages/sles11.2-x86_64-install-compute/instance {\"action\":\"pack\"}||",
example3 => "|Exports an xCAT image based on the specified osimage|POST|/osimages/sles11.2-x86_64-install-compute/instance {\"action\":\"export\"}||",
desc => "Operate the instance of the osimage {imgname}. DataBody: {action:gen|pack|export,params:[{attr1:v1,attr2:v2}]}",
cmd => "",
fhandler => \&imgophdl,
},
DELETE => {
desc => "Delete the stateless or statelite image instance for the osimage {imgname} from the file system",
usage => "||$usagemsg{non_getreturn}",
example => "|Delete the stateless image for the specified osimage|DELETE|/osimages/sles11.2-x86_64-install-compute/instance||",
desc => "Delete the instance for the osimage {imgname} from the file system",
cmd => "rmimage",
fhandler => \&imgophdl,
},
@@ -861,66 +822,82 @@ my %URIdef = (
matcher => '^\/policy$',
GET => {
desc => "Get all the policies in xCAT.",
desc1 => "It will dislplay all the policy resource.",
desc1 => "It will dislplay all the policies defined in policy table.",
usage => "||$usagemsg{objreturn}|",
example => "|Get all the policy objects.|GET|/policy|[\n \"1\",\n \"1.2\",\n \"2\",\n \"4.8\"\n]|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout_remove_appended_type,
},
POST_back => {
desc => "Create a new policy on xCAT MN.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Create |?|?|?|",
cmd => "chdef",
fhandler => \&defhdl,
},
},
policy_allattr => {
desc => "[URI:/policy/{policy_priority}] - The policy resource",
matcher => '^\/policy\/[^\/]*$',
GET => {
desc => "Get all the attibutes for a policy {policy_priority}.",
desc1 => "It will display all the policy attributes for one policy resource.",
desc1 => "It will display all the policy attributes for one policy entry defined in policy table.",
usage => "||$usagemsg{objreturn}|",
example => "|Get all the attribute for policy 1.|GET|/policy/1|{\n \"1\":{\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n}|",
example => "|Get all the attribute for policy 1.|GET|/policy/1|[\n {\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n]|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout,
},
PUT => {
desc => "Change the attibutes for the policy {policy_priority}.",
desc1 => "It will change one or more attributes for a policy.",
desc1 => "It will change one or more attributes defined in policy table.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Set the name attribute for policy 3.|PUT|/policy/3 {\"name\":\"root\"}||",
example => "|Set the name attribute for policy 3.|PUT|/policy/3 {\"name\":\"root\"}|[\n \"1 object definitions have been created or modified.\"\n]|",
cmd => "chdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
POST => {
desc => "Create the policy {policyname}. DataBody: {attr1:v1,att2:v2...}.",
desc1 => "It will creat a new policy resource.",
desc1 => "It will creat a new policy entry in policy table.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Create a new policy 10.|POST|/policy/10 {\"name\":\"root\",\"commands\":\"rpower\"}||",
example => "|Create a new policy 10.|POST|/policy/10 {\"name\":\"root\",\"commands\":\"rpower\"}|[\n \"1 object definitions have been created or modified.\"\n]|",
cmd => "chdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
DELETE => {
desc => "Remove the policy {policy_priority}.",
desc1 => "Remove one or more policy resource.",
desc1 => "Remove one or more policys defined in policy table.",
usage => "||$usagemsg{non_getreturn}|",
example => "|Delete the policy 10.|DELETE|/policy/10||",
example => "|Delete the policy 10.|DELETE|/policy/10|[\n \"1 object definitions have been removed.\"\n]|",
cmd => "rmdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
},
policy_attr => {
desc => "[URI:/policy/{policyname}/attrs/{attr1,attr2,attr3,...}] - The attributes resource for the policy {policy_priority}",
desc => "[URI:/policy/{policyname}/attrs/{attr1;attr2;attr3,...}] - The attributes resource for the policy {policy_priority}",
matcher => '^\/policy\/[^\/]*/attrs/\S+$',
GET => {
desc => "Get the specific attributes for the policy {policy_priority}.",
desc1 => "It will get one or more attributes of a policy.",
desc1 => "It will get one or more attributes defined in policy table.",
usage => "||$usagemsg{objreturn}|",
example => "|Get the name and rule attributes for policy 1.|GET|/policy/1/attrs/name,rule|{\n \"1\":{\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n}|",
example => "|Get the name and rule attributes for policy 1.|GET|/policy/1/attrs/name;rule|[\n {\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n]|",
cmd => "lsdef",
fhandler => \&defhdl,
outhdler => \&defout,
},
PUT => {
desc => "Change the attibutes for the policy {policy_priority}.",
desc1 => "It will change one or more attributes defined in policy table.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Set the name attribute for policy 3.|PUT|/policy/3 {\"name\":\"root\"}|[\n \"1 object definitions have been created or modified.\"\n]|",
cmd => "chdef",
fhandler => \&defhdl,
outhdler => \&noout,
},
},
},
#### definition for global setting resources
@@ -931,16 +908,16 @@ my %URIdef = (
matcher => '^\/globalconf$',
GET => {
desc => "Get all the xCAT global configuration.",
desc1=> "It will display all the global attributes.",
desc1=> "It will display all the attributes defined in site table.",
usage => "||$usagemsg{objreturn}|",
example => "|Get all the global configuration|GET|/globalconf|{\n \"clustersite\":{\n \"xcatconfdir\":\"/etc/xcat\",\n \"tftpdir\":\"/tftpboot\",\n ...\n }\n}|",
example => "|Get all the global configuration|GET|/globalconf|{\n \"clustersite\":{\n \"xcatconfdir\":\"/etc/xcat\",\n \"tftpdir\":\"/tftpboot\",\n ...\n }\n]|",
cmd => "lsdef",
fhandler => \&sitehdl,
outhdler => \&defout,
},
POST_backup => {
desc => "Add the site attributes. DataBody: {attr1:v1,att2:v2...}.",
desc1 => "One or more global attributes could be added/modified.",
desc1 => "One or more attributes could be added/modified to site table.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Add one or more attributes to xCAT database|POST|/globalconf {\"domain\":\"cluster.com\",\"mydomain\":\"mycluster.com\"}||",
cmd => "chdef",
@@ -954,19 +931,19 @@ my %URIdef = (
desc => "Get the specific configuration in global.",
desc1 => "It will display one or more global attributes.",
usage => "||$usagemsg{objreturn}|",
example => "|Get the \'master\' and \'domain\' configuration.|GET|/globalconf/attrs/master,domain|{\n \"clustersite\":{\n \"domain\":\"cluster.com\",\n \"master\":\"192.168.1.15\"\n }\n}|",
example => "|Get the \'master\' and \'domain\' configuration.|GET|/globalconf/attrs/master,domain|[\n {\n \"master\":\"192.168.1.1\",\n \"domain\":\"/cluster.com\",\n }\n|",
cmd => "lsdef",
fhandler => \&sitehdl,
outhdler => \&defout,
},
PUT => {
desc => "Change the global attributes.",
desc => "Change the attributes for the site table.",
desc1 => "It can be used for changing/adding global attributes.",
usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => "|Change/Add the domain attribute.|PUT|/globalconf/attrs/domain {\"domain\":\"cluster.com\"}||",
example => "|Change/Add the domain attribute.|PUT|/globalconf/attrs/domain {\"domain\":\"cluster.com\"||",
cmd => "chdef",
fhandler => \&sitehdl,
outhdler => \&noout,
outhdler => \&noout,
},
POST_backup => {
desc => "Create the global configuration entry. DataBody: {name:value}.",
@@ -974,73 +951,77 @@ my %URIdef = (
example => "|Create the domain attribute|POST|/globalconf/attrs/domain {\"domain\":\"cluster.com\"}|?|",
cmd => "chdef",
fhandler => \&sitehdl,
outhdler => \&noout,
outhdler => \&noout,
},
DELETE => {
desc => "Remove the site attributes.",
desc1 => "Used for femove one or more global attributes.",
desc1 => "Used for femove one or more global attributes defined in site table.",
usage => "||$usagemsg{non_getreturn}|",
example => "|Remove the domain configure.|DELETE|/globalconf/attrs/domain||",
cmd => "chdef",
fhandler => \&sitehdl,
outhdler => \&noout,
outhdler => \&noout,
},
},
},
#### definition for database/table resources
tables => {
table => {
table_nodes => {
desc => "[URI:/tables/{tablelist}/nodes] - The node table resource",
desc1 => "For a large number of nodes, this API call can be faster than using the corresponding nodes resource. The disadvantage is that you need to know the table names the attributes are stored in.",
matcher => '^/tables(/[^/]+)?/nodes(/[^/]+){0,2}$',
desc => "[URI:/table/{tablelist}/nodes/{noderange}/{attrlist}] - The node table resource",
matcher => '^/table/[^/]+/nodes(/[^/]+){0,2}$',
GET => {
desc => "[URI:/tables/{tablelist}/nodes/{noderange}/{attrlist}] - Get table attibutes for a noderange.",
desc1 => "If {attrlist} is omitted, all non-blank attributes will be returned. If {noderange} is omitted, attributes for all nodes will be returned.",
usage => "||An object containing each table. Within each table object is an array of node objects containing the attributes.|",
example => qq(|Get |GET|/tables/ipmi/nodes/node1/bmc|{\n "ipmi":[\n {\n "name":"node1",\n "bmc":"10.0.0.1"\n }\n ]\n}|),
#cmd => "getTablesNodesAttribs",
desc => "Get table attibutes for a noderange. {noderange} and {attrlist} are optional.",
usage => "||An object for the specific attributes.|",
example => "|Get |GET|/table/mac/nodes/node1/mac|{\n \"mac\":[\n {\n \"name\":\"node1\",\n \"mac\":\"mac=6c:ae:8b:41:3f:53\"\n }\n ]\n}|",
cmd => "getTablesNodesAttribs", # not used
fhandler => \&tablenodehdl,
outhdler => \&tableout,
},
PUT => {
desc => "[URI:/tables/nodes/{noderange}] - Change the node table attibutes for the {noderange}.",
usage => "|A hash of table names and attribute objects. DataBody: {table1:{attr1:v1,att2:v2,...}}.|$usagemsg{non_getreturn}|",
example => '|Change the nodehm.mgmt and noderes.netboot attributes for nodes node1-node5.|PUT|/tables/nodes/node1-node5 {"nodehm":{"mgmt":"ipmi"},"noderes":{"netboot":"xnba"}}||',
#cmd => "setNodesAttribs",
fhandler => \&tablenodeputhdl,
outhdler => \&noout,
},
#PUT => {
# desc => "Change the attibutes for the table {table}.",
# cmd => "chdef",
# fhandler => \&defhdl,
#outhdler => \&defout,
#},
#POST => {
# desc => "Create the table {table}. DataBody: {attr1:v1,att2:v2...}.",
# cmd => "mkdef",
# fhandler => \&defhdl,
#},
#DELETE => {
# desc => "Remove the table {table}.",
# cmd => "rmdef",
# fhandler => \&defhdl,
#},
},
table_rows => {
desc => "[URI:/tables/{tablelist}/rows/{keys}/{attrlist}] - The non-node table resource",
desc1 => "Use this for tables that don't have node name as the key of the table, for example: passwd, site, networks, polciy, etc.",
matcher => '^/tables/[^/]+/rows(/[^/]+){0,2}$',
desc => "[URI:/table/{tablelist}/row/{keys}/{attrlist}] - The non-node table resource",
matcher => '^/table/[^/]+/row(/[^/]+){0,2}$',
GET => {
desc => "Get attibutes for rows of non-node tables.",
desc1 => "If {attrlist} is omitted, all non-blank attributes will be returned. If {keys} is omitted, all rows will be returned. If {keys} is specified, only rows that have those key values will be returned. If {keys} is specified, only 1 table name can be specified in {tablelist}.",
usage => "||An object containing each table. Within each table object is an array of row objects containing the attributes.|",
example => qq(|Get|GET|/tables/networks/row/net=192.168.122.0,mask=255.255.255.0/mgtifname,tftpserver|{\n "mgtifname":"virbr0",\n "tftpserver":"192.168.122.1"\n}|),
#cmd => "getTablesAllRowAttribs",
desc => "Get attibutes for rows of non-node tables. {rows} and {attrlist} are optional.",
usage => "||?|",
example => qq(|Get|GET|/table/networks/row/net=192.168.122.0,mask=255.255.255.0/mgtifname,tftpserver|{\n "mgtifname":"virbr0",\n "tftpserver":"192.168.122.1"\n}|),
cmd => "getTablesAllRowAttribs", # not used
fhandler => \&tablerowhdl,
outhdler => \&tableout,
},
PUT => {
desc => "[URI:/tables/{table}/rows/{keys}] - Change the non-node table attibutes for the row that matches the {keys}.",
usage => "|A hash of attribute names and values. DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
example => '|Create a route row in the routes table.|PUT|/tables/routes/rows/routename=privnet {"net":"10.0.1.0","mask":"255.255.255.0","gateway":"10.0.1.254","ifname":"eth1"}||',
#cmd => "setAttribs",
fhandler => \&tablerowputhdl,
outhdler => \&noout,
},
DELETE => {
desc => "[URI:/tables/{table}/rows/{attrvals}] - Delete rows from a non-node table that have the attribute values specified in {attrvals}.",
usage => "||$usagemsg{non_getreturn}|",
example => '|Delete a route row in the routes table.|PUT|/tables/routes/rows/routename=privnet||',
#cmd => "delEntries",
fhandler => \&tablerowdelhdl,
outhdler => \&noout,
},
#PUT => {
# desc => "Change the attibutes for the table {table}.",
# cmd => "chdef",
# fhandler => \&defhdl,
#outhdler => \&defout,
#},
#POST => {
# desc => "Create the table {table}. DataBody: {attr1:v1,att2:v2...}.",
# cmd => "mkdef",
# fhandler => \&defhdl,
#},
#DELETE => {
# desc => "Remove the table {table}.",
# cmd => "rmdef",
# fhandler => \&defhdl,
#},
},
},
@@ -1173,11 +1154,11 @@ my $JSON; # global ptr to the json object. Its set by loadJSON()
# need to do this early, so we can fetch the PUT/POST params
loadJSON();
# the input parameters from both the url and put/post data will be combined and then
# the input parameters from both the url and put/post data will combined and then
# separated into the general params (not specific to the api call) and params specific to the call
# Note: some of the values of the params in the hash can be arrays
# $generalparams - the general parameters like 'debug=1', 'pretty=1'
# $paramhash - all parameters that come from the url or put/post data except the ones that are put in $generalparams
# $paramhash - all parameters come from url or put/post data except the ones in $generalparams
my ($generalparams, $paramhash) = fetchParameters();
my $DEBUGGING = $generalparams->{debug}; # turn on or off the debugging output by setting debug=1 (or 2) in the url string
@@ -1609,14 +1590,14 @@ sub defhdl {
push @args, ('-o', $urilayers[1]);
}
# For the put/post which specifies attributes like mgt=ipmi groups=all
# For the put/post which specifies the attributes mgt=ipmi groups=all
foreach my $k (keys(%$paramhash)) {
push @args, "$k=$paramhash->{$k}" if ($k);
}
if ($params->{'resourcename'} eq "allnode") {
push @args, '-s';
} elsif ($params->{'resourcename'} =~ /(nodeattr|osimage_attr|group_attr|policy_attr|network_attr)/) {
} elsif ($params->{'resourcename'} =~ /(nodeattr|osimage_attr|group_attr|policy_attr)/) {
# if /nodes/node1/attrs/attr1,att2 is specified, for get request,
# use 'lsdef -i' to specify the attribute list
my $attrs = $urilayers[3];
@@ -1824,8 +1805,7 @@ sub imgophdl {
push @{$params->{layers}}, $paramhash->{'file'};
} elsif (exists($paramhash->{'node'})) {
$params->{'cmd'} = "imgcapture";
#push @{$params->{layers}}, $paramhash->{'node'};
push @{$request->{noderange}}, $paramhash->{'node'};
push @{$params->{layers}}, $paramhash->{'node'};
} else {
error("Invalid source.",$STATUS_NOT_FOUND);
}
@@ -1854,13 +1834,13 @@ sub sitehdl {
# push the -t args
push @args, '-t';
push @args, 'site';
if (isGET()) {
if (isGET()) {
push @args, 'clustersite';
}
}
if (defined ($urilayers[2])){
if (isGET()) {
push @args, ('-i', $urilayers[2]);
}
}
}
if (isDelete()) {
if (defined ($urilayers[2])){
@@ -1887,7 +1867,7 @@ sub tablenodehdl {
# the array elements for @urilayers are:
# 0 - 'table'
# 1 - <tablelist>
# 2 - 'nodes'
# 2 - 'node'
# 3 - <noderange> (optional)
# 4 - <attrlist> (optional)
@@ -1901,23 +1881,6 @@ sub tablenodehdl {
$request->{noderange} = $urilayers[3];
}
# For both getTablesAllNodeAttribs and getTablesNodesAttribs, the rest of the request strucutre looks like this:
# table => [
# {
# tablename => nodehm,
# attr => [
# mgmt,
# cons
# ]
# },
# {
# tablename => ipmi,
# attr => [
# ALL
# ]
# }
# ]
# if they specified attrs, sort/group them by table
my $attrlist = $urilayers[4];
if (!defined($attrlist)) { $attrlist = 'ALL'; } # attr=ALL means get all non-blank attributes
@@ -1960,7 +1923,7 @@ sub tablerowhdl {
# the array elements for @urilayers are:
# 0 - 'table'
# 1 - <tablelist>
# 2 - 'rows'
# 2 - 'row'
# 3 - <key-val-list> (optional)
# 4 - <attrlist> (optional)
@@ -1973,22 +1936,6 @@ sub tablerowhdl {
# get all rows for potentially multiple tables
if (!defined($urilayers[3]) || $urilayers[3] eq 'ALLROWS') {
$request->{command} = 'getTablesAllRowAttribs';
# For getTablesAllRowAttribs, the rest of the request strucutre needs to look like this:
# table => [
# {
# tablename => nodehm,
# attr => [
# mgmt,
# cons
# ]
# },
# {
# tablename => ipmi,
# attr => [
# ALL
# ]
# }
# ]
# if they specified attrs, sort/group them by table
my %attrhash;
@@ -2015,18 +1962,6 @@ sub tablerowhdl {
else {
if (scalar(@tables) > 1) { error('currently you can only specify keys for a single table.', $STATUS_BAD_REQUEST); }
$request->{command} = 'getAttribs';
# For getAttribs, the rest of the request strucutre needs to look like this:
# {
# table => networks,
# keys => {
# net => 11.35.0.0,
# mask => 255.255.0.0
# }
# attr => [
# netname,
# dhcpserver
# ]
# },
$request->{table} = $tables[0];
if (defined($urilayers[3])) {
my @keyvals = split(/,/, $urilayers[3]);
@@ -2046,13 +1981,13 @@ sub tablerowhdl {
return $responses;
}
# parse the output of all attrs of tables for the GET calls. This is used for both node-oriented tables
# parse the output of all attrs of tables. This is used for both node-oriented tables
# and non-node-oriented tables.
#todo: investigate a converter straight from xml to json
sub tableout {
my $data = shift;
my $json = {};
# For the table get calls, we turned off ForceArray and KeyAttr for XMLin(), so the output is a little
# For the table calls, we turned off ForceArray and KeyAttr for XMLin(), so the output is a little
# different than usual. Each element is a hash with key "table" that is either a hash or array of hashes.
# Each element of that is a hash with 2 keys called "tablename" and "node". The latter has either: an array of node hashes,
# or (if there is only 1 node returned) the node hash directly.
@@ -2060,7 +1995,7 @@ sub tableout {
foreach my $d (@$data) {
my $table = $d->{table};
if (!defined($table)) { # special case for the getAttribs cmd
$json->{$request->{table}}->[0] = $d;
$json = $d;
last;
}
#debug(Dumper($d)); debug (Dumper($jsonnode));
@@ -2080,159 +2015,6 @@ sub tableout {
addPageContent($JSON->encode($json));
}
# set attrs of nodes in tables
sub tablenodeputhdl {
my $params = shift;
# from the %URIdef:
# desc => "[URI:/tables/nodes/{noderange}] - Change the table attibutes for the {noderange}.",
# usage => "|An array of table objects. Each table object contains the table name and an object of attribute values. DataBody: {table1:{attr1:v1,att2:v2,...}}.|$usagemsg{non_getreturn}|",
# example => '|Change the nodehm.mgmt and noderes.netboot attributes for nodes node1-node5.|PUT|/tables/nodes/node1-node5 {"nodehm":{"mgmt":"ipmi"},"noderes":{"netboot":"xnba"}}||',
my @args;
my @urilayers = @{$params->{'layers'}};
# the array elements for @urilayers are:
# 0 - 'table'
# 1 - 'nodes'
# 2 - <noderange>
# set the command name
$request->{command} = 'setNodesAttribs';
$request->{noderange} = $urilayers[2];
# For setNodesAttribs, the rest of the request strucutre looks like this:
# arg => {
# table => [
# {
# name => nodehm,
# attr => {
# mgmt => ipmi
# }
# },
# {
# name => noderes,
# attr => {
# netboot => xnba
# }
# }
# ]
# }
# Go thru the list of tables (which are the top level keys in paramhash)
my $tables = [];
$request->{arg}->{table} = $tables;
foreach my $k (keys(%$paramhash)) {
my $intable = $k;
my $attrhash = $paramhash->{$k};
my $outtable = { name=>$intable, attr=>$attrhash };
push @$tables, $outtable;
}
my $req = genRequest();
# disabling the KeyAttr option is important in this case, so xmlin doesn't pull the name attribute
# out of the node hash and make it the key
my $responses = sendRequest($req, {SuppressEmpty => undef, ForceArray => 1, KeyAttr => []});
return $responses;
}
# set attrs of a row in a non-node table
sub tablerowputhdl {
my $params = shift;
# from %URIdef:
# desc => "[URI:/tables/{table}/rows/{keys}] - Change the non-node table attibutes for the row that matches the {keys}.",
# usage => "|A hash of attribute names and values. DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|",
# example => '|Creat a route row in the routes table.|PUT|/tables/routes/rows/routename=privnet {"net":"10.0.1.0","mask":"255.255.255.0","gateway":"10.0.1.254","ifname":"eth1"}||',
my @args;
my @urilayers = @{$params->{'layers'}};
# the array elements for @urilayers are:
# 0 - 'table'
# 1 - <tablename>
# 2 - 'rows'
# 3 - <keys>
# set the command name
$request->{command} = 'setAttribs';
# For setAttribs, the rest of the xml request strucutre looks like this:
# <table>routes</table>
# <keys>
# <routename>foo</routename>
# </keys>
# <attr>
# <net>10.0.1.0</net>
# <comments>This is a test</comments>
# </attr>
# set the table name and keys
$request->{table} = $urilayers[1];
my @keyvals = split(/,/, $urilayers[3]);
foreach my $kv (@keyvals) {
my ($key, $value) = split(/\s*=\s*/, $kv, 2);
$request->{keys}->{$key} = $value;
}
# the attribute/value hash is already in paramhash
$request->{attr} = $paramhash;
my $req = genRequest();
# disabling the KeyAttr option is important in this case, so xmlin doesn't pull the name attribute
# out of the node hash and make it the key
my $responses = sendRequest($req, {SuppressEmpty => undef, ForceArray => 1, KeyAttr => []});
return $responses;
}
# delete rows in a non-node table
sub tablerowdelhdl {
my $params = shift;
# from %URIdef:
# desc => "[URI:/tables/{table}/rows/{attrvals}] - Delete rows from a non-node table that have the attribute values specified in {attrvals}.",
# usage => "||$usagemsg{non_getreturn}|",
# example => '|Delete a route row in the routes table.|PUT|/tables/routes/rows/routename=privnet||',
my @args;
my @urilayers = @{$params->{'layers'}};
# the array elements for @urilayers are:
# 0 - 'table'
# 1 - <tablename>
# 2 - 'rows'
# 3 - <attrvals>
# set the command name
$request->{command} = 'delEntries';
# For delEntries, the rest of the xml request strucutre looks like this:
# <table>
# <name>nodelist</name>
# <attr>
# <groups>compute1,lissa</groups>
# <status>down</status>
# </attr>
# </table>
# set the table name and attr/vals
my $table = {}; # will hold the name and attr/vals
$request->{table}->[0] = $table; #todo: the xcat delEntries cmd supports multiple tables in 1 request. We could support this if the attr names were table.attr
$table->{name} = $urilayers[1];
my @attrvals = split(/,/, $urilayers[3]);
foreach my $av (@attrvals) {
my ($attr, $value) = split(/\s*=\s*/, $av, 2);
$table->{attr}->{$attr} = $value;
}
my $req = genRequest();
# disabling the KeyAttr option is important in this case, so xmlin doesn't pull the name attribute
# out of the node hash and make it the key
my $responses = sendRequest($req, {SuppressEmpty => undef, ForceArray => 1, KeyAttr => []});
return $responses;
}
# display the resource list when run 'restapi.pl -d'
sub displayUsage {
foreach my $group (keys %URIdef) {
@@ -2340,12 +2122,8 @@ sub filterData {
#} else {
#otherwise, ignore the 'servicedone' data
# next;
} else {
delete ($_->{serverdone});
if (scalar(keys %{$_}) > 0) {
push @{$outputdata}, $_;
}
}
push @{$outputdata}, $_;
} else {
if (defined ($_->{data}) && ref($_->{data}->[0]) ne "HASH") {
# to get the message in data for the case that errorcode is set but no 'error' attr
@@ -2567,7 +2345,7 @@ sub fetchParameters {
$phash = eval { $JSON->decode($pdata); };
if ($@) {
# remove the code location information to make the output looks better
if ($@ =~ m/ at \//) {
if ($@ =~ / at \//) {
$@ =~ s/ at \/.*$//;
}
error("$@",$STATUS_BAD_REQUEST);
+120 -182
View File
@@ -1,197 +1,135 @@
#! /bin/sh
#!/bin/bash
# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html
# Test driver for xcatws.cgi, pass 3 arguments to it: user, password, noderange
# This test driver will create to dummy nodes, wstest1 and wstest2, so make sure those
# names don't conflict with your nodes on this MN.
# You also have to pass in a noderange of 2 real system x nodes that can be used
# to test some of the r cmds, xdsh, xdcp, nodestat.
# Get all the parameters
for i in $@
do
if [ "$paramname" = "USER" ]; then
USER=$i
paramname=
fi
if [ "$paramname" = "PW" ]; then
PW=$i
paramname=
fi
if [ "$paramname" = "HOST" ]; then
HOST=$i
paramname=
fi
if [ $i = '-u' ]; then
paramname=USER
fi
if [ $i = '-p' ]; then
paramname=PW
fi
if [ $i = '-h' ]; then
paramname=HOST
fi
if [ $i = '-c' ]; then
cert=yes
fi
if [ $i = '-t' ]; then
token=yes
fi
done
# display the usage message
function usage {
echo "Usage:"
echo " xcatws-test.sh -u <USER> -p <pw> [-t]"
echo " xcatws-test.sh -u <USER> -p <pw> -h <FQDN - Full hostname of server> [-c] [-t]"
echo " -u The username of xCAT user which is used to access xCAT resource"
echo " -p The password of username"
echo " <FQDN of xCAT MN> The fully qualified hostname of xCAT management node. It can be an IP if using -k."
echo " -c Check the server identity. The server certificate authentication must be enabled."
echo " -t Using token authentication method."
}
if [ "$USER" = "" ] || [ "$PW" = "" ]; then
echo "Error: Miss username or password"
usage
exit 1
fi
if [ "$cert" = "yes" ] && [ "$HOST" = "" ]; then
echo "Error: -c must be used with -h that user needs specify the FQDN of xCAT MN"
usage
exit 1
user=$1
pw=$2
nr=$3
if [ -z "$3" ]; then
echo "Usage: chkrc <user> <pw> <noderange>"
exit
fi
if [ "$HOST" = "" ]; then
HOST="127.0.0.1"
fi
format='format=json&pretty=1'
ctype='-H Content-Type:application/json'
# Perform the REST API request
function REST {
METHOD=$1 # it should be GET/PUT/POST/DELETE
SRC=$2 # The resource path like /nodes/node1
DATA=$3 # The operation data for PUT/POST/DELETE
if [ "$DATA" != "" ]; then
datamsg="$ctype -d $DATA"
fi
if [ "$cert" = "yes" ]; then
if [ "$token" = "yes" ]; then
CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1"
else
CMD="curl -X $METHOD --cacert /tmp/ca-cert.pem $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW"
fi
else
if [ "$token" = "yes" ]; then
CMD="curl -X $METHOD -k -H X-Auth-Token:$TOKENID $datamsg https://$HOST/xcatws$SRC?pretty=1"
else
CMD="curl -X $METHOD -k $datamsg https://$HOST/xcatws$SRC?pretty=1&userName=$USER&password=$PW"
fi
fi
echo "-------------------------------------------------------------------------------"
echo "Run: [$RESTMSG]"
echo " $CMD"
echo "Output:"
`$CMD 2>/dev/null >/tmp/xcatws-test.log`
cat "/tmp/xcatws-test.log"
echo ""
ERROR=`grep "errorcode" "/tmp/xcatws-test.log"`
if [ "$ERROR" != "" ]; then
echo "FAILED to continue. See the error message in 'error' section."
echo ""
exit 2
fi
function chkrc
{
rc=$?
{ set +x; } 2>/dev/null
if [[ $1 == "not" ]]; then
if [[ $rc -eq 0 ]]; then
echo "Test failed!"
exit
fi
else
if [[ $rc -gt 0 ]]; then
echo "Test failed!"
exit
fi
fi
echo ''
set -x
}
function PUT {
SRC=$1
}
# pcregrep -M 'abc.*(\n|.)*efg' test.txt
# echo debug message
echo "***********************************************************"
echo "** Username: $USER"
echo "** Password: $PW"
echo "** Hostname: $HOST"
#todo: add a test case for every api call that is documented
set -x
# clean up from last time
curl -# -X DELETE -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw" >/dev/null; echo ''
# create test nodes
curl -# -X POST -k "https://127.0.0.1/xcatws/node/wstest1-wstest2?userName=$user&password=$pw&$format" $ctype --data '{"groups":"wstest","netboot":"xnba"}' \
| grep -q '2 object definitions have been created'; chkrc
# list all nodes and make sure they are in the list
curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&$format" \
| pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc
# list all node's group and netboot attributes
curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&field=groups&field=netboot" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# list all attributes of all nodes
curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&field=ALL" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# list the noderange and make sure they are in the list
curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&$format" \
| pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc
# list all node's group and netboot attributes
curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&field=groups&field=netboot" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# list all attributes of all nodes
curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&field=ALL" \
| grep -qE '"nodename":"wstest1".*"groups":"wstest"'; chkrc
# change some attributes
curl -# -X PUT -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&$format" $ctype --data '{"room":"222","netboot":"pxe"}' \
| grep -q '2 object definitions have been created or modified'; chkrc
# verify they got the new values
curl -# -X GET -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&field=room&field=netboot" \
| grep -qE '"nodename":"wstest1".*"room":"222"'; chkrc
# delete the nodes
curl -# -X DELETE -k "https://127.0.0.1/xcatws/node/wstest?userName=$user&password=$pw&$format" \
| grep -q '2 object definitions have been removed'; chkrc
# list all nodes and make sure they are not in the list
curl -# -X GET -k "https://127.0.0.1/xcatws/node?userName=$user&password=$pw&$format" \
| pcregrep -qM '"wstest1",\n\s*"wstest2"'; chkrc not
# list the power state of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/power?userName=$user&password=$pw&$format" \
| grep -q '"power":"on"'; chkrc
# list the nodestat state of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/status?userName=$user&password=$pw&$format" \
| grep -q '":"sshd"'; chkrc
# list the node inventory of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/inventory?userName=$user&password=$pw&$format" \
| grep -q '"Board manufacturer":"IBM"'; chkrc
# list the node vitals of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/vitals?userName=$user&password=$pw&$format" \
| grep -q '"Cooling Fault":"false"'; chkrc
# list the node energy settings of the noderange
curl -# -X GET -k "https://127.0.0.1/xcatws/node/$nr/energy?userName=$user&password=$pw&$format&field=cappingstatus&field=cappingmaxmin" \
| grep -q '"cappingstatus":"off"'; chkrc
# run a cmd on the noderange
curl -# -X POST -k "https://127.0.0.1/xcatws/node/$nr/dsh?userName=$user&password=$pw&$format" $ctype --data '{"command":"pwd"}' \
| grep -q '"/root"'; chkrc
# copy a file to the noderange
curl -# -X POST -k "https://127.0.0.1/xcatws/node/$nr/dcp?userName=$user&password=$pw&$format" $ctype --data '{"source":"/root/.bashrc","target":"/tmp/"}' \
| grep -q '"errorcode":"0"'; chkrc
# test the table calls
curl -# -X GET -k "https://127.0.0.1/xcatws/table/nodelist/wstest?userName=$user&password=$pw&$format"
# get the CA of server certificate
if [ "$cert" = "yes" ]; then
rm -f /tmp/ca-cert.pem
cd /tmp
wget http://$HOST/install/postscripts/ca/ca-cert.pem 2>1 1>/dev/null
echo "** Using CA /tmp/ca-cert.pem for server certificate checking"
fi
exit
# get a token
if [ "$token" = "yes" ]; then
TOKENID=$(curl -X POST -k "https://$HOST/xcatws/tokens?pretty=1" -H Content-Type:application/json --data "{\"userName\":\"$USER\",\"password\":\"$PW\"}" 2>/dev/null | grep '"id"' | awk -F: {'print $2'} | awk -F \" {'print $2'})
echo "** Using Token: $TOKENID to authenticate"
fi
echo "***********************************************************"
echo ""
#curl -X GET -k "https://127.0.0.1/xcatws/groups?userName=$user&password=$pw&$format"
# clean the env
rmdef -t node restapinode[1-9] 1>/dev/null 2>1
rmdef -t group restapi 1>/dev/null 2>1
# get all resources
RESTMSG="Get all available resource"
REST GET "/"
# test global conf
RESTMSG="Get all global configuration resource"
REST GET "/globalconf"
RESTMSG="Change the global configuration domain to cluster.com"
REST PUT "/globalconf/attrs/domain" '{"domain":"cluster.com"}'
RESTMSG="Get the global configuration domain"
REST GET "/globalconf/attrs/domain"
# test node create/change/list/delete
RESTMSG="Create node restapinode1"
REST POST "/nodes/restapinode1" '{"groups":"restapi","arch":"x86_64","mgt":"ipmi","netboot":"xnba"}'
RESTMSG="Display the node restapinode1"
REST GET "/nodes/restapinode1"
RESTMSG="Change the attributes for node restapinode1"
REST PUT "/nodes/restapinode1" '{"mgt":"fsp","netboot":"yaboot"}'
RESTMSG="Display the node restapinode1"
REST GET "/nodes/restapinode1"
RESTMSG="Delete node restapinode1"
REST DELETE "/nodes/restapinode1"
# test multiple nodes manipulation
RESTMSG="Create node restapinode1 and restapinode2"
REST POST "/nodes/restapinode1,restapinode2" '{"groups":"restapi","arch":"x86_64","mgt":"ipmi","netboot":"xnba"}'
RESTMSG="Display the node restapinode1 and restapinode2"
REST GET "/nodes/restapinode1,restapinode2"
RESTMSG="Change the attributes for node restapinode1 and restapinode2"
REST PUT "/nodes/restapinode1,restapinode2" '{"mgt":"hmc","netboot":"grub2"}'
RESTMSG="Display the node restapinode1 and restapinode2"
REST GET "/nodes/restapinode1,restapinode2"
RESTMSG="Display all the nodes in the cluster"
REST GET "/nodes"
# test group
RESTMSG="Display the group restapi"
REST GET "/groups/restapi"
RESTMSG="Change attributes for group restapi"
REST PUT "/groups/restapi" '{"os":"rh7"}'
RESTMSG="Display the group restapi"
REST GET "/groups/restapi"
RESTMSG="Display the nodes in group restapi"
REST GET "/nodes/restapi"
#curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format"
#curl -X GET -k "https://127.0.0.1/xcatws/images?userName=$user&password=$pw&$format&field=osvers"
#curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format"
#curl -X GET -k "https://127.0.0.1/xcatws/images/bp-netboot?userName=$user&password=$pw&$format&field=osvers"
#todo: remove when these test cases are in xcatws-test.pl
#./xcatws-test.pl -u "https://127.0.0.1/xcatws/node/test001?userName=$user&password=$pw" -m GET
#./xcatws-test.pl -u "https://127.0.0.1/xcatws/node/test001?userName=$user&password=$pw" -m PUT "nodepos.room=foo"
File diff suppressed because it is too large Load Diff
@@ -25,7 +25,7 @@ cmd:copycds $$ISO
check:rc==0
cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__
check:rc==0
cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute
check:rc==0
+1 -13
View File
@@ -477,11 +477,10 @@ sub loadcase
$j = -1;
$cases[$i]={};
$cases[$i]->{name}=$name;
$cases[$i]->{filename}=$file;
$cases[$i]->{filename}=$file;
if(!$needshow){
$cases[$i]->{cmd}=[];
$cases[$i]->{check}=[];
$cases[$i]->{cmdcheck}=[];
push(@rightcase, $name);
}else{
$skip = 1;
@@ -546,14 +545,6 @@ sub loadcase
return 1;
}
$z = $z + 1;
}elsif($line =~ /^cmdcheck\s*:\s*(\w.+)/){
next if $skip;
$cases[$i]->{cmdcheck}->[$j][$z] = &getvar($1);
if($cases[$i]->{cmdcheck}->[$j][$z] eq ''){
close(FILE);
return 1;
}
$z = $z + 1;
}elsif($line =~ /^end/){
next if $skip;
$i = $i + 1;
@@ -765,9 +756,6 @@ sub runcase
}
}
}
foreach my $cmdcheck (@{$$case{cmdcheck}->[$j]}){
&runcmd($cmdcheck);
}
$j = $j + 1;
}
my $now2=timelocal(localtime());
-11
View File
@@ -27,10 +27,6 @@ function configipv4(){
echo "NETWORK_${num_v4num}=${str_v4net}" >> $str_conf_file
echo "LABEL_${num_v4num}=${num_v4num}" >> $str_conf_file
fi
if [[ ${str_if_name} == [a-zA-Z0-9]*.[0-9]* ]]; then
echo "VLAN=yes" >> $str_conf_file
fi
#debian ubuntu
elif [ "$str_os_type" = "debian" ];then
str_conf_file="/etc/network/interfaces.d/${str_if_name}"
@@ -44,10 +40,6 @@ function configipv4(){
echo " address ${str_v4ip}" >> $str_conf_file
echo " netmask ${str_v4mask}" >> $str_conf_file
echo " network ${str_v4net}" >> $str_conf_file
if [[ ${str_if_name} == [a-zA-Z0-9]*.[0-9]* ]]; then
parent_device=`echo ${str_if_name} | sed -e 's/\([a-zA-Z0-9]*\)\.[0-9]*/\1/g'`
echo " vlan-raw-device ${parent_device}" >> $str_conf_file
fi
else
# Write the info to the ifcfg file for redhat
str_conf_file=""
@@ -64,9 +56,6 @@ function configipv4(){
echo "IPADDR=${str_v4ip}" >> $str_conf_file
echo "NETMASK=${str_v4mask}" >> $str_conf_file
echo "ONBOOT=yes" >> $str_conf_file
if [[ ${str_if_name} == [a-zA-Z0-9]*.[0-9]* ]]; then
echo "VLAN=yes" >> $str_conf_file
fi
fi
}
+3 -1
View File
@@ -68,4 +68,6 @@ echo "$TMP" > /tmp/xcatenv
. /tmp/xcatenv
/xcatpost/addsiteyum
/xcatpost/updateflag.awk $MASTER 3002
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
/xcatpost/updateflag.awk $MASTER 3002
fi
+14 -20
View File
@@ -163,30 +163,21 @@ cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT
%post
%ifos linux
#Apply the correct httpd/apache configuration file according to the httpd/apache version
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
if expr match $(rpm -q --queryformat "%{VERSION}" httpd) '^2.4[\.0-9]*$' >/dev/null 2>&1
then
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
elif [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
then
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
ln -s -f /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf
else
rm -rf /etc/httpd/conf.d/xcat.conf
cp /etc/httpd/conf.d/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf
rm -rf /etc/apache2/conf.d/xcat.conf
cp /etc/apache2/conf.d/xcat.conf.apach22 /etc/apache2/conf.d/xcat.conf
ln -s -f /etc/httpd/conf.d/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf
fi
rm -rf /etc/apache2/conf.d/xcat.conf.apach22
rm -rf /etc/apache2/conf.d/xcat.conf.apach24
rm -rf /etc/httpd/conf.d/xcat.conf.apach22
rm -rf /etc/httpd/conf.d/xcat.conf.apach24
%endif
if expr match $(rpm -q --queryformat "%{VERSION}" apache2) '^2.4[\.0-9]*$' >/dev/null 2>&1
then
ln -s -f /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf
else
ln -s -f /etc/apache2/conf.d/xcat.conf.apach22 /etc/apache2/conf.d/xcat.conf
fi
# create dir for the current pid
mkdir -p /var/run/xcat
@@ -220,11 +211,12 @@ exit 0
%files
%{prefix}
# one for sles, one for rhel. yes, it's ugly...
/etc/apache2/conf.d/xcat.conf.apach22
/etc/apache2/conf.d/xcat.conf.apach24
/etc/httpd/conf.d/xcat.conf.apach22
/etc/httpd/conf.d/xcat.conf.apach24
/etc/apache2/conf.d/xcat.conf.apach22
/etc/apache2/conf.d/xcat.conf.apach24
/etc/xCATMN
/install/postscripts
/install/prescripts
@@ -238,6 +230,8 @@ exit 0
if [ "$1" = "0" ]; then
rm /etc/httpd/conf.d/xcat.conf
rm /etc/apache2/conf.d/xcat.conf
%ifnos linux
if grep "^xcatd" /etc/inittab >/dev/null