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


Python DiracAdmin.DiracAdmin类代码示例

本文整理汇总了Python中DIRAC.Interfaces.API.DiracAdmin.DiracAdmin的典型用法代码示例。如果您正苦于以下问题:Python DiracAdmin类的具体用法?Python DiracAdmin怎么用?Python DiracAdmin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _sendMail

  def _sendMail( self, subject, body ):
    
    from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
    diracAdmin = DiracAdmin()
    
    address = InfoGetter().getNotificationsThatApply( self.decissionParams, self.actionName )
    if not address[ 'OK' ]:
      return address 
    address = address[ 'Value' ]
    
    for addressDict in address:
      if not 'name' in addressDict:
        return S_ERROR( 'Malformed address dict %s' % addressDict ) 
      if not 'users' in addressDict:
        return S_ERROR( 'Malformed address dict %s' % addressDict )     
      
      for user in addressDict[ 'users' ]:
      
      #FIXME: should not I get the info from the RSS User cache ?
      
        resEmail = diracAdmin.sendMail( user, subject, body )
        if not resEmail[ 'OK' ]:
          return S_ERROR( 'Cannot send email to user "%s"' % user )    
      
    return resEmail 
    
################################################################################
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
开发者ID:cgrefe,项目名称:DIRAC,代码行数:28,代码来源:EmailAction.py

示例2: _sendSMS

  def _sendSMS( self, text ):
    
    from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
    diracAdmin = DiracAdmin()
    
    address = InfoGetter().getNotificationsThatApply( self.decissionParams, self.actionName )
    if not address[ 'OK' ]:
      return address 
    address = address[ 'Value' ]
    
    for addressDict in address:
      if not 'name' in addressDict:
        return S_ERROR( 'Malformed address dict %s' % addressDict ) 
      if not 'users' in addressDict:
        return S_ERROR( 'Malformed address dict %s' % addressDict )     
      
      for user in addressDict[ 'users' ]:
      
        # Where are the SMS numbers defined ?
      
        resSMS = diracAdmin.sendSMS( user, text )
        if not resSMS[ 'OK' ]:
          return S_ERROR( 'Cannot send SMS to user "%s"' % user )    
      
    return resSMS 

################################################################################
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF    
开发者ID:cgrefe,项目名称:DIRAC,代码行数:28,代码来源:SMSAction.py

示例3: export_getSites

 def export_getSites(self):
   """ Get a full list of sites from the service
   """
   activeSites = []
   bannedSites = []
   # list banned sites
   diracAdmin = DiracAdmin()
   bannedSitesHandler = diracAdmin.getBannedSites(printOutput=False)
   if bannedSitesHandler['OK']:
     bannedNames = bannedSitesHandler['Value']
     for bannedName in bannedNames:
       history = diracAdmin.getSiteMaskLogging(bannedName)['Value'][bannedName][::-1]
       bannedSites.append({'name': bannedName, 'status': 'banned',  'swver': '2012-01-01', 'history': simplejson.dumps(history)})
   # list not banned sites
   wmsAdmin = RPCClient('WorkloadManagement/WMSAdministrator', timeout=120)
   siteMaskHandler = wmsAdmin.getSiteMask()
   if siteMaskHandler['OK']:
     activeNames = siteMaskHandler['Value']
     for siteName in activeNames:
       history = diracAdmin.getSiteMaskLogging(siteName)['Value'][siteName][::-1]
       activeSites.append({'name': siteName, 'status': 'ok', 'swver': '2012-11-02', 'history': simplejson.dumps(history)})
   # build list of all sites
   sitesList = []
   sitesList.extend(activeSites)
   sitesList.extend(bannedSites)
   if not sitesList:
     return S_ERROR()
   return S_OK(sitesList)
开发者ID:belle2,项目名称:belle2DIRAC,代码行数:28,代码来源:SiteManagementHandler.py

示例4: execute

 def execute(self):
   """ Get all New tags, mark them as Installing. Old Installing tags are reset to New 
   """
   #### get site mask ###
   diracAdmin = DiracAdmin()
   res = diracAdmin.getSiteMask(printOutput=False)
   if not res["OK"]:
       self.log.error("error retrieving site mask: %s"%str(res["Message"]))
   site_mask = res["Value"]
   res = self.swtc.getTagsWithStatus("New")
   if not res['OK']:
     return res
   if not res['Value']:
     self.log.info("No 'New' tags to consider")
     
   for tag, ces in res['Value'].items():
     for ce in ces: 
       res = getSiteForCEs([ce])
       if not res["OK"]:
           self.log.error("could not retrieve Site name for CE %s"%ce)
       sites = res["Value"].keys()
       for site in sites:
           if site not in site_mask:
               self.log.info("CE/Site disabled %s"%site)
               continue
               # ignore this CE
       res = self.swtc.updateCEStatus(tag, ce, 'Installing')
       if not res['OK']:
         self.log.error(res['Message'])
         continue
       res = None
     
       if self.submitjobs:
         res = self.submitProbeJobs(ce)
       else:
         res = self.swtc.updateCEStatus(tag, ce, 'Valid')
       
       if not res['OK']:
         self.log.error(res['Message'])
       else:
         self.log.info("Done with %s at %s" %(tag, ce))
    
   ##Also, reset to New tags that were in Probing for too long.
   res = self.swtc.getTagsWithStatus("Installing", self.delay)
   if not res['OK']:
     self.log.error("Failed to get old 'Installing' tags")
   else:
     if not res['Value']:
       self.log.info("No 'Installing' tags to reset")
       
     for tag, ces in res['Value'].items():
       for ce in ces:
         res = self.swtc.updateCEStatus(tag, ce, 'New')
         if not res['OK']:
           self.log.error(res['Message'])
           continue
   return S_OK()
开发者ID:brianv0,项目名称:GlastDIRAC,代码行数:57,代码来源:SoftwareMonitorAgent.py

示例5: getPilotLoggingInfo

def getPilotLoggingInfo(gridID):
    output = ""
    diracAdmin = DiracAdmin()
    result = diracAdmin.getPilotLoggingInfo( gridID )
    if not result['OK']:
        output = 'ERROR retrieving pilot logging info, %s'%str(result['Message'])
        gLogger.error(output)
    else:
        output = result['Value']
    return output
开发者ID:Glast,项目名称:GlastDIRAC,代码行数:10,代码来源:dirac-glast-get-stalled-pilot-info.py

示例6: browseUsers

 def browseUsers(self):
   diracAdmin = DiracAdmin()
   names = diracAdmin.csListUsers('belle')['Value']
   users = diracAdmin.csDescribeUsers(names)['Value']
   c.usersData = []
   for name in names:
     email = users[name]['Email']
     dn = users[name]['DN']
     c.usersData.append({'name': name, 'email': email, 'dn': dn})
   return render("/systems/sitemanagement/browseUsers.mako")
开发者ID:belle2,项目名称:belle2DIRAC,代码行数:10,代码来源:sitemanagement.py

示例7: doCommand

  def doCommand( self ):
    '''
      It returns the status of a given CE.

      :return:
        a dictionary with status of each CE queues,
        and 'status' and 'reason' of the CE itself

    '''

    ## INPUT PARAMETERS
    vos = getVOs()
    if vos[ 'OK' ]:
      vo = vos['Value'].pop()
    else:
      return S_ERROR( "No appropriate VO was found! %s" % vos['Message'] )

    if 'ce' not in self.args:
      return S_ERROR( "No computing element 'ce' has been specified!" )
    else:
      ce = self.args['ce']

    host = self.args.get('host')

    #getting BDII info
    diracAdmin = DiracAdmin()
    ceQueues = diracAdmin.getBDIICEState( ce,
                                          useVO = vo,
                                          host = host )
    if not ceQueues['OK']:
      return S_ERROR( '"CE" not found on BDII' )
    elements = ceQueues['Value']

    #extracting the list of CE queues and their status
    result = {}
    for element in elements:
      queue = element.get('GlueCEUniqueID','Unknown') #pylint: disable=no-member
      statusQueue = element.get('GlueCEStateStatus','Unknown') #pylint: disable=no-member
      result[queue] = statusQueue.capitalize()

    #establishing the status of the CE itself
    result['Status'] = 'Production'
    result['Reason'] = "All queues in 'Production'"
    for key, value in result.items():
      #warning: it may not be the case that all queues for a given CE
      #show the same status. In case of mismatch, the status of the CE
      #will be associated to a non-production status
      if key not in ['Status', 'Reason'] and value != 'Production':
        result['Status'] = value
        result['Reason'] = "Queue %s is in status %s" % ( queue, value )

    return S_OK( result )
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:52,代码来源:CEAvailabilityCommand.py

示例8: initialize

  def initialize( self ):
    ''' EmailAgent initialization
    '''

    self.diracAdmin = DiracAdmin()

    return S_OK()
开发者ID:ahaupt,项目名称:DIRAC,代码行数:7,代码来源:EmailAgent.py

示例9: getInfo

def getInfo(params):
  '''
    Retrieve information from BDII
  '''

  from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
  diracAdmin = DiracAdmin()

  if params['info'] == 'ce':
    result = diracAdmin.getBDIICE(params['ce'], host=params['host'])
  if params['info'] == 'ce-state':
    result = diracAdmin.getBDIICEState(params['ce'], useVO=params['vo'], host=params['host'])
  if params['info'] == 'ce-cluster':
    result = diracAdmin.getBDIICluster(params['ce'], host=params['host'])
  if params['info'] == 'ce-vo':
    result = diracAdmin.getBDIICEVOView(params['ce'], useVO=params['vo'], host=params['host'])
  if params['info'] == 'site':
    result = diracAdmin.getBDIISite(params['site'], host=params['host'])
  if params['info'] == 'site-se':
    result = diracAdmin.getBDIISE(params['site'], useVO=params['vo'], host=params['host'])

  if not result['OK']:
    print result['Message']
    DIRAC.exit(2)

  return result
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:26,代码来源:dirac-admin-bdii-info.py

示例10: initialize

 def initialize(self):
   self.pollingTime = self.am_getOption('PollingTime', 86400)
   gMonitor.registerActivity("Iteration", "Agent Loops", AGENT_NAME, "Loops/min", gMonitor.OP_SUM)
   self.ppc = ProcessProdClient()
   self.dirac = DiracILC()
   self.diracadmin = DiracAdmin()
   self.am_setOption( 'shifterProxy', 'Admin' )
   
   return S_OK()
开发者ID:akiyamiyamoto,项目名称:ilddirac,代码行数:9,代码来源:SoftwareManagementAgent.py

示例11: addUserToCS

def addUserToCS(clip, userProps):
  """Add the user to the CS, return list of errors"""
  from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
  diracAdmin = DiracAdmin()
  exitCode = 0
  errorList = []

  if not diracAdmin.csModifyUser( clip.uname, userProps, createIfNonExistant = True )['OK']:
    errorList.append( ( "add user", "Cannot register user: '%s'" % clip.uname ) )
    exitCode = 255
  else:
    result = diracAdmin.csCommitChanges()
    if not result[ 'OK' ]:
      errorList.append( ( "commit", result[ 'Message' ] ) )
      exitCode = 255
  for error in errorList:
    gLogger.error( "%s: %s" % error )
  if exitCode:
    dexit(exitCode)
开发者ID:LCDsoft,项目名称:ILCDIRAC,代码行数:19,代码来源:dirac-ilc-add-user.py

示例12: __getSitesMaskStatus

  def __getSitesMaskStatus( self, sitesName ):
    diracAdmin = DiracAdmin()
    activeSites = diracAdmin.getSiteMask()
#    wmsAdmin = RPCClient( 'WorkloadManagement/WMSAdministrator' )
#    activeSites = wmsAdmin.getSiteMask()

    if not activeSites[ 'OK' ]:
      return activeSites
    activeSites = activeSites[ 'Value' ]

    sitesStatus = {}

    for siteName in sitesName:
      if siteName in activeSites:
        sitesStatus[ siteName ] = 'Active'
      else:
        sitesStatus[ siteName ] = 'Banned'

    return S_OK( sitesStatus )
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:19,代码来源:SiteStatusMonitorHandler.py

示例13: initialize

  def initialize( self ):
    ''' TokenAgent initialization
    '''

    self.notifyHours = self.am_getOption( 'notifyHours', self.notifyHours )
    self.adminMail   = self.am_getOption( 'adminMail', self.adminMail )

    self.rsClient = ResourceStatusClient()
    self.diracAdmin = DiracAdmin()

    return S_OK()
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:11,代码来源:TokenAgent.py

示例14: initialize

  def initialize( self ):
    """Sets defaults
    """

    self.am_setOption( 'PollingTime', 120 )
    self.am_setOption( 'GridEnv', '' )
    self.am_setOption( 'PilotStalledDays', 3 )
    self.pilotDB = PilotAgentsDB()
    self.diracadmin = DiracAdmin()
    self.jobDB = JobDB()
    return S_OK()
开发者ID:cj501885963,项目名称:DIRAC,代码行数:11,代码来源:PilotStatusAgent.py

示例15: __init__

 def __init__(self, cliParams ):
   from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
   self.diracAdmin = DiracAdmin()
   self.modifiedCS = False
   self.softSec = "/Operations/Defaults/AvailableTarBalls"
   self.mailadress = '[email protected]'
   self.cliParams = cliParams
   self.parameter = dict( softSec = self.softSec,
                          platform = cliParams.platform,
                          version = cliParams.version,
                          basepath = cliParams.basePath,
                          initsctipt = cliParams.initScriptLocation
                        )
   self.applications = cliParams.applicationList
开发者ID:akiyamiyamoto,项目名称:ilddirac,代码行数:14,代码来源:dirac-ilc-add-cvmfs-software.py


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