def test_dasd_probe_dasdd_skips_partitions(self, m_dasdview, m_machine): m_machine.return_value = 's390x' m_dasdview.side_effect = iter([self._load_test_data('dasdd.view')]) context = mock.MagicMock() context.list_devices.side_effect = iter([ [{ "MAJOR": "94", "DEVNAME": "/dev/dasdd", "ID_SERIAL": "0X1544", "ID_PATH": "ccw-0.0.1544" }], [{ "MAJOR": "94", "DEVNAME": "/dev/dasdd1", "ID_SERIAL": "0X1544", "ID_PATH": "ccw-0.0.1544", "PARTN": "1" }], ]) expected_results = { '/dev/dasdd': { 'name': '/dev/dasdd', 'device_id': '0.0.1544', 'disk_layout': 'cdl', 'blocksize': 4096 }, } self.assertEqual(expected_results, dasd.probe(context=context))
def test_dasd_probe_dasde(self, m_dasdview, m_machine): m_machine.return_value = 's390x' m_dasdview.side_effect = iter([self._load_test_data('dasde.view')]) context = mock.MagicMock() context.list_devices.side_effect = iter([ [{ "MAJOR": "94", "DEVNAME": "/dev/dasde", "ID_PATH": "ccw-0.0.2250" }], ]) expected_results = { '/dev/dasde': update_probe_data(expected_probe_data['/dev/dasde'], device_id="0.0.2250") } self.assertEqual(expected_results, dasd.probe(context=context))
def test_dasd_probe_virtio_non_dasd(self, m_machine, m_open, m_run): m_machine.return_value = 's390x' virtio_major = random_string() devname = random_string() m_open.return_value = ['{} virtblk\n'.format(virtio_major)] m_run.return_value.returncode = 1 context = mock.MagicMock() context.list_devices.side_effect = iter([ [{ "MAJOR": virtio_major, "DEVNAME": devname }], ]) self.assertEqual({}, dasd.probe(context=context)) m_run.assert_called_once_with(['fdasd', '-i', devname], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def test_dasd_probe_dasde(self, m_dasdview, m_machine): m_machine.return_value = 's390x' m_dasdview.side_effect = iter([self._load_test_data('dasde.view')]) context = mock.MagicMock() context.list_devices.side_effect = iter([ [{ "MAJOR": "94", "DEVNAME": "/dev/dasde", "ID_PATH": "ccw-0.0.2250" }], ]) expected_results = { '/dev/dasde': { 'name': '/dev/dasde', 'device_id': '0.0.2250', 'disk_layout': 'not-formatted', 'blocksize': 512 }, } self.assertEqual(expected_results, dasd.probe(context=context))
def test_dasd_probe_returns_empty_dict_non_s390x_arch(self, m_machine): machine = random_string() self.assertNotEqual("s390x", machine) m_machine.return_value = machine self.assertEqual({}, dasd.probe())