Skip to content

Commit 70939a9

Browse files
authored
Merge pull request #71 from DMTF/Add-Library-Trace-Support
Added trace option to capture details from the debug capabilities of the Redfish library
2 parents 5e6150a + 6304ec8 commit 70939a9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ optional arguments:
4949
--description DESCRIPTION, -d DESCRIPTION
5050
Mockup description to add to the output readme file
5151
--quiet, -q Quiet mode; progress messages suppressed
52+
--trace, -trace Enable tracing; creates the file rf-mockup-create.log
53+
to capture Redfish traces with the service
5254
--maxlogentries MAXLOGENTRIES, -maxlogentries MAXLOGENTRIES
5355
The maximum number of log entries to collect in each
5456
log service

redfishMockupCreate.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import sys
1919
import time
2020
import xml.etree.ElementTree as ET
21+
import logging
22+
from redfish import redfish_logger
2123

2224
# Version info
2325
tool_version = "1.1.1"
@@ -40,6 +42,7 @@ def main():
4042
argget.add_argument( "--Copyright", "-C", type = str, help = "Copyright string to add to each resource", default = None )
4143
argget.add_argument( "--description", "-d", type = str, help = "Mockup description to add to the output readme file", default = "" )
4244
argget.add_argument( "--quiet", "-q", action = "store_true", help = "Quiet mode; progress messages suppressed" )
45+
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" )
4346
argget.add_argument( "--maxlogentries", "-maxlogentries", type = int, help = "The maximum number of log entries to collect in each log service" )
4447
args, unknown = argget.parse_known_args()
4548

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

96+
# Set up the trace file if requested
97+
if args.trace:
98+
redfish_logger( os.path.join( args.Dir, "rf-mockup-create.log" ), "%(asctime)s - %(name)s - %(levelname)s - %(message)s", logging.DEBUG )
99+
93100
# Set up the Redfish object
94101
try:
95102
redfish_obj = redfish.redfish_client( base_url = args.rhost, username = args.user, password = args.password )

0 commit comments

Comments
 (0)