Exemplo n.º 1
0
optP.add_option('--unban',action='store_const',const=True,dest='unban',default=False,help='unban the user')

options,args = optP.parse_args()

if options.user == None:
    print "--user=<prodUserName> is required"
    sys.exit(1)

proxyS = DBProxy()
proxyS.connect(panda_config.dbhost,panda_config.dbpasswd,panda_config.dbuser,panda_config.dbname)

prodUserName = sys.argv[1]
import userinterface.Client as Client

varMap = {}
varMap[':name'] = options.user
if options.unban:
    varMap[':status'] = None
else:
    varMap[':status'] = 'disabled'
    
sql = "UPDATE ATLAS_PANDAMETA.users SET status=:status WHERE name=:name"

status,res = proxyS.querySQLS(sql,varMap)
if res == None:
    print "Failed with database error"
else:
    print "%s rows updated" % res
    

Exemplo n.º 2
0
varMap[':currentPriority'] = args[0]
sql = "SELECT PandaID,currentPriority FROM %s WHERE prodSourceLabel=:prodSourceLabel AND currentPriority<:currentPriority "
if options.killRunning:
    sql += "AND jobStatus=:jobStatus "
    varMap[':jobStatus'] = 'running'
if options.cloud != None:
    sql += "AND cloud=:cloud "
    varMap[':cloud'] = options.cloud
if options.site != None:
    sql += "AND computingSite=:site "
    varMap[':site'] = options.site
for table in [
        'ATLAS_PANDA.jobsActive4', 'ATLAS_PANDA.jobsWaiting4',
        'ATLAS_PANDA.jobsDefined4'
]:
    status, res = proxyS.querySQLS(sql % table, varMap)
    if res != None:
        for id, prio in res:
            if not jobsMap.has_key(prio):
                jobsMap[prio] = []
            if not id in jobsMap[prio]:
                jobsMap[prio].append(id)

# order by PandaID and currentPriority
jobs = []
prioList = jobsMap.keys()
prioList.sort()
for prio in prioList:
    # reverse order by PandaID to kill newer jobs
    ids = jobsMap[prio]
    ids.sort()
Exemplo n.º 3
0
proxyS = DBProxy()
proxyS.connect(panda_config.dbhost,panda_config.dbpasswd,panda_config.dbuser,panda_config.dbname)

jobs = []

varMap = {}
varMap[':prodSourceLabel'] = options.prodSourceLabel
varMap[':taskID'] = args[0]
if not options.noRunning or options.killAny:
    sql = "SELECT PandaID FROM %s WHERE prodSourceLabel=:prodSourceLabel AND taskID=:taskID ORDER BY PandaID"
else:
    sql = "SELECT PandaID FROM %s WHERE prodSourceLabel=:prodSourceLabel AND taskID=:taskID AND NOT jobStatus IN (:js1,:js2) ORDER BY PandaID"
    varMap[':js1'] = 'running'
    varMap[':js2'] = 'transferring'
for table in ['ATLAS_PANDA.jobsActive4','ATLAS_PANDA.jobsWaiting4','ATLAS_PANDA.jobsDefined4']:
    status,res = proxyS.querySQLS(sql % table,varMap)
    if res != None:
        for id, in res:
            if not id in jobs:
                jobs.append(id)

print 'The number of jobs to be killed for prodSourceLabel={0} taskID={1}: {2}'.format(options.prodSourceLabel,
                                                                                       args[0],
                                                                                       len(jobs))
if len(jobs):
    nJob = 100
    iJob = 0
    while iJob < len(jobs):
        print 'kill %s' % str(jobs[iJob:iJob+nJob])
        if options.forceKill:
            Client.killJobs(jobs[iJob:iJob+nJob],9)
Exemplo n.º 4
0
import sys
from taskbuffer.OraDBProxy import DBProxy

from dataservice import AddressFinder

# password
from config import panda_config
passwd = panda_config.dbpasswd

# instantiate DB proxies
proxyS = DBProxy(True)
proxyS.connect(panda_config.dbhost,panda_config.dbpasswd,panda_config.dbuser,panda_config.dbname)

# get DN and address
status,res = proxyS.querySQLS("SELECT dn,email,name FROM ATLAS_PANDAMETA.users",{},arraySize=1000000)
if res == None:
    print "SQL error"
    sys.exit(0)

# to upper chrs
def toUpper(emails):
    retA = []
    for email in emails:
        retA.append(email.upper())
    return retA

outF = open('newemail.sql','w')

for dn,origEmail,name in res:
    if dn == None:
        dn = name
Exemplo n.º 5
0
                default=False,
                help='unban the user')

options, args = optP.parse_args()

if options.user == None:
    print "--user=<prodUserName> is required"
    sys.exit(1)

proxyS = DBProxy()
proxyS.connect(panda_config.dbhost, panda_config.dbpasswd, panda_config.dbuser,
               panda_config.dbname)

prodUserName = sys.argv[1]
import userinterface.Client as Client

varMap = {}
varMap[':name'] = options.user
if options.unban:
    varMap[':status'] = None
else:
    varMap[':status'] = 'disabled'

sql = "UPDATE ATLAS_PANDAMETA.users SET status=:status WHERE name=:name"

status, res = proxyS.querySQLS(sql, varMap)
if res == None:
    print "Failed with database error"
else:
    print "%s rows updated" % res