f844afc49b
- Uses tortilla lib to wrap the REST API (dep) - Uses python requests to manage login/logout (dep) - Provides 2 functional working examples with Redfish simulator and ProLiant server or Moonshot Server - Remove OpenStack deps as this code has to be usable outside of OpenStack - Provides a configuration file to handle credentials and connection URL - Provides a mapping class to handle multiple versions of Redfish (in this version, 0.95.0 for ProLiant and 1.0.0 for mockup) - Provides a first action reset_server to ... reset system The action is commented into simple-proliant.py to not do unexpected reset. - Provides a first retrieving function get_bios_version to get the BIOS version of a system. - Add basic logging capability - Clean up to meet pep8 and doc strings (in progress).
37 lines
877 B
Python
37 lines
877 B
Python
# coding=utf-8
|
|
|
|
import logging
|
|
from logging.handlers import RotatingFileHandler
|
|
|
|
# Global variable definition
|
|
TORTILLADEBUG = True
|
|
logger = None
|
|
|
|
|
|
def initialize_logger(redfish_logfile):
|
|
"""Return api version.
|
|
|
|
:param redfish_logfile: redfish log
|
|
:type str
|
|
:returns: True
|
|
|
|
"""
|
|
global logger
|
|
logger = logging.getLogger()
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
formatter = logging.Formatter(
|
|
'%(asctime)s :: %(levelname)s :: %(message)s'
|
|
)
|
|
file_handler = RotatingFileHandler(redfish_logfile, 'a', 1000000, 1)
|
|
|
|
# First logger to file
|
|
file_handler.setLevel(logging.DEBUG)
|
|
file_handler.setFormatter(formatter)
|
|
logger.addHandler(file_handler)
|
|
|
|
# Second logger to console
|
|
steam_handler = logging.StreamHandler()
|
|
steam_handler.setLevel(logging.DEBUG)
|
|
logger.addHandler(steam_handler)
|
|
return True |