Exemplo n.º 1
0
 def __init__(self, sURL):
     self.sURL = sURL
     gLogger.info("Initializing Configuration Service", "URL is %s" % sURL)
     self.__modificationsIgnoreMask = ["/DIRAC/Configuration/Servers", "/DIRAC/Configuration/Version"]
     gConfigurationData.setAsService()
     if not gConfigurationData.isMaster():
         gLogger.info("Starting configuration service as slave")
         gRefresher.autoRefreshAndPublish(self.sURL)
     else:
         gLogger.info("Starting configuration service as master")
         gRefresher.disable()
         self.__loadConfigurationData()
         self.dAliveSlaveServers = {}
         self._launchCheckSlaves()
Exemplo n.º 2
0
 def __init__( self, sURL ):
   threading.Thread.__init__( self )
   self.sURL = sURL
   gLogger.info( "Initializing Configuration Service", "URL is %s" % sURL )
   self.__modificationsIgnoreMask = [ '/DIRAC/Configuration/Servers', '/DIRAC/Configuration/Version' ]
   gConfigurationData.setAsService()
   if not gConfigurationData.isMaster():
     gLogger.info( "Starting configuration service as slave" )
     gRefresher.autoRefreshAndPublish( self.sURL )
   else:
     gLogger.info( "Starting configuration service as master" )
     gRefresher.disable()
     self.__loadConfigurationData()
     self.dAliveSlaveServers = {}
     self.__launchCheckSlaves()
Exemplo n.º 3
0
 def syncRemoteConfiguration(self, strict=False):
     """
 Force a Resync with Configuration Server
 Under normal conditions this is triggered by an access to any configuration data
 """
     if self.componentName == "Configuration/Server":
         if gConfigurationData.isMaster():
             gLogger.info("Starting Master Configuration Server")
             gRefresher.disable()
             return S_OK()
     retDict = gRefresher.forceRefresh()
     if not retDict['OK']:
         gLogger.error("Can't update from any server", retDict['Message'])
         if strict:
             return retDict
     return S_OK()
Exemplo n.º 4
0
 def syncRemoteConfiguration( self, strict = False ):
   """
   Force a Resync with Configuration Server
   Under normal conditions this is triggered by an access to any configuration data
   """
   if self.componentName == "Configuration/Server" :
     if gConfigurationData.isMaster():
       gLogger.info( "Starting Master Configuration Server" )
       gRefresher.disable()
       return S_OK()
   retDict = gRefresher.forceRefresh()
   if not retDict['OK']:
     gLogger.error( "Can't update from any server", retDict[ 'Message' ] )
     if strict:
       return retDict
   return S_OK()
Exemplo n.º 5
0
def main():

    if os.environ.get("DIRAC_USE_TORNADO_IOLOOP",
                      "false").lower() not in ("yes", "true"):
        raise RuntimeError(
            "DIRAC_USE_TORNADO_IOLOOP is not defined in the environment." +
            "\n" + "It is necessary to run with Tornado." + "\n" +
            "https://dirac.readthedocs.io/en/latest/DeveloperGuide/TornadoServices/index.html"
        )

    from DIRAC.ConfigurationSystem.Client.PathFinder import getServiceSection
    from DIRAC.ConfigurationSystem.Client.ConfigurationData import gConfigurationData
    from DIRAC.ConfigurationSystem.private.Refresher import gRefresher
    from DIRAC.Core.Utilities.DErrno import includeExtensionErrors
    from DIRAC.Core.Tornado.Server.TornadoServer import TornadoServer
    from DIRAC.FrameworkSystem.Client.Logger import gLogger

    if gConfigurationData.isMaster():
        gRefresher.disable()

    localCfg = Script.localCfg
    localCfg.addMandatoryEntry("/DIRAC/Setup")
    localCfg.addDefaultEntry("/DIRAC/Security/UseServerCertificate", "yes")
    localCfg.addDefaultEntry("LogLevel", "INFO")
    localCfg.addDefaultEntry("LogColor", True)
    resultDict = localCfg.loadUserData()
    if not resultDict["OK"]:
        gLogger.initialize("Tornado-CS", "/")
        gLogger.error("There were errors when loading configuration",
                      resultDict["Message"])
        sys.exit(1)

    includeExtensionErrors()

    gLogger.initialize("Tornado-CS", "/")

    # get the specific master CS port
    try:
        csPort = int(
            gConfigurationData.extractOptionFromCFG(
                "%s/Port" % getServiceSection("Configuration/Server")))
    except TypeError:
        csPort = None

    serverToLaunch = TornadoServer(services="Configuration/Server",
                                   port=csPort)
    serverToLaunch.startTornado()
Exemplo n.º 6
0
  def __init__(self, sURL):
    threading.Thread.__init__(self)
    self.sURL = sURL
    gLogger.info("Initializing Configuration Service", "URL is %s" % sURL)
    self.__modificationsIgnoreMask = ['/DIRAC/Configuration/Servers', '/DIRAC/Configuration/Version']
    gConfigurationData.setAsService()
    if not gConfigurationData.isMaster():
      gLogger.info("Starting configuration service as slave")
      gRefresher.autoRefreshAndPublish(self.sURL)
    else:
      gLogger.info("Starting configuration service as master")
      gRefresher.disable()
      self.__loadConfigurationData()
      self.dAliveSlaveServers = {}
      self.__launchCheckSlaves()

    self.__updateResultDict = {"Successful": {}, "Failed": {}}
Exemplo n.º 7
0
def main():
    # Must be defined BEFORE any dirac import
    os.environ['DIRAC_USE_TORNADO_IOLOOP'] = "True"

    from DIRAC.ConfigurationSystem.Client.PathFinder import getServiceSection
    from DIRAC.ConfigurationSystem.Client.ConfigurationData import gConfigurationData
    from DIRAC.ConfigurationSystem.Client.LocalConfiguration import LocalConfiguration
    from DIRAC.ConfigurationSystem.private.Refresher import gRefresher
    from DIRAC.Core.Utilities.DErrno import includeExtensionErrors
    from DIRAC.Core.Tornado.Server.TornadoServer import TornadoServer
    from DIRAC.FrameworkSystem.Client.Logger import gLogger

    if gConfigurationData.isMaster():
        gRefresher.disable()

    localCfg = LocalConfiguration()
    localCfg.addMandatoryEntry("/DIRAC/Setup")
    localCfg.addDefaultEntry("/DIRAC/Security/UseServerCertificate", "yes")
    localCfg.addDefaultEntry("LogLevel", "INFO")
    localCfg.addDefaultEntry("LogColor", True)
    resultDict = localCfg.loadUserData()
    if not resultDict['OK']:
        gLogger.initialize("Tornado-CS", "/")
        gLogger.error("There were errors when loading configuration",
                      resultDict['Message'])
        sys.exit(1)

    includeExtensionErrors()

    gLogger.initialize('Tornado-CS', "/")

    # get the specific master CS port
    try:
        csPort = int(
            gConfigurationData.extractOptionFromCFG(
                '%s/Port' % getServiceSection('Configuration/Server')))
    except TypeError:
        csPort = None

    serverToLaunch = TornadoServer(services='Configuration/Server',
                                   port=csPort)
    serverToLaunch.startTornado()
Exemplo n.º 8
0
 def disableCS(self):
     """
 Do not contact Configuration Server upon initialization
 """
     gRefresher.disable()
Exemplo n.º 9
0
 def disableCS( self ):
   """
   Do not contact Configuration Server upon initialization
   """
   gRefresher.disable()