Exemplo n.º 1
0
    def getConfig(self):

        acf = self.fcl.get('Factory', 'authConf')
        self.log.debug('authmanager config file(s) = %s' % acf)
        acl = ConfigManager().getConfig(sources=acf)
        self.log.debug('successfully read config file(s) %s' % acf)
        return acl
Exemplo n.º 2
0
    def __createconfig(self):
        """Create config, add in options...
        """
        if self.options.confFiles != None:
            try:
                self.fcl = ConfigManager().getConfig(self.options.confFiles)
            except ConfigFailure:
                self.log.error('Failed to create FactoryConfigLoader')
                sys.exit(1)

        self.fcl.set("Factory", "cyclesToDo", str(self.options.cyclesToDo))
        self.fcl.set("Factory", "sleepTime", str(self.options.sleepTime))
        self.fcl.set("Factory", "confFiles", self.options.confFiles)
Exemplo n.º 3
0
    def _mappings(self):

        # Handle mappings configuration
        self.mappingscl = None  # mappings config loader object
        self.mappingscf = self.fcl.generic_get('Factory', 'mappingsConf')
        self.log.debug("mappings.conf file(s) = %s" % self.mappingscf)

        try:
            self.mappingscl = ConfigManager().getConfig(self.mappingscf)
        except ConfigFailure:
            self.log.error('Failed to create ConfigLoader object for mappings')
            sys.exit(0)

        self.log.debug("mappingscl is %s" % self.mappingscl)
Exemplo n.º 4
0
    def _queues_monitor_conf(self):

        # Handle monitor configuration
        self.mcl = None
        self.mcf = self.fcl.generic_get('Factory', 'monitorConf')
        self.log.debug("monitor.conf file(s) = %s" % self.mcf)

        try:
            self.mcl = ConfigManager().getConfig(self.mcf)
        except ConfigFailure:
            self.log.error('Failed to create MonitorConfigLoader')
            sys.exit(0)

        self.log.debug("mcl is %s" % self.mcl)
Exemplo n.º 5
0
    def _updateInfo(self):

        qcl = None

        # 1. we try to read the list of files in queueConf and create a config loader
        qcf = None
        try:
            qcf = self.fcl.get('Factory', 'queueConf')    # the configuration files for queues are a list of URIs
            self.log.debug("queues.conf file(s) = %s" % qcf)
            qcl_files = ConfigManager().getConfig(sources=qcf)
            self.log.debug("successfully read config file(s) %s" % qcf)
        except Exception, e:
            self.log.error("Exception: %s" % str(e))
            self.log.error(traceback.format_exc(None))
Exemplo n.º 6
0
class File(ConfigInterface):

    def __init__(self, factory, config, section):

        self.log = logging.getLogger('autopyfactory.config')
        self.factory = factory
        self.fcl = config
        self.qcl = None
        self.log.info('ConfigPlugin: Object initialized.')

    def _updateInfo(self):

        qcl = None

        # 1. we try to read the list of files in queueConf and create a config loader
        qcf = None
        try:
            qcf = self.fcl.get('Factory', 'queueConf')    # the configuration files for queues are a list of URIs
            self.log.debug("queues.conf file(s) = %s" % qcf)
            qcl_files = ConfigManager().getConfig(sources=qcf)
            self.log.debug("successfully read config file(s) %s" % qcf)
        except Exception, e:
            self.log.error("Exception: %s" % str(e))
            self.log.error(traceback.format_exc(None))

        
        # 2. we try to read the directory in queueDirConf and create a config loader
        qcd = None
        try:
            qcd = self.fcl.get('Factory', 'queueDirConf') # the configuration files for queues are in a directory
            if qcd == "None" or qcd == "":
                qcd = None
            if qcd:
                # FIXME : temporary solution. 
                #         The ConfigManager.getConfig( ) method should know how to handle properly empty directories
                if not os.path.isdir(qcd) or os.listdir(qcd) == []:
                    self.log.warning("queues.conf directory = %s does not exist or it is empty" % qcd)
                    qcd = None
                else:
                    self.log.debug("queues.conf directory = %s" % qcd)
                    qcl_dir = ConfigManager().getConfig(configdir=qcd)

        except Exception, e:
            self.log.error("Exception: %s" % str(e))
            self.log.error(traceback.format_exc(None))
Exemplo n.º 7
0
    if o == '--conf':
        conffile = a
    if o == '--activated':
        activated = int(a)
    if o == '--pending':
        pending = int(a)
    if o == '--running':
        running = int(a)
    if o == '--status':
        status = a

# -------------------------------------------------------------------------------------------------
#           OPEN THE CONF FILE
# -------------------------------------------------------------------------------------------------

conf = ConfigManager().getConfig(conffile)
section_name = conf.sections()[0]

# -------------------------------------------------------------------------------------------------
#           MOCKS
# -------------------------------------------------------------------------------------------------


class sitestatus(object):
    def __init__(self):
        self.status = status
        self.cloud = section_name


class wmsinfo(object):
    def __init__(self):
Exemplo n.º 8
0
    def _updateInfo(self):

        qcl = None

        # 1. we try to read the list of files in queueConf and create a config loader
        qcf = None
        try:
            qcf = self.fcl.get(
                'Factory', 'queueConf'
            )  # the configuration files for queues are a list of URIs
            self.log.debug("queues.conf file(s) = %s" % qcf)
            qcl_files = ConfigManager().getConfig(sources=qcf)
            self.log.debug("successfully read config file(s) %s" % qcf)
        except Exception as e:
            self.log.error("Exception: %s" % str(e))
            self.log.error(traceback.format_exc(None))

        # 2. we try to read the directory in queueDirConf and create a config loader
        qcd = None
        try:
            qcd = self.fcl.get(
                'Factory', 'queueDirConf'
            )  # the configuration files for queues are in a directory
            if qcd == "None" or qcd == "":
                qcd = None
            if qcd:
                # FIXME : temporary solution.
                #         The ConfigManager.getConfig( ) method should know how to handle properly empty directories
                if not os.path.isdir(qcd) or os.listdir(qcd) == []:
                    self.log.warning(
                        "queues.conf directory = %s does not exist or it is empty"
                        % qcd)
                    qcd = None
                else:
                    self.log.debug("queues.conf directory = %s" % qcd)
                    qcl_dir = ConfigManager().getConfig(configdir=qcd)

        except Exception as e:
            self.log.error("Exception: %s" % str(e))
            self.log.error(traceback.format_exc(None))

        # 3. we merge both loader objects
        try:
            if qcf and qcd:
                self.log.debug("both queues file(s) and dir")
                qcl = qcl_files
                qcl.merge(qcl_dir)
            elif qcf and not qcd:
                self.log.debug("queues file(s) only")
                qcl = qcl_files
            elif not qcf and qcd:
                self.log.debug("queues dir only")
                qcl = qcl_dir
            else:
                self.log.error(
                    'no files or directory with queues configuration specified'
                )
                raise ConfigFailure(
                    'no files or directory with queues configuration specified'
                )
        except Exception as err:
            self.log.error('Failed to create queues ConfigLoader object')
            raise ConfigFailure('Failed to create queues ConfigLoader: %s' %
                                err)

        self.log.info('queues ConfigLoader object created')

        self.qcl = qcl