diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 7c20ab9c3..f027a4bba 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1836,48 +1836,56 @@ releases: release_date: '2024-04-30' 9.3.0: changes: - release_summary: '- The ``ome_session`` module is added to allow you to create and delete the sessions on - OpenManage Enterprise and OpenManage Enterprise Modular. + release_summary: '- The ``ome_session`` module is added to allow you to + create and delete the sessions on OpenManage Enterprise and + OpenManage Enterprise Modular. - - Added support to use session ID for authentication of iDRAC, OpenManage Enterprise and OpenManage - Enterprise Modular modules. + - Added support to use session ID for authentication of iDRAC, + OpenManage Enterprise and OpenManage Enterprise Modular modules. - Added time_to_wait option in ``idrac_storage_volume`` module. - Added support for Python 3.12.' major_changes: - - ome_session - This module allows you to create and delete the sessions on + - ome_session - This module allows you to create and delete the + sessions on OpenManage Enterprise and OpenManage Enterprise Modular. + - Added support to use session ID for authentication of iDRAC, OpenManage Enterprise and OpenManage Enterprise Modular. - - Added support to use session ID for authentication of iDRAC, OpenManage Enterprise and OpenManage - Enterprise Modular. minor_changes: - Added time_to_wait option in ``idrac_storage_volume`` module. - Added support for Python 3.12. bugfixes: - - Resolved the issue in ``idrac_virtual_media`` module where the Authorization request header was included - in the request. (https://github.com/dell/dellemc-openmanage-ansible-modules/issues/612) - - Resolved the issue in ``idrac_certificates`` module where subject_alt_name parameter was only accepting - first item in list. (https://github.com/dell/dellemc-openmanage-ansible-modules/issues/584) - - Resolved the issue in ``ome_application_certificate`` module related to a padding error in generated CSR file. + - Resolved the issue in ``idrac_virtual_media`` module where the + Authorization request header was included in the request. + (https://github.com/dell/dellemc-openmanage-ansible-modules/issues/612) + - Resolved the issue in ``idrac_certificates`` module where + subject_alt_name parameter was only accepting first item in list. + (https://github.com/dell/dellemc-openmanage-ansible-modules/issues/584) + - Resolved the issue in ``ome_application_certificate`` module related + to a padding error in generated CSR file. (https://github.com/dell/dellemc-openmanage-ansible-modules/issues/370) known_issues: - - idrac_storage_volume - Issue(290766) - The module will report success instead of showing - failure for new virtual creation on the BOSS-N1 controller if a virtual disk is already - present on the same controller. - - idrac_diagnostics - Issue(285322) - This module doesn't support export of diagnostics - file to HTTP and HTTPS share via SOCKS proxy. - - idrac_firmware - Issue(279282) - This module does not support firmware update using - HTTP, HTTPS, and FTP shares with authentication on iDRAC8. - - ome_diagnostics - Issue(279193) - Export of SupportAssist collection logs to the - share location fails on OME version 4.0.0. - - ome_smart_fabric_uplink - Issue(186024) - The module supported by OpenManage - Enterprise Modular, however it does not allow the creation of multiple uplinks - of the same name. If an uplink is created using the same name as an existing - uplink, then the existing uplink is modified. + - idrac_storage_volume - Issue(290766) - The module will report success + instead of showing failure for new virtual creation on the BOSS-N1 + controller if a virtual disk is already present on the same + controller. + - idrac_diagnostics - Issue(285322) - This module doesn't support + export of diagnostics file to HTTP and HTTPS share via SOCKS + proxy. + - idrac_firmware - Issue(279282) - This module does not support + firmware update using HTTP, HTTPS, and FTP shares with + authentication on iDRAC8. + - ome_diagnostics - Issue(279193) - Export of SupportAssist + collection logs to the share location fails on OME version 4.0.0. + - ome_smart_fabric_uplink - Issue(186024) - The module supported by + OpenManage Enterprise Modular, however it does not allow the + creation of multiple uplinks of the same name. If an uplink is + created using the same name as an existing uplink, then the existing + uplink is modified. modules: - description: - This module allows you to create and delete sessions on OpenManage Enterprise and - OpenManage Enterprise Modular. + This module allows you to create and delete sessions on OpenManage + Enterprise and OpenManage Enterprise Modular. name: ome_session namespace: '' release_date: '2024-05-31' diff --git a/plugins/module_utils/session_utils.py b/plugins/module_utils/session_utils.py index 11f08a2fb..54728a771 100644 --- a/plugins/module_utils/session_utils.py +++ b/plugins/module_utils/session_utils.py @@ -34,8 +34,7 @@ from ansible.module_utils.urls import open_url from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible_collections.dellemc.openmanage.plugins.module_utils.utils import config_ipv6 -from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError -from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError +from ansible.module_utils.urls import open_url from abc import ABC, abstractmethod HEADER_TYPE = "application/json" @@ -305,15 +304,12 @@ def invoke_request(self, uri, method, data=None, query_param=None, headers=None, :return: The response data from the request. :rtype: OpenURLResponse """ - try: - url_kwargs = self._args_session(method, api_timeout, headers=headers, url_kwargs=url_kwargs) - if data and dump: - data = json.dumps(data) - url = self._build_url(uri, query_param=query_param) - resp = open_url(url, data=data, **url_kwargs) - resp_data = OpenURLResponse(resp) - except (HTTPError, URLError, SSLValidationError, ConnectionError) as err: - raise err + url_kwargs = self._args_session(method, api_timeout, headers=headers, url_kwargs=url_kwargs) + if data and dump: + data = json.dumps(data) + url = self._build_url(uri, query_param=query_param) + resp = open_url(url, data=data, **url_kwargs) + resp_data = OpenURLResponse(resp) return resp_data def _get_omam_ca_env(self): diff --git a/plugins/modules/ome_session.py b/plugins/modules/ome_session.py index 702e9175c..8560b7220 100644 --- a/plugins/modules/ome_session.py +++ b/plugins/modules/ome_session.py @@ -233,13 +233,10 @@ def get_session_status(self, session_url, session_id): int: The status code of the session status response. If an HTTPError occurs, the status code of the error is returned. """ - try: - session_status_response = self.instance.invoke_request(SESSION_URL, "GET") - sessions_data = session_status_response.json_data - session_ids = [session_id["@odata.id"].split("'")[1] for session_id in sessions_data["value"]] - session_status = session_id in session_ids - except HTTPError as err: - raise err + session_status_response = self.instance.invoke_request(SESSION_URL, "GET") + sessions_data = session_status_response.json_data + session_ids = [session_id["@odata.id"].split("'")[1] for session_id in sessions_data["value"]] + session_status = session_id in session_ids return session_status def create_session(self): diff --git a/roles/idrac_attributes/molecule/default/converge.yml b/roles/idrac_attributes/molecule/default/converge.yml index aab3d6a7f..d7d393ec1 100644 --- a/roles/idrac_attributes/molecule/default/converge.yml +++ b/roles/idrac_attributes/molecule/default/converge.yml @@ -18,8 +18,9 @@ - name: Asserting after performing operation with wrong hostname ansible.builtin.assert: - that: - - '"" in idrac_attributes_out.msg' + that: >- + '"" in + idrac_attributes_out.msg' - name: Perform update with wrong username ansible.builtin.import_role: @@ -73,11 +74,9 @@ - name: Asserting after performing operation with invalid https_port ansible.builtin.assert: - that: - - '"" in idrac_attributes_out.msg' - # - ('"Connection refused" in idrac_attributes_out.msg') - # or - # ('"urlopen error timed out" in idrac_attributes_out.msg') + that: >- + '"" in + idrac_attributes_out.msg' - name: Perform update with invalid validate_certs ansible.builtin.import_role: @@ -116,8 +115,10 @@ - name: Asserting after performing operation with wrong ca_path ansible.builtin.assert: - that: - - '"" in idrac_attributes_out.msg' + that: >- + '"" in + idrac_attributes_out.msg' - name: Perform update with wrong manager_id ansible.builtin.import_role: diff --git a/roles/idrac_boot/molecule/boot_source_override_enabled_as_continuous_reset_type_none/converge.yml b/roles/idrac_boot/molecule/boot_source_override_enabled_as_continuous_reset_type_none/converge.yml index 782c155ed..dbf9d273b 100644 --- a/roles/idrac_boot/molecule/boot_source_override_enabled_as_continuous_reset_type_none/converge.yml +++ b/roles/idrac_boot/molecule/boot_source_override_enabled_as_continuous_reset_type_none/converge.yml @@ -109,5 +109,7 @@ - name: Asserting TC-115433 in normal mode ansible.builtin.assert: - that: idrac_boot_out.msg == "The boot settings operation is triggered/submitted successfully." + that: >- + "The boot settings operation is triggered/submitted successfully." in + idrac_boot_out.msg when: not ansible_check_mode diff --git a/roles/idrac_boot/molecule/boot_source_override_enabled_as_disabled_reset_type_none/converge.yml b/roles/idrac_boot/molecule/boot_source_override_enabled_as_disabled_reset_type_none/converge.yml index bcb854238..3cd71f208 100644 --- a/roles/idrac_boot/molecule/boot_source_override_enabled_as_disabled_reset_type_none/converge.yml +++ b/roles/idrac_boot/molecule/boot_source_override_enabled_as_disabled_reset_type_none/converge.yml @@ -92,7 +92,9 @@ - name: Asserting TC-115431 in normal mode ansible.builtin.assert: - that: idrac_boot_out.msg == "The boot settings operation is triggered/submitted successfully." + that: >- + "The boot settings operation is triggered/submitted successfully." in + idrac_boot_out.msg when: not ansible_check_mode and idrac_boot_out.changed - name: Asserting TC-115431 in idempotence mode diff --git a/roles/idrac_boot/molecule/boot_source_override_enabled_as_once_reset_type_none/converge.yml b/roles/idrac_boot/molecule/boot_source_override_enabled_as_once_reset_type_none/converge.yml index b021003fe..d9aeee409 100644 --- a/roles/idrac_boot/molecule/boot_source_override_enabled_as_once_reset_type_none/converge.yml +++ b/roles/idrac_boot/molecule/boot_source_override_enabled_as_once_reset_type_none/converge.yml @@ -91,6 +91,8 @@ - name: Asserting TC-115432 in normal mode or idempotence mode ansible.builtin.assert: - that: - - 'idrac_boot_out.msg == "The boot settings operation is triggered/submitted successfully." or "No changes found to be applied."' + that: >- + 'idrac_boot_out.msg == "The boot settings operation is + triggered/submitted successfully." or "No changes found to be + applied."' when: not ansible_check_mode and not idrac_boot_out.changed diff --git a/roles/idrac_boot/molecule/boot_source_override_mode_legacy_job_wait_false/converge.yml b/roles/idrac_boot/molecule/boot_source_override_mode_legacy_job_wait_false/converge.yml index 0c9693e07..142a0bebb 100644 --- a/roles/idrac_boot/molecule/boot_source_override_mode_legacy_job_wait_false/converge.yml +++ b/roles/idrac_boot/molecule/boot_source_override_mode_legacy_job_wait_false/converge.yml @@ -105,6 +105,8 @@ - name: Asserting TC-115429 in normal mode or idempotence mode ansible.builtin.assert: - that: - - 'idrac_boot_out.msg == "The boot settings operation is triggered/submitted successfully." or "No changes found to be applied."' + that: >- + 'idrac_boot_out.msg == "The boot settings operation is + triggered/submitted successfully." or "No changes found to + be applied."' when: not ansible_check_mode and not idrac_boot_out.changed diff --git a/roles/idrac_certificate/molecule/default/converge.yml b/roles/idrac_certificate/molecule/default/converge.yml index 47ec29121..3b394ff6b 100644 --- a/roles/idrac_certificate/molecule/default/converge.yml +++ b/roles/idrac_certificate/molecule/default/converge.yml @@ -165,9 +165,9 @@ - name: Verify task status - Negative - invalid unreachable host ansible.builtin.assert: - that: - - idrac_certificate_out.unreachable - - '"" in idrac_certificate_out.msg' + that: >- + '"" in + idrac_certificate_out.msg' and idrac_certificate_out.unreachable - name: Negative - invalid idrac user ansible.builtin.import_role: diff --git a/roles/idrac_certificate/molecule/default/molecule.yml b/roles/idrac_certificate/molecule/default/molecule.yml index 4b4b16f6d..c6b1e43af 100644 --- a/roles/idrac_certificate/molecule/default/molecule.yml +++ b/roles/idrac_certificate/molecule/default/molecule.yml @@ -1,3 +1,4 @@ +--- scenario: test_sequence: - dependency diff --git a/roles/idrac_gather_facts/molecule/passensor/converge.yml b/roles/idrac_gather_facts/molecule/passensor/converge.yml index 7d0722e50..0194b2019 100644 --- a/roles/idrac_gather_facts/molecule/passensor/converge.yml +++ b/roles/idrac_gather_facts/molecule/passensor/converge.yml @@ -29,7 +29,8 @@ tasks: - name: Fetching Presence and Status Sensor info ansible.builtin.uri: - url: "https://{{ hostname }}{{ api_system }}/Oem/Dell/DellPresenceAndStatusSensors" + url: "https://{{ hostname }}{{ api_system }}/Oem/ + Dell/DellPresenceAndStatusSensors" validate_certs: "{{ validate_certs }}" ca_path: "{{ ca_path | default(omit) }}" method: "{{ idrac_gather_facts_uri_method }}" @@ -44,8 +45,10 @@ - name: Set presence and status sensor facts ansible.builtin.set_fact: - api_response: "{{ passensor_result.json.Members | ansible.utils.remove_keys(target=['@odata.context', + api_response: "{{ passensor_result.json.Members | + ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type', 'Assembly', 'Links']) }}" + when: passensor_result.json.Members is defined - name: Gather Facts for the Presence and Status Sensor ansible.builtin.include_role: @@ -54,14 +57,16 @@ - name: Assert Presence and Status Sensor data ansible.builtin.assert: that: - - "((api_response | length == 0) and (presence_and_status_sensor | length == 0))" + - "((api_response | length == 0) and + (presence_and_status_sensor | length == 0))" fail_msg: "The response from the role does not match" success_msg: "The response from the role matches" when: api_response | length == 0 - name: Check whether output differs ansible.builtin.set_fact: - result_diff: "{{ presence_and_status_sensor | symmetric_difference(api_response) }}" + result_diff: "{{ presence_and_status_sensor | + symmetric_difference(api_response) }}" when: api_response | length > 0 - name: Assert the differences in List diff --git a/roles/idrac_gather_facts/molecule/physicaldisk/converge.yml b/roles/idrac_gather_facts/molecule/physicaldisk/converge.yml index 8883c0b9c..430237de0 100644 --- a/roles/idrac_gather_facts/molecule/physicaldisk/converge.yml +++ b/roles/idrac_gather_facts/molecule/physicaldisk/converge.yml @@ -43,7 +43,10 @@ - name: Get all storage controller ids. ansible.builtin.set_fact: - storage_ids_list: "{{ idrac_gather_facts_controllers_result.json.Members | map('dict2items') | flatten | map(attribute='value') }}" + storage_ids_list: + "{{ idrac_gather_facts_controllers_result.json.Members | + map('dict2items') | flatten | map(attribute='value') }}" + when: idrac_gather_facts_controllers_result.json.Members is defined - name: Get physical disk information using API. ansible.builtin.uri: @@ -52,17 +55,25 @@ loop: "{{ storage_ids_list }}" no_log: true register: idrac_gather_facts_disk_result + when: storage_ids_list is defined - name: Count the number of drives in drives_result.results ansible.builtin.set_fact: - drives_count: "{{ idrac_gather_facts_disk_result.results | map(attribute='json.drives') | list | length }}" + drives_count: "{{ idrac_gather_facts_disk_result.results | + map(attribute='json.drives') | list | length }}" + when: idrac_gather_facts_disk_result.results is defined - name: Set Physical Disk facts ansible.builtin.set_fact: api_response: - "{{ idrac_gather_facts_disk_result.results | selectattr('json', 'defined') | map(attribute='json') | selectattr('Drives', 'defined') | - map(attribute='Drives') | flatten | ansible.utils.remove_keys(target=['@odata.context', '@odata.id', '@odata.type', - 'Actions', 'Assembly', 'Links', 'DellDriveSMARTAttributes', 'DellNVMeSMARTAttributes', 'Operations@odata.count']) }}" + "{{ idrac_gather_facts_disk_result.results | + selectattr('json', 'defined') | map(attribute='json') | + selectattr('Drives', 'defined') | map(attribute='Drives') | + flatten | ansible.utils.remove_keys(target=['@odata.context', + '@odata.id', '@odata.type', 'Actions', 'Assembly', 'Links', + 'DellDriveSMARTAttributes', 'DellNVMeSMARTAttributes', + 'Operations@odata.count']) }}" + when: idrac_gather_facts_disk_result.results is defined - name: Gather Facts for the Physical Disk component ansible.builtin.include_role: diff --git a/roles/idrac_gather_facts/tests/asserts/mmetrics_assert.yml b/roles/idrac_gather_facts/tests/asserts/mmetrics_assert.yml index fd8788382..6964f8d12 100644 --- a/roles/idrac_gather_facts/tests/asserts/mmetrics_assert.yml +++ b/roles/idrac_gather_facts/tests/asserts/mmetrics_assert.yml @@ -14,7 +14,9 @@ - name: Get Memory Metrics ids ansible.builtin.set_fact: - memory_metrics_ids: "{{ response_memory.json.Members | selectattr('Metrics', 'defined') | map(attribute='Metrics') | flatten }}" + memory_metrics_ids: "{{ response_memory.json.Members | + selectattr('Metrics', 'defined') | map(attribute='Metrics') | flatten }}" + when: response_memory.json.Members is defined - name: Get Memory Metrics information. ansible.builtin.uri: @@ -26,20 +28,25 @@ - name: Set Memory Metrics facts ansible.builtin.set_fact: - api_memory_metrics: "{{ response_memory_metrics.results | selectattr('json', 'defined') | map(attribute='json') | flatten | - ansible.utils.remove_keys(target=['@odata.context', '@odata.type', '@odata.id', 'DataSourceUri']) }}" + api_memory_metrics: "{{ response_memory_metrics.results | + selectattr('json', 'defined') | map(attribute='json') | + flatten | ansible.utils.remove_keys(target=['@odata.context', + '@odata.type', '@odata.id', 'DataSourceUri']) }}" + when: response_memory_metrics.results is defined - name: Assert memory metrics ansible.builtin.assert: that: - - "((api_memory_metrics | length == 0) and (memory_metrics | length == 0))" + - "((api_memory_metrics | length == 0) and + (memory_metrics | length == 0))" fail_msg: "The response from the role does not match" success_msg: "The response from the role matches" when: api_memory_metrics| length == 0 - name: Check whether output differs ansible.builtin.set_fact: - result_diff: "{{ memory_metrics | symmetric_difference(api_memory_metrics) }}" + result_diff: "{{ memory_metrics | + symmetric_difference(api_memory_metrics) }}" when: api_memory_metrics| length > 0 - name: Assert the differences in List diff --git a/roles/idrac_gather_facts/tests/asserts/tmetrics_assert.yml b/roles/idrac_gather_facts/tests/asserts/tmetrics_assert.yml index c86b3e985..93f1e3960 100644 --- a/roles/idrac_gather_facts/tests/asserts/tmetrics_assert.yml +++ b/roles/idrac_gather_facts/tests/asserts/tmetrics_assert.yml @@ -1,7 +1,8 @@ --- - name: Get Thermal Metrics information. ansible.builtin.uri: - url: "https://{{ hostname }}{{ api_chassis }}/ThermalSubsystem/ThermalMetrics" + url: + "https://{{ hostname }}{{ api_chassis }}/ThermalSubsystem/ThermalMetrics" validate_certs: "{{ validate_certs }}" method: "{{ idrac_gather_facts_uri_method }}" user: "{{ username }}" @@ -16,19 +17,24 @@ - name: Set Thermal Metrics facts ansible.builtin.set_fact: api_thermal_metrics: "{{ response_thermal_metrics.json | - ansible.utils.remove_keys(target=['@odata.context', '@odata.type', '@odata.id', 'DataSourceUri', 'TemperatureReadingsCelsius@odata.count']) }}" + ansible.utils.remove_keys(target=['@odata.context', '@odata.type', + '@odata.id', 'DataSourceUri', + 'TemperatureReadingsCelsius@odata.count']) }}" + when: response_thermal_metrics is defined - name: Assert thermal metrics ansible.builtin.assert: that: - - "((api_thermal_metrics | length == 0) and (thermal_metrics | length == 0))" + - "((api_thermal_metrics | length == 0) and + (thermal_metrics | length == 0))" fail_msg: "The response from the role does not match" success_msg: "The response from the role matches" when: api_thermal_metrics| length == 0 - name: Check whether output differs ansible.builtin.set_fact: - result_diff: "{{ thermal_metrics | symmetric_difference(api_thermal_metrics) }}" + result_diff: "{{ thermal_metrics | + symmetric_difference(api_thermal_metrics) }}" when: api_thermal_metrics | length > 0 - name: Assert the differences in List diff --git a/roles/redfish_storage_volume/molecule/default/converge.yml b/roles/redfish_storage_volume/molecule/default/converge.yml index 4f04a39c0..11e682d7b 100644 --- a/roles/redfish_storage_volume/molecule/default/converge.yml +++ b/roles/redfish_storage_volume/molecule/default/converge.yml @@ -14,7 +14,7 @@ validate_certs: false state: present volume_type: "NonRedundant" - name: "VD" # noqa: var-naming[no-reserved] + name: "VD" # noqa: var-naming[no-reserved] controller_id: "" drives: "" capacity_bytes: 214748364800 @@ -27,8 +27,9 @@ - name: Asserting after performing operation. ansible.builtin.assert: - that: - - '"" in redfish_storage_volume_out.msg' + that: >- + '"" in + redfish_storage_volume_out.msg' - name: To check the behaviour of invalid credentials. ansible.builtin.import_role: @@ -40,7 +41,7 @@ validate_certs: false state: present volume_type: "NonRedundant" - name: "VD" # noqa: var-naming[no-reserved] + name: "VD" # noqa: var-naming[no-reserved] controller_id: "" drives: "" capacity_bytes: 214748364800 @@ -65,7 +66,7 @@ validate_certs: false state: invalid volume_type: "SpannedStripesWithParity" - name: "VD" # noqa: var-naming[no-reserved] + name: "VD" # noqa: var-naming[no-reserved] controller_id: "" drives: "" capacity_bytes: 214748364800 @@ -77,8 +78,9 @@ - name: Asserting after performing operation for invalid span count. ansible.builtin.assert: - that: |- - redfish_storage_volume_out.msg == "value of state must be one of: present, absent, got: invalid" + that: >- + redfish_storage_volume_out.msg == "value of state must be one of: + present, absent, got: invalid" when: not ansible_check_mode - name: To check the behaviour of invalid certificate path. @@ -92,7 +94,7 @@ ca_path: "/tmp/invalid_ca_path.pem" state: present volume_type: "SpannedStripesWithParity" - name: "VD" # noqa: var-naming[no-reserved] + name: "VD" # noqa: var-naming[no-reserved] controller_id: "" drives: "" capacity_bytes: 214748364800 @@ -105,8 +107,9 @@ - name: Asserting after performing operation for invalid certificate path. ansible.builtin.assert: - that: |- - "[Errno 2] No such file or directory" in redfish_storage_volume_out.msg + that: >- + "[Errno 2] No such file or directory" in + redfish_storage_volume_out.msg - name: To check the behaviour of invalid raid type. ansible.builtin.import_role: @@ -118,7 +121,7 @@ validate_certs: false state: present raid_type: "Invalid" - name: "VD" # noqa: var-naming[no-reserved] + name: "VD" # noqa: var-naming[no-reserved] controller_id: "" drives: "" capacity_bytes: 214748364800 @@ -130,9 +133,10 @@ - name: Asserting after performing operation for invalid raid type. ansible.builtin.assert: - that: > - redfish_storage_volume_out.msg == "value of raid_type must be one of: RAID0, RAID1, RAID5, RAID6, RAID10, - RAID50, RAID60, got: Invalid" + that: >- + "value of raid_type must be one of: RAID0, RAID1, RAID5, RAID6, + RAID10, RAID50, RAID60, got: Invalid" in + redfish_storage_volume_out.msg - name: To check the behaviour of invalid controller_id. ansible.builtin.import_role: @@ -144,7 +148,7 @@ validate_certs: false state: present raid_type: "RAID0" - name: "VD" # noqa: var-naming[no-reserved] + name: "VD" # noqa: var-naming[no-reserved] controller_id: "invalid" capacity_bytes: 214748364800 optimum_io_size_bytes: 65536 @@ -156,6 +160,7 @@ - name: Asserting after performing operation for invalid controller_id. ansible.builtin.assert: - that: > - redfish_storage_volume_out.msg == "Specified Controller invalid does not exist in the System." + that: >- + "Specified Controller invalid does not exist in the System." in + redfish_storage_volume_out.msg when: redfish_storage_volume_out.failed diff --git a/roles/redfish_storage_volume/molecule/default/molecule.yml b/roles/redfish_storage_volume/molecule/default/molecule.yml index e69de29bb..6fe7d44bb 100644 --- a/roles/redfish_storage_volume/molecule/default/molecule.yml +++ b/roles/redfish_storage_volume/molecule/default/molecule.yml @@ -0,0 +1,10 @@ +--- +scenario: + test_sequence: + - dependency + - destroy + - syntax + - create + - converge + - cleanup + - destroy diff --git a/tests/integration/targets/idrac_session/tests/_delete_helper.yml b/tests/integration/targets/idrac_session/tests/_delete_helper.yml index 8377e5c56..8ccfb63b5 100644 --- a/tests/integration/targets/idrac_session/tests/_delete_helper.yml +++ b/tests/integration/targets/idrac_session/tests/_delete_helper.yml @@ -1,3 +1,4 @@ +--- - name: Delete a session dellemc.openmanage.idrac_session: validate_certs: "{{ validate_certs }}" diff --git a/tests/integration/targets/idrac_session/tests/create_idrac_session.yaml b/tests/integration/targets/idrac_session/tests/create_idrac_session.yaml index 5c96e06ae..7ee666498 100644 --- a/tests/integration/targets/idrac_session/tests/create_idrac_session.yaml +++ b/tests/integration/targets/idrac_session/tests/create_idrac_session.yaml @@ -1,12 +1,15 @@ # Dell OpenManage Ansible modules # Copyright (C) 2024 Dell Inc. or its subsidiaries. All Rights Reserved. -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# GNU General Public License v3.0+ (see COPYING or +# https://www.gnu.org/licenses/gpl-3.0.txt) --- - name: Test that we have an iDRAC host, iDRAC username and iDRAC password ansible.builtin.fail: - msg: 'Please define the following variables: idrac_ip, idrac_user and idrac_password.' - when: idrac_ip is not defined or idrac_user is not defined or idrac_password is not defined + msg: 'Please define the following variables: idrac_ip, idrac_user and + idrac_password.' + when: 'idrac_ip is not defined or idrac_user is not defined or idrac_password + is not defined' - block: - name: Create a new session - Check mode @@ -28,7 +31,8 @@ ansible.builtin.assert: that: - create_session_output.changed - - create_session_output.msg == 'The session has been created successfully.' + - 'create_session_output.msg == "The session has been created + successfully."' - create_session_output.x_auth_token - create_session_output.session_data @@ -46,7 +50,8 @@ - name: Extract messages from ExtendedInfo ansible.builtin.set_fact: - actual_messages: "{{ create_session_output.session_data['@Message.ExtendedInfo'] | map(attribute='Message') | list }}" + actual_messages: "{{ create_session_output.session_data + ['@Message.ExtendedInfo'] | map(attribute='Message') | list }}" - name: Assert each element of actual_messages with expected_messages ansible.builtin.assert: @@ -56,7 +61,8 @@ - name: Validate creation of session via API ansible.builtin.uri: - url: "https://{{ idrac_ip | ansible.utils.ipwrap }}:{{ idrac_port }}/redfish/v1/Sessions/{{ session_id }}" + url: "https://{{ idrac_ip | ansible.utils.ipwrap }}:{{ idrac_port }} + /redfish/v1/Sessions/{{ session_id }}" method: GET status_code: 200 user: "{{ idrac_user }}" diff --git a/tests/integration/targets/idrac_session/tests/delete_idrac_session.yaml b/tests/integration/targets/idrac_session/tests/delete_idrac_session.yaml index c2b6d925b..a024939f1 100644 --- a/tests/integration/targets/idrac_session/tests/delete_idrac_session.yaml +++ b/tests/integration/targets/idrac_session/tests/delete_idrac_session.yaml @@ -1,12 +1,15 @@ # Dell OpenManage Ansible modules # Copyright (C) 2024 Dell Inc. or its subsidiaries. All Rights Reserved. -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# GNU General Public License v3.0+ (see COPYING or +# https://www.gnu.org/licenses/gpl-3.0.txt) --- - name: Test that we have an iDRAC host, iDRAC username and iDRAC password ansible.builtin.fail: - msg: 'Please define the following variables: idrac_ip, idrac_user and idrac_password.' - when: idrac_ip is not defined or idrac_user is not defined or idrac_password is not defined + msg: 'Please define the following variables: idrac_ip, idrac_user and + idrac_password.' + when: 'idrac_ip is not defined or idrac_user is not defined or idrac_password + is not defined' - block: - name: Prerequisite - Create a new session @@ -49,7 +52,8 @@ ansible.builtin.assert: that: - delete_session_output.changed - - delete_session_output.msg == 'The session has been deleted successfully.' + - 'delete_session_output.msg == "The session has been deleted + successfully."' - name: Delete session with deleted session dellemc.openmanage.idrac_session: @@ -62,7 +66,8 @@ that: - delete_session_with_deleted_session.failed - not delete_session_with_deleted_session.changed - - 'delete_session_with_deleted_session.msg == "HTTP Error 401: Unauthorized"' + - 'delete_session_with_deleted_session.msg == "HTTP Error 401: + Unauthorized"' - name: Prerequisite - Create another new session dellemc.openmanage.idrac_session: diff --git a/tests/integration/targets/idrac_session/tests/invalid.yaml b/tests/integration/targets/idrac_session/tests/invalid.yaml index 0e3c46b54..dd821d7e8 100644 --- a/tests/integration/targets/idrac_session/tests/invalid.yaml +++ b/tests/integration/targets/idrac_session/tests/invalid.yaml @@ -1,12 +1,15 @@ # Dell OpenManage Ansible modules # Copyright (C) 2024 Dell Inc. or its subsidiaries. All Rights Reserved. -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# GNU General Public License v3.0+ (see COPYING or +# https://www.gnu.org/licenses/gpl-3.0.txt) --- - name: Test that we have an iDRAC host, iDRAC username and iDRAC password - fail: - msg: 'Please define the following variables: idrac_ip, idrac_user and idrac_password.' - when: idrac_ip is not defined or idrac_user is not defined or idrac_password is not defined + ansible.builtin.fail: + msg: 'Please define the following variables: idrac_ip, idrac_user and + idrac_password.' + when: 'idrac_ip is not defined or idrac_user is not defined or idrac_password + is not defined' - block: - name: Negative - Invalid value for state @@ -19,7 +22,8 @@ ansible.builtin.assert: that: - invalid_state.failed - - 'invalid_state.msg == "value of state must be one of: present, absent, got: invalid"' + - 'invalid_state.msg == "value of state must be one of: present, + absent, got: invalid"' - name: Negative - unreachable host dellemc.openmanage.idrac_session: @@ -32,7 +36,8 @@ that: - invalid_unreachable.unreachable - not invalid_unreachable.changed - - 'invalid_unreachable.msg == ""' + - 'invalid_unreachable.msg == ""' - name: Negative - Invalid username dellemc.openmanage.idrac_session: @@ -45,7 +50,8 @@ that: - invalid_username.failed - not invalid_username.changed - - 'invalid_username.msg == "HTTP Error 401: Unauthorized" or invalid_username.msg == ""' + - 'invalid_username.msg == "HTTP Error 401: Unauthorized" or + invalid_username.msg == ""' - name: Negative - Invalid password dellemc.openmanage.idrac_session: @@ -58,7 +64,8 @@ that: - invalid_password.failed - not invalid_password.changed - - 'invalid_password.msg == "HTTP Error 401: Unauthorized" or invalid_password.msg == ""' + - 'invalid_password.msg == "HTTP Error 401: Unauthorized" or + invalid_password.msg == ""' - name: Negative - Invalid port dellemc.openmanage.idrac_session: @@ -71,7 +78,8 @@ that: - invalid_port.unreachable - not invalid_port.changed - - 'invalid_port.msg == ""' + - 'invalid_port.msg == ""' - name: Negative - Invalid validate_certs dellemc.openmanage.idrac_session: @@ -80,8 +88,9 @@ ignore_errors: true - ansible.builtin.set_fact: - invalid_validate_certs_expected_msg: "argument 'validate_certs' is of type and we were unable to convert to bool: The value 'invalid' is - not a valid boolean. Valid booleans include: " + invalid_validate_certs_expected_msg: "argument 'validate_certs' is of + type and we were unable to convert to bool: The value + 'invalid' is not a valid boolean. Valid booleans include: " - name: Verify task status - Negative - Invalid validate_certs ansible.builtin.assert: @@ -101,7 +110,8 @@ that: - invalid_ca_path.failed - not invalid_ca_path.changed - - 'invalid_ca_path.msg == "[Errno 2] No such file or directory: b''/invalid/path''"' + - 'invalid_ca_path.msg == "[Errno 2] No such file or directory: + b''/invalid/path''"' - name: Negative - Invalid timeout type dellemc.openmanage.idrac_session: @@ -114,8 +124,9 @@ that: - invalid_timeout_type.failed - not invalid_timeout_type.changed - - 'invalid_timeout_type.msg == "argument ''timeout'' is of type and we were unable to convert to int: cannot be - converted to an int"' + - 'invalid_timeout_type.msg == "argument ''timeout'' is of type + and we were unable to convert to int: + cannot be converted to an int"' - name: Negative - Invalid timeout value dellemc.openmanage.idrac_session: @@ -141,8 +152,11 @@ that: - invalid_unsupported_argument.failed - not invalid_unsupported_argument.changed - - 'invalid_unsupported_argument.msg =="Unsupported parameters for (dellemc.openmanage.idrac_session) module: unsupported_argument. Supported - parameters include: ca_path, hostname, password, port, session_id, state, timeout, username, validate_certs, x_auth_token (auth_token)."' + - 'invalid_unsupported_argument.msg =="Unsupported parameters for + (dellemc.openmanage.idrac_session) module: unsupported_argument. + Supported parameters include: ca_path, hostname, password, port, + session_id, state, timeout, username, validate_certs, x_auth_token + (auth_token)."' module_defaults: dellemc.openmanage.idrac_session: diff --git a/tests/integration/targets/idrac_session/tests/invalid_delete.yaml b/tests/integration/targets/idrac_session/tests/invalid_delete.yaml index d6b373ab3..f277dd5d8 100644 --- a/tests/integration/targets/idrac_session/tests/invalid_delete.yaml +++ b/tests/integration/targets/idrac_session/tests/invalid_delete.yaml @@ -1,12 +1,15 @@ # Dell OpenManage Ansible modules # Copyright (C) 2024 Dell Inc. or its subsidiaries. All Rights Reserved. -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# GNU General Public License v3.0+ (see COPYING or +# https://www.gnu.org/licenses/gpl-3.0.txt) --- - name: Test that we have an iDRAC host, iDRAC username and iDRAC password ansible.builtin.fail: - msg: 'Please define the following variables: idrac_ip, idrac_user and idrac_password.' - when: idrac_ip is not defined or idrac_user is not defined or idrac_password is not defined + msg: 'Please define the following variables: idrac_ip, idrac_user and + idrac_password.' + when: 'idrac_ip is not defined or idrac_user is not defined or idrac_password + is not defined' - block: - name: Prerequisite - Create a new session @@ -27,12 +30,13 @@ register: invalid_missing_argument ignore_errors: true - - name: Verify task status - Negative - missing required argument for delete operation + - name: Verify task status - Missing required argument for delete operation ansible.builtin.assert: that: - invalid_missing_argument.failed - not invalid_missing_argument.changed - - 'invalid_missing_argument.msg == "state is absent but all of the following are missing: session_id"' + - 'invalid_missing_argument.msg == "state is absent but all of the + following are missing: session_id"' - name: Negative - Invalid session id dellemc.openmanage.idrac_session: @@ -43,8 +47,9 @@ ignore_errors: true - ansible.builtin.set_fact: - invalid_session_id_expected_msg: "argument 'session_id' is of - type and we were unable to convert to int: cannot be converted to an int" + invalid_session_id_expected_msg: "argument 'session_id' is of type + and we were unable to convert to int: + cannot be converted to an int" - name: Verify task status - Negative - Invalid session id ansible.builtin.assert: diff --git a/tests/unit/plugins/modules/test_idrac_certificates.py b/tests/unit/plugins/modules/test_idrac_certificates.py index c5643c8a6..4d45cae73 100644 --- a/tests/unit/plugins/modules/test_idrac_certificates.py +++ b/tests/unit/plugins/modules/test_idrac_certificates.py @@ -291,13 +291,13 @@ def test_upload_ssl_key(self, idrac_default_args): def test_build_generate_csr_payload(self, idrac_default_args): cert_params_data = { "cert_params": { - "subject_alt_name": ['192.198.2.1,192.198.2.2', '192.198.2.3'] + "subject_alt_name": ['192.198.2.1,192.198.2.2', 'X.X.X.X'] } } idrac_default_args.update(cert_params_data) f_module = self.get_module_mock(params=idrac_default_args) payload = self.module._build_generate_csr_payload(f_module, None) - assert payload["AlternativeNames"] == ['192.198.2.1,192.198.2.2,192.198.2.3'] + assert payload["AlternativeNames"] == ['192.198.2.1,192.198.2.2,X.X.X.X'] @pytest.mark.parametrize("params", [{"json_data": { "Actions": { diff --git a/tests/unit/plugins/modules/test_ome_session.py b/tests/unit/plugins/modules/test_ome_session.py index 0cc8da876..6a547dc10 100644 --- a/tests/unit/plugins/modules/test_ome_session.py +++ b/tests/unit/plugins/modules/test_ome_session.py @@ -393,9 +393,8 @@ def test_get_session_status_http_error(self, ome_connection_session_mock): f_module = self.get_module_mock( params=params, check_mode=False) session_obj = self.module.OMESession(f_module) - json_str = to_text(json.dumps({"data": "out"})) session_obj.instance.invoke_request.side_effect = HTTPError(HTTPS_PATH, 400, '', {}, None) - with pytest.raises(HTTPError) as ex: + with pytest.raises(HTTPError): session_obj.get_session_status(SESSION_URL, params["session_id"]) @pytest.mark.parametrize("exc_type",