mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-21 18:01:26 -07:00
* bring Manager power cmds to parity with System power commands
* add changelog fragment
* Update changelogs/fragments/903-enhance-redfish-manager-reset-actions.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e382044e42
)
Co-authored-by: Bill Dodd <billdodd@gmail.com>
This commit is contained in:
parent
951806c888
commit
407d776610
3 changed files with 101 additions and 28 deletions
|
@ -710,24 +710,6 @@ class RedfishUtils(object):
|
|||
def get_multi_volume_inventory(self):
|
||||
return self.aggregate_systems(self.get_volume_inventory)
|
||||
|
||||
def restart_manager_gracefully(self):
|
||||
result = {}
|
||||
key = "Actions"
|
||||
|
||||
# Search for 'key' entry and extract URI from it
|
||||
response = self.get_request(self.root_uri + self.manager_uri)
|
||||
if response['ret'] is False:
|
||||
return response
|
||||
result['ret'] = True
|
||||
data = response['data']
|
||||
action_uri = data[key]["#Manager.Reset"]["target"]
|
||||
|
||||
payload = {'ResetType': 'GracefulRestart'}
|
||||
response = self.post_request(self.root_uri + action_uri, payload)
|
||||
if response['ret'] is False:
|
||||
return response
|
||||
return {'ret': True}
|
||||
|
||||
def manage_indicator_led(self, command):
|
||||
result = {}
|
||||
key = 'IndicatorLED'
|
||||
|
@ -773,6 +755,14 @@ class RedfishUtils(object):
|
|||
return reset_type
|
||||
|
||||
def manage_system_power(self, command):
|
||||
return self.manage_power(command, self.systems_uri,
|
||||
'#ComputerSystem.Reset')
|
||||
|
||||
def manage_manager_power(self, command):
|
||||
return self.manage_power(command, self.manager_uri,
|
||||
'#Manager.Reset')
|
||||
|
||||
def manage_power(self, command, resource_uri, action_name):
|
||||
key = "Actions"
|
||||
reset_type_values = ['On', 'ForceOff', 'GracefulShutdown',
|
||||
'GracefulRestart', 'ForceRestart', 'Nmi',
|
||||
|
@ -790,8 +780,8 @@ class RedfishUtils(object):
|
|||
if reset_type not in reset_type_values:
|
||||
return {'ret': False, 'msg': 'Invalid Command (%s)' % command}
|
||||
|
||||
# read the system resource and get the current power state
|
||||
response = self.get_request(self.root_uri + self.systems_uri)
|
||||
# read the resource and get the current power state
|
||||
response = self.get_request(self.root_uri + resource_uri)
|
||||
if response['ret'] is False:
|
||||
return response
|
||||
data = response['data']
|
||||
|
@ -803,13 +793,13 @@ class RedfishUtils(object):
|
|||
if power_state == "Off" and reset_type in ['GracefulShutdown', 'ForceOff']:
|
||||
return {'ret': True, 'changed': False}
|
||||
|
||||
# get the #ComputerSystem.Reset Action and target URI
|
||||
if key not in data or '#ComputerSystem.Reset' not in data[key]:
|
||||
return {'ret': False, 'msg': 'Action #ComputerSystem.Reset not found'}
|
||||
reset_action = data[key]['#ComputerSystem.Reset']
|
||||
# get the reset Action and target URI
|
||||
if key not in data or action_name not in data[key]:
|
||||
return {'ret': False, 'msg': 'Action %s not found' % action_name}
|
||||
reset_action = data[key][action_name]
|
||||
if 'target' not in reset_action:
|
||||
return {'ret': False,
|
||||
'msg': 'target URI missing from Action #ComputerSystem.Reset'}
|
||||
'msg': 'target URI missing from Action %s' % action_name}
|
||||
action_uri = reset_action['target']
|
||||
|
||||
# get AllowableValues
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue