def _getStatus(self, name, panel): #get RSS status RSSStatus = self._getInfoFromRSSDB(name, panel)[0][1] #get DIRAC status if panel in ('Site_Panel', 'SE_Panel'): if panel == 'Site_Panel': DIRACStatus = self.WMSAdmin.getSiteMaskLogging(name) if DIRACStatus['OK']: DIRACStatus = DIRACStatus['Value'][name].pop()[0] else: raise RSSException, Utils.where(self, self._getStatus) elif panel == 'SE_Panel': ra = getStorageElementStatus(name, 'ReadAccess')['Value'] wa = getStorageElementStatus(name, 'WriteAccess')['Value'] DIRACStatus = {'ReadAccess': ra, 'WriteAccess': wa} status = { name : { 'RSSStatus': RSSStatus, 'DIRACStatus': DIRACStatus } } else: status = { name : { 'RSSStatus': RSSStatus} } return status
def _getStatus(self, name, panel): #get RSS status RSSStatus = self._getInfoFromRSSDB(name, panel)[0][1] #get DIRAC status if panel in ('Site_Panel', 'SE_Panel'): if panel == 'Site_Panel': DIRACStatus = self.WMSAdmin.getSiteMaskLogging(name) if DIRACStatus['OK']: DIRACStatus = DIRACStatus['Value'][name].pop()[0] else: raise RSSException, where(self, self._getStatus) elif panel == 'SE_Panel': ra = getStorageElementStatus(name, 'ReadAccess')['Value'] wa = getStorageElementStatus(name, 'WriteAccess')['Value'] DIRACStatus = {'ReadAccess': ra, 'WriteAccess': wa} status = { name: { 'RSSStatus': RSSStatus, 'DIRACStatus': DIRACStatus } } else: status = {name: {'RSSStatus': RSSStatus}} return status
def _RealBanPolTypeActions(self, res, da, csAPI, setup): # implement real ban if res['Action']: if self.__granularity == 'Site': banList = da.getBannedSites() if not banList['OK']: raise RSSException, where(self, self.enforce) + banList['Message'] else: banList = banList['Value'] if res['Status'] == 'Banned': if self.__name not in banList: banSite = da.banSiteFromMask(self.__name, res['Reason']) if not banSite['OK']: raise RSSException, where(self, self.enforce) + banSite['Message'] if 'Production' in setup: address = getOperationMails('Production')['Value'] else: address = '*****@*****.**' subject = '%s is banned for %s setup' %(self.__name, setup) body = 'Site %s is removed from site mask for %s ' %(self.__name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' %(time.asctime()) body += 'Comment:\n%s' %res['Reason'] sendMail = da.sendMail(address,subject,body) if not sendMail['OK']: raise RSSException, where(self, self.enforce) + sendMail['Message'] else: if self.__name in banList: addSite = da.addSiteInMask(self.__name, res['Reason']) if not addSite['OK']: raise RSSException, where(self, self.enforce) + addSite['Message'] if setup == 'LHCb-Production': address = getOperationMails('Production')['Value'] else: address = '*****@*****.**' subject = '%s is added in site mask for %s setup' %(self.__name, setup) body = 'Site %s is added to the site mask for %s ' %(self.__name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' %(time.asctime()) body += 'Comment:\n%s' %res['Reason'] sendMail = da.sendMail(address,subject,body) if not sendMail['OK']: raise RSSException, where(self, self.enforce) + sendMail['Message'] elif self.__granularity == 'StorageElement': presentReadStatus = getStorageElementStatus( self.__name, 'ReadAccess')['Value'] # presentWriteStatus = getStorageElementStatus( self.__name, 'WriteAccess')['Value'] if res['Status'] == 'Banned': if presentReadStatus != 'InActive': banSE = csAPI.setOption("/Resources/StorageElements/%s/ReadAccess" %(self.__name), "InActive") if not banSE['OK']: raise RSSException, where(self, self.enforce) + banSE['Message'] banSE = csAPI.setOption("/Resources/StorageElements/%s/WriteAccess" %(self.__name), "InActive") if not banSE['OK']: raise RSSException, where(self, self.enforce) + banSE['Message'] commit = csAPI.commit() if not commit['OK']: raise RSSException, where(self, self.enforce) + commit['Message'] if 'Production' in setup: address = getSetup()['Value'] else: address = '*****@*****.**' subject = '%s is banned for %s setup' %(self.__name, setup) body = 'SE %s is removed from mask for %s ' %(self.__name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' %(time.asctime()) body += 'Comment:\n%s' %res['Reason'] sendMail = da.sendMail(address,subject,body) if not sendMail['OK']: raise RSSException, where(self, self.enforce) + sendMail['Message'] else: if presentReadStatus == 'InActive': allowSE = csAPI.setOption("/Resources/StorageElements/%s/ReadAccess" %(self.__name), "Active") if not allowSE['OK']: raise RSSException, where(self, self.enforce) + allowSE['Message'] allowSE = csAPI.setOption("/Resources/StorageElements/%s/WriteAccess" %(self.__name), "Active") if not allowSE['OK']: raise RSSException, where(self, self.enforce) + allowSE['Message'] commit = csAPI.commit() if not commit['OK']: raise RSSException, where(self, self.enforce) + commit['Message'] if setup == 'LHCb-Production': address = getSetup()['Value'] else: address = '*****@*****.**' subject = '%s is allowed for %s setup' %(self.__name, setup) body = 'SE %s is added to the mask for %s ' %(self.__name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' %(time.asctime()) body += 'Comment:\n%s' %res['Reason'] sendMail = da.sendMail(address,subject,body) if not sendMail['OK']: raise RSSException, where(self, self.enforce) + sendMail['Message']
def RealBanPolTypeActions(granularity, name, res, da, csAPI, setup): # implement real ban if res['Action']: if granularity == 'Site': banList = da.getBannedSites() if not banList['OK']: raise RSSException, where(self, self.enforce) + banList['Message'] else: banList = banList['Value'] if res['Status'] == 'Banned': if name not in banList: banSite = da.banSiteFromMask(name, res['Reason']) if not banSite['OK']: raise RSSException, where( self, self.enforce) + banSite['Message'] if 'Production' in setup: address = getOperationMails('Production')['Value'] else: address = '*****@*****.**' subject = '%s is banned for %s setup' % (name, setup) body = 'Site %s is removed from site mask for %s ' % ( name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' % ( time.asctime()) body += 'Comment:\n%s' % res['Reason'] sendMail = da.sendMail(address, subject, body) if not sendMail['OK']: raise RSSException, where( self, self.enforce) + sendMail['Message'] else: if name in banList: addSite = da.addSiteInMask(name, res['Reason']) if not addSite['OK']: raise RSSException, where( self, self.enforce) + addSite['Message'] if setup == 'LHCb-Production': address = getOperationMails('Production')['Value'] else: address = '*****@*****.**' subject = '%s is added in site mask for %s setup' % (name, setup) body = 'Site %s is added to the site mask for %s ' % ( name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' % ( time.asctime()) body += 'Comment:\n%s' % res['Reason'] sendMail = da.sendMail(address, subject, body) if not sendMail['OK']: raise RSSException, where( self, self.enforce) + sendMail['Message'] elif granularity == 'StorageElement': presentReadStatus = getStorageElementStatus(name, 'ReadAccess')['Value'] if res['Status'] == 'Banned': if presentReadStatus != 'InActive': banSE = csAPI.setOption( "/Resources/StorageElements/%s/ReadAccess" % (name), "InActive") if not banSE['OK']: raise RSSException, where( self, self.enforce) + banSE['Message'] banSE = csAPI.setOption( "/Resources/StorageElements/%s/WriteAccess" % (name), "InActive") if not banSE['OK']: raise RSSException, where( self, self.enforce) + banSE['Message'] commit = csAPI.commit() if not commit['OK']: raise RSSException, where( self, self.enforce) + commit['Message'] if 'Production' in setup: address = getSetup()['Value'] else: address = '*****@*****.**' subject = '%s is banned for %s setup' % (name, setup) body = 'SE %s is removed from mask for %s ' % (name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' % ( time.asctime()) body += 'Comment:\n%s' % res['Reason'] sendMail = da.sendMail(address, subject, body) if not sendMail['OK']: raise RSSException, where( self, self.enforce) + sendMail['Message'] else: if presentReadStatus == 'InActive': allowSE = csAPI.setOption( "/Resources/StorageElements/%s/ReadAccess" % (name), "Active") if not allowSE['OK']: raise RSSException, where( self, self.enforce) + allowSE['Message'] allowSE = csAPI.setOption( "/Resources/StorageElements/%s/WriteAccess" % (name), "Active") if not allowSE['OK']: raise RSSException, where( self, self.enforce) + allowSE['Message'] commit = csAPI.commit() if not commit['OK']: raise RSSException, where( self, self.enforce) + commit['Message'] if setup == 'LHCb-Production': address = getSetup()['Value'] else: address = '*****@*****.**' subject = '%s is allowed for %s setup' % (name, setup) body = 'SE %s is added to the mask for %s ' % (name, setup) body += 'setup by the DIRAC RSS on %s.\n\n' % ( time.asctime()) body += 'Comment:\n%s' % res['Reason'] sendMail = da.sendMail(address, subject, body) if not sendMail['OK']: raise RSSException, where( self, self.enforce) + sendMail['Message']
def RealBanPolTypeActions(granularity, name, res, da, csAPI, setup): # implement real ban if res["Action"]: if granularity == "Site": banList = da.getBannedSites() if not banList["OK"]: raise RSSException, where(self, self.enforce) + banList["Message"] else: banList = banList["Value"] if res["Status"] == "Banned": if name not in banList: banSite = da.banSiteFromMask(name, res["Reason"]) if not banSite["OK"]: raise RSSException, where(self, self.enforce) + banSite["Message"] if "Production" in setup: address = getOperationMails("Production")["Value"] else: address = "*****@*****.**" subject = "%s is banned for %s setup" % (name, setup) body = "Site %s is removed from site mask for %s " % (name, setup) body += "setup by the DIRAC RSS on %s.\n\n" % (time.asctime()) body += "Comment:\n%s" % res["Reason"] sendMail = da.sendMail(address, subject, body) if not sendMail["OK"]: raise RSSException, where(self, self.enforce) + sendMail["Message"] else: if name in banList: addSite = da.addSiteInMask(name, res["Reason"]) if not addSite["OK"]: raise RSSException, where(self, self.enforce) + addSite["Message"] if setup == "LHCb-Production": address = getOperationMails("Production")["Value"] else: address = "*****@*****.**" subject = "%s is added in site mask for %s setup" % (name, setup) body = "Site %s is added to the site mask for %s " % (name, setup) body += "setup by the DIRAC RSS on %s.\n\n" % (time.asctime()) body += "Comment:\n%s" % res["Reason"] sendMail = da.sendMail(address, subject, body) if not sendMail["OK"]: raise RSSException, where(self, self.enforce) + sendMail["Message"] elif granularity == "StorageElement": presentReadStatus = getStorageElementStatus(name, "ReadAccess")["Value"] if res["Status"] == "Banned": if presentReadStatus != "InActive": banSE = csAPI.setOption("/Resources/StorageElements/%s/ReadAccess" % (name), "InActive") if not banSE["OK"]: raise RSSException, where(self, self.enforce) + banSE["Message"] banSE = csAPI.setOption("/Resources/StorageElements/%s/WriteAccess" % (name), "InActive") if not banSE["OK"]: raise RSSException, where(self, self.enforce) + banSE["Message"] commit = csAPI.commit() if not commit["OK"]: raise RSSException, where(self, self.enforce) + commit["Message"] if "Production" in setup: address = getSetup()["Value"] else: address = "*****@*****.**" subject = "%s is banned for %s setup" % (name, setup) body = "SE %s is removed from mask for %s " % (name, setup) body += "setup by the DIRAC RSS on %s.\n\n" % (time.asctime()) body += "Comment:\n%s" % res["Reason"] sendMail = da.sendMail(address, subject, body) if not sendMail["OK"]: raise RSSException, where(self, self.enforce) + sendMail["Message"] else: if presentReadStatus == "InActive": allowSE = csAPI.setOption("/Resources/StorageElements/%s/ReadAccess" % (name), "Active") if not allowSE["OK"]: raise RSSException, where(self, self.enforce) + allowSE["Message"] allowSE = csAPI.setOption("/Resources/StorageElements/%s/WriteAccess" % (name), "Active") if not allowSE["OK"]: raise RSSException, where(self, self.enforce) + allowSE["Message"] commit = csAPI.commit() if not commit["OK"]: raise RSSException, where(self, self.enforce) + commit["Message"] if setup == "LHCb-Production": address = getSetup()["Value"] else: address = "*****@*****.**" subject = "%s is allowed for %s setup" % (name, setup) body = "SE %s is added to the mask for %s " % (name, setup) body += "setup by the DIRAC RSS on %s.\n\n" % (time.asctime()) body += "Comment:\n%s" % res["Reason"] sendMail = da.sendMail(address, subject, body) if not sendMail["OK"]: raise RSSException, where(self, self.enforce) + sendMail["Message"]