Merge branch '2.8' of ssh://git.code.sf.net/p/xcat/xcat-core into 2.8

This commit is contained in:
Jarrod Johnson 2014-02-13 09:53:54 -05:00
commit b1fddf8eca
10 changed files with 912 additions and 15 deletions

231
perl-xCAT/xCAT/Zone.pm Normal file
View File

@ -0,0 +1,231 @@
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT::Zone;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
# if AIX - make sure we include perl 5.8.2 in INC path.
# Needed to find perl dependencies shipped in deps tarball.
if ($^O =~ /^aix/i) {
unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2));
}
use lib "$::XCATROOT/lib/perl";
# do not put a use or require for xCAT::Table here. Add to each new routine
# needing it to avoid reprocessing of user tables ( ExtTab.pm) for each command call
use POSIX qw(ceil);
use File::Path;
use Socket;
use strict;
use Symbol;
use warnings "all";
#--------------------------------------------------------------------------------
=head1 xCAT::Zone
=head2 Package Description
This program module file, is a set of Zone utilities used by xCAT *zone commands.
=cut
#--------------------------------------------------------------------------------
=head3 genSSHRootKeys
Arguments:
callback for error messages
directory in which to put the ssh RSA keys
zonename
rsa private key to use for generation ( optional)
Returns:
Error: 1 - key generation failure.
Example:
$rc =xCAT::Zone->genSSHRootKeys($callback,$keydir,$rsakey);
=cut
#--------------------------------------------------------------------------------
sub genSSHRootKeys
{
my ($class, $callback, $keydir,$zonename,$rsakey) = @_;
#
# create /keydir if needed
#
if (!-d $keydir)
{
my $cmd = "/bin/mkdir -m 700 -p $keydir";
my $output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] =
"Could not create $keydir directory";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
}
#
# create /install/postscripts/_ssh/zonename if needed
#
my $installdir = xCAT::TableUtils->getInstallDir(); # get installdir
if (!-d "$installdir/postscripts/_ssh/$zonename")
{
my $cmd = "/bin/mkdir -m 755 -p $installdir/postscripts/_ssh/$zonename";
my $output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] = "Could not create $installdir/postscripts/_ssh/$zonename directory.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
}
#need to gen a new rsa key for root for the zone
my $pubfile = "$keydir/id_rsa.pub";
my $pvtfile = "$keydir/id_rsa";
# if exists, remove the old files
if (-r $pubfile)
{
my $cmd = "/bin/rm $keydir/id_rsa*";
my $output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] = "Could not remove id_rsa files from $keydir directory.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
}
# gen new RSA keys
my $cmd;
my $output;
# if private key was input use it
if (defined ($rsakey)) {
$cmd="/usr/bin/ssh-keygen -y -f $rsakey > $pubfile";
$output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] = "Could not generate $pubfile from $rsakey";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# now copy the private key into the directory
$cmd="cp $rsakey $keydir";
$output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] = "Could not run $cmd";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
} else { # generate all new keys
$cmd = "/usr/bin/ssh-keygen -t rsa -q -b 2048 -N '' -f $pvtfile";
$output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] = "Could not generate $pubfile";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
}
#make sure permissions are correct
$cmd = "chmod 644 $pubfile;chown root $pubfile";
$output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] = "Could set permission and owner on $pubfile";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# copy authorized_keys for install on node
if (-r $pubfile)
{
my $cmd =
"/bin/cp -p $pubfile $installdir/postscripts/_ssh/$zonename ";
my $output = xCAT::Utils->runcmd("$cmd", 0);
if ($::RUNCMD_RC != 0)
{
my $rsp = {};
$rsp->{error}->[0] =
"Could not copy $pubfile to $installdir/postscripts/_ssh/$zonename";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
}
else
{
my $rsp = {};
$rsp->{error}->[0] =
"Could not copy $pubfile to $installdir/postscripts/_ssh/$zonename, because $pubfile does not exist.";
xCAT::MsgUtils->message("E", $rsp, $callback);
}
}
#--------------------------------------------------------------------------------
=head3 getdefaultzone
Arguments:
None
Returns:
Name of the current default zone from the zone table
Example:
my $defaultzone =xCAT::Zone->getdefaultzone();
=cut
#--------------------------------------------------------------------------------
sub getdefaultzone
{
my $defaultzone;
# read all the zone table and find the defaultzone, if it exists
my $tab = xCAT::Table->new("zone");
my @zones = $tab->getAllAttribs('zonename','defaultzone');
foreach my $zone (@zones) {
# Look for the defaultzone=yes/1 entry
if ((defined($zone->{defaultzone})) && ($zone->{defaultzone} =~ "yes")) {
$defaultzone = $zone->{zonename};
}
}
$tab->close();
return $defaultzone;
}
#--------------------------------------------------------------------------------
=head3 iszonedefined
Arguments:
zonename
Returns:
1 if the zone is already in the zone table.
Example:
xCAT::Zone->iszonedefined($zonename);
=cut
#--------------------------------------------------------------------------------
sub iszonedefined
{
my ($class,$zonename) = @_;
# checks the zone table to see if input zonename already in the table
my $tab = xCAT::Table->new("zone");
my $zone = $tab->getAttribs({zonename => $zonename},'sshkeydir');
$tab->close();
if (defined($zone)) {
return 1;
}else{
return 0;
}
}
1;

View File

@ -182,7 +182,8 @@ then
for client in $CFGCLIENTLIST
do
echo "Configuring the chef-client node $client on the chef-server $NODE."
c_fullname="$client.$DOMAIN"
#c_fullname="$client.$DOMAIN"
c_fullname=$client
knife client delete -y $c_fullname > /dev/null 2>&1
knife node delete -y $c_fullname > /dev/null 2>&1

View File

@ -0,0 +1,178 @@
#
# IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html
#
#
# When using this template, you should change the proxy-cidr and object-cidr
# according to your actual network environment!!!!!!!!
#
name "$CLOUD"
description "Grizzly keystone+swift allinone environment file."
override_attributes(
"mysql" => {
"server_root_password" => "cluster",
"server_debian_password" => "cluster",
"server_repl_password" => "cluster",
"allow_remote_root" => true,
"root_network_acl" => "%"
},
"swift" => {
"authmode" => "keystone",
"authkey" => "swift",
"proxy_server_chef_role"=>"os-object-storage",
"network" => {
"proxy-bind-ip" => "#TABLE:clouds:name=$CLOUD:hostip#",
"proxy-cidr" => "11.0.0.0/8",
"account-bind-ip" => "#TABLE:clouds:name=$CLOUD:hostip#",
"container-bind-ip" => "#TABLE:clouds:name=$CLOUD:hostip#",
"object-bind-ip" => "#TABLE:clouds:name=$CLOUD:hostip#",
"object-cidr" => "11.0.0.0/8"
}
},
"openstack" => {
"developer_mode" => true,
"db"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:mgtinterface#",
"compute"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"identity"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"image"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"network"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"volume"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"dashboard"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"metering"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
}
},
"mq"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:mgtinterface#"
},
"identity"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:mgtinterface#",
"db"=>{
"username"=>"keystone",
"password"=> "keystone"
}
},
"endpoints"=>{
"identity-api"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"identity-admin"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"compute-api"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"compute-ec2-api"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"compute-ec2-admin"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"compute-xvpvnc"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"compute-novnc"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"network-api"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"image-api"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"image-registry"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"volume-api"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
},
"metering-api"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#",
}
},
"image" => {
"api"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:mgtinterface#"
},
"registry"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:mgtinterface#"
},
"image_upload" => false,
"upload_images" => ["cirros"],
"upload_image" => {
"cirros" => "https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img"
},
"identity_service_chef_role" => "allinone-compute"
},
"block-storage" => {
"rabbit"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"keystone_service_chef_role" => "allinone-compute"
},
"dashboard" => {
"keystone_service_chef_role" => "allinone-compute",
"use_ssl" => "false"
},
"network" => {
"metadata"=>{
"nova_metadata_ip"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"rabbit"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"api"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:mgtinterface#"
},
"rabbit_server_chef_role" => "allinone-compute",
"l3"=>{
"external_network_bridge_interface"=>"#TABLE:clouds:name=$CLOUD:pubinterface#"
},
"openvswitch"=> {
"tenant_network_type"=>"vlan",
"network_vlan_ranges"=>"physnet1",
"bridge_mappings"=>"physnet1:br-#TABLE:clouds:name=$CLOUD:datainterface#"
}
},
"compute" => {
"identity_service_chef_role" => "allinone-compute",
"rabbit"=>{
"host"=>"#TABLE:clouds:name=$CLOUD:hostip#"
},
"xvpvnc_proxy"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:pubinterface#"
},
"novnc_proxy"=>{
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:pubinterface#"
},
"network" => {
"service_type" => "quantum"
},
"config" => {
"ram_allocation_ratio" => 5.0
},
"libvirt" => {
"bind_interface"=>"#TABLE:clouds:name=$CLOUD:mgtinterface#",
"virt_type" => "#TABLE:clouds:name=$CLOUD:virttype#"
}
}
}
)

View File

@ -11,7 +11,7 @@ B<chdef> [B<-t> I<object-types>] [B<-o> I<object-names>] [B<-n> I<new-name>] [I<
B<chdef> [B<-V>|B<--verbose>] [B<-t> I<object-types>] [B<-o> I<object-names>]
[B<-d>|B<--dynamic>] [B<-p>|B<--plus>] [B<-m>|B<--minus>] [B<-z>|B<--stanza>]
[[B<-w> I<attr>==I<val>] [B<-w> I<attr>=~I<val>] ...] [I<noderange>] [I<attr>=I<val> [I<attr>=I<val...>]]
[B<-u> B<provmethod>=<I<install>|I<netboot>|I<statelite>> B<profile>=<xxx> [I<attr>=I<value>]]
[B<-u> [I<provmethod>=<I<install>|I<netboot>|I<statelite>>] [I<profile>=<xxx>] [I<osvers>=I<value>] [I<osarch>=I<value>]]
=head1 DESCRIPTION
@ -83,9 +83,9 @@ Indicates that the file being piped to the command is in stanza format. See the
=item B<-u>
This option only works for objtype B<osimage>.
Fill in the attributes such as template file, pkglist file and otherpkglist file of osimage object based on the specified parameters. It will search "/install/custom/" directory first, and then "/opt/xcat/share/".
Updating the osimage attribute automatically. If osvers or osarch is not specified, the corresponding value of the management node will be used.
Note: this option only works for objtype B<osimage>.
=back

View File

@ -9,7 +9,7 @@ B<mkdef> [B<-h>|B<--help>] [B<-t> I<object-types>]
B<mkdef> [B<-V>|B<--verbose>] [B<-t> I<object-types>] [B<-o> I<object-names>]
[B<-z>|B<--stanza>] [B<-d>|B<--dynamic>] [B<-f>|B<--force>]
[[B<-w> I<attr>==I<val>] [B<-w> I<attr>=~I<val>] ...] [I<noderange>] [I<attr>=I<val> [I<attr>=I<val...>]]
[B<-u> B<provmethod>=<I<install>|I<netboot>|I<statelite>> B<profile>=<xxx> [I<attr>=I<value>]]
[B<-u> B<provmethod>=<I<install>|I<netboot>|I<statelite>> B<profile>=<xxx> [I<osvers>=I<value>] [I<osarch>=I<value>]]
=head1 DESCRIPTION
@ -73,9 +73,10 @@ Indicates that the file being piped to the command is in stanza format. See the
=item B<-u>
This option only works for objtype B<osimage>.
Fill in the attributes such as template file, pkglist file and otherpkglist file of osimage object based on the specified parameters. It will search "/install/custom/" directory first, and then "/opt/xcat/share/".
The I<provmethod> and I<profile> must be specified. If I<osvers> or I<osarch> is not specified, the corresponding value of the management node will be used.
Fill in the osimage attribute automatically when define osimage. The I<provmethod> and I<profile> must be specified. If osvers or osarch is not specified, the corresponding value of the management node will be used.
Note: this option only works for objtype B<osimage>.
=back

View File

@ -662,7 +662,7 @@ sub update_tables_with_templates
#get the pkglist file
my $pkglistfile=get_pkglist_file_name($cuspath, $profile, $osver, $arch);
if (!$pkglistfile) { $pkglistfile=get_pkglist_file_name($defpath, $profile, $osver, $arch);}
if (!$pkglistfile) { $pkglistfile=get_pkglist_file_name($defpath, $profile, $osver, $arch,$genos);}
#now update the db
if (!$osimagetab) {

View File

@ -4027,7 +4027,7 @@ sub defmk_usage
$rsp->{data}->[4] =
" [-f | --force] [noderange] [attr=val [attr=val...]]";
$rsp->{data}->[5] =
" [-u provmethod=<install|netboot|statelite> profile=<xxx> [attr=value]]\n";
" [-u provmethod=<install|netboot|statelite> profile=<xxx> [osvers=value] [osarch=value]]\n";
$rsp->{data}->[6] =
"\nThe following data object types are supported by xCAT.\n";
my $n = 7;
@ -4077,7 +4077,7 @@ sub defch_usage
$rsp->{data}->[5] =
" [-w attr==val [-w attr=~val] ... ] [noderange] [attr=val [attr=val...]]\n";
$rsp->{data}->[6] =
" [-u [provmethod=<install|netboot|statelite>]|[profile=<xxx>]|[attr=value]]";
" [-u [provmethod=<install|netboot|statelite>]|[profile=<xxx>]|[osvers=value]|[osarch=value]]";
$rsp->{data}->[7] =
"\nThe following data object types are supported by xCAT.\n";
my $n = 8;

View File

@ -190,16 +190,17 @@ sub copycd {
'n=s' => \$distname,
);
unless($distname && $file && $mntpath && $arch) {
$callback->({error=>"distname, file or mntpath not specified, $distname, $file, $mntpath"});
#$callback->({error=>"distname, file or mntpath not specified, $distname, $file, $mntpath"});
return ;
}
if ($distname && $distname !~ /^vios/i) {
$callback->({error=>"distname incorrect"});
#$callback->({error=>"distname incorrect"});
return ;
} elsif ($arch !~ /^ppc64/i) {
$callback->({error=>"arch incorrect"});
#$callback->({error=>"arch incorrect"});
return ;
} elsif (!$file) {
$callback->({error=>"Only suport to use the iso file vios"});
#$callback->({error=>"Only suport to use the iso file vios"});
return;
}
#print __LINE__."=====>vios=====.\n";

View File

@ -0,0 +1,484 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#-------------------------------------------------------
=head1
xCAT plugin package to handle mkzone,chzone,rmzone commands
Supported command:
mkzone,chzone,rmzone - manage xcat cluster zones
=cut
#-------------------------------------------------------
package xCAT_plugin::zone;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
}
use strict;
require xCAT::Utils;
require xCAT::Zone;
require xCAT::MsgUtils;
require xCAT::Table;
use xCAT::NodeRange;
use xCAT::NodeRange qw/noderange abbreviate_noderange/;
use Getopt::Long;
#-------------------------------------------------------
=head3 handled_commands
Return list of commands handled by this plugin
=cut
#-------------------------------------------------------
sub handled_commands
{
return {mkzone => "zone",
chzone => "zone",
rmzone => "zone",
};
}
#-------------------------------------------------------
=head3 process_request
Process the command, this only runs on the management node
=cut
#-------------------------------------------------------
sub process_request
{
my $request = shift;
my $callback = shift;
my $sub_req = shift;
$::CALLBACK = $callback;
my $command = $request->{command}->[0];
my $rc=0;
# the directory which will contain the zone keys
my $keydir="/etc/xcat/sshkeydir/";
# check if Management Node, if not error
unless (xCAT::Utils->isMN())
{
my $rsp = {};
$rsp->{error}->[0] = "The $command may only be run on the Management Node.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return 1;
}
# test to see if any parms
if (scalar($request->{arg} == 0)) {
my $rsp = {};
$rsp->{error}->[0] =
"No parameters input to the $command command, see man page for syntax.";
xCAT::MsgUtils->message("E", $rsp, $callback);
exit 1;
}
my $args = $request->{arg};
@ARGV = @{$args}; # get arguments
my %options = ();
$Getopt::Long::ignorecase = 0;
Getopt::Long::Configure("bundling");
if (
!GetOptions(
'a|noderange=s' => \$options{'noderange'},
'defaultzone|defaultzone' => \$options{'defaultzone'},
'g|assigngrp' => \$options{'assigngroup'},
'f|force' => \$options{'force'},
'h|help' => \$options{'help'},
'k|sshkeypath=s' => \$options{'sshkeypath'},
'K|genkeys' => \$options{'gensshkeys'},
'v|version' => \$options{'version'},
'V|Verbose' => \$options{'verbose'},
)
)
{
&usage($callback,$command);
exit 1;
}
if ($options{'help'})
{
&usage($callback,$command);
exit 0;
}
if ($options{'version'})
{
my $version = xCAT::Utils->Version();
my $rsp = {};
$rsp->{data}->[0] = $version;
xCAT::MsgUtils->message("I", $rsp, $callback);
exit 0;
}
# test to see if the zonename was input
if (scalar(@ARGV) == 0) {
my $rsp = {};
$rsp->{error}->[0] =
"zonename not specified, see man page for syntax.";
xCAT::MsgUtils->message("E", $rsp, $callback);
exit 1;
} else {
$request->{zonename} = $ARGV[0];
}
# save input noderange
if ($options{'noderange'}) {
$request->{noderange}->[0] = $options{'noderange'};
}
if ($options{'verbose'})
{
$::VERBOSE = "yes";
}
if ($command eq "mkzone")
{
$rc=mkzone($request, $callback,\%options,$keydir);
}
if ($command eq "chzone")
{
$rc=chzone($request, $callback,\%options,$keydir);
}
if ($command eq "rmzone")
{
$rc=rmzone($request, $callback,\%options,$keydir);
}
my $rsp = {};
if ($rc ==0) {
$rsp->{info}->[0] = "The $command ran successfully.";
xCAT::MsgUtils->message("I", $rsp, $callback);
} else {
$rsp->{info}->[0] = "The $command had errors.";
xCAT::MsgUtils->message("E", $rsp, $callback);
}
return $rc;
}
#-------------------------------------------------------
=head3
Parses and runs mkzone
=cut
#-------------------------------------------------------
sub mkzone
{
my ($request, $callback,$options,$keydir) = @_;
my $rc=0;
# already checked but lets do it again, need a zonename, it is the only required parm
if (!($request->{zonename})) {
my $rsp = {};
$rsp->{error}->[0] =
"zonename not specified, see man page for syntax.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# test for -g, if no noderange this is an error
if (( ! defined($$options{'noderange'})) && ($$options{'assigngroup'})) {
my $rsp = {};
$rsp->{error}->[0] =
" The -g flag requires a noderange ( -a).";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# check to see if the input zone already exists
if (xCAT::Zone->iszonedefined($request->{zonename})) {
my $rsp = {};
$rsp->{error}->[0] =
" zonename: $request->{zonename} already defined, use chzone or rmzone to change or remove it.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
# Create path to generated ssh keys
$keydir .= $request->{zonename};
# update the zone table
$rc=updatezonetable($request, $callback,$options,$keydir);
if ($rc == 0) { # zone table setup is ok
$rc=updatenodelisttable($request, $callback,$options,$keydir);
if ($rc == 0) { # zone table setup is ok
# generate root ssh keys
$rc=gensshkeys($request, $callback,$options,$keydir);
if ($rc != 0) {
return 1;
}
}
}
return $rc;
}
#-------------------------------------------------------
=head3
Parses and runs chzone
=cut
#-------------------------------------------------------
sub chzone
{
my ($request, $callback,$options,$keydir) = @_;
# my $rsp = {};
#xCAT::MsgUtils->message("I", $rsp, $callback);
return 0;
}
#-------------------------------------------------------
=head3
Parses and runs rmzone
=cut
#-------------------------------------------------------
sub rmzone
{
my ($request, $callback,$options,$keydir) = @_;
# my $rsp = {};
#xCAT::MsgUtils->message("I", $rsp, $callback);
return 0;
}
#-------------------------------------------------------------------------------
=head3
usage
puts out zone command usage message
Arguments:
None
Returns:
Globals:
Error:
None
=cut
#-------------------------------------------------------------------------------
sub usage
{
my ($callback, $command) = @_;
my $usagemsg1="";
my $usagemsg2="";
if ($command eq "mkzone") {
$usagemsg1 = " mkzone -h \n mkzone -v \n";
$usagemsg2 = " mkzone <zonename> [-V] [--defaultzone] [-k <full path to the ssh RSA private key] \n [-a <noderange>] [-g] [-f]";
} else {
if ($command eq "chzone") {
$usagemsg1 = " chzone -h \n chzone -v \n";
$usagemsg2 = " chzone <zonename> [-V] [--defaultzone] [-k <full path to the ssh RSA private key] \n [-K] [-a <noderange>] [-r <noderange>] [-g] ";
} else {
if ($command eq "rmzone") {
$usagemsg1 = " rmzone -h \n rmzone -v \n";
$usagemsg2 = " rmzone <zonename> [-g]";
}
}
}
my $usagemsg .= $usagemsg1 .= $usagemsg2 .= "\n";
if ($callback)
{
my $rsp = {};
$rsp->{data}->[0] = $usagemsg;
xCAT::MsgUtils->message("I", $rsp, $callback);
}
else
{
xCAT::MsgUtils->message("I", $usagemsg);
}
return;
}
#-------------------------------------------------------
=head3
generate the ssh keys and store them in /etc/xcat/sshkeys/<zonename>
=cut
#-------------------------------------------------------
sub gensshkeys
{
my ($request, $callback,$options,$keydir) = @_;
my $rc=0;
# generate root ssh keys
# Did they input a path to existing RSA keys
my $rsakey;
my $zonename=$request->{zonename};
if ($$options{'sshkeypath'}) {
# check to see if RSA keys exists
$rsakey= $$options{'sshkeypath'} .= "/id_rsa";
if (!(-e $rsakey)){ # if it does not exist error out
my $rsp = {};
$rsp->{error}->[0] =
"Input $rsakey does not exist. Cannot generate the ssh root keys for the zone.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
}
$rc =xCAT::Zone->genSSHRootKeys($callback,$keydir, $zonename,$rsakey);
if ($rc !=0) {
my $rsp = {};
$rsp->{error}->[0] =
" Failure generating the ssh root keys for the zone.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
return $rc;
}
#-------------------------------------------------------
=head3
updatezonetable
Add the new zone to the zone table, check if already there and
error - use either chzone or -f to override default
=cut
#-------------------------------------------------------
sub updatezonetable
{
my ($request, $callback,$options,$keydir) = @_;
my $rc=0;
my $zoneentry;
my $tab = xCAT::Table->new("zone");
if ($tab)
{
my %tb_cols;
$tb_cols{sshkeydir} = $keydir;
my $zonename=$request->{zonename};
if ( $$options{'defaultzone'}) { # set the default
# check to see if a default already defined
my $curdefaultzone = xCAT::Zone->getdefaultzone;
if (!(defined ($curdefaultzone))) { # no default defined
$tb_cols{defaultzone} ="yes";
} else { # already a default
if ($$options{'force'}) { # force the default
$tb_cols{defaultzone} ="yes";
$tab->setAttribs({zonename => $zonename}, \%tb_cols);
# now change the old default zone to not be the default
my %tb1_cols;
$tb1_cols{defaultzone} ="no";
$tab->setAttribs({zonename => $curdefaultzone}, \%tb1_cols);
$tab->commit();
$tab->close();
} else { # no force this is an error
my $rsp = {};
$rsp->{error}->[0] =
" Failure setting default zone. The defaultzone $curdefaultzone already exists. Use the -f flag if you want to override the current default zone.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
}
} else { # not a default zone
$tb_cols{defaultzone} ="no";
$tab->setAttribs({zonename => $zonename}, \%tb_cols);
$tab->commit();
$tab->close();
}
} else {
my $rsp = {};
$rsp->{error}->[0] =
" Failure opening the zone table.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
return $rc;
}
#-------------------------------------------------------
=head3
updatenodelisttable
Add the new zonename attribute to any nodes in the noderange ( if a noderange specified)
Add zonename group to nodes in the noderange if -g flag.
=cut
#-------------------------------------------------------
sub updatenodelisttable
{
my ($request, $callback,$options,$keydir) = @_;
my $rc=0;
# test for a noderange, if not supplied nothing to do
if ( ! defined($$options{'noderange'})) {
return 0;
}
my $zonename=$request->{zonename};
# there is a node range. update the nodelist table
# if -g add zonename group also
my $group=$$options{'noderange'};
my @nodes = xCAT::NodeRange::noderange($request->{noderange}->[0]);
my $tab = xCAT::Table->new("nodelist");
if ($tab)
{
# if -g then add the zonename to the group attribute on each node
if ($$options{'assigngroup'}){
foreach my $node (@nodes) {
xCAT::TableUtils->updatenodegroups($node,$tab,$zonename);
}
}
# set the nodelist zonename attribute to the zonename for all nodes in the range
$tab-> setNodesAttribs(\@nodes, { zonename => $zonename });
$tab->commit();
$tab->close();
} else {
my $rsp = {};
$rsp->{error}->[0] =
" Failure opening the nodelist table.";
xCAT::MsgUtils->message("E", $rsp, $callback);
return 1;
}
return $rc;
}
1;

View File

@ -85,7 +85,7 @@ install
#
# text mode install (default is graphical)
#
#text
text
#
# firewall
@ -128,6 +128,7 @@ rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password#
# OR
auth --useshadow --enablemd5
#
# SE Linux
#