Example #1
0
        protected override void Run()
        {
            // First, save changes to the VBD.

            string vbdServerRef = vbd.SaveChanges(Session, null, null);

            if (!VM.IsHVM() && vbd.empty)
            {
                // PV guest require no further action
                return;
            }

            // Then if we can plug the vbd in, do so...
            if (vbdServerRef != null &&
                VBD.get_allowed_operations(Session, vbdServerRef).Contains(vbd_operations.plug))
            {
                log.DebugFormat("Attempting to hot plug VBD {0}.", vbd.uuid);
                this.RelatedTask = XenAPI.VBD.async_plug(Session, vbdServerRef);
                PollToCompletion();
                this.Description = Messages.ATTACHDISKWIZARD_ATTACHED;
            }
            else
            {
                VM vm = this.Connection.Resolve(vbd.VM);
                if (vm != null && vm.power_state != vm_power_state.Halted)
                {
                    if (vbd.type == vbd_type.CD)
                    {
                        ShowUserInstruction?.Invoke(Messages.NEW_DVD_DRIVE_REBOOT);
                    }
                    else
                    {
                        ShowUserInstruction?.Invoke(Messages.NEWDISKWIZARD_MESSAGE);
                    }
                }
            }
        }