def __loadConfigurationData( self ):
    try:
      os.makedirs( os.path.join( DIRAC.rootPath, "etc", "csbackup" ) )
    except:
      pass
    gConfigurationData.loadConfigurationData()
    if gConfigurationData.isMaster():
      bBuiltNewConfiguration = False
      if not gConfigurationData.getName():
        DIRAC.abort( 10, "Missing name for the configuration to be exported!" )
      gConfigurationData.exportName()
      sVersion = gConfigurationData.getVersion()
      if sVersion == "0":
        gLogger.info( "There's no version. Generating a new one" )
        gConfigurationData.generateNewVersion()
        bBuiltNewConfiguration = True

      if self.sURL not in gConfigurationData.getServers():
        gConfigurationData.setServers( self.sURL )
        bBuiltNewConfiguration = True

      gConfigurationData.setMasterServer( self.sURL )

      if bBuiltNewConfiguration:
        gConfigurationData.writeRemoteConfigurationToDisk()
Beispiel #2
0
 def __checkSlavesStatus(self, forceWriteConfiguration=False):
     gLogger.info("Checking status of slave servers")
     iGraceTime = gConfigurationData.getSlavesGraceTime()
     lSlaveURLs = self.dAliveSlaveServers.keys()
     bModifiedSlaveServers = False
     for sSlaveURL in lSlaveURLs:
         if time.time() - self.dAliveSlaveServers[sSlaveURL] > iGraceTime:
             gLogger.info("Found dead slave", sSlaveURL)
             del self.dAliveSlaveServers[sSlaveURL]
             bModifiedSlaveServers = True
     if bModifiedSlaveServers or forceWriteConfiguration:
         gConfigurationData.setServers("%s, %s" % (self.sURL, ", ".join(self.dAliveSlaveServers.keys())))
         self.__generateNewVersion()
Beispiel #3
0
 def publishSlaveServer(self, sSlaveURL):
     if not gConfigurationData.isMaster():
         return S_ERROR("Configuration modification is not allowed in this server")
     gLogger.info("Pinging slave %s" % sSlaveURL)
     rpcClient = RPCClient(sSlaveURL, timeout=10, useCertificates=True)
     retVal = rpcClient.ping()
     if not retVal["OK"]:
         gLogger.info("Slave %s didn't reply" % sSlaveURL)
         return
     if retVal["Value"]["name"] != "Configuration/Server":
         gLogger.info("Slave %s is not a CS serveR" % sSlaveURL)
         return
     bNewSlave = False
     if not sSlaveURL in self.dAliveSlaveServers.keys():
         bNewSlave = True
         gLogger.info("New slave registered", sSlaveURL)
     self.dAliveSlaveServers[sSlaveURL] = time.time()
     if bNewSlave:
         gConfigurationData.setServers("%s, %s" % (self.sURL, ", ".join(self.dAliveSlaveServers.keys())))
         self.__generateNewVersion()