示例#1
0
 def __init__(self):
     self._automaticUpdate = False
     self._lastUpdateTime = 0
     self._refreshTime = gConfigurationData.getRefreshTime()
     self._url = False
     self._refreshEnabled = True
     self._timeout = 60
     self._callbacks = {"newVersion": []}
     gEventDispatcher.registerEvent("CSNewVersion")
示例#2
0
    def _refresh(self, fromMaster=False):
        """
        Refresh configuration
        """
        self._lastUpdateTime = time.time()
        gLogger.debug("Refreshing configuration...")
        gatewayList = getGatewayURLs("Configuration/Server")
        updatingErrorsList = []
        if gatewayList:
            initialServerList = gatewayList
            gLogger.debug("Using configuration gateway",
                          str(initialServerList[0]))
        elif fromMaster:
            masterServer = gConfigurationData.getMasterServer()
            initialServerList = [masterServer]
            gLogger.debug("Refreshing from master %s" % masterServer)
        else:
            initialServerList = gConfigurationData.getServers()
            gLogger.debug("Refreshing from list %s" % str(initialServerList))

        # If no servers in the initial list, we are supposed to use the local configuration only
        if not initialServerList:
            return S_OK()

        randomServerList = List.randomize(initialServerList)
        gLogger.debug("Randomized server list is %s" %
                      ", ".join(randomServerList))

        for sServer in randomServerList:
            from DIRAC.ConfigurationSystem.Client.ConfigurationClient import ConfigurationClient

            oClient = ConfigurationClient(
                url=sServer,
                useCertificates=gConfigurationData.useServerCertificate(),
                skipCACheck=gConfigurationData.skipCACheck(),
            )
            dRetVal = _updateFromRemoteLocation(oClient)
            if dRetVal["OK"]:
                self._refreshTime = gConfigurationData.getRefreshTime()
                return dRetVal
            else:
                updatingErrorsList.append(dRetVal["Message"])
                gLogger.warn(
                    "Can't update from server",
                    "Error while updating from %s: %s" %
                    (sServer, dRetVal["Message"]))
                if dRetVal["Message"].find("Insane environment") > -1:
                    break
        return S_ERROR("Reason(s):\n\t%s" %
                       "\n\t".join(List.uniqueElements(updatingErrorsList)))
示例#3
0
 def __lastRefreshExpired( self ):
   return time.time() - self.__lastUpdateTime >= gConfigurationData.getRefreshTime()
示例#4
0
 def __lastRefreshExpired(self):
     return time.time(
     ) - self.__lastUpdateTime >= gConfigurationData.getRefreshTime()
示例#5
0
 def _lastRefreshExpired(self):
     """
   Just returns if last refresh must be considered as expired or not
 """
     return time.time(
     ) - self._lastUpdateTime >= gConfigurationData.getRefreshTime()