From 137f2978c0967459a06b37cae977d8673f844848 Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 2 Jun 2009 05:29:55 +0000 Subject: [PATCH] add dynamic node group check in subroutine nodech git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3480 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 5c6c46ee4..2705996b4 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -540,6 +540,8 @@ sub nodech my $VERSION; my $HELP; my $deletemode; + my $grptab; + my @grplist; my $nodech_usage = sub { @@ -753,6 +755,25 @@ sub nodech my $val = shift @valoppairs; my $op = shift @valoppairs; my $key = $_; + # When changing the groups of the node, check whether the new group + # is a dynamic group. + if (($key eq 'groups') && ($op eq '=')) { + if (scalar(@grplist) == 0) { # Do not call $grptab->getAllEntries for each node, performance issue. + $grptab = xCAT::Table->new('nodegroup'); + @grplist = @{$grptab->getAllEntries()}; + } + my @grps = split(/,/, $val); + foreach my $grp (@grps) { + foreach my $grpdef_ref (@grplist) { + my %grpdef = %$grpdef_ref; + if (($grpdef{'groupname'} eq $grp) && ($grpdef{'grouptype'} eq 'dynamic')) { + my %rsp; + $rsp{data}->[0] = "nodegroup $grp is a dynamic node group, should not add a node into a dynamic node group statically.\n"; + $callback->(\%rsp); + } + } + } + } if ($op eq '=') { $uhsh{$key} = $val; }