コード例 #1
0
def init_logging(syslog_host="localhost",
                 syslog_port=514,
                 console_output=False):
    """Initialize logging for sspl-setup."""
    _logger.setLevel(logging.INFO)
    # set Logging Handlers
    Utility().create_file(SETUP_LOG_PATH)

    handler = logging.handlers.RotatingFileHandler(SETUP_LOG_PATH,
                                                   mode='a',
                                                   maxBytes=2000000,
                                                   backupCount=5)

    fformat = "%(asctime)s %(name)s[%(process)d]: " \
                "%(levelname)s %(message)s (%(filename)s:%(lineno)d)"
    formatter = logging.Formatter(fformat, datefmt='%b %d %H:%M:%S')
    handler.setFormatter(formatter)
    _logger.addHandler(handler)
    if console_output:
        console = logging.StreamHandler(sys.stderr)
        console.setFormatter(formatter)
        _logger.addHandler(console)
コード例 #2
0
NODE_TYPE = "node_type"
SMART_TEST_INTERVAL = "smart_test_interval"
SSPL_LOG_FILE_PATH = "sspl_log_file_path"
STORAGE = "storage"
STORAGE_SET_ID = "storage_set_id"
STORE_TYPE = "store_type"
THREADED = "threaded"
TIMESTAMP_FILE_PATH = "timestamp_file_path"
TRANSMIT_INTERVAL = "transmit_interval"
TYPE = "type"
UNITS = "units"
USER = "******"
USERNAME = "******"
VIRTUAL_HOST = "virtual_host"
TARGET_BUILD = "target_build"

# Get SRVNODE and ENCLOSURE so it can be used in other files to get
# server_node and enclosure specific config
utility = Utility()
MACHINE_ID = utility.get_machine_id()
OPERATING_SYSTEM = utility.get_os()

Conf.load(SSPL_CONF, "yaml:///etc/sspl.conf")
global_config = Conf.get(SSPL_CONF,
                         "SYSTEM_INFORMATION>global_config_copy_url")
Conf.load(GLOBAL_CONF, global_config)

SRVNODE = Conf.get(GLOBAL_CONF, f'{CLUSTER}>{SERVER_NODES}')[MACHINE_ID]
ENCLOSURE = Conf.get(GLOBAL_CONF,
                     f"{CLUSTER}>{SRVNODE}>{STORAGE}>{ENCLOSURE_ID}")