def test_getStuffToCheck(self):
     for g in ValidRes:
         res = self.rsDB.getStuffToCheck(g, CS.getTypedDictRootedAt("CheckingFreqs/SitesFreqs"), 3)
         self.assertEqual(res, [])
         res = self.rsDB.getStuffToCheck(g, CS.getTypedDictRootedAt("CheckingFreqs/SitesFreqs"))
         self.assertEqual(res, [])
         res = self.rsDB.getStuffToCheck(g, None, None, "aaa")
         self.assertEqual(res, [])
Пример #2
0
 def test_getStuffToCheck(self):
     for g in ValidRes:
         res = self.rsDB.getStuffToCheck(
             g, CS.getTypedDictRootedAt("CheckingFreqs/SitesFreqs"), 3)
         self.assertEqual(res, [])
         res = self.rsDB.getStuffToCheck(
             g, CS.getTypedDictRootedAt("CheckingFreqs/SitesFreqs"))
         self.assertEqual(res, [])
         res = self.rsDB.getStuffToCheck(g, None, None, 'aaa')
         self.assertEqual(res, [])
Пример #3
0
  def initialize( self ):
    """ Standard constructor
    """

    try:
      self.rsDB = ResourceStatusDB()
      self.rmDB = ResourceManagementDB()

      self.StorageElementToBeChecked = Queue.Queue()
      self.StorageElementInCheck     = []

      self.maxNumberOfThreads = self.am_getOption( 'maxThreadsInPool', 1 )
      self.threadPool         = ThreadPool( self.maxNumberOfThreads,
                                            self.maxNumberOfThreads )

      if not self.threadPool:
        self.log.error( 'Can not create Thread Pool' )
        return S_ERROR( 'Can not create Thread Pool' )

      self.setup               = CS.getSetup()[ 'Value' ]
      self.VOExtension         = CS.getExt()
      self.StorageElsReadFreqs = CS.getTypedDictRootedAt("CheckingFreqs")[ 'StorageElsReadFreqs' ]
      self.nc                  = NotificationClient()
      self.diracAdmin          = DiracAdmin()
      self.csAPI               = CSAPI()

      for i in xrange( self.maxNumberOfThreads ):
        self.threadPool.generateJobAndQueueIt( self._executeCheck, args = ( None, ) )

      return S_OK()

    except Exception:
      errorStr = "StElReadInspectorAgent initialization"
      gLogger.exception( errorStr )
      return S_ERROR( errorStr )
Пример #4
0
  def _syncRegistryUsers(self):
    from DIRAC.ResourceStatusSystem.Utilities import CS
    users = CS.getTypedDictRootedAt("Users", root= "/Registry")
    for u in users:
      if type(users[u]['DN']) == list:
        users[u]['DN'] = users[u]['DN'][0]
      if type(users[u]['Email']) == list:
        users[u]['Email'] = users[u]['Email'][0]

      users[u]['DN'] = users[u]['DN'].split('=')[-1]
      self.rmDB.registryAddUser(u, users[u]['DN'].lower(), users[u]['Email'].lower())
Пример #5
0
    def _syncRegistryUsers(self):
        from DIRAC.ResourceStatusSystem.Utilities import CS
        users = CS.getTypedDictRootedAt("Users", root="/Registry")
        for u in users:
            if type(users[u]['DN']) == list:
                users[u]['DN'] = users[u]['DN'][0]
            if type(users[u]['Email']) == list:
                users[u]['Email'] = users[u]['Email'][0]

            users[u]['DN'] = users[u]['DN'].split('=')[-1]
            self.rmDB.registryAddUser(u, users[u]['DN'].lower(),
                                      users[u]['Email'].lower())
Пример #6
0
    def _syncRegistryUsers(self):
        users = CS.getTypedDictRootedAt("Users", root="/Registry")
        usersInCS = set(users.keys())
        #usersInDB = set((u[0] for u in Utils.unpack(self.rmClient.getUserRegistryCache())))

        usersInCache = self.rmClient.getUserRegistryCache()
        if not usersInCache['OK']:
            gLogger.error(usersInCache['Message'])
            return usersInCache

        usersInDB = set(
            [userInCache[0] for userInCache in usersInCache['Value']])

        usersToAdd = usersInCS - usersInDB
        usersToDel = usersInDB - usersInCS

        gLogger.info("Updating Registry Users: + %d, - %d" %
                     (len(usersToAdd), len(usersToDel)))
        if len(usersToAdd) > 0:
            gLogger.debug(str(usersToAdd))
        if len(usersToDel) > 0:
            gLogger.debug(str(usersToDel))

        for u in usersToAdd:
            if type(users[u]['DN']) == list:
                users[u]['DN'] = users[u]['DN'][0]
            if type(users[u]['Email']) == list:
                users[u]['Email'] = users[u]['Email'][0]
            users[u]['DN'] = users[u]['DN'].split('=')[-1]

            #Utils.unpack(self.rmClient.addOrModifyUserRegistryCache( u, users[u]['DN'], users[u]['Email'].lower()))

            res = self.rmClient.addOrModifyUserRegistryCache(
                u, users[u]['DN'], users[u]['Email'].lower())
            if not res['OK']:
                gLogger.error(res['Message'])
                return res

        for u in usersToDel:
            #Utils.protect2(self.rmClient.deleteUserRegistryCache, u)
            res = self.rmClient.deleteUserRegistryCache(u)
            if not res['OK']:
                gLogger.error(res['Message'])
                return res


################################################################################
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
Пример #7
0
  def _syncRegistryUsers(self):
    users = CS.getTypedDictRootedAt("Users", root= "/Registry")
    usersInCS = set(users.keys())
    #usersInDB = set((u[0] for u in Utils.unpack(self.rmClient.getUserRegistryCache())))
    
    usersInCache = self.rmClient.getUserRegistryCache()
    if not usersInCache[ 'OK' ]:
      gLogger.error( usersInCache[ 'Message' ] )
      return usersInCache
    
    usersInDB = set( [ userInCache[ 0 ] for userInCache in usersInCache[ 'Value' ] ] )
    
    usersToAdd = usersInCS - usersInDB
    usersToDel = usersInDB - usersInCS

    gLogger.info("Updating Registry Users: + %d, - %d" % (len(usersToAdd), len(usersToDel)))
    if len(usersToAdd) > 0:
      gLogger.debug(str(usersToAdd))
    if len(usersToDel) > 0:
      gLogger.debug(str(usersToDel))

    for u in usersToAdd:
      if type(users[u]['DN']) == list:
        users[u]['DN'] = users[u]['DN'][0]
      if type(users[u]['Email']) == list:
        users[u]['Email'] = users[u]['Email'][0]
      users[u]['DN'] = users[u]['DN'].split('=')[-1]
      
      #Utils.unpack(self.rmClient.addOrModifyUserRegistryCache( u, users[u]['DN'], users[u]['Email'].lower()))
      
      res = self.rmClient.addOrModifyUserRegistryCache( u, users[u]['DN'], users[u]['Email'].lower() )
      if not res[ 'OK' ]:
        gLogger.error( res[ 'Message' ] )
        return res

    for u in usersToDel:
      #Utils.protect2(self.rmClient.deleteUserRegistryCache, u)
      res = self.rmClient.deleteUserRegistryCache( u )
      if not res[ 'OK' ]:
        gLogger.error( res[ 'Message' ] )
        return res

################################################################################
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
Пример #8
0
def getUsersToNotify(setup, kwargs):
    """Get a list of users to notify (helper function for AlarmPolTypeActions)
  Optional keyword arguments:
  - Granularity
  - SiteType
  - ServiceType
  - ResourceType
  """

    notifications = []
    groups = CS.getTypedDictRootedAt("AssigneeGroups/" + setup)

    for k in groups:
        if Utils.dictMatch(kwargs, groups[k]):
            notifications.append({
                'Users': groups[k]['Users'],
                'Notifications': groups[k]['Notifications']
            })

    return notifications
Пример #9
0
    def _syncResources(self):
        gLogger.info("Starting sync of Resources")

        # resources in the DB now
        #resourcesInDB = set((r[0] for r in Utils.unpack(self.rsClient.getResource())))

        resources = self.rsClient.getResource()
        if not resources['OK']:
            gLogger.error(resources['Message'])
            return resources

        resourcesInDB = set([resource[0] for resource in resources['Value']])

        # Site-CE / Site-SE mapping in CS now
        #CEinCS = Utils.unpack(getSiteCEMapping( 'LCG' ))
        CEinCS = getSiteCEMapping('LCG')
        if not CEinCS['OK']:
            gLogger.error(CEinCS['Message'])
            return CEinCS
        CEinCS = CEinCS['Value']

        # All CEs in CS now
        CEInCS = Utils.set_sanitize(
            [CE for celist in CEinCS.values() for CE in celist])

        # All SE Nodes in CS now
        SENodeInCS = set(CS.getSENodes())

        # LFC Nodes in CS now
        LFCNodeInCS_L = set(CS.getLFCNode(readable="ReadOnly"))
        LFCNodeInCS_C = set(CS.getLFCNode(readable="ReadWrite"))

        # FTS Nodes in CS now
        FTSNodeInCS = set([
            v.split("/")[2][0:-5] for v in CS.getTypedDictRootedAt(
                root="/Resources/FTSEndpoints").values()
        ])

        # VOMS Nodes in CS now
        VOMSNodeInCS = set(CS.getVOMSEndpoints())

        # complete list of resources in CS now
        resourcesInCS = CEInCS | SENodeInCS | LFCNodeInCS_L | LFCNodeInCS_C | FTSNodeInCS | VOMSNodeInCS

        gLogger.info(
            "  %d resources in CS, %s resources in DB, updating %d resources" %
            (len(resourcesInCS), len(resourcesInDB),
             len(resourcesInCS) - len(resourcesInDB)))

        # Remove resources that are not in the CS anymore
        for res in resourcesInDB - resourcesInCS:
            gLogger.info("Purging resource %s. Reason: not in CS anywore." %
                         res)
            self.__purge_resource(res)

        # Add to DB what is in CS now and wasn't before

        # CEs
        for site in CEinCS:
            self.__syncNode(set(CEinCS[site]), resourcesInDB, "", "Computing",
                            site)

        # SRMs
        self.__syncNode(SENodeInCS, resourcesInDB, "SE", "Storage")

        # LFC_C
        self.__syncNode(LFCNodeInCS_C, resourcesInDB, "LFC_C", "Storage")

        # LFC_L
        self.__syncNode(LFCNodeInCS_L, resourcesInDB, "LFC_L", "Storage")

        # FTSs
        self.__syncNode(FTSNodeInCS, resourcesInDB, "FTS", "Storage")

        # VOMSs
        self.__syncNode(VOMSNodeInCS, resourcesInDB, "VOMS", "VOMS")
    def test_DBFail(self):
        self.mock_DB._query.return_value = {"OK": False, "Message": "boh"}
        self.mock_DB._update.return_value = {"OK": False, "Message": "boh"}
        from DIRAC.ResourceStatusSystem.DB.ResourceStatusDB import RSSDBException

        self.assertRaises(
            RSSDBException,
            self.rsDB.addOrModifySite,
            "CNAF",
            "T1",
            "INFN-FERRARA",
            "Banned",
            "test reason",
            datetime.datetime.utcnow(),
            "testOP",
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
        )
        self.assertRaises(RSSDBException, self.rsDB.setSiteStatus, "CNAF", "Active", "reasons", "Federico")
        self.assertRaises(
            RSSDBException,
            self.rsDB._addSiteRow,
            "Ferrara",
            "T2",
            "INFN-FERRARA",
            "Active",
            "reasons",
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            "Federico",
        )
        self.assertRaises(
            RSSDBException,
            self.rsDB._addSiteHistoryRow,
            "Ferrara",
            "Active",
            "reasons",
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            "Federico",
        )

        self.assertRaises(
            RSSDBException,
            self.rsDB.addOrModifyService,
            "Computing@CERN",
            "Computing",
            "CERN",
            "Banned",
            "test reason",
            datetime.datetime.utcnow(),
            "testOP",
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
        )
        self.assertRaises(RSSDBException, self.rsDB.setServiceStatus, "Computing@CERN", "Active", "reasons", "Federico")
        self.assertRaises(
            RSSDBException,
            self.rsDB._addServiceRow,
            "Computing@CERN",
            "Computing",
            "Ferrara",
            "Active",
            "reasons",
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            "Federico",
        )
        self.assertRaises(
            RSSDBException,
            self.rsDB._addServiceHistoryRow,
            "Computing@CERN",
            "Active",
            "reasons",
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            "Federico",
        )

        self.assertRaises(
            RSSDBException,
            self.rsDB.addOrModifyResource,
            "CE01",
            "T1",
            "Computing",
            "CNAF",
            "INFN-T1",
            "Banned",
            "test reason",
            datetime.datetime.utcnow(),
            "testOP",
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
        )
        self.assertRaises(RSSDBException, self.rsDB.setResourceStatus, "CE01", "Active", "reasons", "Federico")
        self.assertRaises(
            RSSDBException,
            self.rsDB._addResourcesRow,
            "CE01",
            "CE",
            "Computing",
            "Ferrara",
            "INFN-FE",
            "Active",
            "reasons",
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            "Federico",
        )
        self.assertRaises(
            RSSDBException,
            self.rsDB._addResourcesHistoryRow,
            "CE01",
            "Active",
            "reasons",
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            "Federico",
        )

        self.assertRaises(RSSDBException, self.rsDB.getStatusList)
        self.assertRaises(RSSDBException, self.rsDB.getEndings, "Resources")
        self.assertRaises(RSSDBException, self.rsDB.getTablesWithHistory)
        self.assertRaises(RSSDBException, self.rsDB.addStatus, "")
        self.assertRaises(RSSDBException, self.rsDB.removeStatus, "")
        self.assertRaises(RSSDBException, self.rsDB.setDateEnd, "Site", "CNAF", datetime.datetime.utcnow())
        self.assertRaises(RSSDBException, self.rsDB.setMonitoredToBeChecked, "Service", "Site", "CNAF")
        self.assertRaises(RSSDBException, self.rsDB.rankRes, "Site", 30)
        self.assertRaises(RSSDBException, self.rsDB.getServiceStats, "xxx")
        self.assertRaises(RSSDBException, self.rsDB.getResourceStats, "Site", "xxx")
        self.assertRaises(RSSDBException, self.rsDB.getStorageElementsStats, "Site", "xxx", "Read")
        self.assertRaises(RSSDBException, self.rsDB.getCountries, "Site")
        # print self.defaultTestResult()

        for g in ["Site", "Service", "Resource"]:
            self.assertRaises(RSSDBException, self.rsDB.getTypesList, g)
            self.assertRaises(RSSDBException, self.rsDB.removeType, g, "xx")

        for g in ValidRes:
            self.assertRaises(RSSDBException, self.rsDB.getMonitoredsList, g)
            self.assertRaises(
                RSSDBException, self.rsDB.getStuffToCheck, g, CS.getTypedDictRootedAt("CheckingFreqs/SitesFreqs"), 3
            )
            self.assertRaises(RSSDBException, self.rsDB.removeRow, g, "xx", datetime.datetime.utcnow())
            self.assertRaises(RSSDBException, self.rsDB.setLastMonitoredCheckTime, g, "xxx")
            self.assertRaises(RSSDBException, self.rsDB.setMonitoredReason, g, "xxx", "x", "x")
Пример #11
0
  def _syncResources( self ):
    gLogger.info("Starting sync of Resources")

    # resources in the DB now
    #resourcesInDB = set((r[0] for r in Utils.unpack(self.rsClient.getResource())))
    
    resources = self.rsClient.getResource()
    if not resources[ 'OK' ]:
      gLogger.error( resources[ 'Message' ] )
      return resources
    
    resourcesInDB = set( [ resource[ 0 ] for resource in resources[ 'Value' ] ] )
      
    # Site-CE / Site-SE mapping in CS now
    #CEinCS = Utils.unpack(getSiteCEMapping( 'LCG' ))
    CEinCS = getSiteCEMapping( 'LCG' )
    if not CEinCS[ 'OK' ]:
      gLogger.error( CEinCS[ 'Message' ] )
      return CEinCS
    CEinCS = CEinCS[ 'Value' ]

    # All CEs in CS now
    CEInCS = Utils.set_sanitize([CE for celist in CEinCS.values() for CE in celist])

    # All SE Nodes in CS now
    SENodeInCS = set(CS.getSENodes())

    # LFC Nodes in CS now
    LFCNodeInCS_L = set(CS.getLFCNode(readable = "ReadOnly"))
    LFCNodeInCS_C = set(CS.getLFCNode(readable = "ReadWrite"))

    # FTS Nodes in CS now
    FTSNodeInCS = set([v.split("/")[2][0:-5] for v
                       in CS.getTypedDictRootedAt(root="/Resources/FTSEndpoints").values()])

    # VOMS Nodes in CS now
    VOMSNodeInCS = set(CS.getVOMSEndpoints())

    # complete list of resources in CS now
    resourcesInCS = CEInCS | SENodeInCS | LFCNodeInCS_L | LFCNodeInCS_C | FTSNodeInCS | VOMSNodeInCS

    gLogger.info("  %d resources in CS, %s resources in DB, updating %d resources" %
                 (len(resourcesInCS), len(resourcesInDB), len(resourcesInCS)-len(resourcesInDB)))

    # Remove resources that are not in the CS anymore
    for res in resourcesInDB - resourcesInCS:
      gLogger.info("Purging resource %s. Reason: not in CS anywore." % res)
      self.__purge_resource(res)

    # Add to DB what is in CS now and wasn't before

    # CEs
    for site in CEinCS:
      self.__syncNode(set(CEinCS[site]), resourcesInDB, "", "Computing", site)

    # SRMs
    self.__syncNode(SENodeInCS, resourcesInDB, "SE", "Storage")

    # LFC_C
    self.__syncNode(LFCNodeInCS_C, resourcesInDB, "LFC_C", "Storage")

    # LFC_L
    self.__syncNode(LFCNodeInCS_L, resourcesInDB, "LFC_L", "Storage")

    # FTSs
    self.__syncNode(FTSNodeInCS, resourcesInDB, "FTS", "Storage")

    # VOMSs
    self.__syncNode(VOMSNodeInCS, resourcesInDB, "VOMS", "VOMS")
Пример #12
0
import unittest

from DIRAC.Core.Base import Script
Script.parseCommandLine()

from DIRAC.ResourceStatusSystem.Utilities.mock                  import Mock
from DIRAC.ResourceStatusSystem.Client.JobsClient               import JobsClient
from DIRAC.ResourceStatusSystem.Client.PilotsClient             import PilotsClient
from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient     import ResourceStatusClient
from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient

from DIRAC.ResourceStatusSystem.Utilities                       import CS

ValidRes = CS.getTypedDictRootedAt("GeneralConfig")['Resource']
ValidStatus = CS.getTypedDictRootedAt("GeneralConfig")['Status']

#############################################################################

class ClientsTestCase( unittest.TestCase ):
  """ Base class for the clients test cases
  """
  def setUp( self ):

    self.mockRSS = Mock()

    self.RSCli = ResourceStatusClient( serviceIn = self.mockRSS )
    self.RMCli = ResourceManagementClient( serviceIn = self.mockRSS )
    self.PilotsCli = PilotsClient()
    self.JobsCli = JobsClient()

#############################################################################
Пример #13
0
""" DIRAC.ResourceStatusSystem.Policy.Configurations Module

    collects everything needed to configure policies
"""

__RCSID__ = "$Id: "

from DIRAC.ResourceStatusSystem.Utilities import CS

pp = CS.getTypedDictRootedAt("PolicyParameters")

Policies = {
  'DT_OnGoing_Only' :
    {
      'Description' : "Ongoing down-times",
      'module'      : 'DT_Policy',
      'commandIn'   : ( 'GOCDBStatus_Command', 'GOCDBStatus_Command' ),
      'args'        : None
    },

  'DT_Scheduled' :
    {
      'Description'     : "Ongoing and scheduled down-times",
      'module'          : 'DT_Policy',
      'commandInNewRes' : ( 'GOCDBStatus_Command', 'GOCDBStatus_Command' ),
      'commandIn'       : ( 'GOCDBStatus_Command', 'DTCached_Command' ),
      'args'            : ( pp["DTinHours"], ),
      'Site_Panel'      : [ {'WebLink': {'CommandIn': ( 'GOCDBStatus_Command', 'DTInfo_Cached_Command' ),
                                         'args': None}},],
      'Resource_Panel'  : [ {'WebLink': {'CommandIn': ( 'GOCDBStatus_Command', 'DTInfo_Cached_Command' ),
                                         'args': None}}]
Пример #14
0
"""
DIRAC.ResourceStatusSystem package

"""

from DIRAC.ResourceStatusSystem.Utilities import CS

__gencfg = CS.getTypedDictRootedAt("GeneralConfig")

ValidRes = __gencfg['Resource']
ValidStatus = __gencfg['Status']
ValidPolicyResult = __gencfg['PolicyResult'] + __gencfg['Status']
ValidSiteType = __gencfg['SiteType']
ValidServiceType = __gencfg['ServiceType']
ValidResourceType = __gencfg['ResourceType']
ValidService = ValidServiceType
PolicyTypes = __gencfg['PolicyTypes']

CheckingFreqs = CS.getTypedDictRootedAt("CheckingFreqs")

#############################################################################
# Web views
#############################################################################

views_panels = {
    'Site': [
        'Site_Panel', 'Service_Computing_Panel', 'Service_Storage_Panel',
        'Service_VOMS_Panel', 'Service_VO-BOX_Panel'
    ],
    'Resource': ['Resource_Panel'],
    'StorageElement': ['SE_Panel']
Пример #15
0
"""
DIRAC.ResourceStatusSystem package

"""

from DIRAC.ResourceStatusSystem.Utilities import CS

__gencfg            = CS.getTypedDictRootedAt( "GeneralConfig" )

ValidRes          = __gencfg[ 'Resource' ]
ValidStatus       = __gencfg[ 'Status' ]
ValidPolicyResult = __gencfg[ 'PolicyResult' ] + __gencfg[ 'Status' ]
ValidSiteType     = __gencfg[ 'SiteType' ]
ValidServiceType  = __gencfg[ 'ServiceType' ]
ValidResourceType = __gencfg[ 'ResourceType' ]
ValidService      = ValidServiceType
PolicyTypes       = __gencfg[ 'PolicyTypes' ]

CheckingFreqs     = CS.getTypedDictRootedAt("CheckingFreqs")

#############################################################################
# Web views
#############################################################################

views_panels = {
  'Site' : ['Site_Panel', 'Service_Computing_Panel', 'Service_Storage_Panel',
            'Service_VOMS_Panel', 'Service_VO-BOX_Panel'],
  'Resource' : ['Resource_Panel'],
  'StorageElement' : ['SE_Panel']
}
Пример #16
0
    def test_DBFail(self):
        self.mock_DB._query.return_value = {'OK': False, 'Message': 'boh'}
        self.mock_DB._update.return_value = {'OK': False, 'Message': 'boh'}
        from DIRAC.ResourceStatusSystem.DB.ResourceStatusDB import RSSDBException

        self.assertRaises(
            RSSDBException, self.rsDB.addOrModifySite, 'CNAF',
            'T1', 'INFN-FERRARA', 'Banned', 'test reason',
            datetime.datetime.utcnow(), 'testOP',
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10))
        self.assertRaises(RSSDBException, self.rsDB.setSiteStatus, 'CNAF',
                          'Active', 'reasons', 'Federico')
        self.assertRaises(
            RSSDBException, self.rsDB._addSiteRow, 'Ferrara', 'T2',
            'INFN-FERRARA', 'Active', 'reasons', datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            'Federico')
        self.assertRaises(
            RSSDBException, self.rsDB._addSiteHistoryRow, 'Ferrara', 'Active',
            'reasons', datetime.datetime.utcnow(), datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            'Federico')

        self.assertRaises(
            RSSDBException, self.rsDB.addOrModifyService, 'Computing@CERN',
            'Computing', 'CERN', 'Banned', 'test reason',
            datetime.datetime.utcnow(), 'testOP',
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10))
        self.assertRaises(RSSDBException, self.rsDB.setServiceStatus,
                          'Computing@CERN', 'Active', 'reasons', 'Federico')
        self.assertRaises(
            RSSDBException, self.rsDB._addServiceRow, 'Computing@CERN',
            'Computing', 'Ferrara', 'Active', 'reasons',
            datetime.datetime.utcnow(), datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            'Federico')
        self.assertRaises(
            RSSDBException, self.rsDB._addServiceHistoryRow, 'Computing@CERN',
            'Active', 'reasons', datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            'Federico')

        self.assertRaises(
            RSSDBException, self.rsDB.addOrModifyResource, 'CE01', 'T1',
            'Computing', 'CNAF', 'INFN-T1', 'Banned', 'test reason',
            datetime.datetime.utcnow(), 'testOP',
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10))
        self.assertRaises(RSSDBException, self.rsDB.setResourceStatus, 'CE01',
                          'Active', 'reasons', 'Federico')
        self.assertRaises(
            RSSDBException, self.rsDB._addResourcesRow, 'CE01', 'CE',
            'Computing', 'Ferrara', 'INFN-FE', 'Active', 'reasons',
            datetime.datetime.utcnow(), datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            'Federico')
        self.assertRaises(
            RSSDBException, self.rsDB._addResourcesHistoryRow, 'CE01',
            'Active', 'reasons', datetime.datetime.utcnow(),
            datetime.datetime.utcnow(),
            datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
            'Federico')

        self.assertRaises(RSSDBException, self.rsDB.getStatusList)
        self.assertRaises(RSSDBException, self.rsDB.getEndings, 'Resources')
        self.assertRaises(RSSDBException, self.rsDB.getTablesWithHistory)
        self.assertRaises(RSSDBException, self.rsDB.addStatus, '')
        self.assertRaises(RSSDBException, self.rsDB.removeStatus, '')
        self.assertRaises(RSSDBException, self.rsDB.setDateEnd, 'Site', 'CNAF',
                          datetime.datetime.utcnow())
        self.assertRaises(RSSDBException, self.rsDB.setMonitoredToBeChecked,
                          'Service', 'Site', 'CNAF')
        self.assertRaises(RSSDBException, self.rsDB.rankRes, 'Site', 30)
        self.assertRaises(RSSDBException, self.rsDB.getServiceStats, 'xxx')
        self.assertRaises(RSSDBException, self.rsDB.getResourceStats, 'Site',
                          'xxx')
        self.assertRaises(RSSDBException, self.rsDB.getStorageElementsStats,
                          'Site', 'xxx', "Read")
        self.assertRaises(RSSDBException, self.rsDB.getCountries, 'Site')
        #print self.defaultTestResult()

        for g in ['Site', 'Service', 'Resource']:
            self.assertRaises(RSSDBException, self.rsDB.getTypesList, g)
            self.assertRaises(RSSDBException, self.rsDB.removeType, g, 'xx')

        for g in ValidRes:
            self.assertRaises(RSSDBException, self.rsDB.getMonitoredsList, g)
            self.assertRaises(
                RSSDBException, self.rsDB.getStuffToCheck, g,
                CS.getTypedDictRootedAt("CheckingFreqs/SitesFreqs"), 3)
            self.assertRaises(RSSDBException, self.rsDB.removeRow, g, 'xx',
                              datetime.datetime.utcnow())
            self.assertRaises(RSSDBException,
                              self.rsDB.setLastMonitoredCheckTime, g, 'xxx')
            self.assertRaises(RSSDBException, self.rsDB.setMonitoredReason, g,
                              'xxx', 'x', 'x')