コード例 #1
0
ファイル: CreateVMAction.cs プロジェクト: ywwseu/xenadmin
        private void AddCdDrive()
        {
            if (Helpers.CustomWithNoDVD(Template))
            {
                return; // we have skipped the install media page because we are a cutom template with no cd drive - the user doesnt want a cd drive
            }
            Description = Messages.CREATE_CD_DRIVE;
            VBD cd_drive = null;

            foreach (VBD vbd in Connection.ResolveAll(VM.VBDs))
            {
                if (vbd.type != vbd_type.CD)
                {
                    continue;
                }

                if ("0123".IndexOf(vbd.userdevice) < 0)  // userdevice is not 0, 1, 2 or 3: these are the valid positions for CD drives
                {
                    continue;
                }

                cd_drive = vbd;
                break;
            }

            if (cd_drive == null)
            {
                cd_drive = CreateCdDrive();
            }

            if (!cd_drive.empty)
            {
                RelatedTask = VBD.async_eject(Session, cd_drive.opaque_ref);
                PollToCompletion(65, 67);
            }

            if (InsMethod == InstallMethod.CD && Cd != null) // obviously dont insert the empty cd
            {
                RelatedTask = VBD.async_insert(Session, cd_drive.opaque_ref, Cd.opaque_ref);
                PollToCompletion(67, 70);
            }
        }
コード例 #2
0
        protected override void Run()
        {
            bool wasEmpty = false;

            if (!cdrom.empty)
            {
                RelatedTask = VBD.async_eject(Session, cdrom.opaque_ref);
                wasEmpty    = true;
                PollToCompletion(0, 50);
            }

            if (vdi != null)
            {
                RelatedTask = VBD.async_insert(Session, cdrom.opaque_ref, vdi.opaque_ref);
                PollToCompletion(wasEmpty ? 50 : 0, 100);
                Description = String.Format(Messages.ISO_LOADED,
                                            vdi.Name, VM.Name);
            }
            else
            {
                Description = String.Format(Messages.ISO_UNLOADED,
                                            VM.Name);
            }
        }