def _attach_orig_disks(self, instance, vm_ref):
        orig_vm_ref = vm_utils.lookup(self._session, instance['name'])
        orig_vdi_refs = self._find_vdi_refs(orig_vm_ref,
                                            exclude_volumes=True)

        # Attach original root disk
        root_vdi_ref = orig_vdi_refs.get(DEVICE_ROOT)
        if not root_vdi_ref:
            raise exception.NotFound(_("Unable to find root VBD/VDI for VM"))

        vbd_ref = vm_utils.create_vbd(self._session, vm_ref, root_vdi_ref,
                                      DEVICE_RESCUE, bootable=False)
        vbd_refs = [vbd_ref]

        # Attach original swap disk
        swap_vdi_ref = orig_vdi_refs.get(DEVICE_SWAP)
        if swap_vdi_ref:
            vbd_ref = vm_utils.create_vbd(self._session, vm_ref, swap_vdi_ref,
                                          DEVICE_SWAP, bootable=False)
            vbd_refs.append(vbd_ref)

        # Attach original ephemeral disks
        for userdevice, vdi_ref in six.iteritems(orig_vdi_refs):
            if userdevice >= DEVICE_EPHEMERAL:
                vbd_ref = vm_utils.create_vbd(self._session, vm_ref, vdi_ref,
                                              userdevice, bootable=False)
                vbd_refs.append(vbd_ref)

        return vbd_refs
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps._attach_orig_disks/original