Beispiel #1
0
def create_tool(tool):
    """
    Create an instance of a tool.
    
    Reads configuration file based on a section:
    
    [plugin-<tool>]
    module=<python module>
    class=<python class>
    
    @param tool: The tool identifier.    
    @return: Instance of a tool.
    """
    try:    
        section = 'plugin-%s' % tool
        modname = config.get_config('module',  str, section=section, mandatory=True)
        clsname = config.get_config('class',  str, section=section, mandatory=True)
        
        mod = __import__(modname)
        comp = modname.split('.')
        for c in comp[1:]:
            mod = getattr(mod, c)
        
        return getattr(mod, clsname)(section)
    except Exception as e:
        raise Exception ('Unable to initialize plug-in %s [%s]' % (tool, e))
Beispiel #2
0
 def __init__(self):
     
     popularityInterface = config.get_config('popularityInterface', type = str)
     if popularityInterface:
         self.__popularityInterface = popularityInterface           
     
     self.__popularity = create_tool(self.__popularityInterface)
            
     creationlimit = config.get_config('creationlimit', int)        
     if creationlimit is not None:
         self.__creationlimit = creationlimit     
     
     thresholds = config.get_config('thresholds', list)
     lastaccess= config.get_config('lastaccess', 'list_2')
     
     is_parsed=self.__parseThresholds__(thresholds, lastaccess)
     if is_parsed:
         self.__logger.info('Successfully parsed the thresholds: %s'%str(self.__thresholds))
     else:
         self.__logger.error('Failed to parse thresholds from configuration file. Using default ones: %s'%str(self.__thresholds))
     
     # parse algorithm2 parameters
     algorithm2_spacetokens   = config.get_config('algorithm2_spacetokens'   ,list)
     if algorithm2_spacetokens is None:
         algorithm2_spacetokens = []
     algorithm2_creationlimit = config.get_dict  ('algorithm2_creationlimit' ,type='positive_int')        
     self.__algorithm2_spacetokens , self.__algorithm2_creationlimit = self.__verifyAlgorithm2param(algorithm2_spacetokens,
                                                                                                    algorithm2_creationlimit)
     self.__logger.debug('Algorithm2_spacetokens   : %s'%self.__algorithm2_spacetokens)
     self.__logger.debug('Algorithm2_creationlimit : %s'%self.__algorithm2_creationlimit)
Beispiel #3
0
 def __init__(self):
     
     popularityInterface = config.get_config('popularityInterface', type = str)
     if popularityInterface:
         self.__popularityInterface = popularityInterface           
     
     self.__popularity = create_tool(self.__popularityInterface)
            
     creationlimit = config.get_config('creationlimit', int)        
     if creationlimit is not None:
         self.__creationlimit = creationlimit     
     
     thresholds = config.get_config('thresholds', list)
     lastaccess= config.get_config('lastaccess', 'list_2')
     
     is_parsed=self.__parseThresholds__(thresholds, lastaccess)
     if is_parsed:
         self.__logger.info('Successfully parsed the thresholds: %s'%str(self.__thresholds))
     else:
         self.__logger.error('Failed to parse thresholds from configuration file. Using default ones: %s'%str(self.__thresholds))
     
     # parse algorithm2 parameters
     algorithm2_spacetokens   = config.get_config('algorithm2_spacetokens', list)
     if algorithm2_spacetokens is None:
         algorithm2_spacetokens = []
     algorithm2_creationlimit = config.get_dict  ('algorithm2_creationlimit', type='positive_int')        
     self.__algorithm2_spacetokens, self.__algorithm2_creationlimit = self.__verifyAlgorithm2param(algorithm2_spacetokens,
                                                                                                    algorithm2_creationlimit)
     self.__logger.debug('Algorithm2_spacetokens   : %s'%self.__algorithm2_spacetokens)
     self.__logger.debug('Algorithm2_creationlimit : %s'%self.__algorithm2_creationlimit)
Beispiel #4
0
    def __init__(self):

        user = config.get_config('db_user', type='str')
        password = config.get_config('db_password', type='str')
        connectionName = config.get_config('db_conn', type='str')
        if not user or not password or not connectionName:
            raise Exception('No DB connection specified in configuration file')

        connection_string = '%s/%s@%s' % (user, password, connectionName)
        self.__connection = cx_Oracle.Connection(connection_string)
        self.__logger = logging.getLogger('dq2.victor.victorDao')
Beispiel #5
0
    def __init__(self):

        user           = config.get_config('db_user', type='str')
        password       = config.get_config('db_password', type='str')
        connectionName = config.get_config('db_conn', type='str')
        if not user or not password or not connectionName:
            raise Exception('No DB connection specified in configuration file')
        
        connection_string = '%s/%s@%s'%(user, password, connectionName)
        self.__connection = cx_Oracle.Connection(connection_string)
        self.__logger = logging.getLogger('dq2.victor.victorDao')
Beispiel #6
0
 def __init__(self):
                                
     accountingInterface = config.get_config('accountingInterface', type = str)
     if accountingInterface:
         self.__accountingInterface = accountingInterface           
     
     self.__accounting = create_tool(self.__accountingInterface)
Beispiel #7
0
    def __init__(self):

        accountingInterface = config.get_config('accountingInterface',
                                                type=str)
        if accountingInterface:
            self.__accountingInterface = accountingInterface

        self.__accounting = create_tool(self.__accountingInterface)
Beispiel #8
0
def get_json_data_https(url):
	
    headers = {"Accept": "application/json", "User-Agent": "Victor"}
    req = urllib2.Request(url=url,headers=headers)
    cert = config.get_config('certificate', type='str')
    key = config.get_config('privatekey', type='str')

    opener = urllib2.build_opener(HTTPSClientAuthHandler(cert=cert,key=key))
    f = opener.open(req)
    data = simplejson.load(f)
    f.close()

    if not data:
        logger.critical('Node usage values could not be retrieved from %s'%(url))
        raise Exception('Nodatafound', 'Node usage values could not be retrieved from %s'%(url))

    return data
Beispiel #9
0
You may not use this file except in compliance with the License.
You may obtain a copy of the License at U{http://www.apache.org/licenses/LICENSE-2.0}
"""

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Utils import formatdate

from dq2.victor import config

__SUBJECT = '[Victor notification]'
__SIGNATURE = 'This is an automatically generated notification. Please do not reply to this mail.'

__stopAlerts = True
stopAlerts = config.get_config('stopAlerts', type=bool)
if stopAlerts is not None:
    __activateAlerts = stopAlerts

__opsRecipients = [
    '*****@*****.**', '*****@*****.**'
]
opsRecipients = config.get_config('opsRecipients', type=list)
if opsRecipients:
    __opsRecipients = opsRecipients

__devRecipients = [
    '*****@*****.**', '*****@*****.**'
]
devRecipients = config.get_config('devRecipients', type=list)
if devRecipients:
Beispiel #10
0
You may obtain a copy of the License at U{http://www.apache.org/licenses/LICENSE-2.0}
"""


import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Utils import formatdate

from dq2.victor import config

__SUBJECT='[Victor notification]'
__SIGNATURE='This is an automatically generated notification. Please do not reply to this mail.'

__stopAlerts=True
stopAlerts = config.get_config('stopAlerts', type=bool)
if stopAlerts is not None:
    __activateAlerts = stopAlerts

__opsRecipients=['*****@*****.**', '*****@*****.**']
opsRecipients = config.get_config('opsRecipients', type=list)
if opsRecipients:
    __opsRecipients = opsRecipients
    
__devRecipients=['*****@*****.**', '*****@*****.**']
devRecipients = config.get_config('devRecipients', type=list)
if devRecipients:
    __devRecipients = devRecipients                  
        
#Development: Overwrite temporarily
__opsRecipients=['*****@*****.**']