def _select_free_device(existing):
 local_devices = frozenset(existing)
 sorted_devices = sorted(existing)
 IN_USE_DEVICES(devices=sorted_devices).write()
 for suffix in 'fghijklmonpqrstuvwxyz':
  next_local_device = ('xvd' + suffix)
  next_local_sd_device = ('sd' + suffix)
  file_name = (u'/dev/sd' + unicode(suffix))
  possible_devices = [next_local_device, next_local_sd_device]
  if (not local_devices.intersection(possible_devices)):
   return file_name
 NO_AVAILABLE_DEVICE(devices=sorted_devices).write()
 raise NoAvailableDevice()

def _select_free_device ( existing ) : local_devices = frozenset ( existing ) sorted_devices = sorted ( existing ) IN_USE_DEVICES ( devices = sorted_devices ) . write ( ) for suffix in 'fghijklmonpqrstuvwxyz' : next_local_device = ( 'xvd' + suffix ) next_local_sd_device = ( 'sd' + suffix ) file_name = ( u'/dev/sd' + unicode ( suffix ) ) possible_devices = [ next_local_device , next_local_sd_device ] if ( not local_devices . intersection ( possible_devices ) ) : return file_name NO_AVAILABLE_DEVICE ( devices = sorted_devices ) . write ( ) raise NoAvailableDevice ( )
given a list of allocated devices .