# Introduce VDI and attach VBD to VM try: vdi_ref = VolumeHelper.introduce_vdi(self._session, sr_ref, vdi_uuid) except StorageError, exc: LOG.exception(exc) self.forget_sr(uuid) raise Exception(_('Unable to create VDI on SR %(sr_ref)s for' ' instance %(instance_name)s') % locals()) dev_number = VolumeHelper.mountpoint_to_number(mountpoint) try: vbd_ref = VolumeHelper.create_vbd(self._session, vm_ref, vdi_ref, dev_number, False) except self.XenAPI.Failure, exc: LOG.exception(exc) self.forget_sr(uuid) raise Exception(_('Unable to use SR %(sr_ref)s for' ' instance %(instance_name)s') % locals()) try: self._session.call_xenapi("VBD.plug", vbd_ref) except self.XenAPI.Failure, exc: LOG.exception(exc) self.forget_sr(uuid) raise Exception(_('Unable to attach volume to instance %s') % instance_name)
vdi_uuid = None # Introduce VDI and attach VBD to VM try: vdi_ref = VolumeHelper.introduce_vdi(self._session, sr_ref, vdi_uuid) except StorageError, exc: LOG.exception(exc) self.forget_sr(uuid) raise Exception( _('Unable to create VDI on SR %(sr_ref)s for' ' instance %(instance_name)s') % locals()) dev_number = VolumeHelper.mountpoint_to_number(mountpoint) try: vbd_ref = VolumeHelper.create_vbd(self._session, vm_ref, vdi_ref, dev_number, False) except self.XenAPI.Failure, exc: LOG.exception(exc) self.forget_sr(uuid) raise Exception( _('Unable to use SR %(sr_ref)s for' ' instance %(instance_name)s') % locals()) try: self._session.call_xenapi("VBD.plug", vbd_ref) except self.XenAPI.Failure, exc: LOG.exception(exc) self.forget_sr(uuid) raise Exception( _('Unable to attach volume to instance %s') % instance_name)