protected override void Run() { VBD cdrom = VM.FindVMCDROM(); if (cdrom == null) { Description = Messages.NEW_DVD_DRIVE_CREATING; // could not find a cd, try and make one List <String> allowedDevices = new List <String>(XenAPI.VM.get_allowed_VBD_devices(Session, VM.opaque_ref)); XenAPI.VBD cdDrive = new XenAPI.VBD(); cdDrive.VM = new XenAPI.XenRef <XenAPI.VM>(VM.opaque_ref); cdDrive.VDI = null; cdDrive.bootable = false; cdDrive.device = ""; cdDrive.userdevice = allowedDevices.Contains("3") ? "3" : allowedDevices[0]; cdDrive.empty = true; cdDrive.type = XenAPI.vbd_type.CD; cdDrive.mode = XenAPI.vbd_mode.RO; VbdSaveAndPlugAction cdCreate = new VbdSaveAndPlugAction(VM, cdDrive, Messages.DVD_DRIVE, Session, InstallingTools, true, _showMustRebootBoxCD, _showVBDWarningBox); cdCreate.RunExternal(Session); Description = Messages.NEW_DVD_DRIVE_DONE; } }
protected override void Run() { VBD cdrom = VM.FindVMCDROM(); if (cdrom == null) { Description = Messages.NEW_DVD_DRIVE_CREATING; // could not find a cd, try and make one if (VM.VBDs.Count >= VM.MaxVBDsAllowed()) { throw new Exception(Messages.CDDRIVE_MAX_ALLOWED_VBDS); } List <String> allowedDevices = new List <String>(XenAPI.VM.get_allowed_VBD_devices(Session, VM.opaque_ref)); if (allowedDevices == null || allowedDevices.Count == 0) { throw new Exception(Messages.CDDRIVE_MAX_ALLOWED_VBDS); } XenAPI.VBD cdDrive = new XenAPI.VBD { VM = new XenAPI.XenRef <XenAPI.VM>(VM.opaque_ref), bootable = false, device = "", userdevice = allowedDevices.Contains("3") ? "3" : allowedDevices[0], empty = true, type = XenAPI.vbd_type.CD, mode = XenAPI.vbd_mode.RO }; var cdCreate = new VbdSaveAndPlugAction(VM, cdDrive, Messages.DVD_DRIVE, Session, true); cdCreate.ShowUserInstruction += msg => ShowUserInstruction?.Invoke(msg); cdCreate.RunExternal(Session); Description = Messages.NEW_DVD_DRIVE_DONE; } }
protected override void Run() { VBD cdrom = VM.FindVMCDROM(); if (cdrom == null) { Description = Messages.NEW_DVD_DRIVE_CREATING; // could not find a cd, try and make one if (VM.VBDs.Count >= VM.MaxVBDsAllowed) { throw new Exception(Messages.CDDRIVE_MAX_ALLOWED_VBDS); } List<String> allowedDevices = new List<String>(XenAPI.VM.get_allowed_VBD_devices(Session, VM.opaque_ref)); if (allowedDevices == null || allowedDevices.Count == 0) { throw new Exception(Messages.CDDRIVE_MAX_ALLOWED_VBDS); } XenAPI.VBD cdDrive = new XenAPI.VBD(); cdDrive.VM = new XenAPI.XenRef<XenAPI.VM>(VM.opaque_ref); cdDrive.VDI = null; cdDrive.bootable = false; cdDrive.device = ""; cdDrive.userdevice = allowedDevices.Contains("3") ? "3" : allowedDevices[0]; cdDrive.empty = true; cdDrive.type = XenAPI.vbd_type.CD; cdDrive.mode = XenAPI.vbd_mode.RO; VbdSaveAndPlugAction cdCreate = new VbdSaveAndPlugAction(VM, cdDrive, Messages.DVD_DRIVE, Session, InstallingTools, true,_showMustRebootBoxCD,_showVBDWarningBox); cdCreate.RunExternal(Session); Description = Messages.NEW_DVD_DRIVE_DONE; } }