mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-05 10:10:31 -07:00
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>
This commit is contained in:
parent
fdbc06c714
commit
abe4e5ce95
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):
|
def get_multi_power_restore_policy(self):
|
||||||
return self.aggregate_systems(self.get_power_restore_policy)
|
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
|
type: dict
|
||||||
default: {}
|
default: {}
|
||||||
version_added: '7.5.0'
|
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:
|
ciphers:
|
||||||
required: false
|
required: false
|
||||||
description:
|
description:
|
||||||
|
@ -358,6 +367,15 @@ EXAMPLES = r"""
|
||||||
Drives:
|
Drives:
|
||||||
- "/redfish/v1/Systems/1/Storage/DE00B000/Drives/1"
|
- "/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 }}
|
- name: Set service identification to {{ service_id }}
|
||||||
community.general.redfish_config:
|
community.general.redfish_config:
|
||||||
category: Manager
|
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
|
# More will be added as module features are expanded
|
||||||
CATEGORY_COMMANDS_ALL = {
|
CATEGORY_COMMANDS_ALL = {
|
||||||
"Systems": ["SetBiosDefaultSettings", "SetBiosAttributes", "SetBootOrder",
|
"Systems": ["SetBiosDefaultSettings", "SetBiosAttributes", "SetBootOrder",
|
||||||
"SetDefaultBootOrder", "EnableSecureBoot", "SetSecureBoot", "DeleteVolumes", "CreateVolume"],
|
"SetDefaultBootOrder", "EnableSecureBoot", "SetSecureBoot", "DeleteVolumes", "CreateVolume",
|
||||||
|
"SetPowerRestorePolicy"],
|
||||||
"Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface", "SetServiceIdentification"],
|
"Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface", "SetServiceIdentification"],
|
||||||
"Sessions": ["SetSessionService"],
|
"Sessions": ["SetSessionService"],
|
||||||
}
|
}
|
||||||
|
@ -423,6 +442,7 @@ def main():
|
||||||
volume_ids=dict(type='list', default=[], elements='str'),
|
volume_ids=dict(type='list', default=[], elements='str'),
|
||||||
secure_boot_enable=dict(type='bool', default=True),
|
secure_boot_enable=dict(type='bool', default=True),
|
||||||
volume_details=dict(type='dict', default={}),
|
volume_details=dict(type='dict', default={}),
|
||||||
|
power_restore_policy=dict(choices=['AlwaysOn', 'AlwaysOff', 'LastState']),
|
||||||
ciphers=dict(type='list', elements='str'),
|
ciphers=dict(type='list', elements='str'),
|
||||||
),
|
),
|
||||||
required_together=[
|
required_together=[
|
||||||
|
@ -488,6 +508,9 @@ def main():
|
||||||
storage_subsystem_id = module.params['storage_subsystem_id']
|
storage_subsystem_id = module.params['storage_subsystem_id']
|
||||||
storage_none_volume_deletion = module.params['storage_none_volume_deletion']
|
storage_none_volume_deletion = module.params['storage_none_volume_deletion']
|
||||||
|
|
||||||
|
# Power Restore Policy
|
||||||
|
power_restore_policy = module.params['power_restore_policy']
|
||||||
|
|
||||||
# ciphers
|
# ciphers
|
||||||
ciphers = module.params['ciphers']
|
ciphers = module.params['ciphers']
|
||||||
|
|
||||||
|
@ -531,6 +554,8 @@ def main():
|
||||||
result = rf_utils.delete_volumes(storage_subsystem_id, volume_ids)
|
result = rf_utils.delete_volumes(storage_subsystem_id, volume_ids)
|
||||||
elif command == "CreateVolume":
|
elif command == "CreateVolume":
|
||||||
result = rf_utils.create_volume(volume_details, storage_subsystem_id, storage_none_volume_deletion)
|
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":
|
elif category == "Manager":
|
||||||
# execute only if we find a Manager service resource
|
# execute only if we find a Manager service resource
|
||||||
|
|
Loading…
Add table
Reference in a new issue