Skip to content

Commit

Permalink
Merge pull request #115 from DMTF/Fix113-Add-Set-Manager-DateTime
Browse files Browse the repository at this point in the history
Fix113 add set manager date time
  • Loading branch information
mraineri authored Jul 27, 2023
2 parents a4411e0 + f806370 commit 3611855
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 4 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,19 @@ The tool will then perform an operation on the `Boot` object within the matching
```
usage: rf_manager_config.py [-h] --user USER --password PASSWORD --rhost RHOST
[--manager MANAGER]
{info,reset,getnet,setnet} ...
{info,reset,getnet,setnet,resettodefaults,settime}
...
A tool to manage managers in a service
positional arguments:
{info,reset,getnet,setnet,resettodefaults}
{info,reset,getnet,setnet,resettodefaults,settime}
info Displays information about a manager
reset Resets a manager
getnet Displays information about an Ethernet interface
setnet Configures an Ethernet interface
resettodefaults Resets a manager to default setting
resettodefaults Resets a manager to default settings
settime Sets the date-time on a manager
required arguments:
--user USER, -u USER The user name for authentication
Expand Down Expand Up @@ -307,12 +309,34 @@ optional arguments:
Example: `rf_manager_config.py -u root -p root -r https://192.168.1.100 reset -t GracefulRestart`

The tool will log into the service specified by the *rhost* argument using the credentials provided by the *user* and *password* arguments.
It then traverses the manager collection for the service to find the matching system specified by the *manager* argument.
It then traverses the manager collection for the service to find the matching manager specified by the *manager* argument.
It will perform the `Reset` action with the specified reset type from the *type* argument.
* If *manager* is not specified, and if the service has exactly one manager, it will perform the operation on the one manager.
* If *type* is not specified, it will attempt a `GracefulRestart`.


#### Set Time

```
usage: rf_manager_config.py settime [-h] [--datetime DATETIME] [--offset OFFSET]
options:
-h, --help show this help message and exit
--datetime DATETIME, -dt DATETIME
The date-time value to set
--offset OFFSET, -o OFFSET
The date-time offset value to set
```

Example: `rf_manager_config.py -u root -p root -r https://192.168.1.100 settime -dt 2023-07-27T12:00:00-05:00`

Example: `rf_manager_config.py -u root -p root -r https://192.168.1.100 settime -o=-05:00`

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 locate the manager specified by the *manager* argument, and applies the *datetime* and *offset* values to the manager instance.
* If *manager* is not specified, and if the service has exactly one manager, it will perform the operation on the one manager.


#### Get Network Interface

```
Expand Down
1 change: 1 addition & 0 deletions redfish_utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .logs import download_diagnostic_data
from .managers import get_manager_ids
from .managers import get_manager
from .managers import set_manager
from .managers import print_manager
from .managers import get_manager_reset_info
from .managers import manager_reset
Expand Down
33 changes: 33 additions & 0 deletions redfish_utilities/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,39 @@ def get_manager( context, manager_id = None ):
verify_response( manager )
return manager

def set_manager( context, manager_id = None, date_time = None, date_time_offset = None ):
"""
Finds a manager matching the given identifier and sets one or more properties
Args:
context: The Redfish client object with an open session
manager_id: The manager to locate; if None, perform on the only manager
date_time: The date-time value to set
date_time_offset: The date-time offset value to set
Returns:
The response of the PATCH
"""

# Locate the manager
manager = get_manager( context, manager_id )

# Build the payload
payload = {}
if date_time is not None:
payload["DateTime"] = date_time
if date_time_offset is not None:
payload["DateTimeOffset"] = date_time_offset

# Update the manager
headers = None
etag = manager.getheader( "ETag" )
if etag is not None:
headers = { "If-Match": etag }
response = context.patch( manager.dict["@odata.id"], body = payload, headers = headers )
verify_response( response )
return response

def print_manager( manager ):
"""
Prints the manager info
Expand Down
5 changes: 5 additions & 0 deletions scripts/rf_manager_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
reset_to_defaults_argget = subparsers.add_parser( "resettodefaults", help = "Resets a manager to default settings" )
reset_to_defaults_argget.add_argument( "--type", "-t", type = str, help = "The type of reset-to-defaults operation to perform", choices = redfish_utilities.reset_to_defaults_types )
reset_to_defaults_argget.add_argument( "--info", "-info", action = "store_true", help = "Indicates if reset-to-defaults information should be reported" )
set_time_argget = subparsers.add_parser( "settime", help = "Sets the date-time on a manager" )
set_time_argget.add_argument( "--datetime", "-dt", type = str, help = "The date-time value to set" )
set_time_argget.add_argument( "--offset", "-o", type = str, help = "The date-time offset value to set" )
args = argget.parse_args()

if args.debug:
Expand Down Expand Up @@ -91,6 +94,8 @@
response = redfish_utilities.manager_reset_to_defaults( redfish_obj, args.manager, args.type )
response = redfish_utilities.poll_task_monitor( redfish_obj, response )
redfish_utilities.verify_response( response )
elif args.command == "settime":
redfish_utilities.set_manager( redfish_obj, args.manager, args.datetime, args.offset )
elif args.command == "getnet":
interface = redfish_utilities.get_manager_ethernet_interface( redfish_obj, args.manager, args.id )
redfish_utilities.print_manager_ethernet_interface( interface )
Expand Down

0 comments on commit 3611855

Please sign in to comment.