예제 #1
0
    def test__insert_vmedia_anew(self, mock_redfish_utils):

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=True) as task:
            mock_vmedia_cd = mock.MagicMock(
                inserted=False,
                media_types=[sushy.VIRTUAL_MEDIA_CD])
            mock_vmedia_floppy = mock.MagicMock(
                inserted=False,
                media_types=[sushy.VIRTUAL_MEDIA_FLOPPY])

            mock_manager = mock.MagicMock()

            mock_manager.virtual_media.get_members.return_value = [
                mock_vmedia_cd, mock_vmedia_floppy]

            mock_redfish_utils.get_system.return_value.managers = [
                mock_manager]

            redfish_boot._insert_vmedia(
                task, 'img-url', sushy.VIRTUAL_MEDIA_CD)

            mock_vmedia_cd.insert_media.assert_called_once_with(
                'img-url', inserted=True, write_protected=True)

            self.assertFalse(mock_vmedia_floppy.insert_media.call_count)
예제 #2
0
    def test__insert_vmedia_already_inserted(self):

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=True) as task:
            mock_vmedia_cd = mock.MagicMock(
                inserted=True,
                image='img-url',
                media_types=[sushy.VIRTUAL_MEDIA_CD])
            mock_manager = mock.MagicMock()

            mock_manager.virtual_media.get_members.return_value = [
                mock_vmedia_cd]

            redfish_boot._insert_vmedia(
                task, [mock_manager], 'img-url', sushy.VIRTUAL_MEDIA_CD)

            self.assertFalse(mock_vmedia_cd.insert_media.call_count)
예제 #3
0
    def test__insert_vmedia_while_ejecting(self):

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=True) as task:
            mock_vmedia_cd = mock.MagicMock(
                inserted=False,
                image='img-url',
                media_types=[sushy.VIRTUAL_MEDIA_CD],
            )
            mock_manager = mock.MagicMock()

            def clear_and_raise(*args, **kwargs):
                mock_vmedia_cd.insert_media.side_effect = None
                raise sushy.exceptions.ServerSideError(
                    "POST", 'img-url', mock.MagicMock())
            mock_vmedia_cd.insert_media.side_effect = clear_and_raise
            mock_manager.virtual_media.get_members.return_value = [
                mock_vmedia_cd]

            redfish_boot._insert_vmedia(
                task, [mock_manager], 'img-url', sushy.VIRTUAL_MEDIA_CD)

            self.assertEqual(mock_vmedia_cd.insert_media.call_count, 2)