本文整理汇总了Python中DIRAC.Interfaces.API.DiracAdmin.DiracAdmin.getBannedSites方法的典型用法代码示例。如果您正苦于以下问题:Python DiracAdmin.getBannedSites方法的具体用法?Python DiracAdmin.getBannedSites怎么用?Python DiracAdmin.getBannedSites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.Interfaces.API.DiracAdmin.DiracAdmin
的用法示例。
在下文中一共展示了DiracAdmin.getBannedSites方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_getSites
# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getBannedSites [as 别名]
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)
示例2: DiracAdmin
# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getBannedSites [as 别名]
########################################################################
# $HeadURL$
# File : dirac-admin-get-banned-sites
# Author : Stuart Paterson
########################################################################
__RCSID__ = "08edcb9 (2010-12-14 13:13:51 +0000) Ricardo Graciani <[email protected]>"
import DIRAC
from DIRAC.Core.Base import Script
Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
diracAdmin = DiracAdmin()
result = diracAdmin.getBannedSites( printOutput = False )
if result['OK']:
banned_sites = result['Value']
else:
print result['Message']
DIRAC.exit( 2 )
for site in banned_sites:
result = diracAdmin.getSiteMaskLogging( site )
if result['OK']:
sites = result['Value']
print '%-30s %s %s %s' % ( site, sites[site][-1][1], sites[site][-1][2], sites[site][-1][3] )
else:
print '%-30s %s' % ( site, result['Message'] )
DIRAC.exit( 0 )
示例3: SoftwareManagementAgent
# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getBannedSites [as 别名]
class SoftwareManagementAgent( AgentModule ):
""" Agent to run software management things
"""
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()
##############################################################################
def execute(self):
""" First we update the site list and banned site
"""
res = getProxyInfo(False, False)
if not res['OK']:
self.log.error("submitTasks: Failed to determine credentials for submission", res['Message'])
return res
proxyInfo = res['Value']
owner = proxyInfo['username']
ownerGroup = proxyInfo['group']
self.log.info("submitTasks: Jobs will be submitted with the credentials %s:%s" % (owner, ownerGroup))
sites = self.diracadmin.getSiteMask()['Value']
for site in sites:
res = self.ppc.changeSiteStatus( {'SiteName' : site, 'Status' : 'OK'} )
if not res['OK']:
self.log.error('Cannot add or update site %s' % site)
banned_sites = self.diracadmin.getBannedSites()['Value']
for banned_site in banned_sites:
self.ppc.changeSiteStatus( {'SiteName' : banned_site, 'Status' : 'Banned'} )
if not res['OK']:
self.log.error('Cannot mark as banned site %s' % banned_site)
##Then we need to get new installation tasks
res = self.ppc.getInstallSoftwareTask()
if not res['OK']:
self.log.error('Failed to obtain task')
task_dict = res['Value']
for softdict in task_dict.values():
self.log.info('Will install %s %s at %s' % (softdict['AppName'], softdict['AppVersion'], softdict['Sites']))
for site in softdict['Sites']:
j = UserJob()
j.setPlatform(softdict['Platform'])
j.dontPromptMe()
j.setDestination(site)
j.setJobGroup("Installation")
j.setName('install_%s' % site)
j._addSoftware(softdict['AppName'], softdict['AppVersion'])
#Add the application here somehow.
res = j.append(SoftwareInstall())
if not res['OK']:
self.log.error(res['Message'])
continue
res = j.submit(self.dirac)
#res = self.dirac.submit(j)
if not res['OK']:
self.log.error('Could not create the job')
continue
jobdict = {}
jobdict['AppName'] = softdict['AppName']
jobdict['AppVersion'] = softdict['AppVersion']
jobdict['Platform'] = softdict['Platform']
jobdict['JobID'] = res['Value']
jobdict['Status'] = 'Waiting'
jobdict['Site'] = site
res = self.ppc.addOrUpdateJob(jobdict)
if not res['OK']:
self.log.error('Could not add job %s: %s' % (jobdict['JobID'], res['Message']))
##Monitor jobs
jobs = {}
res = self.ppc.getJobs()
if not res['OK']:
self.log.error('Could not retrieve jobs')
else:
jobs = res['Value']
for job in jobs:
res = self.dirac.status(job['JobID'])
if res['OK']:
jobstatuses = res['Value']
job['Status'] = jobstatuses['JobID']['Status']
res = self.ppc.addOrUpdateJob(job)
if not res['OK']:
self.log.error("Failed to updated job %s: %s" % (job['JobID'], res['Message']))
else:
self.log.error("Failed to update job %s status" % job['JobID'])
return S_OK()
示例4: DiracAdmin
# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import getBannedSites [as 别名]
# File : dirac-admin-get-banned-sites
# Author : Stuart Paterson
########################################################################
__RCSID__ = "$Id$"
from DIRAC.Core.Base import Script
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()
from DIRAC import exit as DIRACExit
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
diracAdmin = DiracAdmin()
result = diracAdmin.getBannedSites()
if result['OK']:
bannedSites = result['Value']
else:
print result['Message']
DIRACExit(2)
for site in bannedSites:
result = diracAdmin.getSiteMaskLogging(site)
if result['OK']:
for siteLog in result['Value']:
print '%-30s %s %s %s' % (site, siteLog[0], siteLog[1], siteLog[2])
else:
print '%-30s %s' % (site, result['Message'])
DIRACExit(0)