Exemple #1
0
 def getListOfHosts():
     """
 Return the list of all hosts that constitute a DIRAC instance
 """
     client = ComponentMonitoringClient()
     result = client.getHosts({}, False, False)
     if result['OK']:
         hosts = [host['HostName'] for host in result['Value']]
         return S_OK(hosts)
     return S_ERROR('Cannot get list of hosts: %s' % result['Message'])
Exemple #2
0
    def web_getSysInfo(self):

        userData = self.getSessionData()

        DN = str(userData["user"]["DN"])
        group = str(userData["user"]["group"])

        callback = []

        # self.finish( { "success" : "false" , "error" : "No system information found" } )
        # return
        """
    client = SystemAdministratorIntegrator( delegatedDN = DN ,
                                          delegatedGroup = group )
    resultHosts = yield self.threadTask( client.getHostInfo )
    if resultHosts[ "OK" ]:
      hosts = resultHosts['Value']
      for i in hosts:
        if hosts[i]['OK']:
          host = hosts[i]['Value']
          host['Host'] = i
          callback.append( host )
        else:
          callback.append( {'Host':i} )
    else:
      self.finish( { "success" : "false" , "error" :  resultHosts['Message']} )
    """

        callback = []

        client = ComponentMonitoringClient()
        result = client.getHosts({}, False, False)
        if result['OK']:
            hosts = result['Value']

            for obj in hosts:
                host = obj['HostName']
                client = SystemAdministratorClient(host,
                                                   None,
                                                   delegatedDN=DN,
                                                   delegatedGroup=group)
                resultHost = yield self.threadTask(client.getHostInfo)
                if resultHost["OK"]:
                    resultHost["Value"]["Host"] = host
                    if "Timestamp" in resultHost["Value"]:
                        resultHost["Value"]["Timestamp"] = str(
                            resultHost["Value"]["Timestamp"])
                    callback.append(resultHost["Value"])
                else:
                    callback.append({"Host": host})

        total = len(callback)
        if not total > 0:
            self.finish({
                "success": "false",
                "error": "No system information found"
            })
            return

        callback = sorted(callback, key=lambda i: i['Host'])

        # Add the information about the extensions' versions, if available, to display along with the DIRAC version
        for i in range(len(callback)):
            if 'Extension' in callback[i]:
                #We have to keep the backward compatibility (this can heppen when we do not update one host to v6r15 ...
                callback[i]['DIRAC'] = '%s,%s' % (callback[i].get(
                    'DIRACVersion',
                    callback[i].get('DIRAC')), callback[i]['Extension'])
            elif 'Extensions' in callback[i]:
                callback[i]['DIRAC'] = '%s,%s' % (callback[i].get(
                    'DIRAC',
                    callback[i].get('DIRAC')), callback[i]['Extensions'])

        self.finish({"success": "true", "result": callback, "total": total})
  def web_getSysInfo( self ):

    userData = self.getSessionData()

    DN = str( userData["user"]["DN"] )
    group = str( userData["user"]["group"] )

    callback = []


    # self.finish( { "success" : "false" , "error" : "No system information found" } )
    # return
    """
    client = SystemAdministratorIntegrator( delegatedDN = DN ,
                                          delegatedGroup = group )
    resultHosts = yield self.threadTask( client.getHostInfo )
    if resultHosts[ "OK" ]:
      hosts = resultHosts['Value']
      for i in hosts:
        if hosts[i]['OK']:
          host = hosts[i]['Value']
          host['Host'] = i
          callback.append( host )
        else:
          callback.append( {'Host':i} )
    else:
      self.finish( { "success" : "false" , "error" :  resultHosts['Message']} )
    """

    callback = []

    client = ComponentMonitoringClient()
    result = client.getHosts( {}, False, False )
    if result[ 'OK' ]:
      hosts = result[ 'Value' ]

      for obj in hosts:
        host = obj[ 'HostName' ]
        client = SystemAdministratorClient( host , None , delegatedDN = DN ,
                                            delegatedGroup = group )
        resultHost = yield self.threadTask( client.getHostInfo )
        if resultHost[ "OK" ]:
          resultHost[ "Value" ][ "Host" ] = host
          if "Timestamp" in resultHost[ "Value" ]:
            resultHost[ "Value" ][ "Timestamp" ] = str( resultHost[ "Value" ][ "Timestamp" ] )
          callback.append( resultHost[ "Value" ] )
        else:
          callback.append( { "Host":host } )

    total = len( callback )
    if not total > 0:
      self.finish( { "success" : "false" , "error" : "No system information found" } )
      return

    callback = sorted(callback, key=lambda i: i['Host'])

    # Add the information about the extensions' versions, if available, to display along with the DIRAC version
    for i in range( len( callback ) ):
      if 'Extension' in callback[ i ]:
        #We have to keep the backward compatibility (this can heppen when we do not update one host to v6r15 ...
        callback[ i ][ 'DIRAC' ] = '%s,%s' % ( callback[ i ].get( 'DIRACVersion', callback[ i ].get( 'DIRAC' ) ) , callback[ i ][ 'Extension' ] )
      elif 'Extensions' in callback[ i ]:
        callback[ i ][ 'DIRAC' ] = '%s,%s' % ( callback[ i ].get( 'DIRAC', callback[ i ].get( 'DIRAC' ) ) , callback[ i ][ 'Extensions' ] )

    self.finish( { "success" : "true" , "result" : callback , "total" : total } )