mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 03:32:04 +00:00
Merge our code with global xCAT team except for xcatws.cgi
Change-Id: I945c430685fa2febd914be09f6a6f976783abeec
This commit is contained in:
parent
651cdaaaa1
commit
5a83bf5e63
@ -31,7 +31,7 @@ This program module file, is a set of utilities used by xCAT daemon.
|
||||
Here is where we check if $peername is allowed to do $request in policy tbl.
|
||||
$peername, if set signifies client has a cert that the xCAT CA accepted.
|
||||
Logs to syslog and auditlog table all user commands, see site.auditskipcmds
|
||||
attribute and auditnosyslog attribute.
|
||||
attribute and auditnosyslog attribute.
|
||||
|
||||
Arguments:
|
||||
|
||||
@ -94,7 +94,7 @@ sub validate {
|
||||
$req_noderange_info{leftnodes} = \@tmpn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RULE: foreach $rule (@sortedpolicies) {
|
||||
if ($rule->{name} and $rule->{name} ne '*') {
|
||||
|
||||
@ -163,7 +163,7 @@ sub validate {
|
||||
push @non_hit_nodes, $_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($hitnum == 0){
|
||||
next RULE;
|
||||
}elsif($hitnum && $hitnum != $req_noderange_info{leftnodenum}){
|
||||
@ -227,7 +227,32 @@ sub validate {
|
||||
|
||||
$arglist .= " " . $argument;
|
||||
}
|
||||
if ($arglist) { $logst .= $arglist; }
|
||||
my $saveArglist = $arglist;
|
||||
|
||||
# If this is mkvm check for --password or -w
|
||||
if ($request->{command}->[0] eq "mkvm") {
|
||||
|
||||
my $first;
|
||||
my $restcommand;
|
||||
my $passw = index ($saveArglist, '--password');
|
||||
if ($passw > -1) {
|
||||
$passw = $passw + 11;
|
||||
my $first = substr($saveArglist,0,$passw). "******** ";
|
||||
my $restcommand = substr($saveArglist,$passw);
|
||||
$restcommand =~ s/^\S+\s*//;
|
||||
$saveArglist = "$first$restcommand";
|
||||
}
|
||||
# now check for -w with password
|
||||
$passw = index ($saveArglist, '-w');
|
||||
if ($passw > -1) {
|
||||
$passw = $passw + 3;
|
||||
$first = substr($saveArglist,0,$passw). "******** ";
|
||||
$restcommand = substr($saveArglist,$passw);
|
||||
$restcommand =~ s/^\S+\s*//;
|
||||
$saveArglist = "$first$restcommand";
|
||||
}
|
||||
}
|
||||
if ($arglist) { $logst .= $saveArglist; }
|
||||
if ($peername) { $logst .= " for " . $request->{username}->[0] }
|
||||
if ($peerhost) { $logst .= " from " . $peerhost }
|
||||
|
||||
@ -319,7 +344,7 @@ sub validate {
|
||||
|
||||
if($req_noderange_info{leftnodenum}){
|
||||
my $leftnodes = join(",", @{$req_noderange_info{leftnodes}});
|
||||
xCAT::MsgUtils->message("S", "Request matched no policy rule: peername=$peername, peerhost=$peerhost $request->{command}->[0] to $leftnodes");
|
||||
xCAT::MsgUtils->message("S", "Request matched no policy rule: peername=$peername, peerhost=$peerhost $request->{command}->[0] to $leftnodes");
|
||||
}else{
|
||||
xCAT::MsgUtils->message("S", "Request matched no policy rule: peername=$peername, peerhost=$peerhost " . $request->{command}->[0]);
|
||||
}
|
||||
|
@ -46,10 +46,16 @@ sub process_request {
|
||||
@ARGV = @{ $request->{arg} } if (defined $request->{arg});
|
||||
my $argc = scalar @ARGV;
|
||||
|
||||
my $usage = "Usage:\n imgcapture <node> -t|--type {diskless|sysclone} -o|--osimage <osimage> [-V | --verbose] \n imgcapture [-h|--help] \n imgcapture [-v|--version]";
|
||||
my $usage = "Usage: imgcapture <node> -t|--type diskless [-p | --profile <profile>] " .
|
||||
"[-o|--osimage <osimage>] [-i <nodebootif>] [-n <nodenetdrivers>] " .
|
||||
"[-d | --device <devicesToCapture>] [-c | --compress <compressionLevel>] [-V | --verbose] \n\n" .
|
||||
"imgcapture <node> -t|--type sysclone -o|--osimage <osimage> [-V | --verbose] \n" .
|
||||
"imgcapture [-h|--help] \n" .
|
||||
"imgcapture [-v|--version]";
|
||||
|
||||
my $os;
|
||||
my $arch;
|
||||
my $compression; # Supported by the s390x architecture
|
||||
my $device;
|
||||
my $profile;
|
||||
my $bootif;
|
||||
@ -65,6 +71,7 @@ sub process_request {
|
||||
'n=s' => \$netdriver,
|
||||
'osimage|o=s' => \$osimg,
|
||||
"device|d=s" => \$device,
|
||||
"compress|c=s" => \$compression,
|
||||
"help|h" => \$help,
|
||||
"version|v" => \$version,
|
||||
"verbose|V" => \$verbose,
|
||||
@ -123,7 +130,7 @@ sub process_request {
|
||||
# Handle image capture separately for s390x
|
||||
if ($arch eq 's390x') {
|
||||
eval { require xCAT_plugin::zvm; }; # Load z/VM plugin dynamically
|
||||
xCAT_plugin::zvm->imageCapture($callback, $node, $os, $arch, $profile, $osimg, $device);
|
||||
xCAT_plugin::zvm->imageCapture($callback, $node, $os, $arch, $type, $profile, $osimg, $device, $compression);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -99,13 +99,14 @@ sub ximport {
|
||||
my $nodes;
|
||||
my $new_profile;
|
||||
my $remoteHost;
|
||||
my $nozip = 0;
|
||||
|
||||
my $xusage = sub {
|
||||
my $ec = shift;
|
||||
push @{ $rsp{data} }, "imgimport: Takes in an xCAT image bundle and defines it to xCAT so you can use it";
|
||||
push @{ $rsp{data} }, "Usage: ";
|
||||
push @{ $rsp{data} }, "\timgimport [-h|--help]";
|
||||
push @{ $rsp{data} }, "\timgimport <bundle_file_name> [-p|--postscripts <nodelist>] [-f|--profile <new_profile>] [-R|--remotehost <userid\@host>] [-v]";
|
||||
push@{ $rsp{data} }, "\timgimport <bundle_file_name> [-p|--postscripts <nodelist>] [-f|--profile <new_profile>] [-R|--remotehost <userid\@host>] [-n|--nozip] [-v]";
|
||||
if ($ec) { $rsp{errorcode} = $ec; }
|
||||
$callback->(\%rsp);
|
||||
};
|
||||
@ -122,6 +123,7 @@ sub ximport {
|
||||
'R|remotehost=s' => \$remoteHost,
|
||||
'p|postscripts=s' => \$nodes,
|
||||
'f|profile=s' => \$new_profile,
|
||||
'n|nozip' => \$nozip
|
||||
);
|
||||
|
||||
if ($help) {
|
||||
@ -130,7 +132,7 @@ sub ximport {
|
||||
}
|
||||
|
||||
# first extract the bundle
|
||||
extract_bundle($request, $callback, $nodes, $new_profile, $remoteHost);
|
||||
extract_bundle($request, $callback, $nodes, $new_profile, $remoteHost, $nozip );
|
||||
|
||||
}
|
||||
|
||||
@ -608,7 +610,7 @@ sub get_files {
|
||||
if (-f "$rootimgdir/kernel") {
|
||||
$kernel = "$rootimgdir/kernel";
|
||||
}
|
||||
|
||||
|
||||
my $compressedrootimg=xCAT::SvrUtils->searchcompressedrootimg("$rootimgdir");
|
||||
$rootimg = "$rootimgdir/$compressedrootimg";
|
||||
|
||||
@ -1115,6 +1117,7 @@ sub extract_bundle {
|
||||
my $nodes = shift;
|
||||
my $new_profile = shift;
|
||||
my $remoteHost = shift;
|
||||
my $nozip = shift;
|
||||
|
||||
@ARGV = @{ $request->{arg} };
|
||||
my $xml;
|
||||
@ -1188,12 +1191,21 @@ sub extract_bundle {
|
||||
|
||||
$callback->({ data => ["Unbundling image..."] });
|
||||
my $rc;
|
||||
if ($nozip) {
|
||||
if ($::VERBOSE) {
|
||||
$callback->({data=>["tar xvf $bundle -C $tpath"]});
|
||||
$rc = system("tar xvf $bundle -C $tpath");
|
||||
} else {
|
||||
$rc = system("tar xf $bundle -C $tpath");
|
||||
}
|
||||
} else {
|
||||
if ($::VERBOSE) {
|
||||
$callback->({ data => ["tar zxvf $bundle -C $tpath"] });
|
||||
$rc = system("tar zxvf $bundle -C $tpath");
|
||||
} else {
|
||||
$rc = system("tar zxf $bundle -C $tpath");
|
||||
}
|
||||
}
|
||||
|
||||
if ($rc) {
|
||||
$callback->({ error => ["Failed to extract bundle $bundle"], errorcode => [1] });
|
||||
|
@ -55,6 +55,7 @@ sub findme {
|
||||
|
||||
my @SEQdiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover");
|
||||
my @PCMdiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover");
|
||||
my @ZVMDiscover = xCAT::TableUtils->get_site_attribute("__ZVMDiscover");
|
||||
|
||||
if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0]) and ($request->{discoverymethod}->[0] ne 'undef')) {
|
||||
|
||||
@ -62,6 +63,14 @@ sub findme {
|
||||
return;
|
||||
}
|
||||
unless ($SEQdiscover[0]) {
|
||||
if ( $PCMdiscover[0] or $ZVMDiscover[0] ) {
|
||||
|
||||
# profile or z/VM discovery is running, then just return to make the other discovery handle it
|
||||
return;
|
||||
}
|
||||
# update the discoverydata table to have an undefined node
|
||||
$request->{discoverymethod}->[0] = 'undef';
|
||||
xCAT::DiscoveryUtils->update_discovery_data($request);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -436,7 +445,7 @@ sub nodediscoverstart {
|
||||
xCAT::MsgUtils->message("E", $rsp, $cb, 1);
|
||||
}
|
||||
|
||||
my $usageinfo = "nodediscoverstart: Start a discovery process: Sequential or Profile.
|
||||
my $usageinfo = "nodediscoverstart: Start a discovery process: Sequential, Profile or z/VM.
|
||||
Usage:
|
||||
Common:
|
||||
nodediscoverstart [-h|--help|-v|--version|-V|--verbose]
|
||||
@ -444,12 +453,16 @@ Usage:
|
||||
nodediscoverstart noderange=<noderange> [hostiprange=<hostiprange>] [bmciprange=<bmciprange>] [groups=<groups>] [rack=<rack>] [chassis=<chassis>] [height=<height>] [unit=<unit>] [osimage=<osimagename>] [-n|--dns] [-s|--skipbmcsetup] [-V|--verbose]
|
||||
Profile Discovery:
|
||||
nodediscoverstart networkprofile=<networkprofile> imageprofile=<imageprofile> hostnameformat=<hostnameformat> [hardwareprofile=<hardwareprofile>] [groups=<groups>] [rack=<rack>] [chassis=<chassis>] [height=<height>] [unit=<unit>] [rank=rank-num]";
|
||||
z/VM Discovery:
|
||||
nodediscoverstart zvmhost=<noderange> [defineto=both] [groups=<groups>] [ipfilter=<filter>] [openstackoperands=<operands>] [useridfilter=<filter>]
|
||||
nodediscoverstart zvmhost=<noderange> defineto=xcatonly [groups=<groups>] [ipfilter=<filter>] [nodenameformat=<nodenameformat>] [useridfilter=<filter>]
|
||||
nodediscoverstart zvmhost=<noderange> defineto=openstackonly [openstackoperands=<operands>]";
|
||||
$rsp = ();
|
||||
push @{ $rsp->{data} }, $usageinfo;
|
||||
xCAT::MsgUtils->message("I", $rsp, $cb);
|
||||
};
|
||||
|
||||
# valid attributes for deqdiscovery
|
||||
# valid attributes for seqdiscovery
|
||||
my %validargs = (
|
||||
'noderange' => 1,
|
||||
'hostiprange' => 1,
|
||||
@ -492,7 +505,13 @@ Usage:
|
||||
$orgargs{$name} = $value;
|
||||
}
|
||||
|
||||
# Check the noderage=has been specified which is the flag that this is for sequential discovery
|
||||
# Check the zvmhost= has been specified which is the flag that this is for z/VM discovery.
|
||||
# Otherwise, fall thru to handle either sequential or profile discovery.
|
||||
if ( defined( $orgargs{zvmhost} ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Check the noderange= has been specified which is the flag that this is for sequential discovery
|
||||
# Otherwise try to check the whether the networkprofile || hardwareprofile || imageprofile
|
||||
# has been passed, if yes, return to profile discovery
|
||||
unless (defined($orgargs{noderange})) {
|
||||
@ -502,6 +521,7 @@ Usage:
|
||||
return;
|
||||
} else {
|
||||
$usage->($callback, "For sequential discovery, the \'noderange\' option must be specified.");
|
||||
$usage->($callback, "For z/VM discovery, the \'zvmhost\' option must be specified.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -567,7 +587,7 @@ Usage:
|
||||
$sitetab->setAttribs({ "key" => "__SEQDiscover" }, { "value" => "$textparam" });
|
||||
$sitetab->close();
|
||||
|
||||
# Clean the entries which discovery method is 'sequential' from the discoverdata table
|
||||
# Clean the entries which discovery method is 'sequential' from the discoverydata table
|
||||
my $distab = xCAT::Table->new("discoverydata");
|
||||
$distab->delEntries({ method => 'sequential' });
|
||||
$distab->commit();
|
||||
@ -689,9 +709,12 @@ sub nodediscoverstop {
|
||||
xCAT::MsgUtils->message("E", $rsp, $cb, 1);
|
||||
}
|
||||
|
||||
my $usageinfo = "nodediscoverstop: Stop the running discovery: Sequential and Profile.
|
||||
my $usageinfo = "nodediscoverstop: Stop the running discovery: Profile, Sequential and z/VM.
|
||||
Usage:
|
||||
nodediscoverstop [-h|--help|-v|--version] ";
|
||||
Common:
|
||||
nodediscoverstop [-h|--help|-v|--version]
|
||||
z/VM discovery:
|
||||
nodediscoverstop [-z|--zvmhost <noderange>]";
|
||||
$rsp = ();
|
||||
push @{ $rsp->{data} }, $usageinfo;
|
||||
xCAT::MsgUtils->message("I", $rsp, $cb);
|
||||
@ -721,9 +744,10 @@ Usage:
|
||||
# Check the running of sequential discovery
|
||||
my @SEQDiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover");
|
||||
my @PCMDiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover");
|
||||
if ($PCMDiscover[0]) {
|
||||
my @ZVMDiscover = xCAT::TableUtils->get_site_attribute("__ZVMDiscover");
|
||||
if ($PCMDiscover[0] or $ZVMDiscover[0]) {
|
||||
|
||||
# return directly that profile discover will cover it
|
||||
# return directly that the other discovery will handle the stop function.
|
||||
return;
|
||||
} elsif (!$SEQDiscover[0]) {
|
||||
|
||||
@ -731,12 +755,13 @@ Usage:
|
||||
my $rsp;
|
||||
push @{ $rsp->{data} }, "Sequential Discovery is stopped.";
|
||||
push @{ $rsp->{data} }, "Profile Discovery is stopped.";
|
||||
push @{$rsp->{data}}, "z/VM Discovery is stopped.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
my $DBname = xCAT::Utils->get_DBName; # support for DB2
|
||||
# Go thought discoverydata table and display the sequential disocvery entries
|
||||
# Go through discoverydata table and display the sequential discovery entries
|
||||
my $distab = xCAT::Table->new('discoverydata');
|
||||
unless ($distab) {
|
||||
my $rsp;
|
||||
@ -779,7 +804,7 @@ Usage:
|
||||
}
|
||||
|
||||
=head3 nodediscoverls
|
||||
Display the discovered nodes
|
||||
Display the discovered nodes. This supports sequential and z/VM and partially Profile discovery.
|
||||
=cut
|
||||
|
||||
sub nodediscoverls {
|
||||
@ -797,12 +822,14 @@ sub nodediscoverls {
|
||||
}
|
||||
|
||||
my $usageinfo = "nodediscoverls: list the discovered nodes.
|
||||
Usage:
|
||||
Usage:
|
||||
Common:
|
||||
nodediscoverls
|
||||
nodediscoverls [-h|--help|-v|--version]
|
||||
nodediscoverls [-t seq|profile|switch|blade|manual|undef|all] [-l]
|
||||
nodediscoverls [-t seq|profile|switch|blade|manual|undef|zvm|all] [-l]
|
||||
nodediscoverls [-u uuid] [-l]
|
||||
";
|
||||
z/VM:
|
||||
nodediscoverls [-t zvm][-z|--zvmhost <noderange>] [-l]";
|
||||
$rsp = ();
|
||||
push @{ $rsp->{data} }, $usageinfo;
|
||||
xCAT::MsgUtils->message("I", $rsp, $cb);
|
||||
@ -811,14 +838,15 @@ Usage:
|
||||
if ($args) {
|
||||
@ARGV = @$args;
|
||||
}
|
||||
my ($type, $uuid, $long, $help, $ver);
|
||||
my ($type, $uuid, $long, $help, $ver, $zvmHost );
|
||||
if (!GetOptions(
|
||||
't=s' => \$type,
|
||||
'u=s' => \$uuid,
|
||||
'l' => \$long,
|
||||
'h|help' => \$help,
|
||||
'V|verbose' => \$::VERBOSE,
|
||||
'v|version' => \$ver)) {
|
||||
'v|version' => \$ver,
|
||||
'z|zvmhost=s' => \$zvmHost )) {
|
||||
$usage->($callback);
|
||||
return;
|
||||
}
|
||||
@ -833,9 +861,9 @@ Usage:
|
||||
}
|
||||
|
||||
# If the type is specified, display the corresponding type of nodes
|
||||
my @SEQDiscover;
|
||||
my ( @SEQDiscover, @ZVMDiscover );
|
||||
if ($type) {
|
||||
if ($type !~ /^(seq|profile|switch|blade|manual|undef|all)$/) {
|
||||
if ($type !~ /^(seq|profile|switch|blade|manual|undef|zvm|all)$/) {
|
||||
$usage->($callback, "The discovery type \'$type\' is not supported.");
|
||||
return;
|
||||
}
|
||||
@ -844,24 +872,31 @@ Usage:
|
||||
|
||||
# Check the running of sequential discovery
|
||||
@SEQDiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover");
|
||||
@ZVMDiscover = xCAT::TableUtils->get_site_attribute("__ZVMDiscover");
|
||||
if ($SEQDiscover[0]) {
|
||||
$type = "seq";
|
||||
} else {
|
||||
my @PCMDiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover");
|
||||
if ($PCMDiscover[0]) {
|
||||
} elsif ($PCMDiscover[0]) {
|
||||
|
||||
#return directly if my type of discover is not running.
|
||||
#return directly if profile discovery is running.
|
||||
return;
|
||||
} elsif ( $ZVMDiscover[0] ) {
|
||||
# zvmdiscovery handles requests for a running z/VM discovery.
|
||||
return;
|
||||
} else {
|
||||
|
||||
# no type, no seq and no profile, then just diaplay all
|
||||
# no type, no seq and no profile, then just display all
|
||||
$type = "all";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $DBname = xCAT::Utils->get_DBName; # support for DB2
|
||||
# Go thought discoverydata table and display the disocvery entries
|
||||
# If a zvmHost was specified then let zvmdiscovery handle it.
|
||||
# Specifying '-u' will keep processing within seqdiscovery.
|
||||
if ( !$uuid && ( $zvmHost || ( $type && $type eq 'zvm' )) ) {
|
||||
# zvmdiscovery handles request specific to z/VM.
|
||||
return;
|
||||
}
|
||||
|
||||
# Go through discoverydata table and display the discovery entries
|
||||
my $distab = xCAT::Table->new('discoverydata');
|
||||
unless ($distab) {
|
||||
my $rsp;
|
||||
@ -914,7 +949,8 @@ Usage:
|
||||
}
|
||||
|
||||
my $rsp;
|
||||
if ($SEQDiscover[0] && $type eq "sequential") {
|
||||
if (($SEQDiscover[0] && $type eq "sequential" ) or
|
||||
( $type && $type eq "all" )) {
|
||||
push @{ $rsp->{data} }, "Discovered $discoverednum node.";
|
||||
}
|
||||
if (@discoverednodes) {
|
||||
@ -949,8 +985,11 @@ sub nodediscoverstatus {
|
||||
}
|
||||
|
||||
my $usageinfo = "nodediscoverstatus: Display the discovery process status.
|
||||
Usage:
|
||||
nodediscoverstatus [-h|--help|-v|--version] ";
|
||||
Usage:
|
||||
Common:
|
||||
nodediscoverstatus [-h|--help|-v|--version]
|
||||
z/VM
|
||||
nodediscoverstatus [-z|--zvmhost <noderange>]";
|
||||
$rsp = ();
|
||||
push @{ $rsp->{data} }, $usageinfo;
|
||||
xCAT::MsgUtils->message("I", $rsp, $cb);
|
||||
@ -980,6 +1019,7 @@ Usage:
|
||||
# Check the running of sequential discovery
|
||||
my @SEQDiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover");
|
||||
my @PCMDiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover");
|
||||
my @ZVMDiscover = xCAT::TableUtils->get_site_attribute("__ZVMDiscover");
|
||||
if ($SEQDiscover[0]) {
|
||||
my $rsp;
|
||||
push @{ $rsp->{data} }, "Sequential discovery is running.";
|
||||
@ -989,10 +1029,13 @@ Usage:
|
||||
my $rsp;
|
||||
push @{ $rsp->{data} }, "Node discovery for all nodes using profiles is running";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
} elsif ( $ZVMDiscover[0] ) {
|
||||
# z/VM discovery is a more complex response so we let its handler return the response.
|
||||
} else {
|
||||
my $rsp;
|
||||
push @{ $rsp->{data} }, "Sequential Discovery is stopped.";
|
||||
push @{ $rsp->{data} }, "Profile Discovery is stopped.";
|
||||
push @{$rsp->{data}}, "z/VM Discovery is stopped.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
|
||||
@ -1008,6 +1051,9 @@ sub nodediscoverdef {
|
||||
my $subreq = shift;
|
||||
my $args = shift;
|
||||
|
||||
my @inputZvmHosts; # Input list of z/VM host nodes to stop
|
||||
my $zvmHost; # Small scope variable to temporarily hold a z/VM host node value
|
||||
|
||||
# The subroutine used to display the usage message
|
||||
my $usage = sub {
|
||||
my $cb = shift;
|
||||
@ -1021,10 +1067,13 @@ sub nodediscoverdef {
|
||||
|
||||
my $usageinfo = "nodediscoverdef: Define the undefined discovery request, or clean the discovery entries in the discoverydata table (Which can be displayed by nodediscoverls command).
|
||||
Usage:
|
||||
Common:
|
||||
nodediscoverdef -u uuid -n node
|
||||
nodediscoverdef -r -u uuid
|
||||
nodediscoverdef -r -t {seq|profile|switch|blade|manual|undef|all}
|
||||
nodediscoverdef [-h|--help|-v|--version]";
|
||||
nodediscoverdef -r -t {seq|profile|switch|blade|manual|undef|zvm|all}
|
||||
nodediscoverdef [-h|--help|-v|--version]
|
||||
z/VM:
|
||||
nodediscoverdef -r -t zvm [-z|--zvmhost noderange]";
|
||||
$rsp = ();
|
||||
push @{ $rsp->{data} }, $usageinfo;
|
||||
xCAT::MsgUtils->message("I", $rsp, $cb);
|
||||
@ -1042,7 +1091,8 @@ Usage:
|
||||
'r' => \$remove,
|
||||
'h|help' => \$help,
|
||||
'V|verbose' => \$::VERBOSE,
|
||||
'v|version' => \$ver)) {
|
||||
'v|version' => \$ver,
|
||||
'z|zvmhost=s' => \$zvmHost )) {
|
||||
$usage->($callback);
|
||||
return;
|
||||
}
|
||||
@ -1057,6 +1107,29 @@ Usage:
|
||||
}
|
||||
|
||||
my $DBname = xCAT::Utils->get_DBName; # support for DB2
|
||||
# Put any specified zvmhosts into an array for later use.
|
||||
if ( $zvmHost ) {
|
||||
$type = 'zvm' if ( !$type );
|
||||
if ( $type ne 'zvm' ) {
|
||||
xCAT::MsgUtils->message("E", {data=>["Discovery Error: Type must be 'zvm' when '-z' or '--zvmhost' is specified."]}, $callback);
|
||||
return;
|
||||
}
|
||||
if ( index( $zvmHost, ',' ) != -1 ) {
|
||||
# Must have specified multiple host node names
|
||||
my @hosts = split( /,/, $zvmHost );
|
||||
foreach $zvmHost ( @hosts ) {
|
||||
if ( !$zvmHost ) {
|
||||
# Tolerate zvmhost value beginning with a comma.
|
||||
# It is wrong but not worth an error message.
|
||||
next;
|
||||
}
|
||||
push( @inputZvmHosts, $zvmHost );
|
||||
}
|
||||
} else {
|
||||
push( @inputZvmHosts, $zvmHost );
|
||||
}
|
||||
}
|
||||
|
||||
# open the discoverydata table for the subsequent using
|
||||
my $distab = xCAT::Table->new("discoverydata");
|
||||
unless ($distab) {
|
||||
@ -1095,7 +1168,7 @@ Usage:
|
||||
} elsif ($type) {
|
||||
|
||||
# handle the -r -t <...>
|
||||
if ($type !~ /^(seq|profile|switch|blade|manual|undef|all)$/) {
|
||||
if ($type !~ /^(seq|profile|switch|blade|manual|undef|zvm|all)$/) {
|
||||
$usage->($callback, "The discovery type \'$type\' is not supported.");
|
||||
return;
|
||||
}
|
||||
@ -1131,9 +1204,24 @@ Usage:
|
||||
if ($type =~ /^seq/) {
|
||||
$type = "sequential";
|
||||
}
|
||||
# If a noderange of z/VM hosts was specified then delete
|
||||
# all z/VM discovered systems for those hosts. 'zvm' type
|
||||
# must be used when z/VM hosts are specified.
|
||||
if ( @inputZvmHosts ) {
|
||||
my %keyhash;
|
||||
$keyhash{'method'} = 'zvm';
|
||||
foreach $zvmHost ( @inputZvmHosts ) {
|
||||
$keyhash{'otherdata'} = "zvmhost." . $zvmHost;
|
||||
$distab->delEntries( \%keyhash );
|
||||
}
|
||||
$distab->commit();
|
||||
} else {
|
||||
# Otherwise, Delete all systems discovered using the specified method.
|
||||
$distab->delEntries({ method => $type });
|
||||
$distab->commit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
xCAT::MsgUtils->message("I", { data => ["Removing discovery entries finished."] }, $callback);
|
||||
} elsif ($uuid) {
|
||||
|
@ -303,6 +303,8 @@ sub parse_xdcp_cmd
|
||||
'F|File=s' => \$options{'File'},
|
||||
'h|help' => \$options{'help'},
|
||||
'i|rootimg=s' => \$options{'rootimg'},
|
||||
'ip=s' => \$options{'ip'},
|
||||
'show=s' => \$options{'show'},
|
||||
'l|user=s' => \$options{'user'},
|
||||
'n|nodes=s' => \$options{'nodes'},
|
||||
'o|node-options=s' => \$options{'node-options'},
|
||||
@ -459,6 +461,8 @@ sub parse_xdsh_cmd
|
||||
'q|show-config' => \$options{'show-config'},
|
||||
'r|node-rsh=s' => \$options{'node-rsh'},
|
||||
'i|rootimg=s' => \$options{'rootimg'},
|
||||
'ip=s' => \$options{'ip'},
|
||||
'show=s' => \$options{'show'},
|
||||
's|stream' => \$options{'streaming'},
|
||||
't|timeout=i' => \$options{'timeout'},
|
||||
'v|verify' => \$options{'verify'},
|
||||
@ -1070,11 +1074,11 @@ sub process_nodes
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 syncSNZoneKeys
|
||||
Build the xdcp command to send the zone keys to the service nodes
|
||||
Return an array of servicenodes that do not have errors
|
||||
Build the xdcp command to send the zone keys to the service nodes
|
||||
Return an array of servicenodes that do not have errors
|
||||
Returns error code:
|
||||
if = 0, good return continue to process the
|
||||
nodes.
|
||||
nodes.
|
||||
if = 1, global error need to quit
|
||||
|
||||
=cut
|
||||
|
File diff suppressed because it is too large
Load Diff
306
xCAT-server/lib/xcat/plugins/zvmdiagnostics.pm
Normal file
306
xCAT-server/lib/xcat/plugins/zvmdiagnostics.pm
Normal file
@ -0,0 +1,306 @@
|
||||
# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head1
|
||||
|
||||
xCAT plugin to support z/VM (s390x) diagnostics command
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
package xCAT_plugin::zvmdiagnostics;
|
||||
|
||||
#use xCAT::Client;
|
||||
use xCAT::zvmUtils;
|
||||
|
||||
#use xCAT::zvmCPUtils;
|
||||
#use xCAT::MsgUtils;
|
||||
use Sys::Hostname;
|
||||
|
||||
#use xCAT::Table;
|
||||
#use xCAT::Utils;
|
||||
#use xCAT::TableUtils;
|
||||
#use xCAT::ServiceNodeUtils;
|
||||
#use xCAT::NetworkUtils;
|
||||
#use XML::Simple;
|
||||
#use File::Basename;
|
||||
#use File::Copy;
|
||||
#use File::Path;
|
||||
#use File::Temp;
|
||||
use Time::HiRes;
|
||||
use POSIX;
|
||||
use Getopt::Long;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
#use Cwd;
|
||||
# Set $DEBUGGING = 1 to get extra message logging
|
||||
my $DEBUGGING = 0;
|
||||
|
||||
# Common prefix for log messages
|
||||
my $ROUTINE = "zvmdiagnostics";
|
||||
my $COMMAND = "diagnostics";
|
||||
|
||||
my $NOTIFY_FILENAME = "/var/lib/sspmod/appliance_system_role";
|
||||
my $NOTIFY_KEYWORD = "notify";
|
||||
my $NOTIFY_KEYWORD_DELIMITER = "=";
|
||||
|
||||
# If the following line ("1;") is not included, you get:
|
||||
# /opt/xcat/lib/perl/xCAT_plugin/... did not return a true value
|
||||
# where ... is the name of this file
|
||||
1;
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 handled_commands
|
||||
|
||||
Return list of commands handled by this plugin
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub handled_commands {
|
||||
return { $COMMAND => $ROUTINE, };
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 preprocess_request
|
||||
|
||||
Check and setup for hierarchy
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub preprocess_request {
|
||||
my $req = shift;
|
||||
my $callback = shift;
|
||||
my $SUBROUTINE = "preprocess_request";
|
||||
|
||||
# Hash array
|
||||
my %sn;
|
||||
|
||||
# Scalar variable
|
||||
my $sn;
|
||||
|
||||
# Array
|
||||
my @requests;
|
||||
|
||||
if ( $DEBUGGING == 1 ) {
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE entry");
|
||||
}
|
||||
|
||||
# If already preprocessed, go straight to request
|
||||
if ( $req->{_xcatpreprocessed}->[0] == 1 ) {
|
||||
return [$req];
|
||||
}
|
||||
my $nodes = $req->{node};
|
||||
my $service = "xcat";
|
||||
|
||||
# Find service nodes for requested nodes
|
||||
# Build an individual request for each service node
|
||||
if ($nodes) {
|
||||
$sn = xCAT::ServiceNodeUtils->get_ServiceNode( $nodes, $service, "MN" );
|
||||
|
||||
# Build each request for each service node
|
||||
foreach my $snkey ( keys %$sn ) {
|
||||
my $n = $sn->{$snkey};
|
||||
print "snkey=$snkey, nodes=@$n\n";
|
||||
my $reqcopy = {%$req};
|
||||
$reqcopy->{node} = $sn->{$snkey};
|
||||
$reqcopy->{'_xcatdest'} = $snkey;
|
||||
$reqcopy->{_xcatpreprocessed}->[0] = 1;
|
||||
push @requests, $reqcopy;
|
||||
}
|
||||
|
||||
return \@requests;
|
||||
}
|
||||
else {
|
||||
|
||||
# Input error
|
||||
my %rsp;
|
||||
my $rsp;
|
||||
$rsp->{data}->[0] =
|
||||
"Input noderange missing. Usage: $ROUTINE <noderange> \n";
|
||||
xCAT::MsgUtils->message( "I", $rsp, $callback, 0 );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 process_request
|
||||
|
||||
Process the command. This is the main call.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub process_request {
|
||||
my $SUBROUTINE = "process_request";
|
||||
my $request = shift;
|
||||
my $callback = shift;
|
||||
my $nodes = $request->{node};
|
||||
my $command = $request->{command}->[0];
|
||||
my $args = $request->{arg};
|
||||
my $envs = $request->{env};
|
||||
$::STDIN = $request->{stdin}->[0];
|
||||
my %rsp;
|
||||
my $rsp;
|
||||
my @nodes = @$nodes;
|
||||
my $host = hostname();
|
||||
|
||||
if ( $DEBUGGING == 1 ) {
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE entry");
|
||||
}
|
||||
|
||||
# Process ID for xfork()
|
||||
my $pid;
|
||||
|
||||
# Child process IDs
|
||||
my @children = ();
|
||||
|
||||
#*** Collect or manage diagnostics***
|
||||
if ( $command eq $COMMAND ) {
|
||||
foreach (@nodes) {
|
||||
$pid = xCAT::Utils->xfork();
|
||||
|
||||
# Parent process
|
||||
if ($pid) {
|
||||
push( @children, $pid );
|
||||
}
|
||||
|
||||
# Child process
|
||||
elsif ( $pid == 0 ) {
|
||||
if ( xCAT::zvmUtils->isHypervisor($_) ) {
|
||||
#TODO should this be handled inside the subroutine, ala rmvm?
|
||||
if ( $DEBUGGING == 1 ) {
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE for hypervisor - semantically coherent?");
|
||||
}
|
||||
}
|
||||
else {
|
||||
collectDiags( $callback, $_, $args );
|
||||
}
|
||||
|
||||
# Exit process
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
|
||||
# Ran out of resources
|
||||
die "Error: Could not fork\n";
|
||||
}
|
||||
|
||||
} # End of foreach
|
||||
} # End of case
|
||||
|
||||
# Wait for all processes to end
|
||||
foreach (@children) {
|
||||
waitpid( $_, 0 );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 collectDiags
|
||||
|
||||
Description : Collect diagnostics
|
||||
Arguments : Node to collect diagnostics about
|
||||
Returns : Nothing
|
||||
Example : collectDiags($callback, $node);
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub collectDiags {
|
||||
my $SUBROUTINE = "collectDiags";
|
||||
|
||||
# Get inputs
|
||||
my ( $callback, $node, $args ) = @_;
|
||||
my $rc;
|
||||
|
||||
if ( $DEBUGGING == 1 ) {
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE entry");
|
||||
}
|
||||
|
||||
# Get node properties from 'zvm' table
|
||||
my @propNames = ( 'hcp', 'userid', 'discovered' );
|
||||
my $propVals = xCAT::zvmUtils->getNodeProps( 'zvm', $node, @propNames );
|
||||
|
||||
# Get zHCP
|
||||
my $hcp = $propVals->{'hcp'};
|
||||
if ( !$hcp ) {
|
||||
xCAT::zvmUtils->printLn( $callback, "$node: (Error) Missing node HCP" );
|
||||
return;
|
||||
}
|
||||
|
||||
# Get node user ID
|
||||
my $userId = $propVals->{'userid'};
|
||||
if ( !$userId ) {
|
||||
xCAT::zvmUtils->printLn( $callback, "$node: (Error) Missing user ID" );
|
||||
return;
|
||||
}
|
||||
|
||||
# Capitalize user ID
|
||||
$userId =~ tr/a-z/A-Z/;
|
||||
|
||||
if ( $DEBUGGING == 1 ) {
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE sudoer:$::SUDOER zHCP:$hcp sudo:$::SUDO userid:$::userId");
|
||||
}
|
||||
my $out;
|
||||
|
||||
my $requestId = "NoUpstreamRequestID";
|
||||
my $objectId = "NoUpstreamObjectID";
|
||||
my $projectName = "NoUpstreamProjectName";
|
||||
my $userUuid = "NoUpstreamUserUuid";
|
||||
if ($args) {
|
||||
@ARGV = @$args;
|
||||
xCAT::zvmUtils->printSyslog(
|
||||
"$ROUTINE $SUBROUTINE for node:$node on zhcp:$hcp args @$args");
|
||||
|
||||
# Parse options
|
||||
GetOptions(
|
||||
'requestid=s' => \$requestId # Optional
|
||||
, 'objectid=s' => \$objectId # Optional
|
||||
);
|
||||
}
|
||||
|
||||
my $xcatnotify = "OPERATOR"; # Default value
|
||||
my $xcatnotify_found = 0; # Not found yet
|
||||
my (@array, $varname);
|
||||
open( FILE, "<$NOTIFY_FILENAME" );
|
||||
#TODO If file not found ("should never happen"), log error but continue
|
||||
while (<FILE>) {
|
||||
# Find record in file with NOTIFY=something on it, optionally delimited with whitespace
|
||||
next unless ( /^[\s]*$NOTIFY_KEYWORD[\s]*$NOTIFY_KEYWORD_DELIMITER[\s]*(\S+)[\s]*$/iaa );
|
||||
$xcatnotify_found = 1;
|
||||
$xcatnotify = $1; # First parenthesized expression in regex above, that is: \S+
|
||||
if ( $DEBUGGING == 1 ) {
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE xCAT will notify $xcatnotify.");
|
||||
}
|
||||
last; # Ignore anything past the first matching record. Absent a bug elsewhere, there is only one value to find.
|
||||
}
|
||||
close(FILE);
|
||||
if (not $xcatnotify_found) {
|
||||
xCAT::zvmUtils->printSyslog(
|
||||
"$ROUTINE $SUBROUTINE error: failed to parse $NOTIFY_KEYWORD$NOTIFY_KEYWORD_DELIMITER " .
|
||||
"from $NOTIFY_FILENAME, defaulting to notify $xcatnotify");
|
||||
}
|
||||
#TODO add COZ... message ID
|
||||
my $msg = "vmcp MSG $xcatnotify deployment failed: node $node userid $userId on zHCP $hcp";
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE $msg");
|
||||
system($msg);
|
||||
#TODO check system()'s rc
|
||||
|
||||
#TODO Capture diagnostic files
|
||||
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE ... rest of implementation stubbed out ");
|
||||
|
||||
if ( $DEBUGGING == 1 ) {
|
||||
xCAT::zvmUtils->printSyslog("$ROUTINE $SUBROUTINE exit");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
2310
xCAT-server/lib/xcat/plugins/zvmdiscovery.pm
Normal file
2310
xCAT-server/lib/xcat/plugins/zvmdiscovery.pm
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@ install
|
||||
url --url replace_url
|
||||
key --skip
|
||||
lang en_US.UTF-8
|
||||
network --bootproto dhcp
|
||||
network --bootproto=static --ip=replace_ip --netmask=replace_netmask --gateway=replace_gateway --nameserver=replace_nameserver --hostname=replace_hostname
|
||||
rootpw replace_rootpw
|
||||
firewall --disabled
|
||||
authconfig --enableshadow --enablemd5
|
||||
@ -18,7 +18,7 @@ key --skip
|
||||
# here so unless you clear all partitions first, this is
|
||||
# not guaranteed to work
|
||||
zerombr yes
|
||||
clearpart --initlabel --drives=dasda
|
||||
clearpart --all --initlabel --drives=dasda
|
||||
part / --fstype ext3 --size=100 --grow --ondisk=dasda
|
||||
part swap --size=512 --ondisk=dasda
|
||||
|
||||
|
@ -4,7 +4,7 @@ install
|
||||
url --url replace_url
|
||||
key --skip
|
||||
lang en_US.UTF-8
|
||||
network --bootproto dhcp
|
||||
network --bootproto=static --ip=replace_ip --netmask=replace_netmask --gateway=replace_gateway --nameserver=replace_nameserver --hostname=replace_hostname
|
||||
rootpw replace_rootpw
|
||||
firewall --disabled
|
||||
authconfig --enableshadow --enablemd5
|
||||
@ -18,7 +18,7 @@ key --skip
|
||||
# here so unless you clear all partitions first, this is
|
||||
# not guaranteed to work
|
||||
zerombr
|
||||
clearpart --initlabel --drives=dasda
|
||||
clearpart --all --initlabel --drives=dasda
|
||||
part / --fstype ext3 --size=100 --grow --ondisk=dasda
|
||||
part swap --size=512 --ondisk=dasda
|
||||
|
||||
|
@ -4,7 +4,7 @@ install
|
||||
url --url replace_url
|
||||
key --skip
|
||||
lang en_US.UTF-8
|
||||
network --bootproto dhcp
|
||||
network --bootproto=static --ip=replace_ip --netmask=replace_netmask --gateway=replace_gateway --nameserver=replace_nameserver --hostname=replace_hostname
|
||||
rootpw replace_rootpw
|
||||
firewall --disabled
|
||||
authconfig --enableshadow --enablemd5
|
||||
|
@ -4,7 +4,7 @@ install
|
||||
url --url replace_url
|
||||
key --skip
|
||||
lang en_US.UTF-8
|
||||
network --bootproto dhcp
|
||||
network --bootproto=static --ip=replace_ip --netmask=replace_netmask --gateway=replace_gateway --nameserver=replace_nameserver --hostname=replace_hostname
|
||||
rootpw replace_rootpw
|
||||
firewall --disabled
|
||||
authconfig --enableshadow --enablemd5
|
||||
|
@ -1,4 +1,3 @@
|
||||
echo ARP=no >> /etc/sysconfig/network-scripts/ifcfg-eth0
|
||||
|
||||
# Get hostname
|
||||
export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')
|
||||
@ -93,34 +92,26 @@ cd /xcatpost
|
||||
export PATH=$PATH:/xcatpost
|
||||
|
||||
# Use the run_ps subroutine to run the postscripts
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps postscript \1/;s/run_ps postscript\s*#/#/;s/run_ps postscript\s*$//" /xcatpost/mypostscript`
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
|
||||
echo "
|
||||
# Subroutine used to run postscripts
|
||||
# \$1 argument is the script type
|
||||
# rest argument is the script name and arguments
|
||||
run_ps () {
|
||||
logdir=\"/var/log/xcat\"
|
||||
mkdir -p \$logdir
|
||||
logfile=\"/var/log/xcat/xcat.log\"
|
||||
scriptype=\$1
|
||||
shift;
|
||||
|
||||
if [ -z \"\$scriptype\" ]; then
|
||||
scriptype=\"postscript\"
|
||||
fi
|
||||
|
||||
if [ -f \$1 ]; then
|
||||
echo \"Running \$scriptype: \$1\" | tee -a \$logfile
|
||||
./\$@ 2>&1 | tee -a \$logfile
|
||||
echo \"Running postscript: \$@\" | tee -a \$logfile
|
||||
./\$@ 2>&1 | tee -a $logfile
|
||||
else
|
||||
echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile
|
||||
echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
||||
fi
|
||||
}
|
||||
# Subroutine end
|
||||
|
||||
" > /xcatpost/mypostscript
|
||||
echo "$TMP" >> /xcatpost/mypostscript
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps postbootscript \1/;s/run_ps postbootscript\s*#/#/;s/run_ps postbootscript\s*$//" /xcatpost/mypostscript`
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
|
||||
echo "$TMP" > /xcatpost/mypostscript
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
echo ARP=no >> /etc/sysconfig/network-scripts/ifcfg-eth0
|
||||
|
||||
# Get hostname
|
||||
export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')
|
||||
@ -92,34 +91,26 @@ cd /xcatpost
|
||||
export PATH=$PATH:/xcatpost
|
||||
|
||||
# Use the run_ps subroutine to run the postscripts
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps postscript \1/;s/run_ps postscript\s*#/#/;s/run_ps postscript\s*$//" /xcatpost/mypostscript`
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
|
||||
echo "
|
||||
# Subroutine used to run postscripts
|
||||
# \$1 argument is the script type
|
||||
# rest argument is the script name and arguments
|
||||
run_ps () {
|
||||
logdir=\"/var/log/xcat\"
|
||||
mkdir -p \$logdir
|
||||
logfile=\"/var/log/xcat/xcat.log\"
|
||||
scriptype=\$1
|
||||
shift;
|
||||
|
||||
if [ -z \"\$scriptype\" ]; then
|
||||
scriptype=\"postscript\"
|
||||
fi
|
||||
|
||||
if [ -f \$1 ]; then
|
||||
echo \"Running \$scriptype: \$1\" | tee -a \$logfile
|
||||
./\$@ 2>&1 | tee -a \$logfile
|
||||
echo \"Running postscript: \$@\" | tee -a \$logfile
|
||||
./\$@ 2>&1 | tee -a $logfile
|
||||
else
|
||||
echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile
|
||||
echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
||||
fi
|
||||
}
|
||||
# Subroutine end
|
||||
|
||||
" > /xcatpost/mypostscript
|
||||
echo "$TMP" >> /xcatpost/mypostscript
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps postbootscript \1/;s/run_ps postbootscript\s*#/#/;s/run_ps postbootscript\s*$//" /xcatpost/mypostscript`
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
|
||||
echo "$TMP" > /xcatpost/mypostscript
|
||||
|
||||
|
||||
|
@ -100,28 +100,20 @@ PATH=$PATH:/xcatpost
|
||||
export PATH
|
||||
|
||||
# use the run_ps subroutine to run the postscripts
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps postscript \1/;s/run_ps postscript\s*#/#/;s/run_ps postscript\s*$//" /tmp/mypostscript`
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript`
|
||||
echo "
|
||||
# subroutine used to run postscripts
|
||||
# \$1 argument is the script type
|
||||
# rest argument is the script name and arguments
|
||||
run_ps () {
|
||||
logdir=\"/var/log/xcat\"
|
||||
mkdir -p \$logdir
|
||||
logfile=\"/var/log/xcat/xcat.log\"
|
||||
scriptype=\$1
|
||||
shift;
|
||||
|
||||
if [ -z \"\$scriptype\" ]; then
|
||||
scriptype=\"postscript\"
|
||||
fi
|
||||
|
||||
if [ -f \$1 ]; then
|
||||
echo \"Running \$scriptype: \$1\" | tee -a \$logfile
|
||||
echo \"Running postscript: \$@\" | tee -a \$logfile
|
||||
./\$@ 2>&1 1> /tmp/tmp4xcatlog
|
||||
cat /tmp/tmp4xcatlog | tee -a \$logfile
|
||||
else
|
||||
echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile
|
||||
echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
||||
fi
|
||||
}
|
||||
# subroutine end
|
||||
@ -129,7 +121,7 @@ run_ps () {
|
||||
" > /tmp/mypostscript
|
||||
echo "cd /xcatpost" >> /tmp/mypostscript
|
||||
echo "$TMP" >> /tmp/mypostscript
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps postbootscript \1/;s/run_ps postbootscript\s*#/#/;s/run_ps postbootscript\s*$//" /tmp/mypostscript`
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript`
|
||||
echo "$TMP" > /tmp/mypostscript
|
||||
|
||||
|
||||
|
@ -101,28 +101,20 @@ PATH=$PATH:/xcatpost
|
||||
export PATH
|
||||
|
||||
# use the run_ps subroutine to run the postscripts
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps postscript \1/;s/run_ps postscript\s*#/#/;s/run_ps postscript\s*$//" /tmp/mypostscript`
|
||||
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript`
|
||||
echo "
|
||||
# subroutine used to run postscripts
|
||||
# \$1 argument is the script type
|
||||
# rest argument is the script name and arguments
|
||||
run_ps () {
|
||||
logdir=\"/var/log/xcat\"
|
||||
mkdir -p \$logdir
|
||||
logfile=\"/var/log/xcat/xcat.log\"
|
||||
scriptype=\$1
|
||||
shift;
|
||||
|
||||
if [ -z \"\$scriptype\" ]; then
|
||||
scriptype=\"postscript\"
|
||||
fi
|
||||
|
||||
if [ -f \$1 ]; then
|
||||
echo \"Running \$scriptype: \$1\" | tee -a \$logfile
|
||||
echo \"Running postscript: \$@\" | tee -a \$logfile
|
||||
./\$@ 2>&1 1> /tmp/tmp4xcatlog
|
||||
cat /tmp/tmp4xcatlog | tee -a \$logfile
|
||||
else
|
||||
echo \"\$scriptype \$1 does NOT exist.\" | tee -a \$logfile
|
||||
echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
||||
fi
|
||||
}
|
||||
# subroutine end
|
||||
@ -130,7 +122,7 @@ run_ps () {
|
||||
" > /tmp/mypostscript
|
||||
echo "cd /xcatpost" >> /tmp/mypostscript
|
||||
echo "$TMP" >> /tmp/mypostscript
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps postbootscript \1/;s/run_ps postbootscript\s*#/#/;s/run_ps postbootscript\s*$//" /tmp/mypostscript`
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript`
|
||||
echo "$TMP" > /tmp/mypostscript
|
||||
|
||||
|
||||
|
@ -284,8 +284,7 @@
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns>
|
||||
<dhcp_hostname config:type="boolean">true</dhcp_hostname>
|
||||
<dhcp_resolv config:type="boolean">true</dhcp_resolv>
|
||||
<dhcp_hostname config:type="boolean">false</dhcp_hostname>
|
||||
<domain>replace_domain</domain>
|
||||
<hostname>replace_hostname</hostname>
|
||||
<nameservers config:type="list">
|
||||
@ -294,11 +293,14 @@
|
||||
</dns>
|
||||
<interfaces config:type="list">
|
||||
<interface>
|
||||
<bootproto>dhcp</bootproto>
|
||||
<bootproto>static</bootproto>
|
||||
<broadcast>replace_broadcast</broadcast>
|
||||
<device>replace_device</device>
|
||||
<ipaddr>replace_ipaddr</ipaddr>
|
||||
<lladdr>replace_lladdr</lladdr>
|
||||
<netmask>replace_netmask</netmask>
|
||||
<network>replace_network</network>
|
||||
<startmode>auto</startmode>
|
||||
<usercontrol>no</usercontrol>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<managed config:type="boolean">false</managed>
|
||||
|
@ -284,8 +284,7 @@
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns>
|
||||
<dhcp_hostname config:type="boolean">true</dhcp_hostname>
|
||||
<dhcp_resolv config:type="boolean">true</dhcp_resolv>
|
||||
<dhcp_hostname config:type="boolean">false</dhcp_hostname>
|
||||
<domain>replace_domain</domain>
|
||||
<hostname>replace_hostname</hostname>
|
||||
<nameservers config:type="list">
|
||||
@ -294,11 +293,14 @@
|
||||
</dns>
|
||||
<interfaces config:type="list">
|
||||
<interface>
|
||||
<bootproto>dhcp</bootproto>
|
||||
<bootproto>static</bootproto>
|
||||
<broadcast>replace_broadcast</broadcast>
|
||||
<device>replace_device</device>
|
||||
<ipaddr>replace_ipaddr</ipaddr>
|
||||
<lladdr>replace_lladdr</lladdr>
|
||||
<netmask>replace_netmask</netmask>
|
||||
<network>replace_network</network>
|
||||
<startmode>auto</startmode>
|
||||
<usercontrol>no</usercontrol>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<managed config:type="boolean">false</managed>
|
||||
|
@ -238,7 +238,7 @@
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns>
|
||||
<dhcp_hostname config:type="boolean">true</dhcp_hostname>
|
||||
<dhcp_hostname config:type="boolean">false</dhcp_hostname>
|
||||
<dhcp_resolv config:type="boolean">true</dhcp_resolv>
|
||||
<domain>replace_domain</domain>
|
||||
<hostname>replace_hostname</hostname>
|
||||
@ -248,11 +248,14 @@
|
||||
</dns>
|
||||
<interfaces config:type="list">
|
||||
<interface>
|
||||
<bootproto>dhcp</bootproto>
|
||||
<bootproto>static</bootproto>
|
||||
<broadcast>replace_broadcast</broadcast>
|
||||
<device>replace_device</device>
|
||||
<ipaddr>replace_ipaddr</ipaddr>
|
||||
<lladdr>replace_lladdr</lladdr>
|
||||
<netmask>replace_netmask</netmask>
|
||||
<network>replace_network</network>
|
||||
<startmode>auto</startmode>
|
||||
<usercontrol>no</usercontrol>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<managed config:type="boolean">false</managed>
|
||||
|
@ -238,7 +238,7 @@
|
||||
<dhclient_hostname_option>AUTO</dhclient_hostname_option>
|
||||
</dhcp_options>
|
||||
<dns>
|
||||
<dhcp_hostname config:type="boolean">true</dhcp_hostname>
|
||||
<dhcp_hostname config:type="boolean">false</dhcp_hostname>
|
||||
<dhcp_resolv config:type="boolean">true</dhcp_resolv>
|
||||
<domain>replace_domain</domain>
|
||||
<hostname>replace_hostname</hostname>
|
||||
@ -248,11 +248,14 @@
|
||||
</dns>
|
||||
<interfaces config:type="list">
|
||||
<interface>
|
||||
<bootproto>dhcp</bootproto>
|
||||
<bootproto>static</bootproto>
|
||||
<broadcast>replace_broadcast</broadcast>
|
||||
<device>replace_device</device>
|
||||
<ipaddr>replace_ipaddr</ipaddr>
|
||||
<lladdr>replace_lladdr</lladdr>
|
||||
<netmask>replace_netmask</netmask>
|
||||
<network>replace_network</network>
|
||||
<startmode>auto</startmode>
|
||||
<usercontrol>no</usercontrol>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<managed config:type="boolean">false</managed>
|
||||
|
@ -15,6 +15,3 @@ rpm
|
||||
rsync
|
||||
udev
|
||||
s390utils
|
||||
tar
|
||||
gzip
|
||||
xz
|
||||
|
@ -14,6 +14,3 @@ rsync
|
||||
rsyslog
|
||||
udev
|
||||
s390utils
|
||||
tar
|
||||
gzip
|
||||
xz
|
||||
|
579
xCAT-server/share/xcat/scripts/setupDisk
Normal file
579
xCAT-server/share/xcat/scripts/setupDisk
Normal file
@ -0,0 +1,579 @@
|
||||
#!/bin/bash
|
||||
# IBM(c) 2013, 2015 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
###############################################################################
|
||||
# This script is used to handle xCAT disk initialization and configuration(eg.
|
||||
# attach/detach a SCSI volume, add an additional ephemeral disk when vm is in
|
||||
# inactive status). It will be invoked and executed when vm start up.
|
||||
###############################################################################
|
||||
version=3.0
|
||||
|
||||
function getOsVersion {
|
||||
# @Description:
|
||||
# Returns the Linux distro version in an easy to parse format.
|
||||
# @Input:
|
||||
# None
|
||||
# @Output:
|
||||
# os - Variable set with OS and version information. For example:
|
||||
# "rhel62" or "sles11sp2"
|
||||
# @Code:
|
||||
if [[ -e "/etc/os-release" ]]; then
|
||||
os=`cat /etc/os-release | grep "^ID=" | sed \
|
||||
-e 's/ID=//' \
|
||||
-e 's/"//g'`
|
||||
version=`cat /etc/os-release | grep "^VERSION_ID=" | sed \
|
||||
-e 's/VERSION_ID=//' \
|
||||
-e 's/"//g' \
|
||||
-e 's/\.//'`
|
||||
os=$os$version
|
||||
|
||||
#The /etc/SuSE-release file will be deprecated in sles11.4 and later release
|
||||
elif [[ -e "/etc/SuSE-release" ]]; then
|
||||
os='sles'
|
||||
version=`cat /etc/SuSE-release | grep "VERSION =" | sed \
|
||||
-e 's/^.*VERSION =//' \
|
||||
-e 's/\s*$//' \
|
||||
-e 's/.//' \
|
||||
-e 's/[^0-9]*([0-9]+).*/$1/'`
|
||||
os=$os$version
|
||||
|
||||
# Append service level
|
||||
level=`echo "/etc/SuSE-release" | grep "LEVEL =" | sed \
|
||||
-e 's/^.*LEVEL =//' \
|
||||
-e 's/\s*$//' \
|
||||
-e 's/.//' \
|
||||
-e 's/[^0-9]*([0-9]+).*/$1/'`
|
||||
os=$os'sp'$level
|
||||
|
||||
#The /etc/redhat-release file will be deprecated in rhel7 and later release
|
||||
elif [[ -e "/etc/redhat-release" ]]; then
|
||||
os='rhel'
|
||||
version=`cat /etc/redhat-release | grep -i "Red Hat Enterprise Linux Server" | sed \
|
||||
-e 's/[A-Za-z\/\.\(\)]//g' \
|
||||
-e 's/^ *//g' \
|
||||
-e 's/ *$//g' \
|
||||
-e 's/\s.*$//'`
|
||||
os=$os$version
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
function onlineDevice {
|
||||
# @Description:
|
||||
# Brings a Linux device online.
|
||||
# @Input:
|
||||
# Device number, e.g. "0.0.000c"
|
||||
# @Output:
|
||||
# Return code indicates success or failure
|
||||
# @Code:
|
||||
device=$1
|
||||
local funcName="onlineDevice"
|
||||
rc=$(/sbin/chccwdev -e $device > /dev/null; echo $?)
|
||||
if (( rc != 0 )); then
|
||||
if [[ -e /sbin/cio_ignore ]]; then
|
||||
rc=$(/sbin/cio_ignore -r 0.0.$device > /dev/null; echo $?)
|
||||
which udevadm &> /dev/null && udevadm settle || udevsettle
|
||||
fi
|
||||
rc=$(/sbin/chccwdev -e $device > /dev/null; echo $?)
|
||||
if (( rc != 0 )); then
|
||||
echo "$funcName (Error) Could not activate the virtual device $device"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
which udevadm &> /dev/null && udevadm settle || udevsettle
|
||||
return 0
|
||||
}
|
||||
|
||||
function setupDisk {
|
||||
# @Description:
|
||||
# Processes a disk file for the following functions:
|
||||
# Create a file system node
|
||||
# Remove a file system node
|
||||
# Setup a SCSI volume
|
||||
# Removes a SCSI volume
|
||||
# Add a mdisk based ephemeral disk
|
||||
# @Input:
|
||||
# Disk handling parameters
|
||||
# @Output:
|
||||
# None
|
||||
# @Code:
|
||||
local funcName="setupDisk"
|
||||
|
||||
# Parse the parameter from parameter list
|
||||
for parameter in $@; do
|
||||
keyName=${parameter%\=*}
|
||||
value=${parameter#*\=}
|
||||
value=$(echo ${value} | sed -e 's/^ *//g')
|
||||
newKey='xcat_'$keyName
|
||||
eval $newKey=$value
|
||||
done
|
||||
|
||||
# Remove the invokeScript.sh file after we have read it
|
||||
rm -f invokeScript.sh
|
||||
|
||||
##########################################################################
|
||||
# Handle creating a file system node
|
||||
# Disk handler input parameters:
|
||||
# action - "createfilesysnode"
|
||||
# srcFile - location/name of the source file for the mknod command
|
||||
# xcat_tgtFile - location/name of the target file for the mknod command
|
||||
##########################################################################
|
||||
if [[ $xcat_action == "createfilesysnode" ]]; then
|
||||
echo "Creating a file system node, source: $xcat_srcFile, target: $xcat_tgtFile"
|
||||
|
||||
if [[ ! -n $xcat_srcFile ]]; then
|
||||
echo "$funcName (Error) Source file for creating a file system node was not specified"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! -n $xcat_tgtFile ]]; then
|
||||
echo "$funcName (Error) Target file for creating a file system node was not specified"
|
||||
return
|
||||
fi
|
||||
if [[ -e $xcat_tgtFile ]]; then
|
||||
echo "$funcName (Error) Target file for creating a file system node already exists"
|
||||
return
|
||||
fi
|
||||
|
||||
configFile='/etc/udev/rules.d/56-zfcp.rules'
|
||||
# Create udev config file if not exist
|
||||
if [[ ! -e $configFile ]]; then
|
||||
touch $configFile
|
||||
if [[ $os == rhel* ]]; then
|
||||
echo "KERNEL==\"zfcp\", RUN+=\"/sbin/zfcpconf.sh\"" >> ${configFile}
|
||||
echo "KERNEL==\"zfcp\", RUN+=\"/sbin/multipath -r\"" >> ${configFile}
|
||||
fi
|
||||
fi
|
||||
|
||||
tgtNode=$(echo ${xcat_tgtFile} | sed -e 's/^\/dev\///')
|
||||
if [[ $os == sles* || $os == rhel* ]]; then
|
||||
wwpn_lun=$(echo ${xcat_srcFile} | sed -e 's/^\/dev.*-zfcp-//')
|
||||
wwpn=$(echo ${wwpn_lun} | sed -e 's/:0x.*//')
|
||||
lun=$(echo ${wwpn_lun} | sed -e 's/^0x.*://')
|
||||
else
|
||||
wwpn_lun=$(echo ${xcat_srcFile} | sed -e 's/^\/dev.*-fc-//')
|
||||
wwpn=$(echo ${wwpn_lun} | sed -e 's/-lun-.*//')
|
||||
lun=$(echo ${wwpn_lun} | sed -e 's/^0x.*-lun-//')
|
||||
fi
|
||||
|
||||
|
||||
multipath=0
|
||||
out=`echo $wwpn | grep ","`
|
||||
if [[ -n "$out" ]]; then
|
||||
multipath=1
|
||||
fi
|
||||
|
||||
if [[ $os == sles* || $os == rhel* ]]; then
|
||||
fcp=$(echo ${xcat_srcFile} | sed -e 's/^\/dev.*ccw-0.0.//' | sed -e 's/-zfcp-.*$//')
|
||||
else
|
||||
fcp=$(echo ${xcat_srcFile} | sed -e 's/^\/dev.*ccw-0.0.//' | sed -e 's/-fc-.*$//')
|
||||
fi
|
||||
oldIFS=$IFS
|
||||
IFS=","
|
||||
fcpList=($fcp)
|
||||
for fcp in ${fcpList[@]}
|
||||
do
|
||||
if [[ $multipath == 1 ]]; then
|
||||
# Find the name of the multipath device by arbitrary one path in the set
|
||||
wwpnList=($wwpn)
|
||||
for wwpn in ${wwpnList[@]}
|
||||
do
|
||||
if [[ ${wwpn:0:2} -ne "0x" ]]; then
|
||||
wwpn="0x$wwpn"
|
||||
fi
|
||||
if [[ $os == sles* || $os == rhel* ]]; then
|
||||
cur_wwpn_lun=${wwpn}:${lun}
|
||||
srcFile=$(echo ${xcat_srcFile} | sed -e 's/-zfcp-.*//')"-zfcp-"$cur_wwpn_lun
|
||||
srcFile=$(echo ${srcFile} | sed -e 's/ccw-.*-zfcp/ccw-0.0.'$fcp'-zfcp/')
|
||||
else
|
||||
cur_wwpn_lun=${wwpn}-lun-${lun}
|
||||
srcFile=$(echo ${xcat_srcFile} | sed -e 's/-fc-.*//')"-fc-"$cur_wwpn_lun
|
||||
srcFile=$(echo ${srcFile} | sed -e 's/ccw-.*-fc/ccw-0.0.'$fcp'-fc/')
|
||||
fi
|
||||
|
||||
out=`/usr/bin/stat --printf=%n ${srcFile}`
|
||||
if (( $? != 0 )); then
|
||||
echo "$funcName (Error) Unable to stat the source file: $srcFile"
|
||||
continue
|
||||
fi
|
||||
|
||||
out=`/sbin/udevadm info --query=all --name=$srcFile | grep ID_SERIAL=`
|
||||
devName=$(echo ${out} | sed -e 's/^E:\s//')
|
||||
multipathUuid=$(echo $devName | sed -e 's/ID_SERIAL=//')
|
||||
if [[ -n "$multipathUuid" ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$multipathUuid" ]]; then
|
||||
echo "$funcName (Error) Building up multipath failed!"
|
||||
return
|
||||
fi
|
||||
else
|
||||
if [[ $os == sles* || $os == rhel* ]]; then
|
||||
srcFile=$(echo ${xcat_srcFile} | sed -e 's/ccw-.*-zfcp/ccw-0.0.'$fcp'-zfcp/')
|
||||
else
|
||||
srcFile=$(echo ${xcat_srcFile} | sed -e 's/ccw-.*-zfcp/ccw-0.0.'$fcp'-fc/')
|
||||
fi
|
||||
out=`/usr/bin/stat --printf=%n ${srcFile}`
|
||||
if (( $? != 0 )); then
|
||||
echo "$funcName (Error) Unable to stat the source file: $xcat_srcFile"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS=$oldIFS
|
||||
|
||||
# Add the entry into udev config file
|
||||
if [[ $multipath == 1 ]]; then
|
||||
echo "KERNEL==\"dm*\", ENV{DM_UUID}==\"mpath-${multipathUuid}\", SYMLINK+=\"${tgtNode}\"" >> ${configFile}
|
||||
udevadm control --reload
|
||||
udevadm trigger --sysname-match=dm-*
|
||||
else
|
||||
echo "KERNEL==\"sd*\", ATTRS{wwpn}==\"${wwpn}\", ATTRS{fcp_lun}==\"${lun}\", SYMLINK+=\"${tgtNode}%n\"" >> ${configFile}
|
||||
udevadm control --reload
|
||||
udevadm trigger --sysname-match=sd*
|
||||
fi
|
||||
|
||||
echo "$funcName successfully create the file system node ${xcat_tgtFile}"
|
||||
|
||||
##########################################################################
|
||||
# Handle removing a file system node
|
||||
# Disk file input parameters:
|
||||
# action - "removefilesysnode"
|
||||
# tgtFile - location/name of the target file for the mknod command
|
||||
##########################################################################
|
||||
elif [[ $xcat_action == "removefilesysnode" ]]; then
|
||||
echo "Removing a file system node, target: $xcat_tgtFile"
|
||||
if [[ ! -n $xcat_tgtFile ]]; then
|
||||
echo "$funcName (Error) Target file for creating a file system node was not specified"
|
||||
return
|
||||
fi
|
||||
|
||||
configFile='/etc/udev/rules.d/56-zfcp.rules'
|
||||
tgtNode=$(echo ${xcat_tgtFile} | sed -e 's/^\/dev\///')
|
||||
|
||||
sed -i -e /SYMLINK+=\"${tgtNode}%n\"/d ${configFile}
|
||||
sed -i -e /SYMLINK+=\"${tgtNode}\"/d ${configFile}
|
||||
udevadm control --reload
|
||||
udevadm trigger --sysname-match=sd*
|
||||
udevadm trigger --sysname-match=dm-*
|
||||
echo "$funcName successfully remove the file system node ${xcat_tgtFile}"
|
||||
|
||||
##########################################################################
|
||||
# Handle adding a SCSI volume
|
||||
# Disk file input parameters:
|
||||
# action - "addScsiVolume"
|
||||
# fcpAddr - FCP device address
|
||||
# wwpn - WWPN number
|
||||
# lun - LUN number
|
||||
##########################################################################
|
||||
elif [[ $xcat_action == "addScsiVolume" ]]; then
|
||||
echo "Adding a SCSI Volume, FCP addr: $xcat_fcpAddr, WWPN: $xcat_wwpn, LUN: $xcat_lun"
|
||||
|
||||
# Validate the input
|
||||
if [[ ! -n $xcat_fcpAddr ]]; then
|
||||
echo "$funcName (Error) FCP address was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_fcpAddr=`echo $xcat_fcpAddr | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
if [[ ! -n $xcat_wwpn ]]; then
|
||||
echo "$funcName (Error) WWPN was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_wwpn=`echo $xcat_wwpn | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
if [[ ! -n $xcat_lun ]]; then
|
||||
echo "$funcName (Error) LUN was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_lun=`echo $xcat_lun | tr '[A-Z]' '[a-z]'`
|
||||
decimal_lun=$((16#${xcat_lun:0:4}))
|
||||
|
||||
# Online the device
|
||||
oldIFS=$IFS
|
||||
IFS=","
|
||||
fcp_list=($xcat_fcpAddr)
|
||||
for fcp in ${fcp_list[@]}
|
||||
do
|
||||
rc= onlineDevice $fcp
|
||||
if (( rc != 0 )); then
|
||||
return
|
||||
fi
|
||||
if [[ $os == sles12* ]]; then
|
||||
out=`cat /boot/zipl/active_devices.txt | grep -i "0.0.$fcp"`
|
||||
if [[ -z $out ]]; then
|
||||
/sbin/zfcp_host_configure 0.0.$fcp 1
|
||||
fi
|
||||
elif [[ $os == sles11* ]]; then
|
||||
/sbin/zfcp_host_configure 0.0.$fcp 1
|
||||
elif [[ $os == ubuntu* ]]; then
|
||||
/sbin/chzdev zfcp-host $fcp -e
|
||||
fi
|
||||
done
|
||||
|
||||
multipath=0
|
||||
out=`echo $xcat_wwpn | grep ","`
|
||||
if [[ -n "$out" ]]; then
|
||||
multipath=1
|
||||
fi
|
||||
|
||||
# Start multipathd service
|
||||
if [[ $multipath == 1 ]]; then
|
||||
if [[ $os == sles* ]]; then
|
||||
insserv multipathd
|
||||
elif [[ $os == rhel6* ]]; then
|
||||
chkconfig multipathd on
|
||||
else
|
||||
systemctl enable multipathd
|
||||
fi
|
||||
modprobe dm-multipath
|
||||
fi
|
||||
|
||||
for fcp in ${fcp_list[@]}
|
||||
do
|
||||
wwpn_list=($xcat_wwpn)
|
||||
for wwpn in ${wwpn_list[@]}
|
||||
do
|
||||
# Set WWPN and LUN in sysfs
|
||||
echo 0x$xcat_lun > /sys/bus/ccw/drivers/zfcp/0.0.$fcp/0x$wwpn/unit_add
|
||||
|
||||
# Set WWPN and LUN in configuration files
|
||||
if [[ $os == sles* ]]; then
|
||||
# SLES: /etc/udev/rules.d/51-zfcp*
|
||||
/sbin/zfcp_disk_configure 0.0.$fcp $wwpn $xcat_lun 1
|
||||
|
||||
# Configure zFCP device to be persistent
|
||||
touch /etc/udev/rules.d/51-zfcp-0.0.$fcp.rules
|
||||
|
||||
# Check if the file already contains the zFCP channel
|
||||
out=`cat "/etc/udev/rules.d/51-zfcp-0.0.$fcp.rules" | egrep -i "ccw/0.0.$fcp]online"`
|
||||
if [[ ! $out ]]; then
|
||||
echo "ACTION==\"add\", SUBSYSTEM==\"ccw\", KERNEL==\"0.0.$fcp\", IMPORT{program}=\"collect 0.0.$fcp %k 0.0.$fcp zfcp\"" \
|
||||
| tee -a /etc/udev/rules.d/51-zfcp-0.0.$fcp.rules
|
||||
echo "ACTION==\"add\", SUBSYSTEM==\"drivers\", KERNEL==\"zfcp\", IMPORT{program}=\"collect 0.0.$fcp %k 0.0.$fcp zfcp\"" \
|
||||
| tee -a /etc/udev/rules.d/51-zfcp-0.0.$fcp.rules
|
||||
echo "ACTION==\"add\", ENV{COLLECT_0.0.$fcp}==\"0\", ATTR{[ccw/0.0.$fcp]online}=\"1\"" \
|
||||
| tee -a /etc/udev/rules.d/51-zfcp-0.0.$fcp.rules
|
||||
fi
|
||||
|
||||
echo "ACTION==\"add\", KERNEL==\"rport-*\", ATTR{port_name}==\"0x$wwpn\", SUBSYSTEMS==\"ccw\", KERNELS==\"0.0.$fcp\", ATTR{[ccw/0.0.$fcp]0x$wwpn/unit_add}=\"0x$xcat_lun\"" \
|
||||
| tee -a /etc/udev/rules.d/51-zfcp-0.0.$fcp.rules
|
||||
elif [[ $os == rhel* ]]; then
|
||||
# RHEL: /etc/zfcp.conf
|
||||
echo "0.0.$fcp 0x$wwpn 0x$xcat_lun" >> /etc/zfcp.conf
|
||||
echo "add" > /sys/bus/ccw/devices/0.0.$fcp/uevent
|
||||
elif [[ $os == ubuntu* ]]; then
|
||||
# Ubuntu: chzdev zfcp-lun 0.0.$device:0x$wwpn:0x$lun -e
|
||||
/sbin/chzdev zfcp-lun 0.0.$fcp:0x$wwpn:0x$xcat_lun -e
|
||||
fi
|
||||
|
||||
# Settle the file system so when we are done the device is fully available
|
||||
if [[ $(which udevadm 2> /dev/null) != '' ]]; then
|
||||
udevadm settle
|
||||
else
|
||||
udevsettle
|
||||
fi
|
||||
if [[ $os == rhel* || $os == sles* ]]; then
|
||||
if [[ ! -e "/dev/disk/by-path/ccw-0.0.${fcp}-zfcp-0x${wwpn}:0x${xcat_lun}" ]]; then
|
||||
# Sometimes the file takes longer to appear. We will wait up to 3 minutes.
|
||||
maxTime=0
|
||||
for time in 1 2 2 5 10 10 30 60 60
|
||||
do
|
||||
if [[ -e "/dev/disk/by-path/ccw-0.0.${fcp}-zfcp-0x${wwpn}:0x${xcat_lun}" ]]; then
|
||||
# Leave the loop now that the file exists
|
||||
break
|
||||
fi
|
||||
maxTime=$maxTime+$time
|
||||
echo "Sleeping for $time seconds to allow /dev/disk/by-path/ccw-0.0.${fcp}-zfcp-0x${wwpn}:0x${xcat_lun} to be created"
|
||||
sleep $time
|
||||
done
|
||||
fi
|
||||
if [[ ! -e "/dev/disk/by-path/ccw-0.0.${fcp}-zfcp-0x${wwpn}:0x${xcat_lun}" ]]; then
|
||||
echo "/dev/disk/by-path/ccw-0.0.${fcp}-zfcp-0x${wwpn}:0x${xcat_lun} did not appear in $maxTime seconds, continuing."
|
||||
fi
|
||||
elif [[ $os == ubuntu* ]]; then
|
||||
if [[ ! -e "/dev/disk/by-path/ccw-0.0.${fcp}-fc-0x${wwpn}-lun-${decimal_lun}" ]]; then
|
||||
# Sometimes the file takes longer to appear. We will wait up to 3 minutes.
|
||||
maxTime=0
|
||||
for time in 1 2 2 5 10 10 30 60 60
|
||||
do
|
||||
if [[ -e "/dev/disk/by-path/ccw-0.0.${fcp}-fc-0x${wwpn}-lun-${decimal_lun}" ]]; then
|
||||
# Leave the loop now that the file exists
|
||||
break
|
||||
fi
|
||||
maxTime=$maxTime+$time
|
||||
echo "Sleeping for $time seconds to allow /dev/disk/by-path/ccw-0.0.${fcp}-fc-0x${wwpn}-lun-${decimal_lun} to be created"
|
||||
sleep $time
|
||||
done
|
||||
fi
|
||||
if [[ ! -e "/dev/disk/by-path/ccw-0.0.${fcp}-fc-0x${wwpn}-lun-${decimal_lun}" ]]; then
|
||||
echo "/dev/disk/by-path/ccw-0.0.${fcp}-fc-0x${wwpn}-lun-${decimal_lun} did not appear in $maxTime seconds, continuing."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$oldIFS
|
||||
|
||||
/sbin/multipath -r
|
||||
|
||||
echo "$funcName successfully create the SCSI volume"
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Handle removing a SCSI volume
|
||||
# Disk file input parameters:
|
||||
# action - "removeScsiVolume"
|
||||
# fcpAddr - FCP device address
|
||||
# wwpn - WWPN number
|
||||
# lun - LUN number
|
||||
##########################################################################
|
||||
elif [[ $xcat_action == "removeScsiVolume" ]]; then
|
||||
echo "Removing a SCSI Volume, FCP addr: $xcat_fcpAddr, WWPN: $xcat_wwpn, LUN: $xcat_lun"
|
||||
|
||||
# Validate the input
|
||||
if [[ ! -n $xcat_fcpAddr ]]; then
|
||||
echo "$funcName (Error) FCP address was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_fcpAddr=`echo $xcat_fcpAddr | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
if [[ ! -n $xcat_wwpn ]]; then
|
||||
echo "$funcName (Error) WWPN was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_wwpn=`echo $xcat_wwpn | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
if [[ ! -n $xcat_lun ]]; then
|
||||
echo "$funcName (Error) LUN was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_lun=`echo $xcat_lun | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
oldIFS=$IFS
|
||||
IFS=","
|
||||
fcp_list=($xcat_fcpAddr)
|
||||
for fcp in ${fcp_list[@]}
|
||||
do
|
||||
wwpn_list=($xcat_wwpn)
|
||||
for wwpn in ${wwpn_list[@]}
|
||||
do
|
||||
# Delete the SCSI device
|
||||
scsiDevice=`lszfcp -l 0x$xcat_lun | grep 0x$wwpn | cut -d " " -f2`
|
||||
if [[ -n $scsiDevice ]]; then
|
||||
echo 1 > "/sys/bus/scsi/devices/$scsiDevice/delete"
|
||||
fi
|
||||
|
||||
# Delete WWPN and LUN from sysfs
|
||||
if [[ -e /sys/bus/ccw/drivers/zfcp/0.0.$fcp/0x$wwpn/unit_remove ]]; then
|
||||
if [[ $(which udevadm 2> /dev/null) != '' ]]; then
|
||||
udevadm settle
|
||||
else
|
||||
udevsettle
|
||||
fi
|
||||
echo 0x$xcat_lun > /sys/bus/ccw/drivers/zfcp/0.0.$fcp/0x$wwpn/unit_remove
|
||||
fi
|
||||
|
||||
# Delete WWPN and LUN from configuration files
|
||||
if [[ $os == sles11* || $os == sles12* ]]; then
|
||||
# SLES: /etc/udev/rules.d/51-zfcp*
|
||||
expression="/$xcat_lun/d"
|
||||
sed --in-place -e $expression /etc/udev/rules.d/51-zfcp-0.0.$fcp.rules
|
||||
elif [[ $os == rhel* ]]; then
|
||||
# RHEL: /etc/zfcp.conf
|
||||
expression="/$xcat_lun/d"
|
||||
sed --in-place -e $expression /etc/zfcp.conf
|
||||
elif [[ $os == ubuntu* ]]; then
|
||||
# Ubuntu: chzdev zfcp-lun 0.0.$device:0x$wwpn:0x$lun -d
|
||||
/sbin/chzdev zfcp-lun 0.0.$fcp:0x$wwpn:0x$xcat_lun -d
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$oldIFS
|
||||
/sbin/multipath -W
|
||||
/sbin/multipath -r
|
||||
echo "$funcName successfully remove the SCSI volume"
|
||||
|
||||
###########################################################################
|
||||
# Handle adding a mdisk based ephemeral disk.
|
||||
# Disk file input parameters:
|
||||
# action - "addMdisk"
|
||||
# vaddr - virtual address of the minidisk
|
||||
# filesys - Filesystem type
|
||||
# mntdir - The directory that mount the mdisk to
|
||||
##########################################################################
|
||||
elif [[ $xcat_action == "addMdisk" ]]; then
|
||||
echo "Adding a minidisk based ephemeral disk, Vaddr: $xcat_vaddr, Filesystem: $xcat_filesys mountpoint:$xcat_mntdir"
|
||||
|
||||
# Validate the input
|
||||
if [[ ! -n $xcat_vaddr ]]; then
|
||||
echo "$funcName (Error) Virtual address was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_vaddr=`echo $xcat_vaddr | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
# Online the device
|
||||
rc= onlineDevice $xcat_vaddr
|
||||
if (( rc != 0 )); then
|
||||
echo "$funcName (Error) fail to online the disk $xcat_vaddr"
|
||||
return
|
||||
fi
|
||||
|
||||
# Configure the added dasd to be persistent
|
||||
echo "Permanently online the ephemeral disk"
|
||||
if [[ $os == rhel* ]]; then
|
||||
out=`cat "/etc/dasd.conf" | egrep -i $xcat_vaddr`
|
||||
if [[ ! $out ]]; then
|
||||
echo "0.0.$xcat_vaddr" >> /etc/dasd.conf
|
||||
fi
|
||||
elif [[ $os == sles* ]]; then
|
||||
/sbin/dasd_configure 0.0.$xcat_vaddr 1
|
||||
elif [[ $os == ubuntu16* ]]; then
|
||||
touch /etc/sysconfig/hardware/config-ccw-0.0.$xcat_vaddr
|
||||
else
|
||||
echo "$funcName (Error) failed to permanently online the disk:$xcat_vaddr on os: $os, please check if $os is in the supported distribution list"
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
# Mount the mdisk to the specified mount point
|
||||
echo "Mounting the ephemeral disk $xcat_vaddr to directory $xcat_mntdir"
|
||||
if [[ -d $xcat_mntdir ]]; then
|
||||
rm -rf $xcat_mntdir
|
||||
fi
|
||||
mkdir -p $xcat_mntdir
|
||||
|
||||
cp /etc/fstab /etc/fstab.bak
|
||||
out=`cat "/etc/fstab" | egrep -i "ccw-0.0.$xcat_vaddr"`
|
||||
if [[ $out ]]; then
|
||||
sed -i '/ccw-0.0.'"$xcat_vaddr"'/d' /etc/fstab
|
||||
fi
|
||||
|
||||
if [[ $os == sles12* ]]; then
|
||||
echo "/dev/disk/by-path/ccw-0.0.${xcat_vaddr}-part1 $xcat_mntdir $xcat_filesys defaults,nofail 0 0" >> /etc/fstab
|
||||
else
|
||||
echo "/dev/disk/by-path/ccw-0.0.${xcat_vaddr}-part1 $xcat_mntdir $xcat_filesys defaults 0 0" >> /etc/fstab
|
||||
fi
|
||||
|
||||
out=`mount -a 2>&1`
|
||||
if [[ "$out" ]]; then
|
||||
echo "Fail to mount the disk $xcat_vaddr with reason $out"
|
||||
mv /etc/fstab.bak /etc/fstab
|
||||
mount -a
|
||||
else
|
||||
echo "The disk $xcat_vaddr has been mounted to $xcat_mntdir in format $xcat_filesys successfully"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
############################################################################
|
||||
# Main Code Section
|
||||
############################################################################
|
||||
# Get Linux version
|
||||
getOsVersion
|
||||
setupDisk $@
|
||||
rm -f setupDisk
|
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# IBM(c) 2013, 2015 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: xcatconf4z
|
||||
@ -7,10 +8,11 @@
|
||||
# Required-Start: $syslog
|
||||
# Should-Start:
|
||||
# Required-Stop:
|
||||
# Short-Description: xCAT disk initialization and configuration
|
||||
# Short-Description: A basic active engine used to initialize and configure vm.
|
||||
# Description: Reads class x files from the reader and acts based on the type of file.
|
||||
# Files of filetype "disk" cause SCSI disks be configured.
|
||||
# Other files are used to generate an ISO9660 disk for transporting xCAT configurations.
|
||||
# Generate an ISO9660 disk for cloud-init to handle openstack configurations.
|
||||
# Files of filetype "disk" cause disks be configured. (deprecated)
|
||||
# Other files are used to configure vm when it start up.
|
||||
### END INIT INFO
|
||||
|
||||
###############################################################################
|
||||
@ -20,6 +22,7 @@
|
||||
# If nothing is specified then this function will not process any
|
||||
# configuration files in the reader.
|
||||
###############################################################################
|
||||
version=3.0
|
||||
authorizedSenders=''
|
||||
|
||||
function getOsVersion {
|
||||
@ -80,7 +83,7 @@ function onlineDevice {
|
||||
fi
|
||||
rc=$(/sbin/chccwdev -e $device > /dev/null; echo $?)
|
||||
if (( rc != 0 )); then
|
||||
echo "xcatconf4z $funcName (Error) Could not activate the virtual reader"
|
||||
echo "xcatconf4z $funcName (Error) Could not activate the virtual device $device"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
@ -94,7 +97,8 @@ function pullReader {
|
||||
# Drives special processing functions for files of a specific type.
|
||||
# Files with a filetype of:
|
||||
# tgz are unpacked into the transport directory
|
||||
# disk files are read and cause the setupDisk function to be driven
|
||||
# disk files are read and cause the setupDisk function to be driven (deprecated)
|
||||
# doscript that contains a invokeScript.sh which will call the other script in it to do the speicial work
|
||||
# all other files are unpacked into the transport directory
|
||||
# @Input:
|
||||
# None
|
||||
@ -145,14 +149,26 @@ function pullReader {
|
||||
# Receive the spool file
|
||||
echo "Downloading record $spoolid: $file"
|
||||
|
||||
if [[ $type == "txt" ]] || [[ $type == "sh" ]]; then
|
||||
if [[ $type == "txt" ]]; then
|
||||
# Receiving text
|
||||
rc=$(/usr/sbin/vmur re -t $spoolid $file)
|
||||
rc=$(/usr/sbin/vmur re -f $spoolid $file)
|
||||
elif [[ $type == "sh" ]]; then
|
||||
# Receiving shell
|
||||
rc=$(/usr/sbin/vmur re -f $spoolid $file)
|
||||
/bin/bash $file
|
||||
rm $file
|
||||
elif [[ $type == "tgz" ]]; then
|
||||
rc=$(/usr/sbin/vmur re $spoolid $file)
|
||||
/bin/tar xzf $file -C $transportdir
|
||||
rm $file
|
||||
injectFiles
|
||||
elif [[ $type == "doscript" ]]; then
|
||||
rc=$(/usr/sbin/vmur re $spoolid $file)
|
||||
/bin/tar xf $file -C $transportdir
|
||||
rm $file
|
||||
/bin/bash invokeScript.sh
|
||||
elif [[ $type == "disk" ]]; then
|
||||
echo 'disk file encountered and will be handled by the deprecated setupDisk function'
|
||||
rc=$(/usr/sbin/vmur re $spoolid $file)
|
||||
if (( rc == 0 )); then
|
||||
setupDisk $transportdir'/'$file
|
||||
@ -180,11 +196,15 @@ function setupIso {
|
||||
# @Output:
|
||||
# None
|
||||
# @Code:
|
||||
local funcName="setupIso"
|
||||
iso="/var/opt/xcat/transport.iso"
|
||||
|
||||
# If there are files in the transport directory then create an ISO system.
|
||||
if [ "$(ls -A .)" ]; then
|
||||
/usr/bin/mkisofs -l -o $iso $transportdir
|
||||
/usr/bin/mkisofs -l -V 'config-2' -o $iso $transportdir
|
||||
if [ -e /tmp/znetconfig.sh ]; then
|
||||
/bin/bash /tmp/znetconfig.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the ISO filesystem exists then create loop back device pointing
|
||||
@ -350,7 +370,7 @@ function setupDisk {
|
||||
/sbin/zfcp_host_configure 0.0.$xcat_fcpAddr 1
|
||||
/sbin/zfcp_disk_configure 0.0.$xcat_fcpAddr $xcat_wwpn $xcat_lun 1
|
||||
echo "0x$xcat_wwpn:0x$xcat_lun" >> /etc/sysconfig/hardware/hwcfg-zfcp-bus-ccw-0.0.$xcat_fcpAddr
|
||||
elif [[ $os == sles* ]]; then
|
||||
elif [[ $os == sles11* ]]; then
|
||||
/sbin/zfcp_host_configure 0.0.$xcat_fcpAddr 1
|
||||
/sbin/zfcp_disk_configure 0.0.$xcat_fcpAddr $xcat_wwpn $xcat_lun 1
|
||||
|
||||
@ -455,18 +475,115 @@ function setupDisk {
|
||||
if [[ $os == sles10* ]]; then
|
||||
expression="/$xcat_lun/d"
|
||||
sed --in-place -e $expression /etc/sysconfig/hardware/hwcfg-zfcp-bus-ccw-0.0.$xcat_fcpAddr
|
||||
elif [[ $os == sles* ]]; then
|
||||
elif [[ $os == sles11* ]]; then
|
||||
expression="/$xcat_lun/d"
|
||||
sed --in-place -e $expression /etc/udev/rules.d/51-zfcp-0.0.$xcat_fcpAddr.rules
|
||||
elif [[ $os == rhel* ]]; then
|
||||
expression="/$xcat_lun/d"
|
||||
sed --in-place -e $expression /etc/zfcp.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
###########################################################################
|
||||
# Handle adding a mdisk based ephemeral disk.
|
||||
# Disk file input parameters:
|
||||
# action - "addMdisk"
|
||||
# vaddr - virtual address of the minidisk
|
||||
# filesys - Filesystem type
|
||||
# mntdir - The directory that mount the mdisk to
|
||||
##########################################################################
|
||||
elif [[ $xcat_action == "addMdisk" ]]; then
|
||||
echo "Adding a minidisk based ephemeral disk, Vaddr: $xcat_vaddr, Filesystem: $xcat_filesys mountpoint:$xcat_mntdir"
|
||||
|
||||
# Validate the input
|
||||
if [[ ! -n $xcat_vaddr ]]; then
|
||||
echo "xcatconf4z $funcName (Error) Virtual address was not specified"
|
||||
return
|
||||
fi
|
||||
xcat_vaddr=`echo $xcat_vaddr | tr '[A-Z]' '[a-z]'`
|
||||
|
||||
# Online the device
|
||||
rc= onlineDevice $xcat_vaddr
|
||||
if (( rc != 0 )); then
|
||||
echo "xcatconf4z $funcName (Error) fail to online the disk $xcat_vaddr"
|
||||
return
|
||||
fi
|
||||
|
||||
# Configure the added dasd to be persistent
|
||||
echo "Permenently online the ephemeral disk"
|
||||
if [[ $os == rhel* ]]; then
|
||||
out=`cat "/etc/dasd.conf" | egrep -i $xcat_vaddr`
|
||||
if [[ ! $out ]]; then
|
||||
echo "0.0.$xcat_vaddr" >> /etc/dasd.conf
|
||||
fi
|
||||
else
|
||||
/sbin/dasd_configure 0.0.$xcat_vaddr 1
|
||||
fi
|
||||
|
||||
# Mount the mdisk to the specified mount point
|
||||
echo "Mounting the ephemeral disk $xcat_vaddr to directory $xcat_mntdir"
|
||||
if [[ -d $xcat_mntdir ]]; then
|
||||
rm -rf $xcat_mntdir
|
||||
fi
|
||||
mkdir -p $xcat_mntdir
|
||||
|
||||
cp /etc/fstab /etc/fstab.bak
|
||||
out=`cat "/etc/fstab" | egrep -i "ccw-0.0.$xcat_vaddr"`
|
||||
if [[ $out ]]; then
|
||||
sed -i '/ccw-0.0.'"$xcat_vaddr"'/d' /etc/fstab
|
||||
fi
|
||||
echo "/dev/disk/by-path/ccw-0.0.${xcat_vaddr}-part1 $xcat_mntdir $xcat_filesys defaults 0 0" >> /etc/fstab
|
||||
|
||||
out=`mount -a 2>&1`
|
||||
if [[ "$out" ]]; then
|
||||
echo "Fail to mount the disk $xcat_vaddr with reason $out"
|
||||
mv /etc/fstab.bak /etc/fstab
|
||||
mount -a
|
||||
else
|
||||
echo "The disk $xcat_vaddr has been mounted to $xcat_mntdir in format $xcat_filesys successfully"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function injectFiles {
|
||||
# @Description:
|
||||
# Inject network files and scripts
|
||||
# @Input:
|
||||
# None
|
||||
# @Output:
|
||||
# None
|
||||
# @Code:
|
||||
local funcName="injectFiles"
|
||||
|
||||
if [[ ! -e $transportdir/openstack/latest/meta_data.json ]]; then
|
||||
echo "Can not inject files, because no meta_data.json"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "File injecting ...."
|
||||
awk '{
|
||||
#get inject files info
|
||||
split($0 ,res1,/"files": \[/)
|
||||
split(res1[2], res2, /\]/)
|
||||
n=split(res2[1], res, /}, /)
|
||||
|
||||
for(m=1;m<=n;m++)
|
||||
{
|
||||
split(res[m], temp1, /{"path": "/)
|
||||
k=split(temp1[2], temp2, /", "content_path": "/)
|
||||
sub(/"}*$/, "", temp2[2])
|
||||
#print temp2[1] " : " temp2[2]
|
||||
des = dir "/openstack" temp2[2]
|
||||
cmd = "cp " des " " temp2[1]
|
||||
#print cmd
|
||||
system(cmd)
|
||||
}
|
||||
}' dir=$transportdir <$transportdir/openstack/latest/meta_data.json
|
||||
return
|
||||
}
|
||||
|
||||
############################################################################
|
||||
# Main Code Section
|
||||
############################################################################
|
||||
@ -483,13 +600,27 @@ case "$1" in
|
||||
|
||||
if [[ -n "$authorizedSenders" ]]; then
|
||||
pullReader
|
||||
echo "xcatconf4z has successfully processed the reader files."
|
||||
else
|
||||
echo "xcatconf4z is disabled from accepting configuration reader files."
|
||||
fi
|
||||
|
||||
setupIso
|
||||
;;
|
||||
stop|status|restart|reload|force-reload)
|
||||
;;
|
||||
|
||||
status)
|
||||
if [[ -n "$authorizedSenders" ]]; then
|
||||
echo "xcatconf4z is enabled to accept configuration reader files from: $authorizedSenders"
|
||||
else
|
||||
echo "xcatconf4z is disabled from accepting configuration reader files."
|
||||
fi
|
||||
;;
|
||||
|
||||
version)
|
||||
echo "xcatconf4z version:" $version
|
||||
;;
|
||||
|
||||
stop|restart|reload|force-reload)
|
||||
# Do nothing
|
||||
;;
|
||||
esac
|
||||
|
14
xCAT-server/share/xcat/scripts/xcatconf4z.service
Normal file
14
xCAT-server/share/xcat/scripts/xcatconf4z.service
Normal file
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Activation engine for configuring vm when it start up
|
||||
Wants=local-fs.target NetworkManager.service
|
||||
After=local-fs.target
|
||||
Before=NetworkManager.service cloud-init-local.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/xcatconf4z start
|
||||
|
||||
StandardOutput=journal+console
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
13
xCAT-server/share/xcat/tools/zvm/README
Normal file
13
xCAT-server/share/xcat/tools/zvm/README
Normal file
@ -0,0 +1,13 @@
|
||||
z/VM Toolkit
|
||||
|
||||
The list of resources related:
|
||||
Files:
|
||||
prep_zxcatIVP_*.pl
|
||||
|
||||
|
||||
The prep_zxcatIVP_*.pl files are provided for each supported OpenStack release
|
||||
that interacts with xCAT. These scripts end contain the name of the OpenStack
|
||||
release that they support. The scripts scan the OpenStack configuration files
|
||||
and produce a driver script which is used to validate the installation of the
|
||||
OpenStack code with xCAT. For more information on the scripts, invoke the
|
||||
help function for the individual script (operand --help).
|
938
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_HAVANA.pl
Normal file
938
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_HAVANA.pl
Normal file
@ -0,0 +1,938 @@
|
||||
#!/usr/bin/perl
|
||||
###############################################################################
|
||||
# (c) Copyright International Business Machines Corporation 2014.
|
||||
# All Rights Reserved.
|
||||
###############################################################################
|
||||
# COMPONENT: prep_zxcatIVP_HAVANA.pl
|
||||
#
|
||||
# This is a preparation script for Installation Verification Program for xCAT
|
||||
# on z/VM. It prepares the driver script by gathering information from
|
||||
# OpenStack configuration files on the compute node.
|
||||
###############################################################################
|
||||
|
||||
use strict;
|
||||
#use warnings;
|
||||
|
||||
use Getopt::Long;
|
||||
use Sys::Hostname;
|
||||
use Socket;
|
||||
|
||||
my %cinderConf;
|
||||
my %novaConf;
|
||||
my %neutronConf;
|
||||
my %ovsNeutronPluginIni;
|
||||
my %neutronZvmPluginIni;
|
||||
|
||||
my $version = "1.1";
|
||||
my $supportString = "Supports code based on the OpenStack Havana release.";
|
||||
|
||||
my $driver; # Name of driver file to be created less the ".pl"
|
||||
my $driverLocation = "/opt/xcat/bin/"; # Location of the IVP program in xCAT MN.
|
||||
my $driverPrefix = "zxcatIVPDriver_"; # Prefix used in naming the driver program.
|
||||
my $displayHelp = 0; # Display help information.
|
||||
my $ivp = "zxcatIVP.pl"; # z/VM xCAT IVP script name
|
||||
my $obfuscatePw; # Obfuscate the PW in the driver file that is built
|
||||
my $scan; # Type of scan to be performed
|
||||
my $verbose; # Verbose flag - 0: quiet, 1: verbose
|
||||
my $versionOpt = 0; # Shov version information.
|
||||
|
||||
my $localIpAddress; # Local IP address of system where we are prepping
|
||||
|
||||
# set the usage message
|
||||
my $usage_string = "Usage:\n
|
||||
$0\n
|
||||
or\n
|
||||
$0 -s serviceToScan -d driverProgramName\n
|
||||
or\n
|
||||
$0 --scan serviceToScan -driver driverProgramName\n
|
||||
-s | --scan Services to scan ('all', 'nova' or 'neutron').\n
|
||||
-d | --driver Name of driver program to construct.\n
|
||||
--help Display help information.\n
|
||||
-v Display script version information.\n
|
||||
-V Display the verbose message\n";
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 buildDriverProgram
|
||||
|
||||
Description : Build or update the driver program with the
|
||||
data obtained by the scans.
|
||||
Arguments : None
|
||||
Returns : 0 - No error
|
||||
non-zero - Error detected.
|
||||
Example : $rc = buildDriverProgram();
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub buildDriverProgram{
|
||||
my $rc;
|
||||
my @driverText;
|
||||
|
||||
if ( $verbose ) {
|
||||
print "Building the IVP driver program.\n";
|
||||
}
|
||||
|
||||
# Erase any existing driver program.
|
||||
if ( -e $driver and ! -z $driver ) {
|
||||
# Make certain the file is one of our driver files.
|
||||
my $found = `grep 'Function: z/VM xCAT IVP driver program' $driver`;
|
||||
if ( ! $found ) {
|
||||
print "$driver is not a z/VM xCAT IVP driver program\n";
|
||||
print "File will not be changed.\n";
|
||||
return 251;
|
||||
} else {
|
||||
# Rename the existing driver file.
|
||||
print "Existing driver file is being saved as $driver.old\n";
|
||||
rename $driver,"$driver.old";
|
||||
}
|
||||
}
|
||||
|
||||
# Open the driver program for output.
|
||||
$rc = open( my $fileHandle, '>', $driver ) or die;
|
||||
if ( $rc != 1 ) {
|
||||
print "Unable to open $driver for output: $!\n";
|
||||
return ( 200 + $rc );
|
||||
}
|
||||
|
||||
# Construct the file in an array.
|
||||
push( @driverText, "#!/bin/bash" );
|
||||
push( @driverText, "# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html" );
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Function: z/VM xCAT IVP driver program" );
|
||||
push( @driverText, "# Built by $0 version $version." );
|
||||
push( @driverText, "# $supportString" );
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "############## Start of Nova Config Properties" );
|
||||
if ( exists $novaConf{'DEFAULT'}{'my_ip'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# IP address or hostname of the compute node that is accessing this xCAT MN." );
|
||||
push( @driverText, "# From \'my_ip\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_cNAddress=\"$novaConf{'DEFAULT'}{'my_ip'}\"" );
|
||||
} else {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# IP address or hostname of the compute node that is accessing this xCAT MN." );
|
||||
push( @driverText, "# From the local IP address of this system." );
|
||||
push( @driverText, "export zxcatIVP_cNAddress=\"$localIpAddress\"" );
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_user_profile'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Default profile used in creation of server instances." );
|
||||
push( @driverText, "# From \'zvm_user_profile\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_defaultUserProfile=\"$novaConf{'DEFAULT'}{'zvm_user_profile'}\"" );
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_diskpool'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Array of disk pools that are expected to exist." );
|
||||
push( @driverText, "# From \'zvm_diskpool\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_diskpools=\"$novaConf{'DEFAULT'}{'zvm_diskpool'}\"" );
|
||||
}
|
||||
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_fcp_list'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# The list of FCPs used by instances." );
|
||||
push( @driverText, "# From \'zvm_fcp_list\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_instFCPList=\"$novaConf{'DEFAULT'}{'zvm_fcp_list'}\"" );
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_host'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Node of host being managed. If blank, IVP will search for the host node." );
|
||||
push( @driverText, "# From \'zvm_host\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_hostNode=\"$novaConf{'DEFAULT'}{'zvm_host'}\"" );
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_xcat_master'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Node name for xCAT MN (optional)." );
|
||||
push( @driverText, "# From \'zvm_xcat_master\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_mnNode=\"$novaConf{'DEFAULT'}{'zvm_xcat_master'}\"" );
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_xcat_password'} ) {
|
||||
push( @driverText, "" );
|
||||
if ( $obfuscatePw ) {
|
||||
# Obfuscate the password so that it is not easily read.
|
||||
# Currently not used due to GUI restrictions that modify the obfuscated password.
|
||||
push( @driverText, "# User password defined to communicate with xCAT MN. Note: Password is hidden." );
|
||||
push( @driverText, "export zxcatIVP_pw_obfuscated=1" );
|
||||
push( @driverText, "# From \'zvm_xcat_password\' in /etc/nova/nova.conf." );
|
||||
my @chars = split( //, $novaConf{'DEFAULT'}{'zvm_xcat_password'} );
|
||||
my @newChars;
|
||||
foreach my $char ( @chars ) {
|
||||
$char = ~$char;
|
||||
push( @newChars, $char );
|
||||
}
|
||||
my $hiddenPw = join( "", @newChars );
|
||||
push( @driverText, "export zxcatIVP_xcatUserPw=\"$hiddenPw\"" );
|
||||
} else {
|
||||
push( @driverText, "# User password defined to communicate with xCAT MN." );
|
||||
push( @driverText, "# From \'zvm_xcat_password\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_xcatUserPw=\"$novaConf{'DEFAULT'}{'zvm_xcat_password'}\"" );
|
||||
}
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_xcat_server'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Expected IP address of the xcat MN" );
|
||||
push( @driverText, "# From \'zvm_xcat_server\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_xcatMNIp=\"$novaConf{'DEFAULT'}{'zvm_xcat_server'}\"" );
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_xcat_username'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# User defined to communicate with xCAT MN" );
|
||||
push( @driverText, "# From \'zvm_xcat_username\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_xcatUser=\"$novaConf{'DEFAULT'}{'zvm_xcat_username'}\"" );
|
||||
}
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_zhcp_fcp_list'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# The list of FCPs used by zHCP." );
|
||||
push( @driverText, "# From \'zvm_zhcp_fcp_list\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_zhcpFCPList=\"$novaConf{'DEFAULT'}{'zvm_zhcp_fcp_list'}\"" );
|
||||
}
|
||||
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Expected space available in the xCAT MN image repository" );
|
||||
push( @driverText, "# From \'xcat_free_space_threshold\' in /etc/nova/nova.conf." );
|
||||
push( @driverText, "export zxcatIVP_expectedReposSpace=\"$novaConf{'DEFAULT'}{'xcat_free_space_threshold'}G\"" );
|
||||
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "############## End of Nova Config Properties" );
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "############## Start of Neutron Config Properties" );
|
||||
if ( exists $neutronConf{'DEFAULT'}{'base_mac'} ) {
|
||||
my $prefix = $neutronConf{'DEFAULT'}{'base_mac'};
|
||||
$prefix =~ tr/://d;
|
||||
$prefix = substr( $prefix, 0, 6 );
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# User prefix for MAC Addresses of Linux level 2 interfaces" );
|
||||
push( @driverText, "# From \'base_mac\' in /etc/neutron/neutron.conf." );
|
||||
push( @driverText, "export zxcatIVP_macPrefix=\"$prefix\"" );
|
||||
}
|
||||
if ( exists $neutronZvmPluginIni{'agent'}{'xcat_mgt_ip'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# xCat MN's address on the xCAT management network" );
|
||||
push( @driverText, "# From \'xcat_mgt_ip\' in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini." );
|
||||
push( @driverText, "export zxcatIVP_xcatMgtIp=\"$neutronZvmPluginIni{'agent'}{'xcat_mgt_ip'}\"" );
|
||||
}
|
||||
if ( exists $neutronZvmPluginIni{'agent'}{'xcat_mgt_mask'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# xCat management interface netmask" );
|
||||
push( @driverText, "# From \'xcat_mgt_mask\' in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini." );
|
||||
push( @driverText, "export zxcatIVP_mgtNetmask=\"$neutronZvmPluginIni{'agent'}{'xcat_mgt_mask'}\"" );
|
||||
}
|
||||
if ( exists $ovsNeutronPluginIni{'ovs'}{'network_vlan_ranges'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Array of networks and possible VLAN ranges" );
|
||||
push( @driverText, "# From \'network_vlan_ranges\' in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini." );
|
||||
push( @driverText, "export zxcatIVP_networks=\"$ovsNeutronPluginIni{'ovs'}{'network_vlan_ranges'}\"" );
|
||||
}
|
||||
if ( exists $neutronZvmPluginIni{'agent'}{'xcat_zhcp_nodename'} ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Node name for xCAT zHCP server" );
|
||||
push( @driverText, "# From \'xcat_zhcp_nodename\' in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini." );
|
||||
push( @driverText, "export zxcatIVP_zhcpNode=\"$neutronZvmPluginIni{'agent'}{'xcat_zhcp_nodename'}\"" );
|
||||
}
|
||||
# Create the zxcatIVP_vswitchOSAs variable for any networks specified with an rdev list.
|
||||
my $vswitchOSAs = '';
|
||||
foreach my $section (sort keys %neutronZvmPluginIni) {
|
||||
next if ( $section eq 'agent');
|
||||
foreach my $property ( keys %{ $neutronZvmPluginIni{$section} } ) {
|
||||
next if ( $property ne "rdev_list" );
|
||||
my $list = $neutronZvmPluginIni{$section}{$property};
|
||||
$list =~ s/^\s+|\s+$//g; # trim blanks from both ends of the list
|
||||
next if ( $list eq '' );
|
||||
$list =~ s/\s+/\,/g; # insert comma between words
|
||||
$vswitchOSAs = "$section $list $vswitchOSAs";
|
||||
}
|
||||
}
|
||||
if ( defined $vswitchOSAs ) {
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Vswitches and their related OSAs" );
|
||||
push( @driverText, "# From \'rdev_list\' in vswitch sections of /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini." );
|
||||
push( @driverText, "export zxcatIVP_vswitchOSAs=\"$vswitchOSAs\"" );
|
||||
}
|
||||
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "############## End of Neutron Config Properties" );
|
||||
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Name of user under which nova runs, default is nova." );
|
||||
push( @driverText, "# If you system is different then change this property." );
|
||||
push( @driverText, "export zxcatIVP_expUser=\"nova\"" );
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "# Controls whether Warnings/Errors detected by the IVP are" );
|
||||
push( @driverText, "# logged in the xCAT MN syslog, 0: do not log, 1: log to syslog." );
|
||||
push( @driverText, "export zxcatIVP_syslogErrors=1" );
|
||||
push( @driverText, "" );
|
||||
push( @driverText, "perl $driverLocation$ivp" );
|
||||
|
||||
# Write the array to the driver file.
|
||||
foreach (@driverText) {
|
||||
#print "$_\n";
|
||||
print $fileHandle "$_\n"; # Print each entry in our array to the file
|
||||
}
|
||||
|
||||
close $fileHandle;
|
||||
|
||||
print "$driver was built.\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 hashFile
|
||||
|
||||
Description : Read a file with equal signs designating
|
||||
key value pairs and create a hash from it.
|
||||
Arguments : File to read
|
||||
Reference to hash that should be constructed.
|
||||
Returns : 0 - No error
|
||||
non-zero - Error detected.
|
||||
Example : $rc = hashFile( $file, \%novaConf, 1 );
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub hashFile{
|
||||
my ( $file, $hash, $required ) = @_;
|
||||
my $section = "null";
|
||||
my $caseInsensitive = 1; # assume section/properties are case insensitive
|
||||
my @parts;
|
||||
|
||||
if ( !-e $file ) {
|
||||
if ( $required ) {
|
||||
print "Warning: $file does not exist.\n";
|
||||
} else {
|
||||
print "Info: $file does not exist.\n";
|
||||
}
|
||||
return 601;
|
||||
}
|
||||
|
||||
if ( $file =~ /.conf$/ ) {
|
||||
# File is case sensitive, translate sections and property names to uppercase.
|
||||
$caseInsensitive = 0;
|
||||
}
|
||||
|
||||
# Read the configuration file and construct the hash of values.
|
||||
my $out = `egrep -v '(^#|^\\s*\\t*#)' $file`;
|
||||
my @lines = split( "\n", $out );
|
||||
foreach my $line ( @lines ) {
|
||||
if ( $line =~ /^\[/ ) {
|
||||
# Section header line
|
||||
$line =~ s/^\s+|\s+$//g; # trim blanks from both ends of the line
|
||||
$line =~ s/^\[+|\]+$//g; # trim [] from ends of the line
|
||||
if ( $caseInsensitive ) {
|
||||
$section = lc( $line );
|
||||
} else {
|
||||
$section = $line;
|
||||
}
|
||||
} else {
|
||||
# Property line
|
||||
@parts = split( "=", $line );
|
||||
next if ( ! exists $parts[0] );
|
||||
$parts[0] =~ s/^\s+|\s+$//g; # trim both ends of the string
|
||||
next if ( length( $parts[0] ) == 0 );
|
||||
if ( $caseInsensitive ) {
|
||||
$parts[0] = lc( $parts[0] );
|
||||
}
|
||||
|
||||
if ( exists $parts[1] ) {
|
||||
chomp( $parts[1] );
|
||||
$parts[1] =~ s/^\s+|\s+$//g; # trim both ends of the string
|
||||
} else {
|
||||
$parts[1] = '';
|
||||
}
|
||||
|
||||
$$hash{$section}{$parts[0]} = $parts[1];
|
||||
#print "$section $parts[0]" . ": " . $parts[1]. "\n";
|
||||
#print $parts[0] . ": " . $$hash{$section}{$parts[0]}. "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 scanCinder
|
||||
|
||||
Description : Scan the cinder configuration files.
|
||||
Arguments : None
|
||||
Returns : 0 - No error
|
||||
non-zero - Error detected.
|
||||
Example : $rc = scanCinder();
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub scanCinder{
|
||||
my $rc;
|
||||
|
||||
if ( $verbose ) {
|
||||
print "Scanning the Cinder configuration files.\n";
|
||||
}
|
||||
|
||||
# Read the configuration file and construct the hash of values.
|
||||
my $file = '/etc/cinder/cinder.conf';
|
||||
$rc = hashFile( $file, \%cinderConf, 0 );
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 scanNeutron
|
||||
|
||||
Description : Scan the neutron configuration files.
|
||||
Arguments : None
|
||||
Returns : 0 - No error
|
||||
non-zero - Error detected.
|
||||
Example : $rc = scanNeutron();
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub scanNeutron{
|
||||
my $rc;
|
||||
|
||||
if ( $verbose ) {
|
||||
print "Scanning the Neutron configuration files.\n";
|
||||
}
|
||||
|
||||
# Read the configuration file and construct the hash of values.
|
||||
my $file = '/etc/neutron/neutron.conf';
|
||||
$rc = hashFile( $file, \%neutronConf, 1 );
|
||||
|
||||
# Read the configuration file and construct the hash of values.
|
||||
$file = '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini';
|
||||
$rc = hashFile( $file, \%ovsNeutronPluginIni, 1 );
|
||||
|
||||
# Read the configuration file and construct the hash of values.
|
||||
$file = '/etc/neutron/plugins/zvm/neutron_zvm_plugin.ini';
|
||||
$rc = hashFile( $file, \%neutronZvmPluginIni, 1 );
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 scanNova
|
||||
|
||||
Description : Scan the Nova configuration files.
|
||||
Arguments : None.
|
||||
Returns : 0 - No error
|
||||
non-zero - Error detected.
|
||||
Example : $rc = scanNova();
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub scanNova{
|
||||
my $rc;
|
||||
|
||||
if ( $verbose ) {
|
||||
print "Scanning the Nova configuration files.\n";
|
||||
}
|
||||
# Verify the /etc/nova/nova.conf exists.
|
||||
my $file = '/etc/nova/nova.conf';
|
||||
|
||||
$rc = hashFile( $file, \%novaConf, 1 );
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 showHelp
|
||||
|
||||
Description : Show the help inforamtion.
|
||||
Arguments : None.
|
||||
Returns : None.
|
||||
Example : showHelp();
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub showHelp{
|
||||
print "$0 prepares and builds a z/VM xCAT IVP driver program
|
||||
using the information from the configuration files in the
|
||||
compute node. The default name of the driver program is
|
||||
'$driverPrefix' following by the IP address of the
|
||||
system where the driver is being prepared and ending with
|
||||
'.sh'.
|
||||
|
||||
$supportString
|
||||
|
||||
The following files are scanned for input:
|
||||
/etc/cinder/cinder.conf
|
||||
/etc/nova/nova.conf
|
||||
/etc/neutron/neutron.conf
|
||||
/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini
|
||||
/etc/neutron/plugins/zvm/neutron_zvm_plugin.ini
|
||||
The constructed driver program can then be uploaded to
|
||||
the xCAT MN and used to validate the configuration between
|
||||
the compute node and xCAT.\n\n";
|
||||
print $usage_string;
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 validateConfigs
|
||||
|
||||
Description : Compare and validate the configuration
|
||||
values obtained by the scans.
|
||||
Arguments : None.
|
||||
Returns : 0 - No error
|
||||
non-zero - Error detected.
|
||||
Example : $rc = validateConfigs();
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub validateConfigs{
|
||||
my $rc = 0;
|
||||
my $option;
|
||||
if ( $verbose ) {
|
||||
print "Performing a local validation of the configuration files.\n";
|
||||
}
|
||||
|
||||
#*******************************************************
|
||||
# Verify required configuration options were specified.
|
||||
#*******************************************************
|
||||
if ( keys %cinderConf ) {
|
||||
my @requiredCinderOpts = ();
|
||||
foreach $option ( @requiredCinderOpts ) {
|
||||
if ( !exists $cinderConf{'DEFAULT'}{$option} ) {
|
||||
#print "option:$option.\nvalue:$cinderConf{$option}\n";
|
||||
print "Warning: \'$option\' is missing from section \'DEFAULT\'\n" .
|
||||
" in /etc/cinder/cinder.conf.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my @requiredNovaOpts = (
|
||||
"compute_driver",
|
||||
"config_drive_format",
|
||||
"force_config_drive",
|
||||
"host",
|
||||
'instance_name_template',
|
||||
'zvm_diskpool',
|
||||
'zvm_host',
|
||||
'zvm_user_profile',
|
||||
'zvm_xcat_master',
|
||||
'zvm_xcat_server',
|
||||
'zvm_xcat_username',
|
||||
'zvm_xcat_password',
|
||||
);
|
||||
foreach $option ( @requiredNovaOpts ) {
|
||||
if ( !exists $novaConf{'DEFAULT'}{$option} ) {
|
||||
#print "option:$option.\nvalue:$novaConf{$option}\n";
|
||||
print "Warning: \'$option\' is missing from section \'DEFAULT\'\n" .
|
||||
" in /etc/nova/nova.conf.\n";
|
||||
}
|
||||
}
|
||||
|
||||
my @requiredNeutronConfOpts = (
|
||||
'base_mac',
|
||||
'core_plugin',
|
||||
);
|
||||
foreach $option ( @requiredNeutronConfOpts ) {
|
||||
if ( !exists $neutronConf{'DEFAULT'}{$option} ) {
|
||||
print "Warning: \'$option\' is missing from section \'DEFAULT\'\n" .
|
||||
" in /etc/neutron/neutron.conf.\n";
|
||||
}
|
||||
}
|
||||
|
||||
my @requiredOvsNeutronPluginIniOpts = (
|
||||
'network_vlan_ranges',
|
||||
'tenant_network_type',
|
||||
);
|
||||
foreach $option ( @requiredOvsNeutronPluginIniOpts ) {
|
||||
if ( !exists $ovsNeutronPluginIni{'ovs'}{$option} ) {
|
||||
print "Warning: \'$option\' is missing from section \'ovs\'\n" .
|
||||
" in /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini.\n";
|
||||
}
|
||||
}
|
||||
|
||||
my @requiredNeutronZvmPluginIniOpts = (
|
||||
"zvm_xcat_server",
|
||||
);
|
||||
foreach $option ( @requiredNeutronZvmPluginIniOpts ) {
|
||||
if ( !exists $neutronZvmPluginIni{'agent'}{$option} ) {
|
||||
print "Warning: \'$option\' is missing from section \'agent\'\n" .
|
||||
" in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
}
|
||||
}
|
||||
|
||||
#******************************************
|
||||
# Verify optional operands were specified.
|
||||
#******************************************
|
||||
if ( keys %cinderConf ) {
|
||||
if ( !exists $cinderConf{'DEFAULT'}{'san_ip'} and
|
||||
!exists $cinderConf{'DEFAULT'}{'san_private_key'} and
|
||||
!exists $cinderConf{'DEFAULT'}{'storwize_svc_connection_protocol'} and
|
||||
!exists $cinderConf{'DEFAULT'}{'storwize_svc_volpool_name'} and
|
||||
!exists $cinderConf{'DEFAULT'}{'storwize_svc_vol_iogrp'} and
|
||||
!exists $cinderConf{'DEFAULT'}{'volume_driver'} ) {
|
||||
print "Info: z/VM specific Cinder keys are not defined in section \'DEFAULT\'\n" .
|
||||
" in /etc/cinder/cinder.conf. Cinder support for creation of persistent\n" .
|
||||
" disks for z/VM is not enabled. Further testing of these options will\n" .
|
||||
" not occur in this script.\n"
|
||||
} else {
|
||||
my %optionalCinderConfOpts = (
|
||||
"san_ip" => "This property is necessary when using persistent disks obtained\n" .
|
||||
" from the Cinder service.",
|
||||
"san_private_key" => "This property is necessary when using persistent disks obtained\n" .
|
||||
" from the Cinder service.",
|
||||
"storwize_svc_connection_protocol" => "This property is necessary when using persistent disks obtained\n" .
|
||||
" from the Cinder service.",
|
||||
"storwize_svc_volpool_name" => "This property is necessary when using persistent disks obtained\n" .
|
||||
" from the Cinder service.",
|
||||
'storwize_svc_vol_iogrp' => "This property is necessary when using persistent disks obtained\n" .
|
||||
" from the Cinder service.",
|
||||
'volume_driver' => "This property is necessary when using persistent disks obtained\n" .
|
||||
" from the Cinder service.",
|
||||
);
|
||||
my %defaultCinderConfOpts = ();
|
||||
foreach my $key ( keys %optionalCinderConfOpts ) {
|
||||
if ( !exists $cinderConf{'DEFAULT'}{$key} ) {
|
||||
print "Info: \'$key\' is missing from section \'DEFAULT\'\n" .
|
||||
" in /etc/cinder/cinder.conf.\n";
|
||||
if ( $optionalCinderConfOpts{$key} ne '' ) {
|
||||
print " " . $optionalCinderConfOpts{$key} . "\n";
|
||||
}
|
||||
if ( exists $defaultCinderConfOpts{$key} ) {
|
||||
$cinderConf{'DEFAULT'}{$key} = $defaultCinderConfOpts{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %optionalNovaConfOpts = (
|
||||
"image_cache_manager_interval" => "Default of 2400 (seconds) will be used.",
|
||||
"ram_allocation_ratio" => "",
|
||||
"rpc_response_timeout" => "zVM Live migration may timeout with the default " .
|
||||
"value (60 seconds).\n The recommended value for z/VM is 180 to allow " .
|
||||
"zVM live migration\n to succeed.",
|
||||
"xcat_free_space_threshold" => "Default of 50 (G) will be used.",
|
||||
"xcat_image_clean_period" => "Default of 30 (days) will be used.",
|
||||
"zvm_config_drive_inject_password" => "This value will default to 'FALSE'.",
|
||||
'zvm_diskpool_type' => "This value will default to \'ECKD\'.",
|
||||
"zvm_fcp_list" => "Persistent disks cannot be attached to server instances.",
|
||||
"zvm_zhcp_fcp_list" => "",
|
||||
"zvm_image_tmp_path" => "Defaults to '/var/lib/nova/images'.",
|
||||
"zvm_reachable_timeout" => "Default of 300 (seconds) will be used.",
|
||||
"zvm_scsi_pool" => "Default of \'xcatzfcp\' will be used.",
|
||||
"zvm_vmrelocate_force" => "",
|
||||
"zvm_xcat_connection_timeout" => "Default of 3600 seconds will be used.",
|
||||
);
|
||||
my %defaultNovaConfOpts = (
|
||||
"xcat_free_space_threshold" => 50,
|
||||
"xcat_image_clean_period" => 30,
|
||||
'zvm_diskpool_type' => 'ECKD',
|
||||
"zvm_scsi_pool" => "xcatzfcp",
|
||||
);
|
||||
foreach my $key ( keys %optionalNovaConfOpts ) {
|
||||
if ( !exists $novaConf{'DEFAULT'}{$key} ) {
|
||||
print "Info: \'$key\' is missing from section \'DEFAULT\'\n" .
|
||||
" in /etc/nova/nova.conf.\n";
|
||||
if ( $optionalNovaConfOpts{$key} ne '' ) {
|
||||
print " " . $optionalNovaConfOpts{$key} . "\n";
|
||||
}
|
||||
if ( exists $defaultNovaConfOpts{$key} ) {
|
||||
$novaConf{'DEFAULT'}{$key} = $defaultNovaConfOpts{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %optionalNeutronConfOpts = ();
|
||||
my %defaultNeutronConfOpts = ();
|
||||
foreach my $key ( keys %optionalNeutronConfOpts ) {
|
||||
if ( !exists $neutronConf{'DEFAULT'}{$key} ) {
|
||||
print "Info: \'$key\' is missing from section \'DEFAULT\'\n" .
|
||||
" in /etc/neutron/neutron.conf.\n";
|
||||
if ( $optionalNeutronConfOpts{$key} ne '' ) {
|
||||
print " " . $optionalNeutronConfOpts{$key} . "\n";
|
||||
}
|
||||
if ( exists $defaultNeutronConfOpts{$key} ) {
|
||||
$neutronConf{'DEFAULT'}{$key} = $defaultNeutronConfOpts{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %optionalOvsNeutronPluginIniOpts = ();
|
||||
my %defaultOvsNeutronPluginIniOpts = ();
|
||||
foreach my $key ( keys %optionalOvsNeutronPluginIniOpts ) {
|
||||
if ( !exists $ovsNeutronPluginIni{'agent'}{$key} ) {
|
||||
print "Info: \'$key\' is missing from section \'agent\'\n" .
|
||||
" in /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini.\n";
|
||||
if ( $optionalOvsNeutronPluginIniOpts{$key} ne '' ) {
|
||||
print " " . $optionalOvsNeutronPluginIniOpts{$key} . "\n";
|
||||
}
|
||||
if ( exists $defaultOvsNeutronPluginIniOpts{'agent'}{$key} ) {
|
||||
$ovsNeutronPluginIni{'agent'}{$key} = $defaultOvsNeutronPluginIniOpts{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %optionalNeutronZvmPluginIniOpts = (
|
||||
"xcat_mgt_ip" => "This property is necessary when deploying virtual server " .
|
||||
"instances that\n do NOT have public IP addresses.",
|
||||
"xcat_mgt_mask" => "This property is necessary when deploying virtual server " .
|
||||
"instances that\n do NOT have public IP addresses.",
|
||||
"polling_interval" => "A default value of \'2\' will be used.",
|
||||
"xcat_zhcp_nodename" => "A default value of \'zhcp\' will be used.",
|
||||
"zvm_xcat_password" => "A default value of \'admin\' is used.",
|
||||
"zvm_xcat_timeout" => "A default value of 300 seconds is used.",
|
||||
"zvm_xcat_username" => "A default value of \'admin\' is used.",
|
||||
);
|
||||
my %defaultNeutronZvmPluginIniOpts = (
|
||||
"polling_interval" => 2,
|
||||
"xcat_zhcp_nodename" => "zhcp",
|
||||
"zvm_xcat_password" => "admin",
|
||||
"zvm_xcat_timeout" => 300,
|
||||
"zvm_xcat_username" => "admin",
|
||||
);
|
||||
foreach my $key ( keys %optionalNeutronZvmPluginIniOpts ) {
|
||||
if ( !exists $neutronZvmPluginIni{'agent'}{$key} ) {
|
||||
print "Info: \'$key\' is missing from section \'agent\'\n" .
|
||||
" in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
if ( $optionalNeutronZvmPluginIniOpts{$key} ne '' ) {
|
||||
print " " . $optionalNeutronZvmPluginIniOpts{$key} . "\n";
|
||||
}
|
||||
if ( exists $defaultNeutronZvmPluginIniOpts{'agent'}{$key} ) {
|
||||
$neutronZvmPluginIni{'agent'}{$key} = $defaultNeutronZvmPluginIniOpts{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Verify xCAT users are the same.
|
||||
if ( !exists $novaConf{'DEFAULT'}{'zvm_xcat_username'} ) {
|
||||
print "Info: Bypassing validation of 'zvm_xcat_username'.\n" .
|
||||
" It is not specified in /etc/nova/nova.conf.\n";
|
||||
} elsif ( !exists $neutronZvmPluginIni{'agent'}{'zvm_xcat_username'} ) {
|
||||
print "Info: Bypassing validation of 'zvm_xcat_username'.\n" .
|
||||
" It is not specified in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
} else {
|
||||
if ( $novaConf{'DEFAULT'}{'zvm_xcat_username'} ne $neutronZvmPluginIni{'agent'}{'zvm_xcat_username'} ) {
|
||||
print "Warning: xCAT user names mismatch; review 'zvm_xcat_username':\n" .
|
||||
" \'$novaConf{'DEFAULT'}{'zvm_xcat_username'}\' in /etc/nova/nova.conf.\n" .
|
||||
" \'$neutronZvmPluginIni{'agent'}{'zvm_xcat_username'}\' in\n" .
|
||||
" /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Verify xCAT user passwords are the same.
|
||||
if ( !exists $novaConf{'DEFAULT'}{'zvm_xcat_password'} ) {
|
||||
print "Info: Bypassing validation of 'zvm_xcat_password'.\n" .
|
||||
" It is not specified in /etc/nova/nova.conf.\n";
|
||||
} elsif ( !exists $neutronZvmPluginIni{'agent'}{'zvm_xcat_password'} ) {
|
||||
print "Info: Bypassing validation of 'zvm_xcat_password'. It is not specified\n" .
|
||||
" in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
} else {
|
||||
if ( $novaConf{'DEFAULT'}{'zvm_xcat_password'} ne $neutronZvmPluginIni{'agent'}{'zvm_xcat_password'} ) {
|
||||
print "Warning: xCAT user passwords are not the same:\n" .
|
||||
" Please review 'zvm_xcat_password' in /etc/nova/nova.conf and\n" .
|
||||
" /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Verify the xcat server IP addresses are the same.
|
||||
if ( !exists $novaConf{'DEFAULT'}{'zvm_xcat_server'} ) {
|
||||
print "Info: Bypassing validation of 'zvm_xcat_server'.\n" .
|
||||
" It is not specified in /etc/nova/nova.conf.\n";
|
||||
} elsif ( !exists $neutronZvmPluginIni{'agent'}{'zvm_xcat_server'} ) {
|
||||
print "Info: Bypassing validation of 'zvm_xcat_server'.\n" .
|
||||
" It is not specified in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
} else {
|
||||
if ( $novaConf{'DEFAULT'}{'zvm_xcat_server'} ne $neutronZvmPluginIni{'agent'}{'zvm_xcat_server'} ) {
|
||||
print "Warning: xCAT server addresses mismatch; review 'zvm_xcat_server':\n" .
|
||||
" \'$novaConf{'DEFAULT'}{'zvm_xcat_server'}\' in /etc/nova/nova.conf.\n" .
|
||||
" \'$neutronZvmPluginIni{'agent'}{'zvm_xcat_server'}\' in /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Verify the instance name template is valid
|
||||
if ( exists $novaConf{'DEFAULT'}{'instance_name_template'} ) {
|
||||
# Use sprintf which is close enough to the python % support for formatting to construct a sample.
|
||||
my $base_name = sprintf( $novaConf{'DEFAULT'}{'instance_name_template'}, 1 );
|
||||
if ( length( $base_name ) > 8 ) {
|
||||
print "Warning: In /etc/nova/nova.conf, section \`DEFAULT\`, instance_name_template would\n" .
|
||||
" construct a value greater than 8 in length: \'$novaConf{'DEFAULT'}{'instance_name_template'}\'.\n";
|
||||
}
|
||||
if ( $novaConf{'DEFAULT'}{'instance_name_template'} =~ /(^RSZ)/ or $novaConf{'DEFAULT'}{'instance_name_template'} =~ /(^rsz)/ ) {
|
||||
print "Warning: In /etc/nova/nova.conf, instance_name_template begins\n" .
|
||||
" with 'RSZ' or 'rsz': \'$novaConf{'DEFAULT'}{'instance_name_template'}\'\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Verify the compute_driver is for z/VM
|
||||
if ( exists $novaConf{'DEFAULT'}{'compute_driver'} ) {
|
||||
if ( $novaConf{'DEFAULT'}{'compute_driver'} ne "nova.virt.zvm.ZVMDriver" and
|
||||
$novaConf{'DEFAULT'}{'compute_driver'} ne "zvm.ZVMDriver") {
|
||||
print "Warning: In /etc/nova/nova.conf, compute_driver does not contain the\n" .
|
||||
" expected value of \'zvm.ZVMDriver\' and instead contains:\n" .
|
||||
" \'$novaConf{'DEFAULT'}{'compute_driver'}\'\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Check whether the rpc timeout is too small for z/VM
|
||||
if ( exists $novaConf{'DEFAULT'}{'rpc_response_timeout'} ) {
|
||||
if ( $novaConf{'DEFAULT'}{'rpc_response_timeout'} < 180 ) {
|
||||
print "Warning: In /etc/nova/nova.conf, section \'DEFAULT\', rpc_response_timeout\n" .
|
||||
" specifies a value, \'$novaConf{'DEFAULT'}{'rpc_response_timeout'}\', which is " .
|
||||
"less than the recommended value\n of \'180\'.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Verify all SCSI disk operands are specified, if one exists.
|
||||
if ( exists $novaConf{'DEFAULT'}{'zvm_fcp_list'} or exists $novaConf{'DEFAULT'}{'zvm_zhcp_fcp_list'} ) {
|
||||
if ( !exists $novaConf{'DEFAULT'}{'zvm_fcp_list'} ) {
|
||||
print "Warning: In /etc/nova/nova.conf, \'zvm_fcp_list\' does not exist but\n" .
|
||||
" but other SCSI disk related operands exist. Both should be \'\n" .
|
||||
" specified: \'zvm_fcp_list\' and \'zvm_zhcp_fcp_list\'\n";
|
||||
}
|
||||
if ( !exists $novaConf{'DEFAULT'}{'zvm_zhcp_fcp_list'} ) {
|
||||
print "Warning: In /etc/nova/nova.conf, \'zvm_zhcp_fcp_list\' does not exist but\n" .
|
||||
" but other SCSI disk related operands exist. Both should be \'\n" .
|
||||
" specified: \'zvm_fcp_list\' and \'zvm_zhcp_fcp_list\'\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Verify any rdev_list in Neutron z/VM Plugin ini file contains a single value and/or not a comma
|
||||
foreach my $section (sort keys %neutronZvmPluginIni) {
|
||||
next if ( $section eq 'agent');
|
||||
foreach my $property ( keys %{ $neutronZvmPluginIni{$section} } ) {
|
||||
next if ( $property ne "rdev_list" );
|
||||
my $list = $neutronZvmPluginIni{$section}{$property};
|
||||
$list =~ s/^\s+|\s+$//g; # trim blanks from both ends of the list
|
||||
if ( $list eq '' ) {
|
||||
print "Warning: In /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini, section \'$section\',\n" .
|
||||
" \'rdev_list\' is specified but has no value.\n";
|
||||
} else {
|
||||
my @vals = split ( /\s/, $list );
|
||||
if ( $#vals > 0 ) {
|
||||
# $#vals is array size - 1.
|
||||
print "Warning: In /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini, section \'$section\',\n" .
|
||||
" \'rdev_list\' contains too many values.\n";
|
||||
}
|
||||
foreach my $op ( @vals ) {
|
||||
if ( $op =~ m/[^0-9a-fA-F]+/ ) {
|
||||
print "Warning: In /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini, section \'$section\',\n" .
|
||||
" \'rdev_list\' contains non-hexadecimal characters: \'$op\'.\n";
|
||||
} elsif ( length($op) > 4 ) {
|
||||
print "Warning: In /etc/neutron/plugins/zvm/neutron_zvm_plugin.ini, section \'$section\',\n" .
|
||||
" \'rdev_list\' contains a value that is not 1-4 characters in\n" .
|
||||
" length: \'$op\'.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check whether the storwize_svc_connection_protocol is not 'FC' for z/VM
|
||||
if ( exists $cinderConf{'DEFAULT'}{'storwize_svc_connection_protocol'} ) {
|
||||
if ( $cinderConf{'DEFAULT'}{'storwize_svc_connection_protocol'} ne 'FC' ) {
|
||||
print "Warning: In /etc/cinder/cinder.conf, section \'DEFAULT\',\n" .
|
||||
" storwize_svc_connection_protocol specifies a value, " .
|
||||
"\'$cinderConf{'DEFAULT'}{'storwize_svc_connection_protocol'}\',\n" .
|
||||
" which is not the required value of \'FC\'.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Check whether the storwize_svc_connection_protocol is not 'FC' for z/VM
|
||||
if ( exists $cinderConf{'DEFAULT'}{'volume_driver'} ) {
|
||||
if ( $cinderConf{'DEFAULT'}{'volume_driver'} ne 'cinder.volume.drivers.zvm.storwize_svc.StorwizeSVCZVMDriver' ) {
|
||||
print "Warning: In /etc/cinder/cinder.conf, section \'DEFAULT\', volume_driver specifies\n" .
|
||||
" a value, \'$cinderConf{'DEFAULT'}{'volume_driver'}\',\n which is " .
|
||||
"not the required value of\n \'cinder.volume.drivers.zvm.storwize_svc.StorwizeSVCZVMDriver\'.\n";
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#*****************************************************************************
|
||||
# Main routine
|
||||
#*****************************************************************************
|
||||
my $rc = 0;
|
||||
my $clearPwOpt;
|
||||
my $obfuscateOpt;
|
||||
|
||||
# Parse the arguments
|
||||
$Getopt::Long::ignorecase = 0;
|
||||
Getopt::Long::Configure( "bundling" );
|
||||
if (!GetOptions( 's|scan=s' => \$scan,
|
||||
'd|driver=s' => \$driver,
|
||||
'h|help' => \$displayHelp,
|
||||
#'c' => \$clearPwOpt,
|
||||
#'o' => \$obfuscateOpt,
|
||||
'v' => \$versionOpt,
|
||||
'V' => \$verbose )) {
|
||||
print $usage_string;
|
||||
goto FINISH;
|
||||
}
|
||||
|
||||
if ( $versionOpt ) {
|
||||
print "Version: $version\n";
|
||||
print "$supportString\n";
|
||||
}
|
||||
|
||||
if ( $displayHelp ) {
|
||||
showHelp();
|
||||
}
|
||||
|
||||
if ( $displayHelp or $versionOpt ) {
|
||||
goto FINISH;
|
||||
}
|
||||
|
||||
$localIpAddress = inet_ntoa((gethostbyname(hostname))[4]);
|
||||
|
||||
if ( defined( $scan ) ) {
|
||||
if ( $verbose ) {
|
||||
print "Operand --scan: $scan\n";
|
||||
}
|
||||
if ( 'all nova neutron' !~ $scan ) {
|
||||
print "--scan operand($scan) is not all, nova or neutron\n";
|
||||
$rc = 400;
|
||||
goto FINISH;
|
||||
}
|
||||
} else {
|
||||
$scan = 'all';
|
||||
}
|
||||
|
||||
if ( defined( $driver ) ) {
|
||||
if ( $verbose ) {
|
||||
print "Operand --driver: $driver\n";
|
||||
}
|
||||
$driver = "$driver.sh";
|
||||
} else {
|
||||
$driver = "$driverPrefix$localIpAddress.sh";
|
||||
}
|
||||
|
||||
if ( $scan =~ 'all' or $scan =~ 'nova' ) {
|
||||
!( $rc = scanNova() ) or goto FINISH;
|
||||
}
|
||||
|
||||
if ( $scan =~ 'all' or $scan =~ 'cinder' ) {
|
||||
scanCinder();
|
||||
}
|
||||
|
||||
if ( $scan =~ 'all' or $scan =~ 'neutron' ) {
|
||||
!( $rc = scanNeutron() ) or goto FINISH;
|
||||
}
|
||||
|
||||
#if ( $obfuscateOpt ) {
|
||||
# print "obfuscateOpt: $obfuscateOpt\n";
|
||||
# $obfuscatePw = 1;
|
||||
#} elsif ( $clearPwOpt ) {
|
||||
# $obfuscatePw = 0;
|
||||
#}
|
||||
|
||||
!( $rc = validateConfigs() ) or goto FINISH;
|
||||
|
||||
!( $rc = buildDriverProgram() ) or goto FINISH;
|
||||
|
||||
FINISH:
|
||||
exit $rc;
|
||||
|
1096
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_ICEHOUSE.pl
Normal file
1096
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_ICEHOUSE.pl
Normal file
File diff suppressed because it is too large
Load Diff
1531
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_JUNO.pl
Normal file
1531
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_JUNO.pl
Normal file
File diff suppressed because it is too large
Load Diff
1532
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_KILO.pl
Normal file
1532
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_KILO.pl
Normal file
File diff suppressed because it is too large
Load Diff
1738
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_LIBERTY.pl
Normal file
1738
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_LIBERTY.pl
Normal file
File diff suppressed because it is too large
Load Diff
2383
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_NEWTON.pl
Normal file
2383
xCAT-server/share/xcat/tools/zvm/prep_zxcatIVP_NEWTON.pl
Normal file
File diff suppressed because it is too large
Load Diff
@ -18,23 +18,38 @@ AutoReqProv: no
|
||||
|
||||
%define fsm %(if [ "$fsm" = "1" ];then echo 1; else echo 0; fi)
|
||||
|
||||
# Define local variable from environment variable
|
||||
%define pcm %(if [ "$pcm" = "1" ];then echo 1; else echo 0; fi)
|
||||
%define notpcm %(if [ "$pcm" = "1" ];then echo 0; else echo 1; fi)
|
||||
%define s390x %(if [ "$s390x" = "1" ];then echo 1; else echo 0; fi)
|
||||
%define nots390x %(if [ "$s390x" = "1" ];then echo 0; else echo 1; fi)
|
||||
|
||||
# Define a different location for various httpd configs in s390x mode
|
||||
%define httpconfigdir %(if [ "$s390x" = "1" ];then echo "xcathttpdsave"; else echo "xcat"; fi)
|
||||
|
||||
# AIX will build with an arch of "ppc"
|
||||
# also need to fix Requires for AIX
|
||||
%ifos linux
|
||||
BuildArch: noarch
|
||||
Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser perl-Digest-SHA1 perl(LWP::Protocol::https)
|
||||
# Note: ifarch/ifnarch does not work for noarch package, use environment variable instead
|
||||
|
||||
%if %s390x
|
||||
Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser
|
||||
%else
|
||||
Requires: perl-IO-Socket-SSL perl-XML-Simple perl-XML-Parser perl-Digest-SHA1 perl(LWP::Protocol::https) perl-Net-HTTPS-NB perl-HTTP-Async
|
||||
%endif
|
||||
Obsoletes: atftp-xcat
|
||||
%endif
|
||||
|
||||
# The aix rpm cmd forces us to do this outside of ifos type stmts
|
||||
%if %notpcm
|
||||
%ifos linux
|
||||
#
|
||||
# PCM does not use or ship grub2-xcat
|
||||
Requires: grub2-xcat perl-Net-HTTPS-NB perl-HTTP-Async
|
||||
#%endif
|
||||
%if %nots390x
|
||||
Requires: grub2-xcat
|
||||
%endif
|
||||
%endif
|
||||
%endif
|
||||
|
||||
@ -313,7 +328,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/init.d
|
||||
cp etc/init.d/xcatd $RPM_BUILD_ROOT/etc/init.d
|
||||
%endif
|
||||
#TODO: the next has to me moved to postscript, to detect /etc/xcat vs /etc/opt/xcat
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/xcat
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/%httpconfigdir
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-server
|
||||
cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-server
|
||||
@ -324,7 +339,7 @@ chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-server/*
|
||||
mkdir -p $RPM_BUILD_ROOT/%{prefix}/ws
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig
|
||||
|
||||
cp xCAT-wsapi/* $RPM_BUILD_ROOT/%{prefix}/ws
|
||||
|
||||
@ -336,18 +351,18 @@ rm -f $RPM_BUILD_ROOT/%{prefix}/ws/xcatws.cgi
|
||||
|
||||
%if %fsm
|
||||
%else
|
||||
echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22
|
||||
echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache24
|
||||
echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache22
|
||||
echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache24
|
||||
%if %notpcm
|
||||
echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22
|
||||
echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache24
|
||||
echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache22
|
||||
echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache24
|
||||
%endif
|
||||
|
||||
cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache22 >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22
|
||||
cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache24 >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache24
|
||||
cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache22 >> $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache22
|
||||
cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache24 >> $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache24
|
||||
#install lower version(<2.4) apache/httpd conf files by default
|
||||
cp $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22 $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat-ws.conf
|
||||
cp $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22 $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat-ws.conf
|
||||
cp $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache22 $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat-ws.conf
|
||||
cp $RPM_BUILD_ROOT/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache22 $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat-ws.conf
|
||||
%endif
|
||||
|
||||
|
||||
@ -362,12 +377,12 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%defattr(-,root,root)
|
||||
#%doc LICENSE.html
|
||||
%{prefix}
|
||||
/etc/xcat
|
||||
/etc/%httpconfigdir
|
||||
%if %fsm
|
||||
%else
|
||||
/etc/init.d/xcatd
|
||||
#/etc/xcat/conf.orig/xcat-ws.conf.apache24
|
||||
#/etc/xcat/conf.orig/xcat-ws.conf.apache22
|
||||
#/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache24
|
||||
#/etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache22
|
||||
/etc/apache2/conf.d/xcat-ws.conf
|
||||
/etc/httpd/conf.d/xcat-ws.conf
|
||||
%endif
|
||||
@ -434,19 +449,19 @@ fi
|
||||
if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/httpd/conf.d/xcat-ws.conf
|
||||
cp /etc/xcat/conf.orig/xcat-ws.conf.apache24 /etc/httpd/conf.d/xcat-ws.conf
|
||||
cp /etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache24 /etc/httpd/conf.d/xcat-ws.conf
|
||||
fi
|
||||
|
||||
if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/apache2/conf.d/xcat-ws.conf
|
||||
cp /etc/xcat/conf.orig/xcat-ws.conf.apache24 /etc/apache2/conf.d/xcat-ws.conf
|
||||
cp /etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache24 /etc/apache2/conf.d/xcat-ws.conf
|
||||
fi
|
||||
|
||||
if [ -n "$(apache2ctl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ]
|
||||
then
|
||||
rm -rf /etc/apache2/conf.d/xcat-ws.conf
|
||||
cp /etc/xcat/conf.orig/xcat-ws.conf.apache24 /etc/apache2/conf.d/xcat-ws.conf
|
||||
cp /etc/%httpconfigdir/conf.orig/xcat-ws.conf.apache24 /etc/apache2/conf.d/xcat-ws.conf
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
13
xCAT-server/xCAT-wsapi/xcat-ws.conf.apache2
Normal file
13
xCAT-server/xCAT-wsapi/xcat-ws.conf.apache2
Normal file
@ -0,0 +1,13 @@
|
||||
LoadModule rewrite_module /usr/lib64/apache2-prefork/mod_rewrite.so
|
||||
|
||||
# Redirect all http request to https
|
||||
RewriteEngine On
|
||||
RewriteCond %{SERVER_PORT} 80
|
||||
RewriteCond %{HTTPS} !=on
|
||||
RewriteRule ^/?xcatws/(.*) https://%{SERVER_NAME}/xcatws/$1 [R,L]
|
||||
|
||||
<Files xcatws.cgi>
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Files>
|
||||
|
@ -1,8 +1,10 @@
|
||||
LoadModule rewrite_module /usr/lib64/apache2-prefork/mod_rewrite.so
|
||||
|
||||
# Redirect all http request to https
|
||||
RewriteEngine On
|
||||
RewriteCond %{SERVER_PORT} 80
|
||||
RewriteCond %{REQUEST_URI} xcatws
|
||||
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L]
|
||||
RewriteCond %{HTTPS} !=on
|
||||
RewriteRule ^/?xcatws/(.*) https://%{SERVER_NAME}/xcatws/$1 [R,L]
|
||||
|
||||
<Files xcatws.cgi>
|
||||
Order allow,deny
|
||||
|
@ -1,8 +1,8 @@
|
||||
LoadModule rewrite_module /usr/lib64/apache2-prefork/mod_rewrite.so
|
||||
RewriteEngine On
|
||||
RewriteCond %{SERVER_PORT} 80
|
||||
RewriteCond %{REQUEST_URI} xcatws
|
||||
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L]
|
||||
RewriteCond %{HTTPS} !=on
|
||||
RewriteRule ^/?xcatws/(.*) https://%{SERVER_NAME}/xcatws/$1 [R,L]
|
||||
|
||||
<Files xcatws.cgi>
|
||||
Require all granted
|
||||
|
4
xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd
Normal file
4
xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd
Normal file
@ -0,0 +1,4 @@
|
||||
RewriteEngine On
|
||||
RewriteCond %{SERVER_PORT} 80
|
||||
RewriteCond %{HTTPS} !=on
|
||||
RewriteRule ^/?xcatws/(.*) https://%{SERVER_NAME}/xcatws/$1 [R,L]
|
Loading…
x
Reference in New Issue
Block a user