Fixed formatting, improved display of message using glib.printXxxMessage functions
authorAlberto Di Meglio <alberto.di.meglio@cern.ch>
Wed, 2 Mar 2005 20:36:11 +0000 (20:36 +0000)
committerAlberto Di Meglio <alberto.di.meglio@cern.ch>
Wed, 2 Mar 2005 20:36:11 +0000 (20:36 +0000)
Fixed some problems when starting/stopping services
GLITE_USER parameter not exposed anymore in config file, use same user parameters
as WMS to allow installation on same node
Increased module version number to 1.2.0

org.glite.deployment.lb/CHANGELOG [new file with mode: 0644]
org.glite.deployment.lb/config/scripts/glite-lb-config.py
org.glite.deployment.lb/config/templates/glite-lb.cfg.xml
org.glite.deployment.lb/project/version.properties

diff --git a/org.glite.deployment.lb/CHANGELOG b/org.glite.deployment.lb/CHANGELOG
new file mode 100644 (file)
index 0000000..2801c28
--- /dev/null
@@ -0,0 +1,7 @@
+DATE: 02-03-2005 11:05\r
+[dimeglio] Started CHANGELOG\r
+[dimeglio] Fixed formatting, improved display of message using glib.printXxxMessage functions\r
+[dimeglio] Fixed some problems when starting/stopping services\r
+[dimeglio] GLITE_USER parameter not exposed anymore in config file, use same user parameters\r
+                  as WMS to allow installation on same node\r
+[dimeglio] Increased module version number to 1.2.0
\ No newline at end of file
index 92abf88..08a0b48 100644 (file)
@@ -6,7 +6,7 @@
 # For license conditions see the license file or http://eu-egee.org/license.html
 #
 ################################################################################
-# glite-lb-config v. 1.1.0
+# glite-lb-config v. 1.2.0
 #
 # Post-installation script for configuring the gLite Logging and Bookkeping Server
 # Robert Harakaly < robert.harakaly@cern.ch >
@@ -42,7 +42,7 @@ class glite_lb:
     def __init__(self):
         self.mysql = MySQL.Mysql()
         self.verbose = 0
-        self.version = "1.1.0"
+        self.version = "1.2.0"
         self.name = "glite-lb"
         self.friendly_name = "gLite Logging and Bookkeeping"
         
@@ -104,160 +104,189 @@ python %s-config [OPTION...]""" % (self.name, os.environ['GLITE_LOCATION'], \
     #-------------------------------------------------------------------------------
 
     def start(self):
-        self.stop()
 
         self.mysql.start()
         time.sleep(5)
+
         if not os.path.exists('/tmp/mysql.sock'):
             os.symlink('/var/lib/mysql/mysql.sock', '/tmp/mysql.sock')
             
+        pid = glib.getPID('bkserverd')
+        if pid != 0:
+            print 'The gLite LB Server service is already running. Restarting...'
+            os.system('%s/etc/init.d/glite-lb-bkserverd stop' % os.environ['GLITE_LOCATION'])
+        else:
+            print 'Starting the gLite LB Server service...'
+
         os.system('%s/etc/init.d/glite-lb-bkserverd start' % os.environ['GLITE_LOCATION'])
 
-       #-------------------------------------------------------------------
+        pid = glib.getPID('bkserverd')
+
+        if (pid != 0):
+            print "The gLite LB Server service has been started               ",
+            glib.printOkMessage()
+        else:
+            print glib.printErrorMessage("Could not start the gLite LB Server service")
+            print glib.printErrorMessage("Please verify and re-run the script                        "),
+            glib.printFailedMessage()
+            return 1
+        
+        #-------------------------------------------------------------------
         # Start Servicetool
         #-------------------------------------------------------------------
         
         pid = glib.getPID('rgma-servicetool')
         if (pid != 0):
-               print 'The gLite R-GMA Servicetool service is already running. Restarting...'
-               rgmaServicetool.stop()
-       else:
-               print "Starting the gLite R-GMA Servicetool service"
-       rgmaServicetool.start()
+               print 'The gLite R-GMA Servicetool service is already running. Restarting...'
+               rgmaServicetool.stop()
+        else:
+            print "Starting the gLite R-GMA Servicetool service"
+
+        rgmaServicetool.start()
 
         
         # Check that the daemon is running
        
-       pid = glib.getPID('rgma-servicetool')
+        pid = glib.getPID('rgma-servicetool')
 
         if (pid != 0):
-               print "The gLite R-GMA Servicetool service has been started               ", glib.printOkMessage()
+            print "The gLite R-GMA Servicetool service has been started               ",
+            glib.printOkMessage()
         else:
-               print "ERROR ==> Could not start the gLite R-GMA Servicetool service"
-               print "ERROR ==> Please verify and re-run the script"
-               return 1
+            print glib.printErrorMessage("Could not start the gLite R-GMA Servicetool service")
+            print glib.printErrorMessage("Please verify and re-run the script                        "),
+            glib.printFailedMessage()
+            return 1
         
         return 0
         
     def stop(self):
-        os.system('%s/etc/init.d/glite-lb-bkserverd stop' % os.environ['GLITE_LOCATION'])
+
+        pid = glib.getPID('bkserverd')
+        if (pid != 0):
+            os.system('%s/etc/init.d/glite-lb-bkserverd stop' % os.environ['GLITE_LOCATION'])
+
+        pid = glib.getPID('bkserverd')
+        if (pid != 0):
+            print 'Could not stop the LB Server service            ',
+            glib.printFailedMessage()
+        else:
+            print 'The LB Server service has been stopped            ',
+            glib.printOkMessage()
+        
         self.mysql.stop()
 
-       #-------------------------------------------------------------------
+        #-------------------------------------------------------------------
         # Stop the servicetool
         #-------------------------------------------------------------------
 
         pid = glib.getPID('rgma-servicetool')
-       if (pid != 0):
-               rgmaServicetool.stop()
-               pid = glib.getPID('rgma-servicetool')
-               if (pid != 0):
-                       print 'Failed to stop rgma-servicetool'
-               else:
-                       print "[OK]"
-       else:
-               print "[OK] rgmaServicetool was already stopped"
+        if (pid != 0):
+            rgmaServicetool.stop()
+
+        pid = glib.getPID('rgma-servicetool')
+        if (pid != 0):
+            print 'Could not stop the R-GMA Servicetool service            ', glib.printFailedMessage()
+        else:
+            print 'The R-GMA Servicetool service has been stopped            ', glib.printOkMessage()
         
         return 0
         
     def configure(self):
         
         # Create the GLITE_USER if it doesn't exists
-        print "\n1 - Creating/Verifying the GLITE_USER account %s" % params['GLITE_USER']
+        print "\nCreating/Verifying the GLITE_USER account %s" % params['GLITE_USER']
         glib.add_user(params['GLITE_USER'],params['GLITE_USER'])
         (uid,gid) = glib.get_user_info(params['GLITE_USER'])
         glib.check_dir(os.environ['GLITE_LOCATION_VAR'],0755, uid, gid)
         glib.check_dir("/home/%s/.certs" % params['GLITE_USER'],0755, uid, gid)
         lb_cert_path = pwd.getpwnam(params['GLITE_USER'])[5] + "/" + params['user.certificate.path']
-        print "\n[OK]"
+        glib.printOkMessage()
 
         # Create all directories needed
-        print "\n2 - Verify CA certificates directory"
+        print "\nVerify CA certificates directory            ",
         glib.check_dir(os.environ['GLITE_CERT_DIR'])
-        print "\n[OK]"
+        glib.printOkMessage()
          
         # Copy certificates
-        print "\n3 - Copy host certificates to GLITE_USER home directory as service certificates"
+        print "\nCopy host certificates to GLITE_USER home directory as service certificates",
         glib.check_dir( lb_cert_path, 0755, uid, gid)
         os.system("cp %s %s %s/" % (params['host.certificate.file'], params['host.key.file'], lb_cert_path))
         os.chown("%s/hostcert.pem" % lb_cert_path, uid,gid)
+        os.chmod("%s/hostcert.pem" % lb_cert_path, 0644)
         os.chown("%s/hostkey.pem" % lb_cert_path, uid,gid)
-        print "\n[OK]"
-                
+        os.chmod("%s/hostkey.pem" % lb_cert_path, 0400)
+        glib.printOkMessage()
+
         # Create the MySQL database
-        print "\n4 - Create/Verify the %s database" % params['lb.database.name']
+        print "\nCreate/Verify the %s database" % params['lb.database.name']
         self.mysql.stop()
         time.sleep(5)
         self.mysql.start()
         
         # Check if database exists
-        
-        os.system('/usr/bin/mysqlaccess %s %s' % (params['lb.database.username'],params['lb.database.name']))
-        
-        file = open('/tmp/mysql_ct', 'w')
-        file.write("USE %s;\n" % params['lb.database.name'])
-        file.close()
-        channels = os.popen3('/usr/bin/mysql < /tmp/mysql_ct')
-        
-        for line in channels[2].xreadlines():
-            print line
-            if line.find("Unknown database") != -1:
-                # Create database
-                print ('\n==> Creating MySQL %s database\n' % params['lb.database.name'])
-        
-                os.system('/bin/rm /tmp/mysql_ct')
-                
-                file = open('/tmp/mysql_ct', 'w')
-                text = ['CREATE DATABASE %s;\n' % params['lb.database.name'], 
-                           'GRANT ALL PRIVILEGES ON %s.* TO %s@localhost IDENTIFIED BY "";\n' % (params['lb.database.name'],params['lb.database.username']),
-                           'USE %s;\n' % params['lb.database.name'],
-                           '\. %s/etc/glite-lb-dbsetup.sql\n' % os.environ['GLITE_LOCATION']]
-        
-                file.writelines(text)
-                file.close()
-                os.system('/usr/bin/mysql < /tmp/mysql_ct')
-                os.system('/bin/rm /tmp/mysql_ct')
-                break
+        if self.mysql.existsDB(params['lb.database.name']) == 0:
+            # Create database
+            print ('\n==> Creating MySQL %s database\n' % params['lb.database.name'])
+    
+            os.system('/bin/rm /tmp/mysql_ct')
+            
+            file = open('/tmp/mysql_ct', 'w')
+            text = ['CREATE DATABASE %s;\n' % params['lb.database.name'], 
+                       'GRANT ALL PRIVILEGES ON %s.* TO %s@localhost IDENTIFIED BY "";\n' % (params['lb.database.name'],params['lb.database.username']),
+                       'USE %s;\n' % params['lb.database.name'],
+                       '\. %s/etc/glite-lb-dbsetup.sql\n' % os.environ['GLITE_LOCATION']]
+    
+            file.writelines(text)
+            file.close()
+            os.system('/usr/bin/mysql < /tmp/mysql_ct')
+            os.system('/bin/rm /tmp/mysql_ct')
         else:
             print "\n==> MySQL database %s already exist\n" % params['lb.database.name']
             
         if not os.path.exists('/tmp/mysql.sock'):
             os.symlink('/var/lib/mysql/mysql.sock', '/tmp/mysql.sock')
 
-       #Creating the indexes
-       print 'Creating the index configuration file /opt/glite/etc/glite-lb-index.conf'
-       path = "%s/etc/glite-lb-index.conf" % os.environ['GLITE_LOCATION']
-       pathBak = "%s/etc/glite-lb-index.conf.bak" % os.environ['GLITE_LOCATION']
-
-       if os.path.exists(pathBak):
-               os.remove(pathBak)
-       if os.path.exists(path):
-               os.rename(path,pathBak)
-       file = open(path, 'w')
-       file.write("[\n")
-       file.write("            JobIndices = {\n")
-       for index in params['lb.index.list']:
-               file.write("                            [ type = \"system\"; name = \"%s\" ],\n" % index)
-       file.write("            }\n")
-       file.write("]\n")
-       file.close()
-       print "Running glite-lb-bkindex"        
-       os.system('/opt/glite/bin/glite-lb-bkindex -r /opt/glite/etc/glite-lb-index.conf')
-
+       #Creating the indexes
+       print 'Creating the index configuration file %s/etc/glite-lb-index.conf            ' % os.environ['GLITE_LOCATION'],
+       path = "%s/etc/glite-lb-index.conf" % os.environ['GLITE_LOCATION']
+       pathBak = "%s/etc/glite-lb-index.conf.bak" % os.environ['GLITE_LOCATION']
+    
+       if os.path.exists(pathBak):
+               os.remove(pathBak)
+       if os.path.exists(path):
+               os.rename(path,pathBak)
+       file = open(path, 'w')
+       file.write("[\n")
+       file.write("            JobIndices = {\n")
+       for index in params['lb.index.list']:
+               file.write("                            [ type = \"system\"; name = \"%s\" ],\n" % index)
+       file.write("            }\n")
+       file.write("]\n")
+       file.close()
+        glib.printOkMessage()
+       
+        print "Running glite-lb-bkindex                    ",  
+        os.system('%s/bin/glite-lb-bkindex -r %s/etc/glite-lb-index.conf' % (os.environ['GLITE_LOCATION'],os.environ['GLITE_LOCATION']))
+        glib.printOkMessage()
+    
         self.mysql.stop()
-
-       #-------------------------------------------------------------------
+    
+        #-------------------------------------------------------------------
         # RGMA servicetool: configure servicetool
         #-------------------------------------------------------------------
-        print"Configuring the servicetool"
-       if rgmaServicetool.configure(glib):
-       # error in configuring services
-          print "FAILED configuring the service tool"
-          return 1
-       print "OK Configuring the Service Tool"
         
-        print "\n[OK]"
-         
+        print "Configuring the R-GMA Servicetool..."
+    
+        if rgmaServicetool.configure(glib):
+            # error in configuring services
+            print "Configuring the R-GMA Servicetool...                ",
+            glib.printFailedMessage()
+            return 1
+    
+        print "Configuring the R-GMA Servicetool...                ",
+        glib.printOkMessage()
+            
         return 0
         
 #-------------------------------------------------------------------------------
@@ -278,16 +307,19 @@ def set_env():
     if not os.path.exists(os.environ['GLITE_LOCATION_TMP']):
         os.mkdir(os.environ['GLITE_LOCATION_TMP'],0755)
 
-    (uid,gid) = glib.add_user(params['GLITE_USER'])
-    lb_cert_path = pwd.getpwnam(params['GLITE_USER'])[5] + "/" + params['user.certificate.path']
+    if not params.has_key('glite.user.group'):
+        params['glite.user.group'] = ''
+    (uid,gid) = glib.add_user(params['glite.user.name'],params['glite.user.group'])
+    glib.export('GLITE_USER',params['glite.user.name'])
+    lb_cert_path = pwd.getpwnam(os.environ['GLITE_USER'])[5] + "/" + params['user.certificate.path']
     glib.export('GLITE_HOST_CERT',"%s/hostcert.pem" % lb_cert_path)
     glib.export('GLITE_HOST_KEY',"%s/hostkey.pem" % lb_cert_path)
     glib.export('GLOBUS_LOCATION',params['GLOBUS_LOCATION'])
     glib.export('GLITE_CERT_DIR',params['ca.certificates.dir'])
-    glib.export('GLITE_USER',params['GLITE_USER'])
     
     # bin and lib paths
-    glib.addEnvPath("PATH","/usr/bin/:%s/bin:%s/externals/bin:%s/bin" % (os.environ['GLOBUS_LOCATION'],os.environ['GLITE_LOCATION'],os.environ['GLITE_LOCATION']))
+    glib.addEnvPath("PATH","/usr/bin/:%s/bin:%s/bin:%s/externals/bin:%s/bin" \
+        % (os.environ['JAVA_HOME'],os.environ['GLOBUS_LOCATION'],os.environ['GLITE_LOCATION'],os.environ['GLITE_LOCATION']))
     glib.addEnvPath("LD_LIBRARY_PATH","/usr/lib:%s/lib:%s/externals/lib:%s/lib" % (os.environ['GLOBUS_LOCATION'], os.environ['GLITE_LOCATION'],os.environ['GLITE_LOCATION']))
 
     # Set environment
@@ -385,15 +417,20 @@ if __name__ == '__main__':
         
     # Configure the service
     if service.configure() == 0:
-        print "%s configuration successfully completed\n" % service.friendly_name
-       glib.registerService()
+        print "%s configuration successfully completed                " % service.friendly_name,
+        glib.printOkMessage()
+        glib.registerService()
     else:
-        print "An error occurred while configuring the %s" % service.friendly_name
+        print "An error occurred while configuring the %s            " % service.friendly_name,
+        glib.printFailedMessage()
         sys.exit(1)
         
     # Start the service
-    # service.stop()
-    if service.start() != 0:
-        print "An error occurred while starting the %s" % service.friendly_name
+    if service.start() == 0:
+        print "The %s was successfully started           " % service.friendly_name,
+        glib.printOkMessage()
+    else:
+        print "An error occurred while starting the %s            " % service.friendly_name,
+        glib.printFailedMessage()
         sys.exit(1)
 
index e968fad..8577038 100644 (file)
@@ -6,10 +6,17 @@
                <!-- User-defined parameters - Please change them -->
                <!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
 
-               <GLITE_USER
-                       description="The account used to run the LB daemons"
-                       value="gproduct"/>
-                       
+               <!--  gLite services user accounts  -->
+               <glite.user.name 
+                       description="Name of the user account used to run the gLite services
+                       on this LB node"
+                       value="changeme"/>
+
+               <glite.user.group
+                       description="Group of the user specified in the 'glite.user.name'
+                       parameter. Leave it empty of comment it out to use the same as 'glite.user.name'"
+                       value="changeme"/>
+               
                <!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
                <!-- Advanced parameters - Change them if you know what you're doing -->
                <!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
index 2be3a97..f136064 100644 (file)
@@ -1,4 +1,4 @@
 
-module.version = 1.1.0
+module.version = 1.1.1
 module.age = 1
                                
\ No newline at end of file