Esempio n. 1
0
 def servicestate(inputDict, **kwargs):
     """ Set Service State in DB """
     # Only 2 Services are supported to report via URL
     # DTNRM-Agent and DTNRM-Ruler
     if inputDict['servicename'] not in ['Agent', 'Ruler']:
         raise NotFoundError(
             'This Service %s is not supported by Frontend' %
             inputDict['servicename'])
     reportServiceStatus(inputDict['servicename'],
                         inputDict['servicestate'], kwargs['sitename'],
                         None, inputDict['hostname'])
Esempio n. 2
0
 def updatehost(self, inputDict, **kwargs):
     """ Update Host in DB.
         Must provide dictionary with:
             ip       -> ip of new host
         Example:
             GOOD: {"ip": "1.2.3.4", "site": "T2_US_Caltech", "status": "benchhmark",
                    "hostype": "gridftp", "port": 11234}"""
     # Validate that these entries are known...
     dbobj = getVal(self.dbI, **kwargs)
     host = dbobj.get('hosts', limit=1, search=[['ip', inputDict['ip']]])
     if not host:
         raise NotFoundError(
             'This IP %s is not registered at all. Call addhost' %
             inputDict['ip'])
     out = {
         'id': host[0]['id'],
         'hostname': inputDict['hostname'],
         'ip': inputDict['ip'],
         'updatedate': getUTCnow(),
         'hostinfo': str(inputDict)
     }
     dbobj.update('hosts', [out])
     return
Esempio n. 3
0
def getAllFileContent(inputFile):
    """ Get all file content as a string """
    if os.path.isfile(inputFile):
        with open(inputFile, 'r') as fd:
            return fd.read()
    raise NotFoundError('File %s was not found on the system.' % inputFile)