# For license conditions see the license file or http://eu-egee.org/license.html
#
################################################################################
-# glite-lb-config v. 1.3.0
+# glite-lb-config v. 2.1.0
#
# Post-installation script for configuring the gLite Logging and Bookkeping Server
# Robert Harakaly < robert.harakaly@cern.ch >
sys.path.append(".")
from gLiteInstallerLib import gLib
+from gLiteInstallerLib import ConfigParams
+from gliteRgmaServicetool import gliteRgmaServicetoolInstance
from gliteRgmaServicetool import gliteRgmaServicetool
import mysql as MySQL
self.version = "2.1.0"
self.name = "glite-lb"
self.friendly_name = "gLite Logging and Bookkeeping"
- params['module.version'] = self.version
#-------------------------------------------------------------------------------
# Banner
#-------------------------------------------------------------------
# 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()
-
-
- # Check that the daemon is running
-
- pid = glib.getPID('rgma-servicetool')
-
- if (pid != 0):
- print "The gLite R-GMA Servicetool service has been started ",
- glib.printOkMessage()
- else:
- glib.printErrorMessage("Could not start the gLite R-GMA Servicetool service")
- glib.printErrorMessage("Please verify and re-run the script "),
- glib.printFailedMessage()
+
+ errorcode = rgmaServicetool.start()
+ if (errorcode != 0):
return 1
return 0
self.mysql.stop()
#-------------------------------------------------------------------
- # Stop the servicetool
+ # Servicetool
#-------------------------------------------------------------------
- pid = glib.getPID('rgma-servicetool')
- if (pid != 0):
- rgmaServicetool.stop()
+ if rgmaServicetool.stop():
+ error_level = 1
- 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 status(self):
if retval != 0:
error_level = 1
+ #-------------------------------------------------------------------
+ # Servicetool
+ #-------------------------------------------------------------------
+
+ if rgmaServicetool.status() != 0:
+ error_level = 1
+
return error_level
def configure(self):
glib.printFailedMessage()
else:
print "\nConfiguring gLite Security Utilities ",
- glib.printOkMessage()
+ glib.printOkMessage()
# Create the GLITE_USER if it doesn't exists
print "\nCreating/Verifying the GLITE_USER account %s" % os.environ['GLITE_USER']
# start MySQL
self.mysql.stop()
time.sleep(5)
- self.mysql.start()
-
+ self.mysql.start()
+
if not os.path.exists('/tmp/mysql.sock'):
os.symlink('/var/lib/mysql/mysql.sock', '/tmp/mysql.sock')
self.mysql.add_user(params['lb.database.name'],params['lb.database.username'],"",self.mysql_root_password)
text = ['USE %s;\n' % params['lb.database.name'],
- '\. %s/etc/glite-lb-dbsetup.sql\n' % os.environ['GLITE_LOCATION']]
+ '\. %s/etc/glite-lb-dbsetup.sql\n' % os.environ['GLITE_LOCATION']]
file.writelines(text)
file.close()
#-------------------------------------------------------------------
# RGMA servicetool: configure servicetool
#-------------------------------------------------------------------
+ # Instantiate the rgma-servicetool class
+ rgmaServicetool = gliteRgmaServicetool()
+ rgmaServicetool.verbose = self.verbose
- print "Configuring the R-GMA Servicetool..."
-
+ # Create Local Logger instance
+ serviceId = "%s_%s" % (glib.fq_hostname, params['locallogger.serviceType'])
+ servicetoolInstance = gliteRgmaServicetoolInstance(glib, serviceId)
+
+ # set params
+ servicetoolInstance.setServiceName(params['lbserver.serviceName'])
+ servicetoolInstance.setServiceType(params['lbserver.serviceType'])
+ servicetoolInstance.setServiceVersion(self.version)
+ servicetoolInstance.setStatusScript(params['lbserver.statusScript'])
+ servicetoolInstance.setEndpoint(params['lbserver.endpoint'])
+
+ # add instance to the gLite configuration
+ if servicetoolInstance.add() == 1:
+ return 1
+
+ # Configure servicetool
if rgmaServicetool.configure(glib):
- # error in configuring services
- print "Configuring the R-GMA Servicetool... ",
- glib.printFailedMessage()
+ # error in configuring servicetool
return 1
-
- print "Configuring the R-GMA Servicetool... ",
- glib.printOkMessage()
-
+
return 0
#-------------------------------------------------------------------------------
params['mysql.root.password'] = ""
params['lb.database.name'] = "lbserver20"
params['lb.database.username'] = "lbserver"
-
+
+ params['lbserver.serviceName'] = 'LB Server service at %s' % glib.fq_hostname
+ params['lbserver.serviceType'] = 'org.glite.lb.server'
+ params['lbserver.statusScript'] = '%s/etc/init.d/glite-lb-bkserverd status' % params['GLITE_LOCATION']
+ params['lbserver.endpoint'] = 'not available'
+
def set_env():
# gLite
print '"\nThis script must be run as root\n'
sys.exit(1)
+ # Get an instance of the ConfigParams class
+ params = ConfigParams()
+
# Get an instance of the library class
glib = gLib()
# Load parameters
- params = {}
loadDefaults(params)
try:
opts, args = glib.getopt(sys.argv[1:], '', ['siteconfig='])
# Check cli options
for o, a in opts:
+
if o in ("-h", "--help"):
service.usage()
sys.exit(0)
+
if o in ("-v", "--version"):
service.showVersion()
sys.exit(0)
+
if o in ("-c", "--checkconf"):
service.copyright()
service.showVersion()
glib.print_params(params)
sys.exit(0)
-
- if o == "--configure":
- # Check certificates
- if params.has_key('glite.installer.checkcerts'):
- if params['glite.installer.checkcerts'] == "true":
- if glib.check_certs(params) != 0:
- print "An error occurred while configuring the %s service" \
- % service.friendly_name
- sys.exit(1)
-
- # Print configuration parameters
- if verbose:
- glib.print_params(params)
+ if o == "--configure":
- service.copyright()
- service.showVersion()
- service.banner()
+ # Check certificates
+ if params.has_key('glite.installer.checkcerts'):
+ if params['glite.installer.checkcerts'] == "true":
+ if glib.check_certs(params) != 0:
+ print "An error occurred while configuring the %s service" \
+ % service.friendly_name
+ sys.exit(1)
+
+ # Print configuration parameters
+ if verbose:
+ glib.print_params(params)
+ service.copyright()
+ service.showVersion()
+ service.banner()
+
# Stop all services
glib.printInfoMessage("\n\nStopping all running LB services...")
service.stop()
- # Configure the service
+ # Configure the service
return_result = service.configure()
if return_result == 0:
print "\n\nThe %s configuration was successfully completed\n" % service.friendly_name
print "You can now start the service using the --start option of this script\n\n"
- glib.registerService()
+ glib.registerService()
sys.exit(0)
sys.exit(2)
- else:
+ else:
print "\n\nAn unrecoverable error occurred while configuring the %s" \
% service.friendly_name
- sys.exit(1)
-
+ sys.exit(1)
+
if o in ("start", "--start"):
- # Start the service
- if service.start() == 0:
+ # Start the service
+ if service.start() == 0:
print "\n\nThe %s was successfully started " % service.friendly_name,
- glib.printOkMessage()
+ glib.printOkMessage()
sys.exit(0)
- else:
+ else:
print "\n\nAn error occurred while starting the %s " % service.friendly_name,
- glib.printFailedMessage()
- sys.exit(1)
-
+ glib.printFailedMessage()
+ sys.exit(1)
+
if o in ("stop", "--stop"):
# Stop the service
if service.stop() == 0:
print "\n\nAn unrecoverable error occurred while stopping the %s " % service.friendly_name,
glib.printFailedMessage()
sys.exit(1)
+
if o == "--status":
sys.exit(service.status())
</parameters>
- <!--RGMA service publishing: log server -->
- <instance name="lb.rgma" service="rgma-servicetool">
- <parameters>
-
- <rgma.servicetool.enable
- description="Publish log server via RGMA servicetool. If this variable is set to 'false': the other
- values of this instance are not taken into account.[Example: 'true'] [Type: 'boolean']"
-
- value="true"/>
-
- <rgma.servicetool.service_type
- description="The service type. This should be uniquely defined for each service type.
- The recommended format is the service namespace in
- reversed domain name format [Type: 'string']"
- value="org.glite.lb.lbserver"/>
-
- <rgma.servicetool.name
- description="Name of the service. This should be globally unique.
- [Example: 'HOSTANME_LB_LocalLogger'] [Type: 'String']"
- value="${HOSTNAME}_${rgma.servicetool.service_type}"/>
-
- <rgma.servicetool.url_endpoint
- description="URL to contact the service at.
- This should be unique for each service. Use example and adapt host.
- Example: http://your.host.name/LB/LBServer
- [Type: 'string']"
- value="not available"/>
-
- <rgma.servicetool.service_version
- description="Service version in the form 'major.minor.patch'
- Example: 1.2.3
- [Type: 'string']"
- value="${module.version}"/>
-
- <rgma.servicetool.publish_interval
- description="How often to check and publish service information.
- Example: 3600 [Type: 'string'] [Unit: 'seconds']"
- value="3600"/>
-
- <rgma.servicetool.status_script
- description="Script to run when determining the service status.
- This script should return an exit code of 0 to indicate the service is OK, other values
- should indicate an error. The first line of the standard output should be a brief message
- describing the service status (e.g. 'Accepting connections')
- Example: ${GLITE_LOCATION}/etc/init.d/glite-lb-bkserverd status
- [Type: 'string']"
- value="${GLITE_LOCATION}/etc/init.d/glite-lb-bkserverd status"/>
-
- <rgma.servicetool.status_interval
- description="How often to check and publish service status.
- Example: 60 [Type: 'string'] [Unit: 'seconds']"
- value="30"/>
-
- <rgma.servicetool.url_wsdl
- description="URL of a WSDL document for the service (leave blank if the
- service has no WSDL).
- Example: http://example.rl.ac.uk/service?WSDL
- [Type: 'string']"
- value="not available"/>
-
- <rgma.servicetool.url_semantics
- description="URL of a document containing a detailed description of the service
- and how it should be used.
- Example: http://example.rl.ac.uk/service/semantics.html
- [Type: 'string']"
- value="not available"/>
-
- </parameters>
- </instance>
-
</config>