def do_removetagfromdb(self,argss):
     """ forget tag (drop in DB)
         *** USE WITH ABSOLUTE CARE!!! ***
         *** only used by OPERATORS ***
         cleantag tag
     """
     args = argss.split()
     if len(args)<1:
         print self.do_removetagfromdb.__doc__
         return
     tag = args[0]
     completed = False
     ces_removed = 0
     print "Removing tag %s from DB"%tag
     for i in range(3):
         # ask 3 times!
         res = PromptUser.promptUser("Are you REALLY sure?!", choices=['y','n'], default='n')
         if not res['OK']:
             return
         elif res['Value'] != 'y':
             return
     while not completed:
         res = self.client.cleanTagAtSite(tag,"ALL")
         if not res['OK']:
             print "Failed to remove tag %s: %s"%(tag,res['Message'])
         elif res['OK'] and len(res['Value']['Failed'])!=0:
             print 'Failed to remove tag %s in %i CEs'%(tag,len(res['Value']['Failed']))
         else:
             completed = True
             ces_removed+=len(res['Value']['Successful'])
     print "Removed %s from %i CEs"%(tag,ces_removed)
 def do_removetagfromdb(self, argss):
     """ forget tag (drop in DB)
         *** USE WITH ABSOLUTE CARE!!! ***
         *** only used by OPERATORS ***
         cleantag tag
     """
     args = argss.split()
     if len(args) < 1:
         print self.do_removetagfromdb.__doc__
         return
     tag = args[0]
     completed = False
     ces_removed = 0
     print "Removing tag %s from DB" % tag
     for i in range(3):
         # ask 3 times!
         res = PromptUser.promptUser("Are you REALLY sure?!",
                                     choices=['y', 'n'],
                                     default='n')
         if not res['OK']:
             return
         elif res['Value'] != 'y':
             return
     while not completed:
         res = self.client.cleanTagAtSite(tag, "ALL")
         if not res['OK']:
             print "Failed to remove tag %s: %s" % (tag, res['Message'])
         elif res['OK'] and len(res['Value']['Failed']) != 0:
             print 'Failed to remove tag %s in %i CEs' % (
                 tag, len(res['Value']['Failed']))
         else:
             completed = True
             ces_removed += len(res['Value']['Successful'])
     print "Removed %s from %i CEs" % (tag, ces_removed)
 def do_forcestatus(self, args):
     """ update status of tag, site or both
         *** USE WITH ABSOLUTE CARE!!! ***
         forcestatus tag <tag> <status> [<site>] : the entire tag is set for all sites, site is optional.
         forcestatus site <site> <status> : all tags at the site are updated 
         status can only be Valid, Bad, and New
     """
     argss = args.split()
     if (len(argss) == 0):
         print self.do_forcestatus.__doc__
         return
     option = argss[0]
     del argss[0]
     res = tag = site = status = None
     if option == "site":
         if len(argss) < 1:
             print self.do_forcestatus.__doc__
         tag = ""
         site = argss[0]
         status = argss[1]
     elif option == "tag":
         if len(argss) < 1:
             print self.do_forcestatus.__doc__
         site = "ALL"
         tag = argss[0]
         status = argss[1]
         if len(argss) == 3:
             site = argss[-1]
     else:
         print "ERROR parsing command"
         print self.do_forcestatus.__doc__
         return
     if status not in ['Bad', 'New', 'Valid']:
         print "ERROR invalid status"
         print self.do_forcestatus.__doc__
         return
     if status == 'New' and tag == "":
         if site == "ALL":
             print "ERROR bad boy, you should never reset the entire DB!!"
             return
         else:
             print 'Resetting all tags at site %s' % site
     print "Force update to status=%s:\nsites=%s\ntags=%s " % (status, site,
                                                               tag)
     res = PromptUser.promptUser("Are you sure?!",
                                 choices=['y', 'n'],
                                 default='n')
     if not res['OK']:
         return
     elif res['Value'] != 'y':
         return
     res = self.client.updateStatus(tag, site, status)
     if not res['OK']:
         print 'Message: %s' % res['Message']
     elif res['Value']['Failed']:
         print 'Failed to update %s' % res['Value']['Failed']
     else:
         print 'Successfully updated %i CEs' % len(
             res['Value']['Successful'])
     return
 def do_forcestatus(self,args):
     """ update status of tag, site or both
         *** USE WITH ABSOLUTE CARE!!! ***
         forcestatus tag <tag> <status> [<site>] : the entire tag is set for all sites, site is optional.
         forcestatus site <site> <status> : all tags at the site are updated 
         status can only be Valid, Bad, and New
     """
     argss = args.split()
     if (len(argss)==0):
         print self.do_forcestatus.__doc__
         return
     option = argss[0]
     del argss[0]
     res = tag = site = status = None
     if option == "site":
         if len(argss)<1:
             print self.do_forcestatus.__doc__
         tag = ""
         site = argss[0]
         status = argss[1]
     elif option == "tag":
         if len(argss)<1:
             print self.do_forcestatus.__doc__
         site = "ALL"
         tag = argss[0]
         status = argss[1]
         if len(argss)==3:
             site = argss[-1]
     else:
         print "ERROR parsing command"
         print self.do_forcestatus.__doc__
         return
     if status not in ['Bad','New','Valid']:
         print "ERROR invalid status"
         print self.do_forcestatus.__doc__
         return
     if status == 'New' and tag == "":
         if site == "ALL":
             print "ERROR bad boy, you should never reset the entire DB!!"
             return
         else:
             print 'Resetting all tags at site %s'%site
     print "Force update to status=%s:\nsites=%s\ntags=%s "%(status,site,tag)
     res = PromptUser.promptUser("Are you sure?!", choices=['y','n'], default='n')
     if not res['OK']:
         return
     elif res['Value'] != 'y':
         return
     res = self.client.updateStatus(tag,site,status)
     if not res['OK']:
         print 'Message: %s'%res['Message']
     elif res['Value']['Failed']:
         print 'Failed to update %s'%res['Value']['Failed']
     else:
         print 'Successfully updated %i CEs'%len(res['Value']['Successful'])
     return