From e44ce9826029e6c78ebdce8b3256ee1c55c0f150 Mon Sep 17 00:00:00 2001 From: nott Date: Sun, 12 Oct 2008 17:43:32 +0000 Subject: [PATCH] Fix problem with groups being defined when using a stanza file. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2323 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 46 +++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 3eac6d2ec..5cd2a1ee6 100644 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -1104,7 +1104,50 @@ sub defmk } } # end - if group type - } + # + # Need special handling for node objects that have the + # groups attr set - may need to create group defs + # + if (($type eq "node") && $::FINALATTRS{$obj}{groups}) + { + + # get the list of groups in the "groups" attr + my @grouplist; + @grouplist = split(/,/, $::FINALATTRS{$obj}{groups}); + + # get the list of all defined group objects + + my @definedgroups = xCAT::DBobjUtils->getObjectsOfType("group"); + + my %GroupHash; + foreach my $g (@grouplist) + { + if (!grep(/^$g$/, @definedgroups)) + { + + # define it + $GroupHash{$g}{objtype} = "group"; + $GroupHash{$g}{grouptype} = "static"; + $GroupHash{$g}{members} = "static"; + } + } + if (defined(%GroupHash)) + { + + if (xCAT::DBobjUtils->setobjdefs(\%GroupHash) != 0) + { + my $rsp; + $rsp->{data}->[0] = + "Could not write data to the xCAT database.\n"; + + # xCAT::MsgUtils->message("E", $rsp, $::callback); + $error = 1; + } + } + + } # end - if type = node + + } # end of each obj # # write each object into the tables in the xCAT database @@ -1729,6 +1772,7 @@ sub defch } } # end - if type = node + } # end - for each object to update #