def do_install(self, args):
        """
        Install various DIRAC components

        usage:

          install mysql
          install db <database>
          install service <system> <service> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install agent <system> <agent> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install executor <system> <executor> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
    """
        argss = args.split()
        if not argss:
            print self.do_install.__doc__
            return

        option = argss[0]
        del argss[0]
        if option == "mysql":
            print "Installing MySQL database, this can take a while ..."
            client = SystemAdministratorClient(self.host, self.port)
            if InstallTools.mysqlPassword == 'LocalConfig':
                InstallTools.mysqlPassword = ''
            InstallTools.getMySQLPasswords()
            result = client.installMySQL(InstallTools.mysqlRootPwd,
                                         InstallTools.mysqlPassword)
            if not result['OK']:
                self.__errMsg(result['Message'])
            else:
                print "MySQL:", result['Value']
                print "You might need to restart SystemAdministrator service to take new settings into account"
        elif option == "db":
            if not argss:
                print self.do_install.__doc__
                return
            database = argss[0]
            client = SystemAdministratorClient(self.host, self.port)

            result = client.getAvailableDatabases()
            if not result['OK']:
                self.__errMsg("Can not get database list: %s" %
                              result['Message'])
                return
            if not result['Value'].has_key(database):
                self.__errMsg("Unknown database %s: " % database)
                return
            system = result['Value'][database]['System']
            setup = gConfig.getValue('/DIRAC/Setup', '')
            if not setup:
                self.__errMsg("Unknown current setup")
                return
            instance = gConfig.getValue(
                '/DIRAC/Setups/%s/%s' % (setup, system), '')
            if not instance:
                self.__errMsg("No instance defined for system %s" % system)
                self.__errMsg(
                    "\tAdd new instance with 'add instance %s <instance_name>'"
                    % system)
                return

            if not InstallTools.mysqlPassword:
                InstallTools.mysqlPassword = '******'
            InstallTools.getMySQLPasswords()
            result = client.installDatabase(database,
                                            InstallTools.mysqlRootPwd)
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            extension, system = result['Value']
            # result = client.addDatabaseOptionsToCS( system, database )
            InstallTools.mysqlHost = self.host
            result = client.getInfo()
            if not result['OK']:
                self.__errMsg(result['Message'])
            hostSetup = result['Value']['Setup']
            result = InstallTools.addDatabaseOptionsToCS(
                gConfig, system, database, hostSetup)
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            print "Database %s from %s/%s installed successfully" % (
                database, extension, system)
        elif option in ["service", "agent", "executor"]:
            if len(argss) < 2:
                print self.do_install.__doc__
                return

            system = argss[0]
            del argss[0]
            component = argss[0]
            del argss[0]

            specialOptions = {}
            module = ''
            for i in range(len(argss)):
                if argss[i] == "-m":
                    specialOptions['Module'] = argss[i + 1]
                    module = argss[i + 1]
                if argss[i] == "-p":
                    opt, value = argss[i + 1].split('=')
                    specialOptions[opt] = value
            if module == component:
                module = ''

            client = SystemAdministratorClient(self.host, self.port)
            # First need to update the CS
            # result = client.addDefaultOptionsToCS( option, system, component )
            InstallTools.host = self.host
            result = client.getInfo()
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            hostSetup = result['Value']['Setup']

            # Install Module section if not yet there
            if module:
                result = InstallTools.addDefaultOptionsToCS(
                    gConfig, option, system, module, getCSExtensions(),
                    hostSetup)
                # Add component section with specific parameters only
                result = InstallTools.addDefaultOptionsToCS(
                    gConfig,
                    option,
                    system,
                    component,
                    getCSExtensions(),
                    hostSetup,
                    specialOptions,
                    addDefaultOptions=False)
            else:
                # Install component section
                result = InstallTools.addDefaultOptionsToCS(
                    gConfig, option, system, component, getCSExtensions(),
                    hostSetup, specialOptions)

            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            # Then we can install and start the component
            result = client.setupComponent(option, system, component, module)
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            compType = result['Value']['ComponentType']
            runit = result['Value']['RunitStatus']
            print "%s %s_%s is installed, runit status: %s" % (
                compType, system, component, runit)
        else:
            print "Unknown option:", option
Пример #2
0
  def do_install( self, args ):
    """
        Install various DIRAC components

        usage:

          install mysql
          install db <database>
          install service <system> <service> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install agent <system> <agent> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install executor <system> <executor> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
    """
    argss = args.split()
    if not argss:
      print self.do_install.__doc__
      return

    option = argss[0]
    del argss[0]
    if option == "mysql":
      print "Installing MySQL database, this can take a while ..."
      client = SystemAdministratorClient( self.host, self.port )
      if InstallTools.mysqlPassword == 'LocalConfig':
        InstallTools.mysqlPassword = ''
      InstallTools.getMySQLPasswords()
      result = client.installMySQL( InstallTools.mysqlRootPwd, InstallTools.mysqlPassword )
      if not result['OK']:
        self.__errMsg( result['Message'] )
      else:
        print "MySQL:", result['Value']
        print "You might need to restart SystemAdministrator service to take new settings into account"
    elif option == "db":
      if not argss:
        print self.do_install.__doc__
        return
      database = argss[0]
      client = SystemAdministratorClient( self.host, self.port )

      result = client.getAvailableDatabases()
      if not result['OK']:
        self.__errMsg( "Can not get database list: %s" % result['Message'] )
        return
      if not result['Value'].has_key( database ):
        self.__errMsg( "Unknown database %s: " % database )
        return
      system = result['Value'][database]['System']
      setup = gConfig.getValue( '/DIRAC/Setup', '' )
      if not setup:
        self.__errMsg( "Unknown current setup" )
        return
      instance = gConfig.getValue( '/DIRAC/Setups/%s/%s' % ( setup, system ), '' )
      if not instance:
        self.__errMsg( "No instance defined for system %s" % system )
        self.__errMsg( "\tAdd new instance with 'add instance %s <instance_name>'" % system )
        return

      if not InstallTools.mysqlPassword:
        InstallTools.mysqlPassword = '******'
      InstallTools.getMySQLPasswords()
      result = client.installDatabase( database, InstallTools.mysqlRootPwd )
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      extension, system = result['Value']
      # result = client.addDatabaseOptionsToCS( system, database )
      InstallTools.mysqlHost = self.host
      result = client.getInfo()
      if not result['OK']:
        self.__errMsg( result['Message'] )
      hostSetup = result['Value']['Setup']
      result = InstallTools.addDatabaseOptionsToCS( gConfig, system, database, hostSetup )
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      print "Database %s from %s/%s installed successfully" % ( database, extension, system )
    elif option in ["service","agent","executor"] :
      if len( argss ) < 2:
        print self.do_install.__doc__
        return

      system = argss[0]
      del argss[0]
      component = argss[0]
      del argss[0]
      
      specialOptions = {}
      module = ''
      for i in range(len(argss)):
        if argss[i] == "-m":
          specialOptions['Module'] = argss[i+1]
          module = argss[i+1]
        if argss[i] == "-p":
          opt,value = argss[i+1].split('=')
          specialOptions[opt] = value           
      if module == component:
        module = ''
      
      client = SystemAdministratorClient( self.host, self.port )
      # First need to update the CS
      # result = client.addDefaultOptionsToCS( option, system, component )
      InstallTools.host = self.host
      result = client.getInfo()
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      hostSetup = result['Value']['Setup']
      
      # Install Module section if not yet there
      if module:
        result = InstallTools.addDefaultOptionsToCS( gConfig, option, system, module, 
                                                     getCSExtensions(), hostSetup )
        # Add component section with specific parameters only
        result = InstallTools.addDefaultOptionsToCS( gConfig, option, system, component, 
                                                     getCSExtensions(), hostSetup, specialOptions, 
                                                     addDefaultOptions = False )
      else:  
        # Install component section
        result = InstallTools.addDefaultOptionsToCS( gConfig, option, system, component, 
                                                     getCSExtensions(), hostSetup, specialOptions )
    
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      # Then we can install and start the component
      result = client.setupComponent( option, system, component, module )
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      compType = result['Value']['ComponentType']
      runit = result['Value']['RunitStatus']
      print "%s %s_%s is installed, runit status: %s" % ( compType, system, component, runit )
    else:
      print "Unknown option:", option
    def do_install(self, args):
        """ 
        Install various DIRAC components 
    
        usage:
        
          install mysql
          install db <database>
          install service <system> <service>
          install agent <system> <agent>
    """
        argss = args.split()
        if not argss:
            print self.do_install.__doc__
            return

        option = argss[0]
        del argss[0]
        if option == "mysql":
            print "Installing MySQL database, this can take a while ..."
            client = SystemAdministratorClient(self.host, self.port)
            if InstallTools.mysqlPassword == 'LocalConfig':
                InstallTools.mysqlPassword = ''
            InstallTools.getMySQLPasswords()
            result = client.installMySQL(InstallTools.mysqlRootPwd,
                                         InstallTools.mysqlPassword)
            if not result['OK']:
                self.__errMsg(result['Message'])
            else:
                print "MySQL:", result['Value']
                print "You might need to restart SystemAdministrator service to take new settings into account"
        elif option == "db":
            if not argss:
                print self.do_install.__doc__
                return
            database = argss[0]
            client = SystemAdministratorClient(self.host, self.port)

            result = client.getAvailableDatabases()
            if not result['OK']:
                self.__errMsg("Can not get database list: %s" %
                              result['Message'])
                return
            if not result['Value'].has_key(database):
                self.__errMsg("Unknown database %s: " % database)
                return
            system = result['Value'][database]['System']
            setup = gConfig.getValue('/DIRAC/Setup', '')
            if not setup:
                self.__errMsg("Unknown current setup")
                return
            instance = gConfig.getValue(
                '/DIRAC/Setups/%s/%s' % (setup, system), '')
            if not instance:
                self.__errMsg("No instance defined for system %s" % system)
                self.__errMsg(
                    "\tAdd new instance with 'add instance %s <instance_name>'"
                    % system)
                return

            if not InstallTools.mysqlPassword:
                InstallTools.mysqlPassword = '******'
            InstallTools.getMySQLPasswords()
            result = client.installDatabase(database,
                                            InstallTools.mysqlRootPwd)
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            extension, system = result['Value']
            # result = client.addDatabaseOptionsToCS( system, database )
            InstallTools.mysqlHost = self.host
            result = client.getInfo()
            if not result['OK']:
                self.__errMsg(result['Message'])
            hostSetup = result['Value']['Setup']
            result = InstallTools.addDatabaseOptionsToCS(
                gConfig, system, database, hostSetup)
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            print "Database %s from %s/%s installed successfully" % (
                database, extension, system)
        elif option == "service" or option == "agent":
            if len(argss) < 2:
                print self.do_install.__doc__
                return

            system = argss[0]
            component = argss[1]
            client = SystemAdministratorClient(self.host, self.port)
            # First need to update the CS
            # result = client.addDefaultOptionsToCS( option, system, component )
            InstallTools.host = self.host
            result = client.getInfo()
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            hostSetup = result['Value']['Setup']
            result = InstallTools.addDefaultOptionsToCS(
                gConfig, option, system, component, getCSExtensions(),
                hostSetup)
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            # Then we can install and start the component
            result = client.setupComponent(option, system, component)
            if not result['OK']:
                self.__errMsg(result['Message'])
                return
            compType = result['Value']['ComponentType']
            runit = result['Value']['RunitStatus']
            print "%s %s_%s is installed, runit status: %s" % (
                compType, system, component, runit)
        else:
            print "Unknown option:", option
  def do_install( self, args ):
    """ 
        Install various DIRAC components 
    
        usage:
        
          install mysql
          install db <database>
          install service <system> <service>
          install agent <system> <agent>
    """
    argss = args.split()
    if not argss:
      print self.do_install.__doc__
      return

    option = argss[0]
    del argss[0]
    if option == "mysql":
      print "Installing MySQL database, this can take a while ..."
      client = SystemAdministratorClient( self.host, self.port )
      if InstallTools.mysqlPassword == 'LocalConfig':
        InstallTools.mysqlPassword = ''
      InstallTools.getMySQLPasswords()
      result = client.installMySQL( InstallTools.mysqlRootPwd, InstallTools.mysqlPassword )
      if not result['OK']:
        self.__errMsg( result['Message'] )
      else:
        print "MySQL:", result['Value']
        print "You might need to restart SystemAdministrator service to take new settings into account"
    elif option == "db":
      if not argss:
        print self.do_install.__doc__
        return
      database = argss[0]
      client = SystemAdministratorClient( self.host, self.port )

      result = client.getAvailableDatabases()
      if not result['OK']:
        self.__errMsg( "Can not get database list: %s" % result['Message'] )
        return
      if not result['Value'].has_key( database ):
        self.__errMsg( "Unknown database %s: " % database )
        return
      system = result['Value'][database]['System']
      setup = gConfig.getValue( '/DIRAC/Setup', '' )
      if not setup:
        self.__errMsg( "Unknown current setup" )
        return
      instance = gConfig.getValue( '/DIRAC/Setups/%s/%s' % ( setup, system ), '' )
      if not instance:
        self.__errMsg( "No instance defined for system %s" % system )
        self.__errMsg( "\tAdd new instance with 'add instance %s <instance_name>'" % system )
        return

      if not InstallTools.mysqlPassword:
        InstallTools.mysqlPassword = '******'
      InstallTools.getMySQLPasswords()
      result = client.installDatabase( database, InstallTools.mysqlRootPwd )
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      extension, system = result['Value']
      # result = client.addDatabaseOptionsToCS( system, database )
      InstallTools.mysqlHost = self.host
      result = client.getInfo()
      if not result['OK']:
        self.__errMsg( result['Message'] )
      hostSetup = result['Value']['Setup']
      result = InstallTools.addDatabaseOptionsToCS( gConfig, system, database, hostSetup )
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      print "Database %s from %s/%s installed successfully" % ( database, extension, system )
    elif option == "service" or option == "agent":
      if len( argss ) < 2:
        print self.do_install.__doc__
        return

      system = argss[0]
      component = argss[1]
      client = SystemAdministratorClient( self.host, self.port )
      # First need to update the CS
      # result = client.addDefaultOptionsToCS( option, system, component )
      InstallTools.host = self.host
      result = client.getInfo()
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      hostSetup = result['Value']['Setup']
      result = InstallTools.addDefaultOptionsToCS( gConfig, option, system, component, getCSExtensions(), hostSetup )
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      # Then we can install and start the component
      result = client.setupComponent( option, system, component )
      if not result['OK']:
        self.__errMsg( result['Message'] )
        return
      compType = result['Value']['ComponentType']
      runit = result['Value']['RunitStatus']
      print "%s %s_%s is installed, runit status: %s" % ( compType, system, component, runit )
    else:
      print "Unknown option:", option
  def do_install( self, args ):
    """
        Install various DIRAC components

        usage:

          install mysql
          install db <database>
          install service <system> <service> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install agent <system> <agent> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install executor <system> <executor> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
    """
    argss = args.split()
    if not argss:
      gLogger.notice( self.do_install.__doc__ )
      return

    option = argss[0]
    del argss[0]
    if option == "mysql":
      gLogger.notice( "Installing MySQL database, this can take a while ..." )
      client = SystemAdministratorClient( self.host, self.port )
      if gComponentInstaller.mysqlPassword == 'LocalConfig':
        gComponentInstaller.mysqlPassword = ''
      gComponentInstaller.getMySQLPasswords()
      result = client.installMySQL( gComponentInstaller.mysqlRootPwd, gComponentInstaller.mysqlPassword )
      if not result['OK']:
        self._errMsg( result['Message'] )
      else:
        gLogger.notice( "MySQL:", result['Value'] )
        gLogger.notice( "You might need to restart SystemAdministrator service to take new settings into account" )
    elif option == "db":
      if not argss:
        gLogger.notice( self.do_install.__doc__ )
        return
      database = argss[0]
      client = SystemAdministratorClient( self.host, self.port )

      result = client.getAvailableDatabases()
      if not result['OK']:
        self._errMsg( "Can not get database list: %s" % result['Message'] )
        return
      if not result['Value'].has_key( database ):
        self._errMsg( "Unknown database %s: " % database )
        return
      system = result['Value'][database]['System']
      setup = gConfig.getValue( '/DIRAC/Setup', '' )
      if not setup:
        self._errMsg( "Unknown current setup" )
        return
      instance = gConfig.getValue( '/DIRAC/Setups/%s/%s' % ( setup, system ), '' )
      if not instance:
        self._errMsg( "No instance defined for system %s" % system )
        self._errMsg( "\tAdd new instance with 'add instance %s <instance_name>'" % system )
        return

      if not gComponentInstaller.mysqlPassword:
        gComponentInstaller.mysqlPassword = '******'
      gComponentInstaller.getMySQLPasswords()
      result = client.installDatabase( database, gComponentInstaller.mysqlRootPwd )
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      extension, system = result['Value']

      result = client.getHostInfo()
      if not result[ 'OK' ]:
        self._errMsg( result[ 'Message' ] )
        return
      else:
        cpu = result[ 'Value' ][ 'CPUModel' ]
      hostname = self.host
      if not result[ 'OK' ]:
        self._errMsg( result[ 'Message' ] )
        return

      if database != 'InstalledComponentsDB':
        result = MonitoringUtilities.monitorInstallation( 'DB', system.replace( 'System', '' ), database, cpu = cpu, hostname = hostname )
        if not result['OK']:
          self._errMsg( result['Message'] )
          return
      # result = client.addDatabaseOptionsToCS( system, database )
      gComponentInstaller.mysqlHost = self.host
      result = client.getInfo()
      if not result['OK']:
        self._errMsg( result['Message'] )
      hostSetup = result['Value']['Setup']
      result = gComponentInstaller.addDatabaseOptionsToCS( gConfig, system, database, hostSetup, overwrite = True )
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      gLogger.notice( "Database %s from %s/%s installed successfully" % ( database, extension, system ) )
    elif option in self.runitComponents:
      if len( argss ) < 2:
        gLogger.notice( self.do_install.__doc__ )
        return

      system = argss[0]
      del argss[0]
      component = argss[0]
      del argss[0]

      specialOptions = {}
      module = ''
     
      for i in range(len(argss)):
        if argss[i] == "-m":
          specialOptions['Module'] = argss[i+1]
          module = argss[i+1]
        if argss[i] == "-p":
          opt,value = argss[i+1].split('=')
          specialOptions[opt] = value
      if module == component:
        module = ''

      client = SystemAdministratorClient( self.host, self.port )
      # First need to update the CS
      # result = client.addDefaultOptionsToCS( option, system, component )
      gComponentInstaller.host = self.host
      result = client.getInfo()
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      hostSetup = result['Value']['Setup']
    
      # Install Module section if not yet there
      if module:
        result = gComponentInstaller.addDefaultOptionsToCS( gConfig, option, system, module,
                                                            getCSExtensions(), hostSetup )
        # in case of Error we must stop, this can happen when the module name is wrong...
        if not result['OK']:
          self._errMsg( result['Message'] )
          return
        # Add component section with specific parameters only
        result = gComponentInstaller.addDefaultOptionsToCS( gConfig, option, system, component,
                                                            getCSExtensions(), hostSetup, specialOptions,
                                                            addDefaultOptions = True )
      else:
        # Install component section
        result = gComponentInstaller.addDefaultOptionsToCS( gConfig, option, system, component,
                                                            getCSExtensions(), hostSetup, specialOptions )

      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      # Then we can install and start the component
      result = client.setupComponent( option, system, component, module )
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      compType = result['Value']['ComponentType']
      runit = result['Value']['RunitStatus']
      gLogger.notice( "%s %s_%s is installed, runit status: %s" % ( compType, system, component, runit ) )

      # And register it in the database
      result = client.getHostInfo()
      if not result[ 'OK' ]:
        self._errMsg( result[ 'Message' ] )
        return
      else:
        cpu = result[ 'Value' ][ 'CPUModel' ]
      hostname = self.host
      if component == 'ComponentMonitoring':
        # Make sure that the service is running before trying to use it
        nTries = 0
        maxTries = 5
        mClient = ComponentMonitoringClient()
        result = mClient.ping()
        while not result[ 'OK' ] and nTries < maxTries:
          time.sleep( 3 )
          result = mClient.ping()
          nTries = nTries + 1

        if not result[ 'OK' ]:
          self._errMsg( 'ComponentMonitoring service taking too long to start. Installation will not be logged into the database' )
          return

        result = MonitoringUtilities.monitorInstallation( 'DB', system, 'InstalledComponentsDB', cpu = cpu, hostname = hostname )
        if not result['OK']:
          self._errMsg( 'Error registering installation into database: %s' % result[ 'Message' ] )
          return
      
      result = MonitoringUtilities.monitorInstallation( option, system, component, module, cpu = cpu, hostname = hostname )
      if not result['OK']:
        self._errMsg( 'Error registering installation into database: %s' % result[ 'Message' ] )
        return
    else:
      gLogger.notice( "Unknown option:", option )
Пример #6
0
  def do_install( self, args ):
    """
        Install various DIRAC components

        usage:

          install mysql
          install db <database>
          install service <system> <service> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install agent <system> <agent> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
          install executor <system> <executor> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
    """
    argss = args.split()
    if not argss:
      gLogger.notice( self.do_install.__doc__ )
      return

    option = argss[0]
    del argss[0]
    if option == "mysql":
      gLogger.notice( "Installing MySQL database, this can take a while ..." )
      client = SystemAdministratorClient( self.host, self.port )
      if gComponentInstaller.mysqlPassword == 'LocalConfig':
        gComponentInstaller.mysqlPassword = ''
      gComponentInstaller.getMySQLPasswords()
      result = client.installMySQL( gComponentInstaller.mysqlRootPwd, gComponentInstaller.mysqlPassword )
      if not result['OK']:
        self._errMsg( result['Message'] )
      else:
        gLogger.notice( "MySQL:", result['Value'] )
        gLogger.notice( "You might need to restart SystemAdministrator service to take new settings into account" )
    elif option == "db":
      if not argss:
        gLogger.notice( self.do_install.__doc__ )
        return
      database = argss[0]
      client = SystemAdministratorClient( self.host, self.port )

      result = client.getAvailableDatabases()
      if not result['OK']:
        self._errMsg( "Can not get database list: %s" % result['Message'] )
        return
      if not result['Value'].has_key( database ):
        self._errMsg( "Unknown database %s: " % database )
        return
      system = result['Value'][database]['System']
      setup = gConfig.getValue( '/DIRAC/Setup', '' )
      if not setup:
        self._errMsg( "Unknown current setup" )
        return
      instance = gConfig.getValue( '/DIRAC/Setups/%s/%s' % ( setup, system ), '' )
      if not instance:
        self._errMsg( "No instance defined for system %s" % system )
        self._errMsg( "\tAdd new instance with 'add instance %s <instance_name>'" % system )
        return

      if not gComponentInstaller.mysqlPassword:
        gComponentInstaller.mysqlPassword = '******'
      gComponentInstaller.getMySQLPasswords()
      result = client.installDatabase( database, gComponentInstaller.mysqlRootPwd )
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      extension, system = result['Value']

      result = client.getHostInfo()
      if not result[ 'OK' ]:
        self._errMsg( result[ 'Message' ] )
        return
      else:
        cpu = result[ 'Value' ][ 'CPUModel' ]
      hostname = self.host
      if not result[ 'OK' ]:
        self._errMsg( result[ 'Message' ] )
        return

      if database != 'InstalledComponentsDB':
        result = MonitoringUtilities.monitorInstallation( 'DB', system.replace( 'System', '' ), database, cpu = cpu, hostname = hostname )
        if not result['OK']:
          self._errMsg( result['Message'] )
          return
      # result = client.addDatabaseOptionsToCS( system, database )
      gComponentInstaller.mysqlHost = self.host
      result = client.getInfo()
      if not result['OK']:
        self._errMsg( result['Message'] )
      hostSetup = result['Value']['Setup']
      result = gComponentInstaller.addDatabaseOptionsToCS( gConfig, system, database, hostSetup, overwrite = True )
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      gLogger.notice( "Database %s from %s/%s installed successfully" % ( database, extension, system ) )
    elif option in self.runitComponents:
      if len( argss ) < 2:
        gLogger.notice( self.do_install.__doc__ )
        return

      system = argss[0]
      del argss[0]
      component = argss[0]
      del argss[0]

      specialOptions = {}
      module = ''
     
      for i in range(len(argss)):
        if argss[i] == "-m":
          specialOptions['Module'] = argss[i+1]
          module = argss[i+1]
        if argss[i] == "-p":
          opt,value = argss[i+1].split('=')
          specialOptions[opt] = value
      if module == component:
        module = ''

      client = SystemAdministratorClient( self.host, self.port )
      # First need to update the CS
      # result = client.addDefaultOptionsToCS( option, system, component )
      gComponentInstaller.host = self.host
      result = client.getInfo()
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      hostSetup = result['Value']['Setup']
    
      # Install Module section if not yet there
      if module:
        result = gComponentInstaller.addDefaultOptionsToCS( gConfig, option, system, module,
                                                            getCSExtensions(), hostSetup )
        # in case of Error we must stop, this can happen when the module name is wrong...
        if not result['OK']:
          self._errMsg( result['Message'] )
          return
        # Add component section with specific parameters only
        result = gComponentInstaller.addDefaultOptionsToCS( gConfig, option, system, component,
                                                            getCSExtensions(), hostSetup, specialOptions,
                                                            addDefaultOptions = True )
      else:
        # Install component section
        result = gComponentInstaller.addDefaultOptionsToCS( gConfig, option, system, component,
                                                            getCSExtensions(), hostSetup, specialOptions )

      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      # Then we can install and start the component
      result = client.setupComponent( option, system, component, module )
      if not result['OK']:
        self._errMsg( result['Message'] )
        return
      compType = result['Value']['ComponentType']
      runit = result['Value']['RunitStatus']
      gLogger.notice( "%s %s_%s is installed, runit status: %s" % ( compType, system, component, runit ) )

      # And register it in the database
      result = client.getHostInfo()
      if not result[ 'OK' ]:
        self._errMsg( result[ 'Message' ] )
        return
      else:
        cpu = result[ 'Value' ][ 'CPUModel' ]
      hostname = self.host
      if component == 'ComponentMonitoring':
        # Make sure that the service is running before trying to use it
        nTries = 0
        maxTries = 5
        mClient = ComponentMonitoringClient()
        result = mClient.ping()
        while not result[ 'OK' ] and nTries < maxTries:
          time.sleep( 3 )
          result = mClient.ping()
          nTries = nTries + 1

        if not result[ 'OK' ]:
          self._errMsg( 'ComponentMonitoring service taking too long to start. Installation will not be logged into the database' )
          return

        result = MonitoringUtilities.monitorInstallation( 'DB', system, 'InstalledComponentsDB', cpu = cpu, hostname = hostname )
        if not result['OK']:
          self._errMsg( 'Error registering installation into database: %s' % result[ 'Message' ] )
          return
      
      result = MonitoringUtilities.monitorInstallation( option, system, component, module, cpu = cpu, hostname = hostname )
      if not result['OK']:
        self._errMsg( 'Error registering installation into database: %s' % result[ 'Message' ] )
        return
    else:
      gLogger.notice( "Unknown option:", option )