当前位置: 首页>>代码示例>>Python>>正文


Python ResourceStatusClient.getStorageElementsStats方法代码示例

本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient.getStorageElementsStats方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceStatusClient.getStorageElementsStats方法的具体用法?Python ResourceStatusClient.getStorageElementsStats怎么用?Python ResourceStatusClient.getStorageElementsStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient的用法示例。


在下文中一共展示了ResourceStatusClient.getStorageElementsStats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: StorageElementsStats_Command

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import getStorageElementsStats [as 别名]
class StorageElementsStats_Command( Command ):
  """
  The StorageElementsStats_Command class is a command class to know about
  present storageElementss stats
  """

  def doCommand( self ):
    """
    Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getStorageElementsStats`

    :params:
      :attr:`args`: a tuple
        - `args[0]` should be in ['Site', 'Resource']

        - `args[1]` should be the name of the Site or Resource

    :returns:

    """
    super( StorageElementsStats_Command, self ).doCommand()

    if self.args[0] in ( 'Service', 'Services' ):
      granularity = 'Site'
      name = self.args[1].split( '@' )[1]
    elif self.args[0] in ( 'Site', 'Sites', 'Resource', 'Resources' ):
      granularity = self.args[0]
      name = self.args[1]
    else:
      raise InvalidRes, where( self, self.doCommand )

    if self.client is None:
      from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient
      self.client = ResourceStatusClient( timeout = self.timeout )

    try:
      resR = self.client.getStorageElementsStats( granularity, name, 'Read' )['Value']
      resW = self.client.getStorageElementsStats( granularity, name, 'Write' )['Value']
    except:
      gLogger.exception( "Exception when calling ResourceStatusClient for %s %s" % ( granularity, name ) )
      return {'Result':'Unknown'}

    res = {}
    for key in ValidStatus:
      res[ key ] = resR[ key ] + resW[ key ]

    return {'Result':res}

  doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:50,代码来源:RS_Command.py

示例2: StorageElementsStats_Command

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import getStorageElementsStats [as 别名]
class StorageElementsStats_Command(Command):
    """
  The StorageElementsStats_Command class is a command class to know about
  present storageElementss stats
  """

    def doCommand(self):
        """
    Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getStorageElementsStats`

    :params:
      :attr:`args`: a tuple
        - `args[0]` should be in ['Site', 'Resource']

        - `args[1]` should be the name of the Site or Resource

    :returns:

    """
        super(StorageElementsStats_Command, self).doCommand()

        if self.args[0] in ("Service", "Services"):
            granularity = "Site"
            name = self.args[1].split("@")[1]
        elif self.args[0] in ("Site", "Sites", "Resource", "Resources"):
            granularity = self.args[0]
            name = self.args[1]
        else:
            raise InvalidRes, where(self, self.doCommand)

        if self.client is None:
            from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient

            self.client = ResourceStatusClient(timeout=self.timeout)

        try:
            res = self.client.getStorageElementsStats(granularity, name)
        except:
            gLogger.exception("Exception when calling ResourceStatusClient for %s %s" % (granularity, name))
            return {"Result": "Unknown"}

        return {"Result": res}

    doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
开发者ID:roiser,项目名称:DIRAC,代码行数:46,代码来源:RS_Command.py


注:本文中的DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient.getStorageElementsStats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。