Skip to content

Commit

Permalink
Merge pull request #71 from DMTF/Boot-Mode
Browse files Browse the repository at this point in the history
Added --mode argument to 'rf_boot_override.py' to control Legacy vs UEFI
  • Loading branch information
mraineri authored Mar 18, 2022
2 parents 4347e5d + 005bf37 commit f0c90d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,15 @@ optional arguments:
-h, --help show this help message and exit
--system SYSTEM, -s SYSTEM
The ID of the system to set
--info, -info Indicates if boot information should be reported
--target TARGET, -t TARGET
The target boot device; if not provided the tool will
display the current boot settings
--uefi UEFI, -uefi UEFI
If target is 'UefiTarget', the UEFI Device Path of the
device to boot. If target is 'UefiBootNext', the UEFI
Boot Option string of the device to boot.
--mode MODE, -m MODE The requested boot mode ('UEFI' or 'Legacy')
--reset, -reset Signifies that the system is reset after the boot
override is set
```
Expand Down
17 changes: 12 additions & 5 deletions scripts/rf_boot_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,42 @@
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 address of the Redfish service (with scheme)" )
argget.add_argument( "--system", "-s", type = str, help = "The ID of the system to set" )
argget.add_argument( "--info", "-info", action = "store_true", help = "Indicates if boot information should be reported" )
argget.add_argument( "--target", "-t", type = str, help = "The target boot device; if not provided the tool will display the current boot settings" )
argget.add_argument( "--uefi", "-uefi", type = str, help = "If target is 'UefiTarget', the UEFI Device Path of the device to boot. If target is 'UefiBootNext', the UEFI Boot Option string of the device to boot." )
argget.add_argument( "--mode", "-m", type = str, help = "The requested boot mode ('UEFI' or 'Legacy')" )
argget.add_argument( "--reset", "-reset", action = "store_true", help = "Signifies that the system is reset after the boot override is set" )
args = argget.parse_args()

# Verify the combination of arguments is correct
if args.target is None:
args.info = True
if args.uefi or args.mode or args.reset:
argget.error( "Cannot use '--uefi', '--mode', or '--reset' without '--target'" )

# Set up the Redfish object
redfish_obj = redfish.redfish_client( base_url = args.rhost, username = args.user, password = args.password )
redfish_obj.login( auth = "session" )

try:
if args.target is None:
# Target not specified; just get the settings and display them
if args.info:
boot = redfish_utilities.get_system_boot( redfish_obj, args.system )
redfish_utilities.print_system_boot( boot )
else:
# Build and send the boot request based on the arguments given
uefi_target = None
boot_next = None
boot_mode = "Once"
boot_enable = "Once"
if args.target == "UefiTarget":
uefi_target = args.uefi
if args.target == "UefiBootNext":
boot_next = args.uefi
if args.target == "None":
print( "Disabling one time boot..." )
boot_mode = "Disabled"
boot_enable = "Disabled"
else:
print( "Setting a one time boot for {}...".format( args.target ) )
redfish_utilities.set_system_boot( redfish_obj, args.system, args.target, boot_mode, None, uefi_target, boot_next )
redfish_utilities.set_system_boot( redfish_obj, args.system, args.target, boot_enable, args.mode, uefi_target, boot_next )

# Reset the system if requested
if args.reset:
Expand Down

0 comments on commit f0c90d1

Please sign in to comment.