def testDiskNumbers(self): # Various testing our target generation # # Note: using single quotes in strings to avoid # codespell flagging the 'ba' assert self.assertEqual('a', DeviceDisk.num_to_target(1)) self.assertEqual('b', DeviceDisk.num_to_target(2)) self.assertEqual('z', DeviceDisk.num_to_target(26)) self.assertEqual('aa', DeviceDisk.num_to_target(27)) self.assertEqual('ab', DeviceDisk.num_to_target(28)) self.assertEqual('az', DeviceDisk.num_to_target(52)) self.assertEqual('ba', DeviceDisk.num_to_target(53)) self.assertEqual('zz', DeviceDisk.num_to_target(27 * 26)) self.assertEqual('aaa', DeviceDisk.num_to_target(27 * 26 + 1)) self.assertEqual(DeviceDisk.target_to_num('hda'), 0) self.assertEqual(DeviceDisk.target_to_num('hdb'), 1) self.assertEqual(DeviceDisk.target_to_num('sdz'), 25) self.assertEqual(DeviceDisk.target_to_num('sdaa'), 26) self.assertEqual(DeviceDisk.target_to_num('vdab'), 27) self.assertEqual(DeviceDisk.target_to_num('vdaz'), 51) self.assertEqual(DeviceDisk.target_to_num('xvdba'), 52) self.assertEqual(DeviceDisk.target_to_num('xvdzz'), 26 * (25 + 1) + 25) self.assertEqual(DeviceDisk.target_to_num('xvdaaa'), 26 * 26 * 1 + 26 * 1 + 0) disk = virtinst.DeviceDisk(self.conn) disk.bus = 'ide' self.assertEqual('hda', disk.generate_target([])) self.assertEqual('hdb', disk.generate_target(['hda'])) self.assertEqual('hdc', disk.generate_target(['hdb', 'sda'])) self.assertEqual('hdb', disk.generate_target(['hda', 'hdd']))
def testDiskNumbers(self): # Various testing our target generation self.assertEqual("a", DeviceDisk.num_to_target(1)) self.assertEqual("b", DeviceDisk.num_to_target(2)) self.assertEqual("z", DeviceDisk.num_to_target(26)) self.assertEqual("aa", DeviceDisk.num_to_target(27)) self.assertEqual("ab", DeviceDisk.num_to_target(28)) self.assertEqual("az", DeviceDisk.num_to_target(52)) self.assertEqual("ba", DeviceDisk.num_to_target(53)) self.assertEqual("zz", DeviceDisk.num_to_target(27 * 26)) self.assertEqual("aaa", DeviceDisk.num_to_target(27 * 26 + 1)) self.assertEqual(DeviceDisk.target_to_num("hda"), 0) self.assertEqual(DeviceDisk.target_to_num("hdb"), 1) self.assertEqual(DeviceDisk.target_to_num("sdz"), 25) self.assertEqual(DeviceDisk.target_to_num("sdaa"), 26) self.assertEqual(DeviceDisk.target_to_num("vdab"), 27) self.assertEqual(DeviceDisk.target_to_num("vdaz"), 51) self.assertEqual(DeviceDisk.target_to_num("xvdba"), 52) self.assertEqual(DeviceDisk.target_to_num("xvdzz"), 26 * (25 + 1) + 25) self.assertEqual(DeviceDisk.target_to_num("xvdaaa"), 26 * 26 * 1 + 26 * 1 + 0) disk = virtinst.DeviceDisk(self.conn) disk.bus = "ide" self.assertEqual("hda", disk.generate_target([])) self.assertEqual("hdb", disk.generate_target(["hda"])) self.assertEqual("hdc", disk.generate_target(["hdb", "sda"])) self.assertEqual("hdb", disk.generate_target(["hda", "hdd"])) disk.bus = "virtio-scsi" self.assertEqual("sdb", disk.generate_target(["sda", "sdg", "sdi"], 0)) self.assertEqual("sdh", disk.generate_target(["sda", "sdg"], 1))
def test_disk_numtotarget(): # Various testing our target generation # # Note: using single quotes in strings to avoid # codespell flagging the 'ba' assert assert DeviceDisk.num_to_target(1) == 'a' assert DeviceDisk.num_to_target(2) == 'b' assert DeviceDisk.num_to_target(26) == 'z' assert DeviceDisk.num_to_target(27) == 'aa' assert DeviceDisk.num_to_target(28) == 'ab' assert DeviceDisk.num_to_target(52) == 'az' assert DeviceDisk.num_to_target(53) == 'ba' assert DeviceDisk.num_to_target(27 * 26) == 'zz' assert DeviceDisk.num_to_target(27 * 26 + 1) == 'aaa' assert DeviceDisk.target_to_num('hda') == 0 assert DeviceDisk.target_to_num('hdb') == 1 assert DeviceDisk.target_to_num('sdz') == 25 assert DeviceDisk.target_to_num('sdaa') == 26 assert DeviceDisk.target_to_num('vdab') == 27 assert DeviceDisk.target_to_num('vdaz') == 51 assert DeviceDisk.target_to_num('xvdba') == 52 assert DeviceDisk.target_to_num('xvdzz') == 26 * (25 + 1) + 25 assert DeviceDisk.target_to_num('xvdaaa') == 26 * 26 * 1 + 26 * 1 + 0 conn = utils.URIs.open_testdefault_cached() disk = virtinst.DeviceDisk(conn) disk.bus = 'ide' assert disk.generate_target([]) == 'hda' assert disk.generate_target(['hda']) == 'hdb' assert disk.generate_target(['hdb', 'sda']) == 'hdc' assert disk.generate_target(['hda', 'hdd']) == 'hdb'
def testDiskNumbers(self): # Various testing our target generation self.assertEqual("a", DeviceDisk.num_to_target(1)) self.assertEqual("b", DeviceDisk.num_to_target(2)) self.assertEqual("z", DeviceDisk.num_to_target(26)) self.assertEqual("aa", DeviceDisk.num_to_target(27)) self.assertEqual("ab", DeviceDisk.num_to_target(28)) self.assertEqual("az", DeviceDisk.num_to_target(52)) self.assertEqual("ba", DeviceDisk.num_to_target(53)) self.assertEqual("zz", DeviceDisk.num_to_target(27 * 26)) self.assertEqual("aaa", DeviceDisk.num_to_target(27 * 26 + 1)) self.assertEqual(DeviceDisk.target_to_num("hda"), 0) self.assertEqual(DeviceDisk.target_to_num("hdb"), 1) self.assertEqual(DeviceDisk.target_to_num("sdz"), 25) self.assertEqual(DeviceDisk.target_to_num("sdaa"), 26) self.assertEqual(DeviceDisk.target_to_num("vdab"), 27) self.assertEqual(DeviceDisk.target_to_num("vdaz"), 51) self.assertEqual(DeviceDisk.target_to_num("xvdba"), 52) self.assertEqual(DeviceDisk.target_to_num("xvdzz"), 26 * (25 + 1) + 25) self.assertEqual(DeviceDisk.target_to_num("xvdaaa"), 26 * 26 * 1 + 26 * 1 + 0) disk = virtinst.DeviceDisk(self.conn) disk.bus = "ide" self.assertEqual("hda", disk.generate_target([])) self.assertEqual("hdb", disk.generate_target(["hda"])) self.assertEqual("hdc", disk.generate_target(["hdb", "sda"])) self.assertEqual("hdb", disk.generate_target(["hda", "hdd"])) disk.bus = "virtio-scsi" self.assertEqual("sdb", disk.generate_target(["sda", "sdg", "sdi"], 0)) self.assertEqual("sdh", disk.generate_target(["sda", "sdg"], 1))