コード例 #1
0
def load_config(app):
    global params

    import os
    from webui2.config_parser import config_parser
    try:
        currentdir = os.path.dirname(os.path.realpath(__file__))
        configuration_file = "%s/%s" % (currentdir, 'plugin.cfg')
        logger.info("[WebUI-logs] Plugin configuration file: %s", configuration_file)
        scp = config_parser('#', '=')
        z = params.copy()
        z.update(scp.parse_config(configuration_file))
        params = z

        params['logs_type'] = [item.strip() for item in params['logs_type'].split(',')]
        if len(params['logs_hosts']) > 0:
            params['logs_hosts'] = [item.strip() for item in params['logs_hosts'].split(',')]
        if len(params['logs_services']) > 0:
            params['logs_services'] = [item.strip() for item in params['logs_services'].split(',')]

        logger.info("[WebUI-logs] configuration loaded.")
        logger.info("[WebUI-logs] configuration, fetching types: %s", params['logs_type'])
        logger.info("[WebUI-logs] configuration, hosts: %s", params['logs_hosts'])
        logger.info("[WebUI-logs] configuration, services: %s", params['logs_services'])
        return True
    except Exception as exp:
        logger.warning("[WebUI-logs] configuration file (%s) not available: %s", configuration_file, str(exp))
        return False
コード例 #2
0
ファイル: cv_host.py プロジェクト: seedickcode/mod-webui
def get_page(name, type):
    global params

    # user = app.check_user_authentication()

    logger.debug("[WebUI-cvhost], get_page for %s, type: '%s'", name, type)

    try:
        currentdir = os.path.dirname(os.path.realpath(__file__))
        configuration_file = "%s/%s.cfg" % (currentdir, type)
        logger.debug("Plugin configuration file: %s", configuration_file)
        scp = config_parser('#', '=')
        z = params.copy()
        z.update(scp.parse_config(configuration_file))
        params = z

        logger.debug("[WebUI-cvhost] configuration loaded.")
        logger.debug("[WebUI-cvhost] configuration, load: %s (%s)", params['svc_load_name'], params['svc_load_used'])
        logger.debug("[WebUI-cvhost] configuration, cpu: %s (%s)", params['svc_cpu_name'], params['svc_cpu_used'])
        logger.debug("[WebUI-cvhost] configuration, disk: %s (%s)", params['svc_dsk_name'], params['svc_dsk_used'])
        logger.debug("[WebUI-cvhost] configuration, memory: %s (%s)", params['svc_mem_name'], params['svc_mem_used'])
        logger.debug("[WebUI-cvhost] configuration, network: %s (%s)", params['svc_net_name'], params['svc_net_used'])
        # logger.info("[WebUI-cvhost] configuration, printer: %s (%s)", params['svc_prn_name'], params['svc_prn_used'])
    except Exception, exp:
        logger.warning("[WebUI-cvhost] configuration file (%s) not available or bad formed: %s", configuration_file, str(exp))
        app.redirect404()
        all_perfs = {}
        all_states = {}
        return {'app': app, 'config': type, 'all_perfs':all_perfs, 'all_states':all_states}
コード例 #3
0
ファイル: logs.py プロジェクト: pombredanne/mod-webui
def load_config(app):
    global params
    
    import os
    from webui2.config_parser import config_parser
    try:
        currentdir = os.path.dirname(os.path.realpath(__file__))
        configuration_file = "%s/%s" % (currentdir, 'plugin.cfg')
        logger.info("[WebUI-logs] Plugin configuration file: %s", configuration_file)
        scp = config_parser('#', '=')
        z = params.copy()
        z.update(scp.parse_config(configuration_file))
        params = z

        params['logs_type'] = [item.strip() for item in params['logs_type'].split(',')]
        if len(params['logs_hosts']) > 0:
            params['logs_hosts'] = [item.strip() for item in params['logs_hosts'].split(',')]
        if len(params['logs_services']) > 0:
            params['logs_services'] = [item.strip() for item in params['logs_services'].split(',')]
        
        logger.info("[WebUI-logs] configuration loaded.")
        logger.info("[WebUI-logs] configuration, fetching types: %s", params['logs_type'])
        logger.info("[WebUI-logs] configuration, hosts: %s", params['logs_hosts'])
        logger.info("[WebUI-logs] configuration, services: %s", params['logs_services'])
        return True
    except Exception, exp:
        logger.warning("[WebUI-logs] configuration file (%s) not available: %s", configuration_file, str(exp))
        return False
コード例 #4
0
def get_page(name):
    global params

    # user = app.check_user_authentication()

    config = 'default'
    if '/' in name:
        config = name.split('/')[1]
        name = name.split('/')[0]

    # Find host type if provided in parameters ...
    # @mohierf: not yet implemented ...
    type = app.request.query.get('type', 'default')

    logger.debug("[WebUI-cvhost], get_page for %s (%s)", name,
                 app.request.query_string)

    try:
        currentdir = os.path.dirname(os.path.realpath(__file__))
        configuration_file = "%s/%s.cfg" % (currentdir, config)
        logger.debug("Plugin configuration file: %s", configuration_file)
        scp = config_parser('#', '=')
        z = params.copy()
        z.update(scp.parse_config(configuration_file))
        params = z

        logger.debug("[WebUI-cvhost] configuration loaded.")
        logger.debug("[WebUI-cvhost] configuration, load: %s (%s)",
                     params['svc_load_name'], params['svc_load_used'])
        logger.debug("[WebUI-cvhost] configuration, cpu: %s (%s)",
                     params['svc_cpu_name'], params['svc_cpu_used'])
        logger.debug("[WebUI-cvhost] configuration, disk: %s (%s)",
                     params['svc_dsk_name'], params['svc_dsk_used'])
        logger.debug("[WebUI-cvhost] configuration, memory: %s (%s)",
                     params['svc_mem_name'], params['svc_mem_used'])
        logger.debug("[WebUI-cvhost] configuration, network: %s (%s)",
                     params['svc_net_name'], params['svc_net_used'])
        # logger.debug("[WebUI-cvhost] configuration, printer: %s (%s)", params['svc_prn_name'], params['svc_prn_used'])
    except Exception, exp:
        logger.warning(
            "[WebUI-cvhost] configuration file (%s) not available: %s",
            configuration_file, str(exp))
        all_perfs = {}
        all_states = {}
        return {
            'app': app,
            'config': config,
            'all_perfs': all_perfs,
            'all_states': all_states
        }
コード例 #5
0
def get_page(name, type):
    global params

    # user = app.check_user_authentication()

    logger.debug("[WebUI-cvhost], get_page for %s, type: '%s'", name, type)

    try:
        currentdir = os.path.dirname(os.path.realpath(__file__))
        configuration_file = "%s/%s.cfg" % (currentdir, type)
        logger.debug("Plugin configuration file: %s", configuration_file)
        scp = config_parser('#', '=')
        z = params.copy()
        z.update(scp.parse_config(configuration_file))
        params = z

        logger.debug("[WebUI-cvhost] configuration loaded.")
        logger.debug("[WebUI-cvhost] configuration, load: %s (%s)",
                     params['svc_load_name'], params['svc_load_used'])
        logger.debug("[WebUI-cvhost] configuration, cpu: %s (%s)",
                     params['svc_cpu_name'], params['svc_cpu_used'])
        logger.debug("[WebUI-cvhost] configuration, disk: %s (%s)",
                     params['svc_dsk_name'], params['svc_dsk_used'])
        logger.debug("[WebUI-cvhost] configuration, memory: %s (%s)",
                     params['svc_mem_name'], params['svc_mem_used'])
        logger.debug("[WebUI-cvhost] configuration, network: %s (%s)",
                     params['svc_net_name'], params['svc_net_used'])
        # logger.info("[WebUI-cvhost] configuration, printer: %s (%s)", params['svc_prn_name'], params['svc_prn_used'])
    except Exception, exp:
        logger.warning(
            "[WebUI-cvhost] configuration file (%s) not available or bad formed: %s",
            configuration_file, str(exp))
        app.redirect404()
        all_perfs = {}
        all_states = {}
        return {
            'app': app,
            'config': type,
            'all_perfs': all_perfs,
            'all_states': all_states
        }
コード例 #6
0
ファイル: cv_host.py プロジェクト: vizvayu/mod-webui
def get_page(name):
    global params
    
    # user = app.check_user_authentication()
    
    config = 'default'
    if '/' in name:
        config = name.split('/')[1]
        name = name.split('/')[0]
        
    # Find host type if provided in parameters ...
    # @mohierf: not yet implemented ...
    type = app.request.query.get('type', 'default')

    logger.debug("[WebUI-cvhost], get_page for %s (%s)", name, app.request.query_string)

    try:
        currentdir = os.path.dirname(os.path.realpath(__file__))
        configuration_file = "%s/%s.cfg" % (currentdir, config)
        logger.debug("Plugin configuration file: %s", configuration_file)
        scp = config_parser('#', '=')
        z = params.copy()
        z.update(scp.parse_config(configuration_file))
        params = z

        logger.debug("[WebUI-cvhost] configuration loaded.")
        logger.debug("[WebUI-cvhost] configuration, load: %s (%s)", params['svc_load_name'], params['svc_load_used'])
        logger.debug("[WebUI-cvhost] configuration, cpu: %s (%s)", params['svc_cpu_name'], params['svc_cpu_used'])
        logger.debug("[WebUI-cvhost] configuration, disk: %s (%s)", params['svc_dsk_name'], params['svc_dsk_used'])
        logger.debug("[WebUI-cvhost] configuration, memory: %s (%s)", params['svc_mem_name'], params['svc_mem_used'])
        logger.debug("[WebUI-cvhost] configuration, network: %s (%s)", params['svc_net_name'], params['svc_net_used'])
        # logger.debug("[WebUI-cvhost] configuration, printer: %s (%s)", params['svc_prn_name'], params['svc_prn_used'])
    except Exception, exp:
        logger.warning("[WebUI-cvhost] configuration file (%s) not available: %s", configuration_file, str(exp))
        all_perfs = {}
        all_states = {}
        return {'app': app, 'config': config, 'all_perfs':all_perfs, 'all_states':all_states}
コード例 #7
0
ファイル: log_test.py プロジェクト: Azef1/mod-webui
#!/usr/bin/python

# -*- coding: utf-8 -*-

from pymongo.connection import Connection
import time, datetime

import os,sys
currentdir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0,currentdir+"/../..")
from webui2.config_parser import config_parser

scp = config_parser('#', '=')
params = scp.parse_config('plugin.cfg')
print params

mongo_host = params['mongo_host']
mongo_port = int(params['mongo_port'])
logs_limit = int(params['logs_limit'])
# logs_type = [item.strip() for item in params['logs_type'].split(',')]
# logs_hosts = [item.strip() for item in params['logs_hosts'].split(',')]
# logs_services = [item.strip() for item in params['logs_services'].split(',')]
logs_type = params['logs_type'].split(',')
logs_hosts = params['logs_hosts'].split(',')
logs_services = params['logs_services'].split(',')

con = Connection(mongo_host, mongo_port)
db = con['logs']
app = None # app is not otherwise
if not db:
    message = "Error : Unable to connect to mongo database"
コード例 #8
0
### Will be populated by the UI with it's own value
app = None

# Get plugin's parameters from configuration file (not useful currently but future ideas ...)
params = {}
params['fake'] = "fake"

import os
from webui2.config_parser import config_parser
plugin_name = os.path.splitext(os.path.basename(__file__))[0]
try:
    currentdir = os.path.dirname(os.path.realpath(__file__))
    configuration_file = "%s/%s" % (currentdir, 'plugin.cfg')
    logger.debug("Plugin configuration file: %s", configuration_file)
    scp = config_parser('#', '=')
    params = scp.parse_config(configuration_file)

    # mongo_host = params['mongo_host']
    params['fake'] = params['fake']

    logger.debug("WebUI plugin '%s', configuration loaded." % (plugin_name))
    # logger.debug("Plugin %s configuration, database: %s (%s)", plugin_name, params['mongo_host'], params['mongo_port'])
except Exception, exp:
    logger.warning(
        "WebUI plugin '%s', configuration file (%s) not available: %s",
        plugin_name, configuration_file, str(exp))


def config_page():
    app.bottle.redirect("/")