Skip to content

Commit c80c8e6

Browse files
Jenkinsopenstack-gerrit
Jenkins
authored andcommitted
Merge "libvirt: Delete the lase_device of find_disk_dev_for_disk_bus" into stable/newton
2 parents 865ed31 + 3d0ec34 commit c80c8e6

File tree

3 files changed

+24
-38
lines changed

3 files changed

+24
-38
lines changed

nova/tests/unit/virt/libvirt/test_blockinfo.py

+13-18
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ def test_find_disk_dev(self):
124124
dev = blockinfo.find_disk_dev_for_disk_bus(mapping, 'scsi')
125125
self.assertEqual('sdb', dev)
126126

127-
dev = blockinfo.find_disk_dev_for_disk_bus(mapping, 'scsi',
128-
last_device=True)
129-
self.assertEqual('sdz', dev)
130-
131127
dev = blockinfo.find_disk_dev_for_disk_bus(mapping, 'virtio')
132128
self.assertEqual('vda', dev)
133129

@@ -164,9 +160,8 @@ def test_get_next_disk_dev(self):
164160

165161
mapping['disk.config'] = blockinfo.get_next_disk_info(mapping,
166162
'ide',
167-
'cdrom',
168-
True)
169-
self.assertEqual({'dev': 'hdd', 'bus': 'ide', 'type': 'cdrom'},
163+
'cdrom')
164+
self.assertEqual({'dev': 'hda', 'bus': 'ide', 'type': 'cdrom'},
170165
mapping['disk.config'])
171166

172167
def test_get_next_disk_dev_boot_index(self):
@@ -262,7 +257,7 @@ def test_get_disk_mapping_rescue_with_config(self):
262257
'disk.rescue': {'bus': 'virtio', 'dev': 'vda',
263258
'type': 'disk', 'boot_index': '1'},
264259
'disk': {'bus': 'virtio', 'dev': 'vdb', 'type': 'disk'},
265-
'disk.config.rescue': {'bus': 'ide', 'dev': 'hdd',
260+
'disk.config.rescue': {'bus': 'ide', 'dev': 'hda',
266261
'type': 'cdrom'},
267262
'root': {'bus': 'virtio', 'dev': 'vda',
268263
'type': 'disk', 'boot_index': '1'},
@@ -379,17 +374,17 @@ def test_get_disk_mapping_simple_configdrive(self):
379374
"virtio", "ide",
380375
image_meta)
381376

382-
# The last device is selected for this. on x86 is the last ide
383-
# device (hdd). Since power only support scsi, the last device
384-
# is sdz
377+
# Pick the first drive letter on the bus that is available
378+
# as the config drive. Delete the last device hardcode as
379+
# the config drive here.
385380

386-
bus_ppc = ("scsi", "sdz")
387-
bus_aarch64 = ("scsi", "sdz")
381+
bus_ppc = ("scsi", "sda")
382+
bus_aarch64 = ("scsi", "sda")
388383
expect_bus = {"ppc": bus_ppc, "ppc64": bus_ppc,
389384
"ppc64le": bus_ppc, "aarch64": bus_aarch64}
390385

391386
bus, dev = expect_bus.get(blockinfo.libvirt_utils.get_arch({}),
392-
("ide", "hdd"))
387+
("ide", "hda"))
393388

394389
expect = {
395390
'disk': {'bus': 'virtio', 'dev': 'vda',
@@ -418,13 +413,13 @@ def test_get_disk_mapping_cdrom_configdrive(self):
418413
"virtio", "ide",
419414
image_meta)
420415

421-
bus_ppc = ("scsi", "sdz")
422-
bus_aarch64 = ("scsi", "sdz")
416+
bus_ppc = ("scsi", "sda")
417+
bus_aarch64 = ("scsi", "sda")
423418
expect_bus = {"ppc": bus_ppc, "ppc64": bus_ppc,
424419
"ppc64le": bus_ppc, "aarch64": bus_aarch64}
425420

426421
bus, dev = expect_bus.get(blockinfo.libvirt_utils.get_arch({}),
427-
("ide", "hdd"))
422+
("ide", "hda"))
428423

429424
expect = {
430425
'disk': {'bus': 'virtio', 'dev': 'vda',
@@ -454,7 +449,7 @@ def test_get_disk_mapping_disk_configdrive(self):
454449
'disk': {'bus': 'virtio', 'dev': 'vda',
455450
'type': 'disk', 'boot_index': '1'},
456451
'disk.local': {'bus': 'virtio', 'dev': 'vdb', 'type': 'disk'},
457-
'disk.config': {'bus': 'virtio', 'dev': 'vdz', 'type': 'disk'},
452+
'disk.config': {'bus': 'virtio', 'dev': 'vdc', 'type': 'disk'},
458453
'root': {'bus': 'virtio', 'dev': 'vda',
459454
'type': 'disk', 'boot_index': '1'},
460455
}

nova/tests/unit/virt/libvirt/test_driver.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -3344,13 +3344,13 @@ def test_get_guest_config_with_configdrive(self):
33443344
cfg = drvr._get_guest_config(instance_ref, [],
33453345
image_meta, disk_info)
33463346

3347-
# The last device is selected for this. on x86 is the last ide
3348-
# device (hdd). Since power only support scsi, the last device
3349-
# is sdz
3347+
# Pick the first drive letter on the bus that is available
3348+
# as the config drive. Delete the last device hardcode as
3349+
# the config drive here.
33503350

3351-
expect = {"ppc": "sdz", "ppc64": "sdz",
3352-
"ppc64le": "sdz", "aarch64": "sdz"}
3353-
disk = expect.get(blockinfo.libvirt_utils.get_arch({}), "hdd")
3351+
expect = {"ppc": "sda", "ppc64": "sda",
3352+
"ppc64le": "sda", "aarch64": "sda"}
3353+
disk = expect.get(blockinfo.libvirt_utils.get_arch({}), "hda")
33543354
self.assertIsInstance(cfg.devices[2],
33553355
vconfig.LibvirtConfigGuestDisk)
33563356
self.assertEqual(cfg.devices[2].target_dev, disk)
@@ -14851,7 +14851,7 @@ def test_get_guest_disk_config_rbd_older_config_drive_fall_back(self):
1485114851
mock_rbd_image.exists.return_value = False
1485214852
instance = objects.Instance()
1485314853
disk_mapping = {'disk.config': {'bus': 'ide',
14854-
'dev': 'hdd',
14854+
'dev': 'hda',
1485514855
'type': 'file'}}
1485614856
flavor = objects.Flavor(extra_specs={})
1485714857

nova/virt/libvirt/blockinfo.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,13 @@ def get_dev_count_for_disk_bus(disk_bus):
164164

165165

166166
def find_disk_dev_for_disk_bus(mapping, bus,
167-
last_device=False,
168167
assigned_devices=None):
169168
"""Identify a free disk dev name for a bus.
170169
171170
Determines the possible disk dev names for
172171
the bus, and then checks them in order until
173172
it identifies one that is not yet used in the
174-
disk mapping. If 'last_device' is set, it will
175-
only consider the last available disk dev name.
173+
disk mapping.
176174
177175
Returns the chosen disk_dev name, or raises an
178176
exception if none is available.
@@ -186,10 +184,7 @@ def find_disk_dev_for_disk_bus(mapping, bus,
186184
assigned_devices = []
187185

188186
max_dev = get_dev_count_for_disk_bus(bus)
189-
if last_device:
190-
devs = [max_dev - 1]
191-
else:
192-
devs = range(max_dev)
187+
devs = range(max_dev)
193188

194189
for idx in devs:
195190
disk_dev = dev_prefix + chr(ord('a') + idx)
@@ -321,7 +316,6 @@ def get_disk_bus_for_disk_dev(virt_type, disk_dev):
321316

322317
def get_next_disk_info(mapping, disk_bus,
323318
device_type='disk',
324-
last_device=False,
325319
boot_index=None,
326320
assigned_devices=None):
327321
"""Determine the disk info for the next device on disk_bus.
@@ -335,7 +329,6 @@ def get_next_disk_info(mapping, disk_bus,
335329

336330
disk_dev = find_disk_dev_for_disk_bus(mapping,
337331
disk_bus,
338-
last_device,
339332
assigned_devices)
340333
info = {'bus': disk_bus,
341334
'dev': disk_dev,
@@ -530,8 +523,7 @@ def get_disk_mapping(virt_type, instance,
530523
device_type)
531524
config_info = get_next_disk_info(mapping,
532525
disk_bus,
533-
device_type,
534-
last_device=True)
526+
device_type)
535527
mapping['disk.config.rescue'] = config_info
536528

537529
return mapping
@@ -616,8 +608,7 @@ def get_disk_mapping(virt_type, instance,
616608
device_type)
617609
config_info = get_next_disk_info(mapping,
618610
disk_bus,
619-
device_type,
620-
last_device=True)
611+
device_type)
621612
mapping['disk.config'] = config_info
622613

623614
return mapping

0 commit comments

Comments
 (0)