Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

Commit 6dd34ad

Browse files
authored
Merge pull request #14 from DMTF/Fix11-Add-Results-Location
Added optional 'logdir' argument to specify the log directory
2 parents 1455d96 + 8313498 commit 6dd34ad

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The tool will log into the service specified by the *rhost* argument using the c
3131
* The type specified by the `@odata.type` is found in the OpenAPI specification, but the `@odata.id` property does not match any of the patterns specified by the OpenAPI specification
3232
* The resource is missing the `@odata.id` property and/or the `@odata.type` property
3333

34-
An HTML report is constructed and saved in the same directory as the tool.
34+
An HTML report is constructed and saved in the same directory as the tool, or the directory specified by the *logdir* argument.
3535

3636

3737
## Options
@@ -55,6 +55,9 @@ required arguments:
5555
5656
optional arguments:
5757
-h, --help show this help message and exit
58+
--logdir LOGDIR, -d LOGDIR
59+
Output directory for logs
60+
5861
```
5962

6063
## Release Process

redfish-uri-validator.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def scan_object( uri, resource, partial_path ):
219219
# No matches
220220
return False
221221

222-
def generate_report( results, user, password, rhost, openapi ):
222+
def generate_report( results, user, password, rhost, openapi, logdir ):
223223
"""
224224
Creates an HTML report
225225
@@ -229,6 +229,7 @@ def generate_report( results, user, password, rhost, openapi ):
229229
password: The password to use for the service
230230
rhost: The host to use for the service
231231
openapi: The file name of the OpenAPI specification to use
232+
logdir: The output log directory
232233
"""
233234

234235
# The string template for the report
@@ -326,6 +327,10 @@ def generate_report( results, user, password, rhost, openapi ):
326327

327328
current_time = datetime.now()
328329
log_file = datetime.strftime( current_time, "RedfishURITestReport_%m_%d_%Y_%H%M%S.html" )
330+
if logdir is not None:
331+
if not os.path.isdir( logdir ):
332+
os.makedirs( logdir )
333+
log_file = logdir + os.path.sep + log_file
329334
print( "Generating {}...". format( log_file ) )
330335
with open( log_file, "w", encoding = "utf-8") as out_file:
331336
out_file.write( html_string.format( RedfishLogo.logo, tool_version, current_time.strftime( "%c" ),
@@ -339,6 +344,7 @@ def generate_report( results, user, password, rhost, openapi ):
339344
argget.add_argument( "--password", "-p", type = str, required = True, help = "The password for authentication" )
340345
argget.add_argument( "--rhost", "-r", type = str, required = True, help = "The address of the Redfish service (with address prefix)" )
341346
argget.add_argument( "--openapi", "-o", type = str, required = True, help = "The OpenAPI spec to use for validation" )
347+
argget.add_argument( "--logdir", "-d", type = str, default = None, help = "Output directory for logs" )
342348
args = argget.parse_args()
343349

344350
# Run the test
@@ -347,5 +353,5 @@ def generate_report( results, user, password, rhost, openapi ):
347353
sys.exit( 1 )
348354
else:
349355
# Generate the report
350-
generate_report( results, args.user, args.password, args.rhost, args.openapi )
356+
generate_report( results, args.user, args.password, args.rhost, args.openapi, args.logdir )
351357
sys.exit( 0 )

0 commit comments

Comments
 (0)