def test_rename_datastore_raise_vim_fault(self): exc = vim.VimFault() exc.msg = 'vim_fault' type(self.mock_ds_ref).RenameDatastore = MagicMock(side_effect=exc) with self.assertRaises(VMwareApiError) as excinfo: salt.utils.vmware.rename_datastore(self.mock_ds_ref, 'fake_new_name') self.assertEqual(excinfo.exception.strerror, 'vim_fault')
def test_create_datacenter_raise_vim_fault(self): exc = vim.VimFault() exc.msg = 'VimFault msg' self.mock_root_folder = MagicMock( CreateDatacenter=MagicMock(side_effect=exc)) with patch('salt.utils.vmware.get_root_folder', MagicMock(return_value=self.mock_root_folder)): with self.assertRaises(VMwareApiError) as excinfo: vmware.create_datacenter(self.mock_si, 'fake_dc') self.assertEqual(excinfo.exception.strerror, 'VimFault msg')
def set_state(self, state): fault = None if state == 'error': fault = vim.VimFault() self._managed_object.SetTaskState(state, None, fault)