docs: def _layout_to_vdev(layout, device_dir=None):
      '''
      Turn the layout data into usable vdevs spedcification
  
      We need to support 2 ways of passing the layout:
  
      .. code::
          layout_new:
            - mirror:
              - disk0
              - disk1
            - mirror:
              - disk2
              - disk3
  
      .. code:
          layout_legacy:
            mirror-0:
              disk0
              disk1
            mirror-1:
              disk2
              disk3
  
      '''
      vdevs = []
  
      # NOTE: check device_dir exists
      if device_dir and not os.path.exists(device_dir):
          device_dir = None
  
      # NOTE: handle list of OrderedDicts (new layout)
      if isinstance(layout, list):
          # NOTE: parse each vdev as a tiny layout and just append
          for vdev in layout:
              if isinstance(vdev, OrderedDict):
                  vdevs.extend(_layout_to_vdev(vdev, device_dir))
              else:
                  if device_dir and vdev[0] != '/':
                      vdev = os.path.join(device_dir, vdev)
                  vdevs.append(vdev)
  
      # NOTE: handle nested OrderedDict (legacy layout)
      #       this is also used to parse the nested OrderedDicts
      #       from the new layout
      elif isinstance(layout, OrderedDict):
          for vdev in layout:
              # NOTE: extract the vdev type and disks in the vdev
              vdev_type = vdev.split('-')[0]
              vdev_disk = layout[vdev]
  
              # NOTE: skip appending the dummy type 'disk'
              if vdev_type != 'disk':
                  vdevs.append(vdev_type)
  
              # NOTE: ensure the disks are a list (legacy layout are not)
              if not isinstance(vdev_disk, list):
                  vdev_disk = vdev_disk.split(' ')
  
              # NOTE: also append the actualy disks behind the type
              #       also prepend device_dir to disks if required
              for disk in vdev_disk:
                  if device_dir and disk[0] != '/':
                      disk = os.path.join(device_dir, disk)
                  vdevs.append(disk)
  
      # NOTE: we got invalid data for layout
      else:
          vdevs = None
  
      return vdevs