mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-05 02:00:30 -07:00
[PR #9837/abe4e5ce backport][stable-10] Redfish: implement setting PowerRestorePolicy (#9878)
Redfish: implement setting PowerRestorePolicy (#9837)
This property ("The desired power state of the system when power is
restored after a power loss.") was added in ComputerSystem.v1_6_0 which
became part of 2018.3 Redfish release.
Tested against an OpenBMC system running bmcweb Redfish server making sure the
policy is updated only when needed and that errors and messages are propogated
properly.
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
(cherry picked from commit abe4e5ce95
)
Co-authored-by: Paul Fertser <fercerpav@gmail.com>
This commit is contained in:
parent
cee6c98d2a
commit
2583152512
3 changed files with 32 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- redfish_config - add command ``SetPowerRestorePolicy`` to set the desired power state of the system when power is restored (https://github.com/ansible-collections/community.general/pull/9837).
|
|
@ -3983,3 +3983,7 @@ class RedfishUtils(object):
|
|||
|
||||
def get_multi_power_restore_policy(self):
|
||||
return self.aggregate_systems(self.get_power_restore_policy)
|
||||
|
||||
def set_power_restore_policy(self, policy):
|
||||
body = {'PowerRestorePolicy': policy}
|
||||
return self.patch_request(self.root_uri + self.systems_uri, body, check_pyld=True)
|
||||
|
|
|
@ -171,6 +171,15 @@ options:
|
|||
type: dict
|
||||
default: {}
|
||||
version_added: '7.5.0'
|
||||
power_restore_policy:
|
||||
description:
|
||||
- The desired power state of the system when power is restored after a power loss.
|
||||
type: str
|
||||
choices:
|
||||
- AlwaysOn
|
||||
- AlwaysOff
|
||||
- LastState
|
||||
version_added: '10.5.0'
|
||||
ciphers:
|
||||
required: false
|
||||
description:
|
||||
|
@ -358,6 +367,15 @@ EXAMPLES = r"""
|
|||
Drives:
|
||||
- "/redfish/v1/Systems/1/Storage/DE00B000/Drives/1"
|
||||
|
||||
- name: Set PowerRestorePolicy
|
||||
community.general.redfish_config:
|
||||
category: Systems
|
||||
command: SetPowerRestorePolicy
|
||||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
power_restore_policy: "AlwaysOff"
|
||||
|
||||
- name: Set service identification to {{ service_id }}
|
||||
community.general.redfish_config:
|
||||
category: Manager
|
||||
|
@ -384,7 +402,8 @@ from ansible.module_utils.common.text.converters import to_native
|
|||
# More will be added as module features are expanded
|
||||
CATEGORY_COMMANDS_ALL = {
|
||||
"Systems": ["SetBiosDefaultSettings", "SetBiosAttributes", "SetBootOrder",
|
||||
"SetDefaultBootOrder", "EnableSecureBoot", "SetSecureBoot", "DeleteVolumes", "CreateVolume"],
|
||||
"SetDefaultBootOrder", "EnableSecureBoot", "SetSecureBoot", "DeleteVolumes", "CreateVolume",
|
||||
"SetPowerRestorePolicy"],
|
||||
"Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface", "SetServiceIdentification"],
|
||||
"Sessions": ["SetSessionService"],
|
||||
}
|
||||
|
@ -423,6 +442,7 @@ def main():
|
|||
volume_ids=dict(type='list', default=[], elements='str'),
|
||||
secure_boot_enable=dict(type='bool', default=True),
|
||||
volume_details=dict(type='dict', default={}),
|
||||
power_restore_policy=dict(choices=['AlwaysOn', 'AlwaysOff', 'LastState']),
|
||||
ciphers=dict(type='list', elements='str'),
|
||||
),
|
||||
required_together=[
|
||||
|
@ -488,6 +508,9 @@ def main():
|
|||
storage_subsystem_id = module.params['storage_subsystem_id']
|
||||
storage_none_volume_deletion = module.params['storage_none_volume_deletion']
|
||||
|
||||
# Power Restore Policy
|
||||
power_restore_policy = module.params['power_restore_policy']
|
||||
|
||||
# ciphers
|
||||
ciphers = module.params['ciphers']
|
||||
|
||||
|
@ -531,6 +554,8 @@ def main():
|
|||
result = rf_utils.delete_volumes(storage_subsystem_id, volume_ids)
|
||||
elif command == "CreateVolume":
|
||||
result = rf_utils.create_volume(volume_details, storage_subsystem_id, storage_none_volume_deletion)
|
||||
elif command == "SetPowerRestorePolicy":
|
||||
result = rf_utils.set_power_restore_policy(power_restore_policy)
|
||||
|
||||
elif category == "Manager":
|
||||
# execute only if we find a Manager service resource
|
||||
|
|
Loading…
Add table
Reference in a new issue