Skip to content

Commit

Permalink
Merge pull request #71 from DMTF/Add-Library-Trace-Support
Browse files Browse the repository at this point in the history
Added trace option to capture details from the debug capabilities of the Redfish library
  • Loading branch information
mraineri authored Sep 17, 2021
2 parents 5e6150a + 6304ec8 commit 70939a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ optional arguments:
--description DESCRIPTION, -d DESCRIPTION
Mockup description to add to the output readme file
--quiet, -q Quiet mode; progress messages suppressed
--trace, -trace Enable tracing; creates the file rf-mockup-create.log
to capture Redfish traces with the service
--maxlogentries MAXLOGENTRIES, -maxlogentries MAXLOGENTRIES
The maximum number of log entries to collect in each
log service
Expand Down
9 changes: 8 additions & 1 deletion redfishMockupCreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import sys
import time
import xml.etree.ElementTree as ET
import logging
from redfish import redfish_logger

# Version info
tool_version = "1.1.1"
Expand All @@ -40,6 +42,7 @@ def main():
argget.add_argument( "--Copyright", "-C", type = str, help = "Copyright string to add to each resource", default = None )
argget.add_argument( "--description", "-d", type = str, help = "Mockup description to add to the output readme file", default = "" )
argget.add_argument( "--quiet", "-q", action = "store_true", help = "Quiet mode; progress messages suppressed" )
argget.add_argument( "--trace", "-trace", action = "store_true", help = "Enable tracing; creates the file rf-mockup-create.log in the output directory to capture Redfish traces with the service" )
argget.add_argument( "--maxlogentries", "-maxlogentries", type = int, help = "The maximum number of log entries to collect in each log service" )
args, unknown = argget.parse_known_args()

Expand All @@ -63,7 +66,7 @@ def main():
try:
os.makedirs( args.Dir )
except Exception as err:
print( "ERROR: Aborting; xould not create output directory '{}': {}".format( args.Dir, err ) )
print( "ERROR: Aborting; could not create output directory '{}': {}".format( args.Dir, err ) )
sys.exit( 1 )
else:
if len( os.listdir( args.Dir ) ) != 0:
Expand All @@ -90,6 +93,10 @@ def main():
print( "ERROR: Aborting; could not create README file in output directory: {}".format( err ) )
sys.exit( 1 )

# Set up the trace file if requested
if args.trace:
redfish_logger( os.path.join( args.Dir, "rf-mockup-create.log" ), "%(asctime)s - %(name)s - %(levelname)s - %(message)s", logging.DEBUG )

# Set up the Redfish object
try:
redfish_obj = redfish.redfish_client( base_url = args.rhost, username = args.user, password = args.password )
Expand Down

0 comments on commit 70939a9

Please sign in to comment.