def test_get_first_unused_and_safely_removable(self): virttest.utils_zchannels.cmd_status_output = mock.Mock(return_value=(0, "\n".join(OUT_OK))) subchannel_paths = SubchannelPaths() subchannel_paths.get_info() device = subchannel_paths.get_first_unused_and_safely_removable() self.assertIsNotNone(device) self.assertEqual("0.0.26aa", device[1])
def test_get_first_unused_and_safely_removable_not_safe(self): not_safe = OUT_OK.copy() not_safe[6] = not_safe[6].replace("01021112", "11122122") virttest.utils_zchannels.cmd_status_output = mock.Mock(return_value=(0, "\n".join(not_safe))) subchannel_paths = SubchannelPaths() subchannel_paths.get_info() device = subchannel_paths.get_first_unused_and_safely_removable() self.assertIsNone(device)
def get_device_info(): """ Gets the device info for passthrough """ paths = SubchannelPaths() paths.get_info() device = paths.get_first_unused_and_safely_removable() schid = device[paths.HEADER["Subchan."]] chpids = device[paths.HEADER["CHPIDs"]] return schid, chpids
def device_is_listed(session, chpids): """ Checks if the css device is listed by comparing the channel path ids. :param session: guest console session :param chipds: chpids where the disk is connected, e.g. "11122122" """ paths = SubchannelPaths(session) paths.get_info() devices_inside_guest = [ x for x in paths.devices if x[paths.HEADER["CHPIDs"]] == chpids ] return len(devices_inside_guest) > 0
def get_partitioned_dasd_path(): """ Selects and prepares DASD for test case :return path: absolute path to block device, e.g. '/dev/dasda' """ paths = SubchannelPaths() paths.get_info() device = paths.get_first_unused_and_safely_removable() if not device: raise TestError("Couldn't find dasd device for test") global TEST_DASD_ID TEST_DASD_ID = device[paths.HEADER["Device"]] enable_disk(TEST_DASD_ID) disk_path = get_device_path(TEST_DASD_ID) wait_for(lambda: ccw.format_dasd(disk_path, None), 10, first=1.0) wait_for(lambda: ccw.make_dasd_part(disk_path, None), 10, first=1.0) return disk_path
def get_first_device_identifiers(chpids, session): """ Gets the usual device identifier cssid.ssid.devno :param chpids: chpids where the disk is connected, e.g. "11122122" :param session: guest session :return: Pair of strings, "cssid.ssid.devno" "cssid.ssid.schid" :raises TestError: if the device can't be found inside guest """ paths = SubchannelPaths(session) paths.get_info() devices_inside_guest = [ x for x in paths.devices if x[paths.HEADER["CHPIDs"]] == chpids ] if not devices_inside_guest: raise TestError("Device with chpids %s wasn't" " found inside guest" % chpids) first = devices_inside_guest[0] return first[paths.HEADER["Device"]], first[paths.HEADER["Subchan."]]
def test_get_info(self): virttest.utils_zchannels.cmd_status_output = mock.Mock(return_value=(0, "\n".join(OUT_OK))) subchannel_paths = SubchannelPaths() subchannel_paths.get_info() self.assertEqual(8, len(subchannel_paths.devices))