class StorageElementsStatsCommand(Command): """ The StorageElementsStats_Command class is a command class to know about present storageElementss stats """ def __init__(self, args=None, clients=None): super(StorageElementsStatsCommand, self).__init__(args, clients) if 'ResourceStatusClient' in self.apis: self.rsClient = self.apis['ResourceStatusClient'] else: self.rsClient = ResourceStatusClient() def doCommand(self): """ Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getStorageElementStats` :params: :attr:`args`: a tuple - `args[0]` should be in ['Site', 'Resource'] - `args[1]` should be the name of the Site or Resource :returns: """ # try: if self.args[0] == 'Service': granularity = 'Site' name = self.args[1].split('@')[1] elif self.args[0] in ['Site', 'Resource']: granularity = self.args[0] name = self.args[1] else: return self.returnERROR( S_ERROR('%s is not a valid granularity' % self.args[0])) res = self.rsClient.getStorageElementStats(granularity, name, statusType=None) if not res['OK']: return self.returnERROR(res) # except Exception, e: # _msg = '%s (%s): %s' % ( self.__class__.__name__, self.args, e ) # gLogger.exception( _msg ) # return S_ERROR( _msg ) return res
class StorageElementsStatsCommand( Command ): """ The StorageElementsStats_Command class is a command class to know about present storageElementss stats """ def __init__( self, args = None, clients = None ): super( StorageElementsStatsCommand, self ).__init__( args, clients ) if 'ResourceStatusClient' in self.apis: self.rsClient = self.apis[ 'ResourceStatusClient' ] else: self.rsClient = ResourceStatusClient() def doCommand( self ): """ Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getStorageElementStats` :params: :attr:`args`: a tuple - `args[0]` should be in ['Site', 'Resource'] - `args[1]` should be the name of the Site or Resource :returns: """ # try: if self.args[0] == 'Service': granularity = 'Site' name = self.args[1].split( '@' )[1] elif self.args[0] in [ 'Site', 'Resource' ]: granularity = self.args[0] name = self.args[1] else: return self.returnERROR( S_ERROR( '%s is not a valid granularity' % self.args[ 0 ] ) ) res = self.rsClient.getStorageElementStats( granularity, name, statusType = None ) if not res[ 'OK' ]: return self.returnERROR( res ) # except Exception, e: # _msg = '%s (%s): %s' % ( self.__class__.__name__, self.args, e ) # gLogger.exception( _msg ) # return S_ERROR( _msg ) return res