From 4d3e209c3e7dec67fdf299529b519cc991c58688 Mon Sep 17 00:00:00 2001 From: jjohnson2 Date: Mon, 30 Mar 2015 15:25:33 -0400 Subject: [PATCH] Push xCAT nodegroup membership to confluent With noderanges, it would be very handy for xCAT group membership to be reflected in confluent. Have makeconfluentcfg push that data into confluent. --- xCAT-server/lib/xcat/plugins/confluent.pm | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/confluent.pm b/xCAT-server/lib/xcat/plugins/confluent.pm index 26291a6d9..a46c4f8ce 100644 --- a/xCAT-server/lib/xcat/plugins/confluent.pm +++ b/xCAT-server/lib/xcat/plugins/confluent.pm @@ -347,6 +347,39 @@ sub donodeent { } my $ipmiauthdata = xCAT::PasswordUtils::getIPMIAuth( noderange=>\@toconfignodes, ipmihash=>$ipmientries); + my $nltab = xCAT::Table->new('nodelist', -create=>0); + my $groupdata = {}; + if ($nltab) { + $groupdata = $nltab->getNodesAttribs(\@toconfignodes, + [qw/groups/]); + } + my @cfgroups; + foreach (keys %$groupdata) { + push @cfgroups, split /,/,$groupdata->{$_}->[0]->{groups}; + } + $confluent->read('/nodegroups/'); + my $currgroup = $confluent->next_result(); + my %currgroups; + while ($currgroup) { + if (exists $currgroup->{item}) { + my $groupname = $currgroup->{item}->{href}; + $groupname =~ s/\/$//; + $currgroups{$groupname} = 1; + } + $currgroup = $confluent->next_result(); + } + foreach (@cfgroups) { + if (not exists $currgroups{$_}) { + $confluent->create('/nodegroups/', parameters=>{name=>$_}); + my $rsp = $confluent->next_result(); + while ($rsp) { + if (exists $rsp->{error}) { + xCAT::SvrUtils::sendmsg([1,"Confluent error: " . $rsp->{error}],$cb); + } + $rsp = $confluent->next_result(); + } + } + } # Go thru all nodes specified to add them to the file foreach my $node (sort keys %$cfgenthash) { @@ -379,6 +412,7 @@ foreach my $node (sort keys %$cfgenthash) { } elsif ($::XCATSITEVALS{'consoleondemand'} and $::XCATSITEVALS{'consoleondemand'} !~ m/^n/) { $parameters{'console.logging'} = 'none'; } + $parameters{'groups'} = [split /,/,$groupdata->{$node}->[0]->{'groups'}]; if (exists $currnodes{$node}) { $confluent->update('/nodes/'.$node.'/attributes/current', parameters=>\%parameters); my $rsp = $confluent->next_result();