def get_disk_bus_for_device_type(virt_type, image_meta=None, device_type='disk'):
 if image_meta:
  key = (('hw_' + device_type) + '_bus')
  disk_bus = image_meta.get('properties', {}).get(key)
  if (disk_bus is not None):
   if (not is_disk_bus_valid_for_virt(virt_type, disk_bus)):
    raise exception.UnsupportedHardware(model=disk_bus, virt=virt_type)
   return disk_bus
 if (virt_type == 'uml'):
  if (device_type == 'disk'):
   return 'uml'
 elif (virt_type == 'lxc'):
  return 'lxc'
 elif (virt_type == 'xen'):
  if (device_type == 'cdrom'):
   return 'ide'
  elif (device_type == 'disk'):
   return 'xen'
 elif (virt_type in ('qemu', 'kvm')):
  if (device_type == 'cdrom'):
   return 'ide'
  elif (device_type == 'disk'):
   return 'virtio'
 return None

def get_disk_bus_for_device_type ( virt_type , image_meta = None , device_type = 'disk' ) : if image_meta : key = ( ( 'hw_' + device_type ) + '_bus' ) disk_bus = image_meta . get ( 'properties' , { } ) . get ( key ) if ( disk_bus is not None ) : if ( not is_disk_bus_valid_for_virt ( virt_type , disk_bus ) ) : raise exception . UnsupportedHardware ( model = disk_bus , virt = virt_type ) return disk_bus if ( virt_type == 'uml' ) : if ( device_type == 'disk' ) : return 'uml' elif ( virt_type == 'lxc' ) : return 'lxc' elif ( virt_type == 'xen' ) : if ( device_type == 'cdrom' ) : return 'ide' elif ( device_type == 'disk' ) : return 'xen' elif ( virt_type in ( 'qemu' , 'kvm' ) ) : if ( device_type == 'cdrom' ) : return 'ide' elif ( device_type == 'disk' ) : return 'virtio' return None
determine the best disk bus to use for a device type .