From 82caea177c06d5288f480c9647fe8e3ef42c6cd8 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 19 Feb 2014 08:49:43 -0500 Subject: [PATCH] designchanges --- perl-xCAT/xCAT/Zone.pm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/perl-xCAT/xCAT/Zone.pm b/perl-xCAT/xCAT/Zone.pm index bf62b7635..6c5c06eb6 100644 --- a/perl-xCAT/xCAT/Zone.pm +++ b/perl-xCAT/xCAT/Zone.pm @@ -199,7 +199,7 @@ sub getdefaultzone foreach my $zone (@zones) { # Look for the defaultzone=yes/1 entry if ((defined($zone->{defaultzone})) && - (($zone->{defaultzone} =~ "yes") || ($zone->{defaultzone} = "1"))) { + (($zone->{defaultzone} =~ "yes") || ($zone->{defaultzone} eq "1"))) { $defaultzone = $zone->{zonename}; } $tab->close(); @@ -255,22 +255,23 @@ sub iszonedefined If the nodes nodelist.zonename attribute is undefined: If there is a defaultzone in the zone table, the node is assigned to that zone If there is no defaultzone in the zone table, the node is assigned to the ~.ssh keydir + $::GETZONEINFO_RC + 0 = good return + 1 = error occured =cut #-------------------------------------------------------------------------------- sub getzoneinfo { my ($class, $callback,$nodes) = @_; - - # make the list into an array -# $nodelist=~ s/\s*//g; # remove blanks -# my @nodes = split ',', $nodelist; + $::GETZONEINFO_RC=0; my $zonehash; my $defaultzone; # read all the zone table my $zonetab = xCAT::Table->new("zone"); + my @zones; if ($zonetab){ - my @zones = $zonetab->getAllAttribs('zonename','sshkeydir','defaultzone'); + @zones = $zonetab->getAllAttribs('zonename','sshkeydir','sshbetweennodes','defaultzone'); $zonetab->close(); if (@zones) { foreach my $zone (@zones) { @@ -279,7 +280,7 @@ sub getzoneinfo $zonehash->{$zonename}->{defaultzone}= $zone->{defaultzone}; # find the defaultzone if ((defined($zone->{defaultzone})) && - (($zone->{defaultzone} =~ "yes") || ($zone->{defaultzone} = "1"))) { + (($zone->{defaultzone} =~ "yes") || ($zone->{defaultzone} eq "1"))) { $defaultzone = $zone->{zonename}; } } @@ -289,6 +290,7 @@ sub getzoneinfo $rsp->{error}->[0] = "Error reading the zone table. "; xCAT::MsgUtils->message("E", $rsp, $callback); + $::GETZONEINFO_RC =1; return; } @@ -314,6 +316,15 @@ sub getzoneinfo $zonename=$nodehash->{$node}->[0]->{zonename}; } if (defined($zonename)) { # zonename explicitly defined in nodelist.zonename + # check to see if defined in the zone table + if (!(grep(/^$zonename$/, @zones))) { + my $rsp = {}; + $rsp->{error}->[0] = + "$node has a zonenane: $zonename that is not define in the zone table. Remove the zonename from the node, or create the zone using mkzone."; + xCAT::MsgUtils->message("E", $rsp, $callback); + $::GETZONEINFO_RC =1; + return; + } push @{$zonehash->{$zonename}->{nodes}},$node; } else { # no explict zonename if (defined ($defaultzone)) { # there is a default zone in the zone table, use it