def idrac_lc_status_mock(self, mocker):
     omsdk_mock = MagicMock()
     idrac_obj = MagicMock()
     omsdk_mock.config_mgr = idrac_obj
     type(idrac_obj).LCStatus = Mock(return_value="lcstatus")
     type(idrac_obj).LCReady = Mock(return_value="lcready")
     return idrac_obj
Beispiel #2
0
 def idrac_firmware_update_mock(self, mocker):
     omsdk_mock = MagicMock()
     idrac_obj = MagicMock()
     omsdk_mock.update_mgr = idrac_obj
     idrac_obj.update_from_repo = Mock(
         return_value={
             "update_status": {
                 "job_details": {
                     "Data": {
                         "StatusCode": 200,
                         "body": {
                             "PackageList": [{}]
                         }
                     }
                 }
             }
         })
     idrac_obj.update_from_repo_url = Mock(
         return_value={
             "job_details": {
                 "Data": {
                     "StatusCode": 200,
                     "body": {
                         "PackageList": [{}]
                     }
                 }
             }
         })
     return idrac_obj
 def idrac_configure_eventing_mock(self, mocker):
     omsdk_mock = MagicMock()
     idrac_obj = MagicMock()
     omsdk_mock.file_share_manager = idrac_obj
     omsdk_mock.config_mgr = idrac_obj
     type(idrac_obj).create_share_obj = Mock(return_value="Status")
     type(idrac_obj).set_liason_share = Mock(return_value="Status")
     return idrac_obj
Beispiel #4
0
 def idrac_storage_volume_mock(self, mocker):
     omsdk_mock = MagicMock()
     idrac_obj = MagicMock()
     omsdk_mock.file_share_manager = idrac_obj
     omsdk_mock.config_mgr = idrac_obj
     type(idrac_obj).create_share_obj = Mock(return_value="servicesstatus")
     type(idrac_obj).set_liason_share = Mock(return_value="servicestatus")
     return idrac_obj
 def test_run_export_server_config_profile_runtimeerror_case(
         self, idrac_connection_server_configure_profile_mock,
         idrac_default_args, idrac_file_manager_server_config_profile_mock):
     idrac_default_args.update({
         "share_name": "sharename",
         "share_user": "******",
         "share_password": "******",
         "command": "export",
         "job_wait": True,
         "scp_components": "IDRAC",
         "scp_file": "scp_file.xml",
         "end_host_power_state": "On",
         "shutdown_type": "Graceful",
         "export_format": "XML",
         "export_use": "Default"
     })
     message = {"Status": "Failed"}
     f_module = self.get_module_mock(params=idrac_default_args)
     obj = MagicMock()
     idrac_connection_server_configure_profile_mock.config_mgr = obj
     obj.scp_export = Mock(return_value=message)
     with pytest.raises(Exception) as ex:
         self.module.run_export_server_config_profile(
             idrac_connection_server_configure_profile_mock, f_module)
     assert "Failed to export scp." == str(ex.value)
Beispiel #6
0
 def test_create_storage_success_case01(
         self, idrac_connection_storage_volume_mock, idrac_default_args,
         mocker):
     idrac_default_args.update({
         "volumes": {
             "name": "volume1"
         },
         "controller_id": "x56y"
     })
     mocker.patch(
         "ansible_collections.dellemc.openmanage.plugins.modules.dellemc_idrac_storage_volume."
         "multiple_vd_config",
         return_value={
             "name": "volume1",
             "stripe_size": 1.3
         })
     obj = MagicMock()
     idrac_connection_storage_volume_mock.config_mgr.RaidHelper = obj
     obj.new_virtual_disk = Mock(return_value=[{
         "name": "volume1",
         "stripe_size": 1.3
     }])
     f_module = self.get_module_mock(params=idrac_default_args)
     result = self.module.create_storage(
         idrac_connection_storage_volume_mock, f_module)
     assert result == [{'name': 'volume1', 'stripe_size': 1.3}]
Beispiel #7
0
 def idrac_firmware_job_mock(self, mocker):
     omsdk_mock = MagicMock()
     idrac_obj = MagicMock()
     omsdk_mock.job_mgr = idrac_obj
     idrac_obj.get_job_status_redfish = Mock(return_value={
         "update_status": {
             "job_details": {
                 "Data": {
                     "StatusCode": 200,
                     "body": {
                         "PackageList": [{}]
                     }
                 }
             }
         }
     })
     idrac_obj.job_wait = Mock(return_value="21543")
     return idrac_obj
Beispiel #8
0
 def test_delete_storage_case(self, idrac_connection_storage_volume_mock,
                              idrac_default_args):
     idrac_default_args.update({"volumes": [{"name": "nameofvolume"}]})
     msg = {"Status": "Success"}
     obj = MagicMock()
     idrac_connection_storage_volume_mock.config_mgr.RaidHelper = obj
     obj.delete_virtual_disk = Mock(return_value=msg)
     f_module = self.get_module_mock(params=idrac_default_args)
     result = self.module.delete_storage(
         idrac_connection_storage_volume_mock, f_module)
     assert result == {"Status": "Success"}
Beispiel #9
0
 def test_view_storage_success_case(self,
                                    idrac_connection_storage_volume_mock,
                                    idrac_default_args):
     idrac_default_args.update({
         "controller_id": "controller",
         "volume_id": "virtual_disk"
     })
     msg = {"Status": "Success"}
     obj = MagicMock()
     idrac_connection_storage_volume_mock.config_mgr.RaidHelper = obj
     obj.view_storage = Mock(return_value=msg)
     f_module = self.get_module_mock(params=idrac_default_args)
     result = self.module.view_storage(idrac_connection_storage_volume_mock,
                                       f_module)
     assert result == {"Status": "Success"}
Beispiel #10
0
 def test_view_storage_failed_case(self,
                                   idrac_connection_storage_volume_mock,
                                   idrac_default_args):
     idrac_default_args.update({
         "controller_id": "controller",
         "volume_id": "virtual_disk"
     })
     msg = {"Status": "Failed", "msg": "Failed to fetch storage details"}
     obj = MagicMock()
     idrac_connection_storage_volume_mock.config_mgr.RaidHelper = obj
     obj.view_storage = Mock(return_value=msg)
     f_module = self.get_module_mock(params=idrac_default_args)
     with pytest.raises(Exception) as ex:
         self.module.view_storage(idrac_connection_storage_volume_mock,
                                  f_module)
     assert "Failed to fetch storage details" == str(ex.value)
 def test_run_setup_csior_disable_case(
         self, idrac_connection_lc_attribute_mock, idrac_default_args,
         idrac_file_manager_lc_attribute_mock):
     idrac_default_args.update({
         "share_name": "sharename",
         "share_mnt": "mountname",
         "share_user": "******",
         "share_password": "******",
         "csior": 'Disabled'
     })
     message = {"changes_applicable": True}
     obj = MagicMock()
     idrac_connection_lc_attribute_mock.config_mgr = obj
     type(obj).disable_csior = Mock(return_value=message)
     idrac_connection_lc_attribute_mock.config_mgr.is_change_applicable.return_value = message
     f_module = self.get_module_mock(params=idrac_default_args,
                                     check_mode=True)
     with pytest.raises(Exception) as ex:
         self.module.run_setup_idrac_csior(
             idrac_connection_lc_attribute_mock, f_module)
     assert ex.value.args[0] == "Changes found to commit!"
Beispiel #12
0
    def test_update_firmware_redfish_success_case03(self, idrac_connection_firmware_mock,
                                                    idrac_connection_firmware_redfish_mock,
                                                    idrac_default_args, mocker, re_match_mock):
        idrac_default_args.update({"share_name": "https://downloads.dell.com", "catalog_file_name": "Catalog.xml",
                                   "share_user": "******", "share_password": "******",
                                   "share_mnt": "shrmnt",
                                   "reboot": True, "job_wait": False, "ignore_cert_warning": True,
                                   "apply_update": True
                                   })
        mocker.patch(MODULE_PATH + "idrac_firmware.update_firmware_url_redfish",
                     return_value=(
                         {"job_details": {"Data": {"StatusCode": 200, "body": {"PackageList": [{}]}}}},
                         {"Data": {"StatusCode": 200, "body": {"PackageList": [{}]}}}))

        mocker.patch(MODULE_PATH + "idrac_firmware._convert_xmltojson",
                     return_value=({"BaseLocation": None,
                                    "ComponentID": "18981",
                                    "ComponentType": "APAC",
                                    "Criticality": "3",
                                    "DisplayName": "Dell OS Driver Pack",
                                    "JobID": None,
                                    "PackageName": "Drivers-for-OS-Deployment_Application_X0DW6_WN64_"
                                                   "19.10.12_A00.EXE",
                                    "PackagePath": "FOLDER05902898M/1/Drivers-for-OS-"
                                                   "Deployment_Application_X0DW6_WN64_19.10.12_A00.EXE",
                                    "PackageVersion": "19.10.12",
                                    "RebootType": "NONE",
                                    "Target": "DCIM:INSTALLED#802__DriverPack.Embedded.1:LC.Embedded.1"
                                    }, True))
        f_module = self.get_module_mock(params=idrac_default_args)
        idrac_connection_firmware_mock.re_match_mock.group = Mock(return_value="3.30")
        idrac_connection_firmware_redfish_mock.success = True
        idrac_connection_firmware_redfish_mock.json_data = {"FirmwareVersion": "3.30"}
        mocker.patch(MODULE_PATH + "idrac_firmware._convert_xmltojson", return_value=("INSTANCENAME", False, False))
        idrac_connection_firmware_mock.ServerGeneration = "14"
        result = self.module.update_firmware_redfish(idrac_connection_firmware_mock, f_module)
        assert result["changed"] is False
        assert result["update_msg"] == "Successfully triggered the job to update the firmware."
Beispiel #13
0
 def test_set_liason_share_success_case(
         self, idrac_connection_storage_volume_mock, idrac_default_args,
         idrac_file_manager_storage_volume_mock):
     idrac_default_args.update({
         "share_name": "sharename",
         "state": "delete",
         "share_path": "sharpath"
     })
     message = {
         "Status": 'Failed',
         "Data": {
             'Message': "Failed to set Liason share"
         }
     }
     obj = MagicMock()
     idrac_connection_storage_volume_mock.tempfile.gettempdir() + os.sep
     idrac_connection_storage_volume_mock.file_share_manager.create_share_obj.return_value = message
     idrac_connection_storage_volume_mock.config_mgr = obj
     obj.set_liason_share = Mock(return_value=message)
     f_module = self.get_module_mock(params=idrac_default_args)
     with pytest.raises(Exception) as ex:
         self.module.set_liason_share(idrac_connection_storage_volume_mock,
                                      f_module)
     assert "Failed to set Liason share" == str(ex.value)
 def idrac_system_inventory_mock(self, mocker):
     omsdk_mock = MagicMock()
     idrac_obj = MagicMock()
     omsdk_mock.get_entityjson = idrac_obj
     type(idrac_obj).get_json_device = Mock(return_value="msg")
     return idrac_obj
Beispiel #15
0
 def idrac_mock(self, mocker):
     omsdk_mock = MagicMock()
     idrac_obj = MagicMock()
     omsdk_mock.config_mgr = idrac_obj
     type(idrac_obj).reset_idrac = Mock(return_value="idracreset")
     return idrac_obj