Skip to content

Commit

Permalink
Merge pull request #78 from DMTF/cleanup
Browse files Browse the repository at this point in the history
Made change to allow for the scheme to be included in the 'rhost' argument
  • Loading branch information
mraineri authored Jul 8, 2022
2 parents f3e95e2 + 0735a41 commit 5995a9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ usage: redfishMockupCreate.py [-h] --user USER --password PASSWORD --rhost
[--Copyright COPYRIGHT]
[--description DESCRIPTION] [--quiet]
A tool to walk a Redfish a service and create a mockup from all resources
A tool to walk a Redfish service and create a mockup from all resources
required arguments:
--user USER, -u USER The user name for authentication
Expand All @@ -38,25 +38,27 @@ required arguments:
optional arguments:
-h, --help show this help message and exit
--Dir DIR, -D DIR Output directory for the mockup; defaults to
'rfMockUpDfltDir'
--Secure, -S Use HTTPS for all operations
--Auth {None,Basic,Session}, -A {None,Basic,Session}
Authentication mode
--Headers, -H Captures the response headers in the mockup
--Time, -T Capture the time of each GET in the mockup
--Dir DIR, -D DIR Output directory for the mockup
--Copyright COPYRIGHT, -C COPYRIGHT
Copyright string to add to each resource
--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
in the output directory to capture Redfish traces with
the service
--maxlogentries MAXLOGENTRIES, -maxlogentries MAXLOGENTRIES
The maximum number of log entries to collect in each
log service
```

### Description
Example: `python redfishMockupCreate.py -u root -p root -r 192.168.1.100 -S -D /output`

The tool will log into the service specified by the *rhost* argument using the credentials provided by the *user* and *password* arguments.
It will then walk the service to find all resources and place each resource in directory specified by the *Dir* argument.
Expand All @@ -65,13 +67,7 @@ For every resource found, it will create an "index.json" file in the output dire
If the *Headers* argument is specified, it will save the response headers for each resource in a "headers.json" file.
If the *Time* argument is specified, it will save the time elapsed for each resource in a "time.json" file.

### Native system example

```bash
python redfishMockupCreate.py -u root -p root -r 192.168.1.100 -S -D /home/user/redfish-mockup
```

### Docker container example
## Docker container example

To run as a Docker container, use one of these actions to pull or build the container:

Expand Down
13 changes: 7 additions & 6 deletions redfishMockupCreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def main():
"""

# Get the input arguments
argget = argparse.ArgumentParser( description = "A tool to walk a Redfish a service and create a mockup from all resources" )
argget = argparse.ArgumentParser( description = "A tool to walk a Redfish service and create a mockup from all resources" )
argget.add_argument( "--user", "-u", type = str, required = True, help = "The user name for authentication" )
argget.add_argument( "--password", "-p", type = str, required = True, help = "The password for authentication" )
argget.add_argument( "--rhost", "-r", type = str, required = True, help = "The IP address (and port) of the Redfish service" )
argget.add_argument( "--Dir", "-D", type = str, help = "Output directory for the mockup; defaults to 'rfMockUpDfltDir'", default = "rfMockUpDfltDir" )
argget.add_argument( "--Secure", "-S", action = "store_true", help = "Use HTTPS for all operations" )
argget.add_argument( "--Auth", "-A", type = str, help = "Authentication mode", choices = [ "None", "Basic", "Session" ], default = "Session" )
argget.add_argument( "--Headers", "-H", action = "store_true", help = "Captures the response headers in the mockup" )
argget.add_argument( "--Time", "-T", action = "store_true", help = "Capture the time of each GET in the mockup" )
argget.add_argument( "--Dir", "-D", type = str, help = "Output directory for the mockup", default = "rfMockUpDfltDir" )
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" )
Expand All @@ -63,10 +63,11 @@ def main():

# Build the base URL for the service
# More backwards compatibility
if args.Secure:
args.rhost = "https://{}".format( args.rhost )
else:
args.rhost = "http://{}".format( args.rhost )
if "://" not in args.rhost:
if args.Secure:
args.rhost = "https://{}".format( args.rhost )
else:
args.rhost = "http://{}".format( args.rhost )

# Set up the output
if not os.path.isdir( args.Dir ):
Expand Down

0 comments on commit 5995a9a

Please sign in to comment.