mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Redfish: Add options to check the availability of the service (#8434)
* Redfish: Add options to check the availability of the service Signed-off-by: Mike Raineri <michael.raineri@dell.com> * Updates based on review feedback Signed-off-by: Mike Raineri <michael.raineri@dell.com> * Updated comment to reflect changed behavior Signed-off-by: Mike Raineri <michael.raineri@dell.com> * Added changelog fragments Signed-off-by: Mike Raineri <michael.raineri@dell.com> * Update changelogs/fragments/8051-Redfish-Wait-For-Service.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Signed-off-by: Mike Raineri <michael.raineri@dell.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
d46e12e280
commit
961767e2dd
4 changed files with 102 additions and 9 deletions
|
@ -288,6 +288,20 @@ options:
|
|||
type: str
|
||||
choices: [ ResetAll, PreserveNetworkAndUsers, PreserveNetwork ]
|
||||
version_added: 8.6.0
|
||||
wait:
|
||||
required: false
|
||||
description:
|
||||
- Block until the service is ready again.
|
||||
type: bool
|
||||
default: false
|
||||
version_added: 9.1.0
|
||||
wait_timeout:
|
||||
required: false
|
||||
description:
|
||||
- How long to block until the service is ready again before giving up.
|
||||
type: int
|
||||
default: 120
|
||||
version_added: 9.1.0
|
||||
|
||||
author:
|
||||
- "Jose Delarosa (@jose-delarosa)"
|
||||
|
@ -685,6 +699,16 @@ EXAMPLES = '''
|
|||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
|
||||
- name: Restart manager power gracefully and wait for it to be available
|
||||
community.general.redfish_command:
|
||||
category: Manager
|
||||
command: GracefulRestart
|
||||
resource_id: BMC
|
||||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
wait: True
|
||||
|
||||
- name: Restart manager power gracefully
|
||||
community.general.redfish_command:
|
||||
category: Manager
|
||||
|
@ -841,7 +865,9 @@ def main():
|
|||
),
|
||||
strip_etag_quotes=dict(type='bool', default=False),
|
||||
reset_to_defaults_mode=dict(choices=['ResetAll', 'PreserveNetworkAndUsers', 'PreserveNetwork']),
|
||||
bios_attributes=dict(type="dict")
|
||||
bios_attributes=dict(type="dict"),
|
||||
wait=dict(type='bool', default=False),
|
||||
wait_timeout=dict(type='int', default=120),
|
||||
),
|
||||
required_together=[
|
||||
('username', 'password'),
|
||||
|
@ -1016,7 +1042,7 @@ def main():
|
|||
command = 'PowerGracefulRestart'
|
||||
|
||||
if command.startswith('Power'):
|
||||
result = rf_utils.manage_manager_power(command)
|
||||
result = rf_utils.manage_manager_power(command, module.params['wait'], module.params['wait_timeout'])
|
||||
elif command == 'ClearLogs':
|
||||
result = rf_utils.clear_logs()
|
||||
elif command == 'VirtualMediaInsert':
|
||||
|
|
|
@ -359,6 +359,16 @@ EXAMPLES = '''
|
|||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
|
||||
- name: Check the availability of the service with a timeout of 5 seconds
|
||||
community.general.redfish_info:
|
||||
category: Service
|
||||
command: CheckAvailability
|
||||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
timeout: 5
|
||||
register: result
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
|
@ -385,6 +395,7 @@ CATEGORY_COMMANDS_ALL = {
|
|||
"GetUpdateStatus"],
|
||||
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs", "GetNetworkProtocols",
|
||||
"GetHealthReport", "GetHostInterfaces", "GetManagerInventory", "GetServiceIdentification"],
|
||||
"Service": ["CheckAvailability"],
|
||||
}
|
||||
|
||||
CATEGORY_COMMANDS_DEFAULT = {
|
||||
|
@ -393,7 +404,8 @@ CATEGORY_COMMANDS_DEFAULT = {
|
|||
"Accounts": "ListUsers",
|
||||
"Update": "GetFirmwareInventory",
|
||||
"Sessions": "GetSessions",
|
||||
"Manager": "GetManagerNicInventory"
|
||||
"Manager": "GetManagerNicInventory",
|
||||
"Service": "CheckAvailability",
|
||||
}
|
||||
|
||||
|
||||
|
@ -473,7 +485,13 @@ def main():
|
|||
module.fail_json(msg="Invalid Category: %s" % category)
|
||||
|
||||
# Organize by Categories / Commands
|
||||
if category == "Systems":
|
||||
if category == "Service":
|
||||
# service-level commands are always available
|
||||
for command in command_list:
|
||||
if command == "CheckAvailability":
|
||||
result["service"] = rf_utils.check_service_availability()
|
||||
|
||||
elif category == "Systems":
|
||||
# execute only if we find a Systems resource
|
||||
resource = rf_utils._find_systems_resource()
|
||||
if resource['ret'] is False:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue