2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright (c) 2017-2018 Dell EMC Inc.
|
2022-08-05 12:28:29 +02:00
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
module: redfish_config
|
|
|
|
short_description: Manages Out-Of-Band controllers using Redfish APIs
|
|
|
|
description:
|
|
|
|
- Builds Redfish URIs locally and sends them to remote OOB controllers to
|
|
|
|
set or update a configuration attribute.
|
|
|
|
- Manages BIOS configuration settings.
|
|
|
|
- Manages OOB controller configuration settings.
|
2023-02-20 17:28:13 +01:00
|
|
|
extends_documentation_fragment:
|
|
|
|
- community.general.attributes
|
|
|
|
attributes:
|
|
|
|
check_mode:
|
|
|
|
support: none
|
|
|
|
diff_mode:
|
|
|
|
support: none
|
2020-03-09 10:11:07 +01:00
|
|
|
options:
|
|
|
|
category:
|
|
|
|
required: true
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Category to execute on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
command:
|
|
|
|
required: true
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- List of commands to execute on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: list
|
2021-02-12 06:47:23 +01:00
|
|
|
elements: str
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri:
|
|
|
|
required: true
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Base URI of OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
username:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Username for authenticating to OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
password:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Password for authenticating to OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2021-03-19 21:14:33 +01:00
|
|
|
auth_token:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Security token for authenticating to OOB controller.
|
2021-03-19 21:14:33 +01:00
|
|
|
type: str
|
|
|
|
version_added: 2.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
bios_attributes:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Dictionary of BIOS attributes to update.
|
2020-03-09 10:11:07 +01:00
|
|
|
default: {}
|
|
|
|
type: dict
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
timeout:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Timeout in seconds for HTTP requests to OOB controller.
|
2023-09-29 13:00:15 +02:00
|
|
|
- The default value for this param is C(10) but that is being deprecated
|
|
|
|
and it will be replaced with C(60) in community.general 9.0.0.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: int
|
|
|
|
boot_order:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- List of BootOptionReference strings specifying the BootOrder.
|
2020-03-09 10:11:07 +01:00
|
|
|
default: []
|
|
|
|
type: list
|
2020-11-27 08:01:02 +01:00
|
|
|
elements: str
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
network_protocols:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Setting dict of manager services to update.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: dict
|
2022-11-01 19:25:51 +01:00
|
|
|
default: {}
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
resource_id:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- ID of the System, Manager or Chassis to modify.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
nic_addr:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- EthernetInterface Address string on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
default: 'null'
|
|
|
|
type: str
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
nic_config:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Setting dict of EthernetInterface on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: dict
|
2022-11-01 19:25:51 +01:00
|
|
|
default: {}
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2021-09-01 22:59:27 +02:00
|
|
|
strip_etag_quotes:
|
|
|
|
description:
|
|
|
|
- Removes surrounding quotes of etag used in C(If-Match) header
|
|
|
|
of C(PATCH) requests.
|
|
|
|
- Only use this option to resolve bad vendor implementation where
|
|
|
|
C(If-Match) only matches the unquoted etag string.
|
|
|
|
type: bool
|
|
|
|
default: false
|
|
|
|
version_added: 3.7.0
|
2021-11-13 13:59:29 +01:00
|
|
|
hostinterface_config:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Setting dict of HostInterface on OOB controller.
|
|
|
|
type: dict
|
2022-11-01 19:25:51 +01:00
|
|
|
default: {}
|
2021-11-13 13:59:29 +01:00
|
|
|
version_added: '4.1.0'
|
|
|
|
hostinterface_id:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Redfish HostInterface instance ID if multiple HostInterfaces are present.
|
|
|
|
type: str
|
|
|
|
version_added: '4.1.0'
|
2022-09-25 17:07:45 +02:00
|
|
|
sessions_config:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Setting dict of Sessions.
|
|
|
|
type: dict
|
2022-11-01 19:25:51 +01:00
|
|
|
default: {}
|
2022-09-25 17:07:45 +02:00
|
|
|
version_added: '5.7.0'
|
2023-08-05 20:52:55 +02:00
|
|
|
storage_subsystem_id:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Id of the Storage Subsystem on which the volume is to be created.
|
|
|
|
type: str
|
|
|
|
default: ''
|
|
|
|
version_added: '7.3.0'
|
|
|
|
volume_ids:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- List of IDs of volumes to be deleted.
|
|
|
|
type: list
|
|
|
|
default: []
|
|
|
|
elements: str
|
|
|
|
version_added: '7.3.0'
|
2023-09-20 22:25:40 +02:00
|
|
|
secure_boot_enable:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Setting parameter to enable or disable SecureBoot.
|
|
|
|
type: bool
|
|
|
|
default: True
|
|
|
|
version_added: '7.5.0'
|
2023-02-17 13:24:35 +01:00
|
|
|
author:
|
|
|
|
- "Jose Delarosa (@jose-delarosa)"
|
|
|
|
- "T S Kushal (@TSKushal)"
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
- name: Set BootMode to UEFI
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetBiosAttributes
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
bios_attributes:
|
|
|
|
BootMode: "Uefi"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Set multiple BootMode attributes
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetBiosAttributes
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
bios_attributes:
|
|
|
|
BootMode: "Bios"
|
|
|
|
OneTimeBootMode: "Enabled"
|
|
|
|
BootSeqRetry: "Enabled"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2021-03-09 21:23:20 +01:00
|
|
|
- name: Enable PXE Boot for NIC1
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetBiosAttributes
|
|
|
|
resource_id: 437XR1138R2
|
2021-03-09 21:23:20 +01:00
|
|
|
bios_attributes:
|
|
|
|
PxeDev1EnDis: Enabled
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Set BIOS default settings with a timeout of 20 seconds
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetBiosDefaultSettings
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
timeout: 20
|
|
|
|
|
|
|
|
- name: Set boot order
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetBootOrder
|
|
|
|
boot_order:
|
|
|
|
- Boot0002
|
|
|
|
- Boot0001
|
|
|
|
- Boot0000
|
|
|
|
- Boot0003
|
|
|
|
- Boot0004
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Set boot order to the default
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetDefaultBootOrder
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Set Manager Network Protocols
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: SetNetworkProtocols
|
|
|
|
network_protocols:
|
|
|
|
SNMP:
|
2022-09-06 20:42:17 +02:00
|
|
|
ProtocolEnabled: true
|
2020-03-09 10:11:07 +01:00
|
|
|
Port: 161
|
|
|
|
HTTP:
|
2022-09-06 20:42:17 +02:00
|
|
|
ProtocolEnabled: false
|
2020-03-09 10:11:07 +01:00
|
|
|
Port: 8080
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Set Manager NIC
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_config:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: SetManagerNic
|
|
|
|
nic_config:
|
|
|
|
DHCPv4:
|
2022-09-06 20:42:17 +02:00
|
|
|
DHCPEnabled: false
|
2020-03-09 10:11:07 +01:00
|
|
|
IPv4StaticAddresses:
|
|
|
|
Address: 192.168.1.3
|
|
|
|
Gateway: 192.168.1.1
|
|
|
|
SubnetMask: 255.255.255.0
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2021-11-13 13:59:29 +01:00
|
|
|
|
|
|
|
- name: Disable Host Interface
|
|
|
|
community.general.redfish_config:
|
|
|
|
category: Manager
|
|
|
|
command: SetHostInterface
|
|
|
|
hostinterface_config:
|
|
|
|
InterfaceEnabled: false
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Enable Host Interface for HostInterface resource ID '2'
|
|
|
|
community.general.redfish_config:
|
|
|
|
category: Manager
|
|
|
|
command: SetHostInterface
|
|
|
|
hostinterface_config:
|
|
|
|
InterfaceEnabled: true
|
|
|
|
hostinterface_id: "2"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2022-09-25 17:07:45 +02:00
|
|
|
|
|
|
|
- name: Set SessionService Session Timeout to 30 minutes
|
|
|
|
community.general.redfish_config:
|
|
|
|
category: Sessions
|
|
|
|
command: SetSessionService
|
|
|
|
sessions_config:
|
|
|
|
SessionTimeout: 1800
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2023-02-17 13:24:35 +01:00
|
|
|
|
|
|
|
- name: Enable SecureBoot
|
|
|
|
community.general.redfish_config:
|
|
|
|
category: Systems
|
|
|
|
command: EnableSecureBoot
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2023-08-05 20:52:55 +02:00
|
|
|
|
2023-09-20 22:25:40 +02:00
|
|
|
- name: Set SecureBoot
|
|
|
|
community.general.redfish_config:
|
|
|
|
category: Systems
|
|
|
|
command: SetSecureBoot
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
secure_boot_enable: True
|
|
|
|
|
2023-08-05 20:52:55 +02:00
|
|
|
- name: Delete All Volumes
|
|
|
|
community.general.redfish_config:
|
|
|
|
category: Systems
|
|
|
|
command: DeleteVolumes
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
storage_subsystem_id: "DExxxxxx"
|
|
|
|
volume_ids: ["volume1", "volume2"]
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
msg:
|
|
|
|
description: Message with action result or error description
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
sample: "Action was successful"
|
|
|
|
'''
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible_collections.community.general.plugins.module_utils.redfish_utils import RedfishUtils
|
2021-06-26 23:59:11 +02:00
|
|
|
from ansible.module_utils.common.text.converters import to_native
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
# More will be added as module features are expanded
|
|
|
|
CATEGORY_COMMANDS_ALL = {
|
|
|
|
"Systems": ["SetBiosDefaultSettings", "SetBiosAttributes", "SetBootOrder",
|
2023-09-20 22:25:40 +02:00
|
|
|
"SetDefaultBootOrder", "EnableSecureBoot", "SetSecureBoot", "DeleteVolumes"],
|
2022-09-25 17:07:45 +02:00
|
|
|
"Manager": ["SetNetworkProtocols", "SetManagerNic", "SetHostInterface"],
|
|
|
|
"Sessions": ["SetSessionService"],
|
2020-03-09 10:11:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
result = {}
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=dict(
|
|
|
|
category=dict(required=True),
|
2021-02-12 06:47:23 +01:00
|
|
|
command=dict(required=True, type='list', elements='str'),
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri=dict(required=True),
|
2021-03-19 21:14:33 +01:00
|
|
|
username=dict(),
|
|
|
|
password=dict(no_log=True),
|
|
|
|
auth_token=dict(no_log=True),
|
2020-03-09 10:11:07 +01:00
|
|
|
bios_attributes=dict(type='dict', default={}),
|
2023-09-29 13:00:15 +02:00
|
|
|
timeout=dict(type='int'),
|
2020-03-09 10:11:07 +01:00
|
|
|
boot_order=dict(type='list', elements='str', default=[]),
|
|
|
|
network_protocols=dict(
|
|
|
|
type='dict',
|
|
|
|
default={}
|
|
|
|
),
|
|
|
|
resource_id=dict(),
|
|
|
|
nic_addr=dict(default='null'),
|
|
|
|
nic_config=dict(
|
|
|
|
type='dict',
|
|
|
|
default={}
|
2021-09-01 22:59:27 +02:00
|
|
|
),
|
|
|
|
strip_etag_quotes=dict(type='bool', default=False),
|
2021-11-13 13:59:29 +01:00
|
|
|
hostinterface_config=dict(type='dict', default={}),
|
|
|
|
hostinterface_id=dict(),
|
2022-09-25 17:07:45 +02:00
|
|
|
sessions_config=dict(type='dict', default={}),
|
2023-08-05 20:52:55 +02:00
|
|
|
storage_subsystem_id=dict(type='str', default=''),
|
2023-09-20 22:25:40 +02:00
|
|
|
volume_ids=dict(type='list', default=[], elements='str'),
|
|
|
|
secure_boot_enable=dict(type='bool', default=True)
|
2020-03-09 10:11:07 +01:00
|
|
|
),
|
2021-03-19 21:14:33 +01:00
|
|
|
required_together=[
|
|
|
|
('username', 'password'),
|
|
|
|
],
|
|
|
|
required_one_of=[
|
|
|
|
('username', 'auth_token'),
|
|
|
|
],
|
|
|
|
mutually_exclusive=[
|
|
|
|
('username', 'auth_token'),
|
|
|
|
],
|
2020-03-09 10:11:07 +01:00
|
|
|
supports_check_mode=False
|
|
|
|
)
|
|
|
|
|
2023-09-29 13:00:15 +02:00
|
|
|
if module.params['timeout'] is None:
|
|
|
|
timeout = 10
|
|
|
|
module.deprecate(
|
|
|
|
'The default value {0} for parameter param1 is being deprecated and it will be replaced by {1}'.format(
|
|
|
|
10, 60
|
|
|
|
),
|
|
|
|
version='9.0.0',
|
|
|
|
collection_name='community.general'
|
|
|
|
)
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
category = module.params['category']
|
|
|
|
command_list = module.params['command']
|
|
|
|
|
|
|
|
# admin credentials used for authentication
|
|
|
|
creds = {'user': module.params['username'],
|
2021-03-19 21:14:33 +01:00
|
|
|
'pswd': module.params['password'],
|
|
|
|
'token': module.params['auth_token']}
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# timeout
|
|
|
|
timeout = module.params['timeout']
|
|
|
|
|
|
|
|
# BIOS attributes to update
|
|
|
|
bios_attributes = module.params['bios_attributes']
|
|
|
|
|
|
|
|
# boot order
|
|
|
|
boot_order = module.params['boot_order']
|
|
|
|
|
|
|
|
# System, Manager or Chassis ID to modify
|
|
|
|
resource_id = module.params['resource_id']
|
|
|
|
|
|
|
|
# manager nic
|
|
|
|
nic_addr = module.params['nic_addr']
|
|
|
|
nic_config = module.params['nic_config']
|
|
|
|
|
2021-09-01 22:59:27 +02:00
|
|
|
# Etag options
|
|
|
|
strip_etag_quotes = module.params['strip_etag_quotes']
|
|
|
|
|
2021-11-13 13:59:29 +01:00
|
|
|
# HostInterface config options
|
|
|
|
hostinterface_config = module.params['hostinterface_config']
|
|
|
|
|
|
|
|
# HostInterface instance ID
|
|
|
|
hostinterface_id = module.params['hostinterface_id']
|
|
|
|
|
2022-09-25 17:07:45 +02:00
|
|
|
# Sessions config options
|
|
|
|
sessions_config = module.params['sessions_config']
|
|
|
|
|
2023-08-05 20:52:55 +02:00
|
|
|
# Volume deletion options
|
|
|
|
storage_subsystem_id = module.params['storage_subsystem_id']
|
|
|
|
volume_ids = module.params['volume_ids']
|
|
|
|
|
2023-09-20 22:25:40 +02:00
|
|
|
# Set SecureBoot options
|
|
|
|
secure_boot_enable = module.params['secure_boot_enable']
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
# Build root URI
|
|
|
|
root_uri = "https://" + module.params['baseuri']
|
|
|
|
rf_utils = RedfishUtils(creds, root_uri, timeout, module,
|
2021-09-01 22:59:27 +02:00
|
|
|
resource_id=resource_id, data_modification=True, strip_etag_quotes=strip_etag_quotes)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# Check that Category is valid
|
|
|
|
if category not in CATEGORY_COMMANDS_ALL:
|
2021-02-23 23:19:27 +01:00
|
|
|
module.fail_json(msg=to_native("Invalid Category '%s'. Valid Categories = %s" % (category, list(CATEGORY_COMMANDS_ALL.keys()))))
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# Check that all commands are valid
|
|
|
|
for cmd in command_list:
|
|
|
|
# Fail if even one command given is invalid
|
|
|
|
if cmd not in CATEGORY_COMMANDS_ALL[category]:
|
|
|
|
module.fail_json(msg=to_native("Invalid Command '%s'. Valid Commands = %s" % (cmd, CATEGORY_COMMANDS_ALL[category])))
|
|
|
|
|
|
|
|
# Organize by Categories / Commands
|
|
|
|
if category == "Systems":
|
|
|
|
# execute only if we find a System resource
|
|
|
|
result = rf_utils._find_systems_resource()
|
|
|
|
if result['ret'] is False:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "SetBiosDefaultSettings":
|
|
|
|
result = rf_utils.set_bios_default_settings()
|
|
|
|
elif command == "SetBiosAttributes":
|
|
|
|
result = rf_utils.set_bios_attributes(bios_attributes)
|
|
|
|
elif command == "SetBootOrder":
|
|
|
|
result = rf_utils.set_boot_order(boot_order)
|
|
|
|
elif command == "SetDefaultBootOrder":
|
|
|
|
result = rf_utils.set_default_boot_order()
|
2023-02-17 13:24:35 +01:00
|
|
|
elif command == "EnableSecureBoot":
|
|
|
|
result = rf_utils.enable_secure_boot()
|
2023-09-20 22:25:40 +02:00
|
|
|
elif command == "SetSecureBoot":
|
|
|
|
result = rf_utils.set_secure_boot(secure_boot_enable)
|
2023-08-05 20:52:55 +02:00
|
|
|
elif command == "DeleteVolumes":
|
|
|
|
result = rf_utils.delete_volumes(storage_subsystem_id, volume_ids)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Manager":
|
|
|
|
# execute only if we find a Manager service resource
|
|
|
|
result = rf_utils._find_managers_resource()
|
|
|
|
if result['ret'] is False:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "SetNetworkProtocols":
|
|
|
|
result = rf_utils.set_network_protocols(module.params['network_protocols'])
|
|
|
|
elif command == "SetManagerNic":
|
|
|
|
result = rf_utils.set_manager_nic(nic_addr, nic_config)
|
2021-11-13 13:59:29 +01:00
|
|
|
elif command == "SetHostInterface":
|
|
|
|
result = rf_utils.set_hostinterface_attributes(hostinterface_config, hostinterface_id)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2022-09-25 17:07:45 +02:00
|
|
|
elif category == "Sessions":
|
|
|
|
# execute only if we find a Sessions resource
|
|
|
|
result = rf_utils._find_sessionservice_resource()
|
|
|
|
if result['ret'] is False:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "SetSessionService":
|
|
|
|
result = rf_utils.set_session_service(sessions_config)
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
# Return data back or fail with proper message
|
|
|
|
if result['ret'] is True:
|
2021-05-11 19:30:09 +02:00
|
|
|
if result.get('warning'):
|
|
|
|
module.warn(to_native(result['warning']))
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
module.exit_json(changed=result['changed'], msg=to_native(result['msg']))
|
|
|
|
else:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|