Doing some more debugging, it looks like the disk_info['mapping'] is just processed in order:
disk_info={'disk_bus': u'scsi', 'cdrom_bus': 'ide', 'mapping': {u'/dev/sdb': {'bus': u'scsi', 'type': u'disk', 'dev': u'sdb'}, 'root': {'bus': u'scsi', 'boot_index': '1', 'type': u'disk', 'dev': u'sda'}, u'/dev/sda': {'bus': u'scsi', 'boot_index': '1', 'type': u'disk', 'dev': u'sda'}}}
I guess in _get_guest_storage_config this takes place, or maybe in _get_guest_disk_config, but since it seems to just iterate through the mapping in the order provided while incrementing the LUN each time, we end up with this situation.
Doing some more debugging, it looks like the disk_info[ 'mapping' ] is just processed in order:
disk_info= {'disk_ bus': u'scsi', 'cdrom_bus': 'ide', 'mapping': {u'/dev/sdb': {'bus': u'scsi', 'type': u'disk', 'dev': u'sdb'}, 'root': {'bus': u'scsi', 'boot_index': '1', 'type': u'disk', 'dev': u'sda'}, u'/dev/sda': {'bus': u'scsi', 'boot_index': '1', 'type': u'disk', 'dev': u'sda'}}}
I guess in _get_guest_ storage_ config this takes place, or maybe in _get_guest_ disk_config, but since it seems to just iterate through the mapping in the order provided while incrementing the LUN each time, we end up with this situation.