From aba08f3683a2da9f332dce522e535aa34cb55ace Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 14 May 2008 12:16:47 +0000 Subject: [PATCH] Add Service Node LDAP setup plugin git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1385 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/LDAPsn.pm | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 xCAT-server-2.0/lib/xcat/plugins/LDAPsn.pm diff --git a/xCAT-server-2.0/lib/xcat/plugins/LDAPsn.pm b/xCAT-server-2.0/lib/xcat/plugins/LDAPsn.pm new file mode 100644 index 000000000..fad48843b --- /dev/null +++ b/xCAT-server-2.0/lib/xcat/plugins/LDAPsn.pm @@ -0,0 +1,111 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#------------------------------------------------------- +package xCAT_plugin::LDAPsn; +use xCAT::Table; + +use xCAT::Utils; + +use xCAT::MsgUtils; +use Getopt::Long; + +#------------------------------------------------------- + +=head1 + xCAT plugin package to setup of LDAP on the ServiceNode + + +#------------------------------------------------------- + +=head3 handled_commands + +Check to see if on a Service Node +Check database to see if this node is a LDAP server +Call setup_LDAP + +=cut + +#------------------------------------------------------- + +sub handled_commands +{ + my $rc = 0; + if (xCAT::Utils->isServiceNode()) + { + my @nodeinfo = xCAT::Utils->determinehostname; + my $nodename = pop @nodeinfo; # get hostname + my @nodeipaddr = @nodeinfo; # get ip addresses + my $service = "ldapserver"; + + $rc = xCAT::Utils->isServiceReq($nodename, $service, \@nodeipaddr); + if ($rc == 1) + { + + # service needed on this Service Node + $rc = &setup_LDAP(); + if ($rc == 0) + { + xCAT::Utils->update_xCATSN($service); + } + } + else + { + if ($rc == 2) + { # service setup, just start the daemon + $cmd = "service ldap restart"; + system $cmd; + if ($? > 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd"); + return 1; + } + } + } + } + return $rc; +} + +#------------------------------------------------------- + +=head3 process_request + + Process the command + +=cut + +#------------------------------------------------------- +sub process_request +{ + return; +} + +#----------------------------------------------------------------------------- + +=head3 setup_LDAP + + Sets up LDAP + +=cut + +#----------------------------------------------------------------------------- +sub setup_LDAP +{ + + $cmd = "chkconfig ldap on"; + system $cmd; + if ($? > 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd"); + return 1; + } + $cmd = "service ldap restart"; + system $cmd; + if ($? > 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd"); + return 1; + } + + return 0; +} +1;