def _GatherAndLinkBlockDevs(instance):
  """Set up an instance's block device(s).

  This is run on the primary node at instance startup. The block
  devices must be already assembled.

  @type instance: L{objects.Instance}
  @param instance: the instance whose disks we should assemble
  @rtype: list
  @return: list of (disk_object, link_name, drive_uri)

  """
  block_devices = []
  for idx, disk in enumerate(instance.disks_info):
    device = _RecursiveFindBD(disk)
    if device is None:
      raise errors.BlockDeviceError("Block device '%s' is not set up." %
                                    str(disk))
    device.Open()
    try:
      # Create both index-based and uuid-based symlinks
      # for backwards compatibility
      _SymlinkBlockDev(instance.name, device.dev_path, idx=idx)
      link_name = _SymlinkBlockDev(instance.name, device.dev_path,
                                   uuid=disk.uuid)
    except __HOLE__, e:
      raise errors.BlockDeviceError("Cannot create block device symlink: %s" %
                                    e.strerror)
    uri = _CalculateDeviceURI(instance, disk, device)

    block_devices.append((disk, link_name, uri))

  return block_devices
dataset/ETHPy150Open ganeti/ganeti/lib/backend.py/_GatherAndLinkBlockDevs