Ejemplo n.º 1
0
    def doCommand(self):
        """ 
    Return getServiceInfo from SLS Client
    
    :attr:`args`: 
     - args[0]: string: should be a ValidRes

     - args[1]: string: should be the (DIRAC) name of the ValidRes

     - args[2]: list: list of info requested
    """
        super(SLSServiceInfo_Command, self).doCommand()

        if self.client is None:
            from DIRAC.Core.LCG.SLSClient import SLSClient
            self.client = SLSClient()

        if self.args[0] == 'StorageElement':
            #know the SLS name of the SE
            SLSName = _getCastorSESLSName(self.args[1])
        elif self.args[0] == 'Service':
            #know the SLS name of the VO BOX
            SLSName = _getServiceSLSName(self.args[1], self.args[2])
        else:
            raise InvalidRes, where(self, self.doCommand)

        try:
            #gLogger.info(SLSName,self.args[2])
            res = self.client.getServiceInfo(SLSName,
                                             self.args[2],
                                             timeout=self.timeout)
            if not res['OK']:
                gLogger.error("No SLS sensors for " + self.args[0] + " " +
                              self.args[1])
                return {'Result': None}
            return {'Result': res['Value']}
        except urllib2.HTTPError:
            gLogger.error("No (not all) SLS sensors for " + self.args[0] +
                          " " + self.args[1])
            return {'Result': None}
        except urllib2.URLError:
            gLogger.error("SLS timed out for " + self.args[0] + " " +
                          self.args[1])
            return {'Result': 'Unknown'}
        except:
            gLogger.exception("Exception when calling SLSClient for " +
                              self.args[0] + " " + self.args[1])
            return {'Result': 'Unknown'}
Ejemplo n.º 2
0
    def doCommand(self):
        """ 
    Return getStatus from SLS Client
    
    :attr:`args`: 
     - args[0]: string: should be a ValidRes

     - args[1]: string: should be the (DIRAC) name of the ValidRes

     - args[2]: string: should be the ValidRes type (e.g. 'VO-BOX')
    """
        super(SLSStatus_Command, self).doCommand()

        if self.client is None:
            from DIRAC.Core.LCG.SLSClient import SLSClient
            self.client = SLSClient()

        if self.args[0] == 'StorageElement':
            #know the SLS name of the SE
            SLSName = _getSESLSName(self.args[1])
        elif self.args[0] == 'Service':
            #know the SLS name of the VO BOX
            SLSName = _getServiceSLSName(self.args[1], self.args[2])
        else:
            raise InvalidRes, where(self, self.doCommand)

        try:
            res = self.client.getAvailabilityStatus(SLSName,
                                                    timeout=self.timeout)
            if not res['OK']:
                gLogger.error("No SLS sensors for " + self.args[0] + " " +
                              self.args[1])
                return {'Result': None}
            return {'Result': res['Value']}
        except urllib2.URLError:
            gLogger.error("SLS timed out for " + self.args[0] + " " +
                          self.args[1])
            return {'Result': 'Unknown'}
        except:
            gLogger.exception("Exception when calling SLSClient for %s" %
                              SLSName)
            return {'Result': 'Unknown'}
Ejemplo n.º 3
0
    def doCommand(self):
        """ 
    Return getLink from SLS Client
    
    :attr:`args`: 
      - args[0]: string: should be a ValidRes

      - args[1]: string: should be the (DIRAC) name of the ValidRes
    """
        super(SLSLink_Command, self).doCommand()

        if self.client is None:
            from DIRAC.Core.LCG.SLSClient import SLSClient
            self.client = SLSClient()

        if self.args[0] in ('StorageElementRead', 'StorageElementWrite'):
            #know the SLS name of the SE
            SLSName = _getSESLSName(self.args[1])
        elif self.args[0] == 'Service':
            #know the SLS name of the VO BOX
            SLSName = _getServiceSLSName(self.args[1], self.args[2])
        else:
            raise InvalidRes, where(self, self.doCommand)

        try:
            res = self.client.getLink(SLSName)
            if not res['OK']:
                gLogger.error("No SLS sensors for " + self.args[0] + " " +
                              self.args[1])
                return {'Result': None}
            return {'Result': res['Value']}
        except urllib2.URLError:
            gLogger.error("SLS timed out for " + self.args[0] + " " +
                          self.args[1])
            return {'Result': 'Unknown'}
        except:
            gLogger.exception("Exception when calling SLSClient")
            return {'Result': 'Unknown'}