示例#1
0
  def export_updateSoftware( self, version, rootPath = "", gridVersion = "" ):
    """ Update the local DIRAC software installation to version
    """

    # Check that we have a sane local configuration
    result = gConfig.getOptionsDict( '/LocalInstallation' )
    if not result['OK']:
      return S_ERROR( 'Invalid installation - missing /LocalInstallation section in the configuration' )
    elif not result['Value']:
      return S_ERROR( 'Invalid installation - empty /LocalInstallation section in the configuration' )

    if rootPath and not os.path.exists( rootPath ):
      return S_ERROR( 'Path "%s" does not exists' % rootPath )
    # For LHCb we need to check Oracle client
    installOracleClient = False
    oracleFlag = gConfig.getValue( '/LocalInstallation/InstallOracleClient', 'unknown' )
    if oracleFlag.lower() in ['yes', 'true', '1']:
      installOracleClient = True
    elif oracleFlag.lower() == "unknown":
      result = systemCall( 30, ['python', '-c', 'import cx_Oracle'] )
      if result['OK'] and result['Value'][0] == 0:
        installOracleClient = True

    cmdList = ['dirac-install', '-r', version, '-t', 'server']
    if rootPath:
      cmdList.extend( ['-P', rootPath] )

    # Check if there are extensions
    extensionList = getCSExtensions()
    if extensionList:
      #by default we do not install WebApp
      if "WebApp" in extensionList: 
        extensionList.remove("WebApp")
      
    webPortal = gConfig.getValue( '/LocalInstallation/WebApp', False ) # this is the new portal
    if webPortal:
      if "WebAppDIRAC" not in extensionList:
        extensionList.append("WebAppDIRAC")
   
    cmdList += ['-e', ','.join( extensionList )]
    
    project = gConfig.getValue('/LocalInstallation/Project')
    if project:
      cmdList += ['-l', project ]
      
    # Are grid middleware bindings required ?
    if gridVersion:
      cmdList.extend( ['-g', gridVersion] )

    targetPath = gConfig.getValue( '/LocalInstallation/TargetPath',
                                   gConfig.getValue( '/LocalInstallation/RootPath', '' ) )
    if targetPath and os.path.exists( targetPath + '/etc/dirac.cfg' ):
      cmdList.append( targetPath + '/etc/dirac.cfg' )
    else:
      return S_ERROR( 'Local configuration not found' )

    result = systemCall( 240, cmdList )
    if not result['OK']:
      return result
    status = result['Value'][0]
    if status != 0:
      # Get error messages
      error = []
      output = result['Value'][1].split( '\n' )
      for line in output:
        line = line.strip()
        if 'error' in line.lower():
          error.append( line )
      if error:
        message = '\n'.join( error )
      else:
        message = "Failed to update software to %s" % version
      return S_ERROR( message )

    # Check if there is a MySQL installation and fix the server scripts if necessary
    if os.path.exists( gComponentInstaller.mysqlDir ):
      startupScript = os.path.join( gComponentInstaller.instancePath,
                                    'mysql', 'share', 'mysql', 'mysql.server' )
      if not os.path.exists( startupScript ):
        startupScript = os.path.join( gComponentInstaller.instancePath, 'pro',
                                      'mysql', 'share', 'mysql', 'mysql.server' )
      if os.path.exists( startupScript ):
        gComponentInstaller.fixMySQLScripts( startupScript )

    # For LHCb we need to check Oracle client
    if installOracleClient:
      result = systemCall( 30, 'install_oracle-client.sh' )
      if not result['OK']:
        return result
      status = result['Value'][0]
      if status != 0:
        # Get error messages
        error = result['Value'][1].split( '\n' )
        error.extend( result['Value'][2].split( '\n' ) )
        error.append( 'Failed to install Oracle client module' )
        return S_ERROR( '\n'.join( error ) )

    if webPortal:
    # we have a to compile the new web portal...
      webappCompileScript = os.path.join( gComponentInstaller.instancePath, 'pro', "WebAppDIRAC/scripts", "dirac-webapp-compile.py" )
      outfile = "%s.out" % webappCompileScript
      err = "%s.err" % webappCompileScript
      result = systemCall( False, ['dirac-webapp-compile', ' > ', outfile, ' 2> ', err] )
      if not result['OK']:
        return result
      if result['Value'][0] != 0:
        error = result['Value'][1].split( '\n' )
        error.extend( result['Value'][2].split( '\n' ) )
        error.append( 'Failed to compile the java script!' )
        return S_ERROR( '\n'.join( error ) )

    return S_OK()
示例#2
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-fix-mysql-script
# Author :  Ricardo Graciani
########################################################################
"""
Fixes the mysql.server script, it requires a proper /LocalInstallation section
"""
__RCSID__ = "$Id$"
#
from DIRAC.Core.Base import Script

Script.disableCS()
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option] ... [cfgfile]' % Script.scriptName
]))

Script.addDefaultOptionValue('/DIRAC/Security/UseServerCertificate', 'yes')
Script.addDefaultOptionValue('LogLevel', 'INFO')
Script.parseCommandLine()
from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
#
gComponentInstaller.exitOnError = True
#
result = gComponentInstaller.fixMySQLScripts()
if not result['OK']:
    print "ERROR:", result['Message']
    exit(-1)
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-fix-mysql-script
# Author :  Ricardo Graciani
########################################################################
"""
Fixes the mysql.server script, it requires a proper /LocalInstallation section
"""
__RCSID__ = "$Id$"
#
from DIRAC.Core.Base import Script
Script.disableCS()
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option] ... [cfgfile]' % Script.scriptName ] ) )

Script.addDefaultOptionValue( '/DIRAC/Security/UseServerCertificate', 'yes' )
Script.addDefaultOptionValue( 'LogLevel', 'INFO' )
Script.parseCommandLine()
from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
#
gComponentInstaller.exitOnError = True
#
result = gComponentInstaller.fixMySQLScripts()
if not result['OK']:
  print "ERROR:", result['Message']
  exit( -1 )
    def export_updateSoftware(self, version, rootPath="", gridVersion=""):
        """ Update the local DIRAC software installation to version
    """

        # Check that we have a sane local configuration
        result = gConfig.getOptionsDict("/LocalInstallation")
        if not result["OK"]:
            return S_ERROR("Invalid installation - missing /LocalInstallation section in the configuration")
        elif not result["Value"]:
            return S_ERROR("Invalid installation - empty /LocalInstallation section in the configuration")

        if rootPath and not os.path.exists(rootPath):
            return S_ERROR('Path "%s" does not exists' % rootPath)
        # For LHCb we need to check Oracle client
        installOracleClient = False
        oracleFlag = gConfig.getValue("/LocalInstallation/InstallOracleClient", "unknown")
        if oracleFlag.lower() in ["yes", "true", "1"]:
            installOracleClient = True
        elif oracleFlag.lower() == "unknown":
            result = systemCall(30, ["python", "-c", "import cx_Oracle"])
            if result["OK"] and result["Value"][0] == 0:
                installOracleClient = True

        cmdList = ["dirac-install", "-r", version, "-t", "server"]
        if rootPath:
            cmdList.extend(["-P", rootPath])

        # Check if there are extensions
        extensionList = getCSExtensions()
        if extensionList:
            if "WebApp" in extensionList:
                extensionList.remove("WebApp")
            cmdList += ["-e", ",".join(extensionList)]

        webPortal = gConfig.getValue("/LocalInstallation/WebApp", False)  # this is the new portal
        if webPortal:
            if "WebAppDIRAC" not in extensionList:
                extensionList.append("WebAppDIRAC")

        if extensionList:
            cmdList += ["-e", ",".join(extensionList)]

        # Are grid middleware bindings required ?
        if gridVersion:
            cmdList.extend(["-g", gridVersion])

        targetPath = gConfig.getValue(
            "/LocalInstallation/TargetPath", gConfig.getValue("/LocalInstallation/RootPath", "")
        )
        if targetPath and os.path.exists(targetPath + "/etc/dirac.cfg"):
            cmdList.append(targetPath + "/etc/dirac.cfg")
        else:
            return S_ERROR("Local configuration not found")

        result = systemCall(240, cmdList)
        if not result["OK"]:
            return result
        status = result["Value"][0]
        if status != 0:
            # Get error messages
            error = []
            output = result["Value"][1].split("\n")
            for line in output:
                line = line.strip()
                if "error" in line.lower():
                    error.append(line)
            if error:
                message = "\n".join(error)
            else:
                message = "Failed to update software to %s" % version
            return S_ERROR(message)

        # Check if there is a MySQL installation and fix the server scripts if necessary
        if os.path.exists(gComponentInstaller.mysqlDir):
            startupScript = os.path.join(gComponentInstaller.instancePath, "mysql", "share", "mysql", "mysql.server")
            if not os.path.exists(startupScript):
                startupScript = os.path.join(
                    gComponentInstaller.instancePath, "pro", "mysql", "share", "mysql", "mysql.server"
                )
            if os.path.exists(startupScript):
                gComponentInstaller.fixMySQLScripts(startupScript)

        # For LHCb we need to check Oracle client
        if installOracleClient:
            result = systemCall(30, "install_oracle-client.sh")
            if not result["OK"]:
                return result
            status = result["Value"][0]
            if status != 0:
                # Get error messages
                error = result["Value"][1].split("\n")
                error.extend(result["Value"][2].split("\n"))
                error.append("Failed to install Oracle client module")
                return S_ERROR("\n".join(error))

        if webPortal:
            # we have a to compile the new web portal...
            webappCompileScript = os.path.join(
                gComponentInstaller.instancePath, "pro", "WebAppDIRAC/scripts", "dirac-webapp-compile.py"
            )
            outfile = "%s.out" % webappCompileScript
            err = "%s.err" % webappCompileScript
            result = systemCall(False, ["dirac-webapp-compile", " > ", outfile, " 2> ", err])
            if not result["OK"]:
                return result
            if result["Value"][0] != 0:
                error = result["Value"][1].split("\n")
                error.extend(result["Value"][2].split("\n"))
                error.append("Failed to compile the java script!")
                return S_ERROR("\n".join(error))

        return S_OK()