private void RefreshButtons()
        {
            bool flag = (this.sr == null) || this.sr.Locked;
            SelectedItemCollection   selectedVDIs = this.SelectedVDIs;
            DeleteVirtualDiskCommand command      = new DeleteVirtualDiskCommand(Program.MainWindow, selectedVDIs)
            {
                AllowMultipleVBDDelete = true,
                AllowRunningVMDelete   = true
            };

            if (command.CanExecute())
            {
                this.RemoveButton.Enabled = true;
                this.RemoveButtonContainer.RemoveAll();
            }
            else
            {
                this.RemoveButton.Enabled = false;
                this.RemoveButtonContainer.SetToolTip(command.ToolTipText);
            }
            Command command2 = this.MoveMigrateCommand(selectedVDIs);

            if (command2.CanExecute())
            {
                this.buttonMove.Enabled = true;
                this.toolTipContainerMove.RemoveAll();
            }
            else
            {
                this.buttonMove.Enabled = false;
                this.toolTipContainerMove.SetToolTip(command2.ToolTipText);
            }
            if (flag)
            {
                this.buttonRefresh.Enabled = false;
            }
            else if (HelpersGUI.BeingScanned(this.sr))
            {
                this.buttonRefresh.Enabled = false;
                this.toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP);
            }
            else
            {
                this.buttonRefresh.Enabled = true;
                this.toolTipContainerRescan.RemoveAll();
            }
            this.addVirtualDiskButton.Enabled = !flag;
            if (selectedVDIs.Count == 1)
            {
                VDI vdi = selectedVDIs.AsXenObjects <VDI>()[0];
                this.EditButton.Enabled = (!flag && !vdi.is_a_snapshot) && !vdi.Locked;
            }
            else
            {
                this.EditButton.Enabled = false;
            }
            this.removeDropDownButton.Enabled = command.CanExecute();
        }
Example #2
0
        private void DeleteVdi()
        {
            List <VBDRow> rows = SelectedVBDRows;

            if (rows == null)
            {
                return;
            }
            List <SelectedItem> l = new List <SelectedItem>();

            foreach (VBDRow r in rows)
            {
                l.Add(new SelectedItem(r.VDI));
            }

            DeleteVirtualDiskCommand cmd = new DeleteVirtualDiskCommand(Program.MainWindow, l);

            // User has visibility that this disk in use by this VM. Allow unplug + delete in single step (non default behaviour),
            // but only if we are the only VBD (default behaviour)
            cmd.AllowRunningVMDelete = true;
            if (cmd.CanExecute())
            {
                cmd.Execute();
            }
        }
Example #3
0
        private void removeVirtualDisk_Click(object sender, EventArgs e)
        {
            SelectedItemCollection   vdis = SelectedVDIs;
            DeleteVirtualDiskCommand cmd  = new DeleteVirtualDiskCommand(Program.MainWindow, vdis);

            cmd.AllowMultipleVBDDelete = true;
            if (cmd.CanExecute())
            {
                cmd.Execute();
            }
        }
Example #4
0
        private void RemoveSelectedVdis()
        {
            SelectedItemCollection   vdis = SelectedVDIs;
            DeleteVirtualDiskCommand cmd  = new DeleteVirtualDiskCommand(Program.MainWindow, vdis)
            {
                AllowMultipleVBDDelete = true
            };

            if (cmd.CanExecute())
            {
                cmd.Execute();
            }
        }
        private void removeVirtualDisk_Click(object sender, EventArgs e)
        {
            SelectedItemCollection   selectedVDIs = this.SelectedVDIs;
            DeleteVirtualDiskCommand command      = new DeleteVirtualDiskCommand(Program.MainWindow, selectedVDIs)
            {
                AllowMultipleVBDDelete = true,
                AllowRunningVMDelete   = true
            };

            if (command.CanExecute())
            {
                command.Execute();
            }
        }
Example #6
0
        private void UpdateButtons()
        {
            AttachVirtualDiskCommand attachCmd = new AttachVirtualDiskCommand(Program.MainWindow, vm);

            AttachButton.Enabled = attachCmd.CanExecute();
            AddButton.Enabled    = attachCmd.CanExecute();

            List <VBDRow> vbdRows = SelectedVBDRows;

            if (dataGridViewStorage.Rows.Count == 0 || vbdRows == null || vm == null)
            {
                DeactivateButton.Enabled = false;
                DetachButton.Enabled     = false;
                DeleteButton.Enabled     = false;
                EditButton.Enabled       = false;
                MoveButton.Enabled       = false;
                return;
            }
            EditButton.Enabled = vbdRows.Count == 1 && !vbdRows[0].VBD.Locked && !vbdRows[0].VDI.Locked;

            List <SelectedItem> selectedVDIs = new List <SelectedItem>();
            List <SelectedItem> selectedVBDs = new List <SelectedItem>();

            foreach (VBDRow r in vbdRows)
            {
                selectedVDIs.Add(new SelectedItem(r.VDI));
                selectedVBDs.Add(new SelectedItem(r.VBD));
            }
            DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, selectedVDIs);

            // User has visibility that this disk in use by this VM. Allow unplug + delete in single step (non default behaviour),
            // but only if we are the only VBD (default behaviour)
            deleteCmd.AllowRunningVMDelete = true;
            if (deleteCmd.CanExecute())
            {
                DeleteButtonContainer.RemoveAll();
                DeleteButton.Enabled = true;
            }
            else
            {
                DeleteButtonContainer.SetToolTip(deleteCmd.ToolTipText);
                DeleteButton.Enabled = false;
            }

            Command activationCmd = null;

            SelectedItemCollection vbdCol = new SelectedItemCollection(selectedVBDs);

            if (vbdCol.AsXenObjects <VBD>().Find(delegate(VBD vbd) { return(!vbd.currently_attached); }) == null)
            {
                // no VBDs are attached so we are deactivating
                toolStripMenuItemDeactivate.Text = DeactivateButton.Text = Messages.DEACTIVATE;
                activationCmd = new DeactivateVBDCommand(Program.MainWindow, selectedVBDs);
            }
            else
            {
                // this is the default cause in the mixed attached/detached scenario. We try to activate all the selection
                // The command error reports afterwards about the ones which are already attached
                toolStripMenuItemDeactivate.Text = DeactivateButton.Text = Messages.ACTIVATE;
                activationCmd = new ActivateVBDCommand(Program.MainWindow, selectedVBDs);
            }

            if (activationCmd.CanExecute())
            {
                DeactivateButtonContainer.RemoveAll();
                DeactivateButton.Enabled = true;
            }
            else
            {
                DeactivateButtonContainer.SetToolTip(activationCmd.ToolTipText);
                DeactivateButton.Enabled = false;
            }

            DetachVirtualDiskCommand detachCmd = new DetachVirtualDiskCommand(Program.MainWindow, selectedVDIs, vm);

            if (detachCmd.CanExecute())
            {
                DetachButtonContainer.RemoveAll();
                DetachButton.Enabled = true;
            }
            else
            {
                DetachButtonContainer.SetToolTip(detachCmd.ToolTipText);
                DetachButton.Enabled = false;
            }

            // Move button
            Command moveCmd = MoveVirtualDiskDialog.MoveMigrateCommand(Program.MainWindow, selectedVDIs);

            if (moveCmd.CanExecute())
            {
                MoveButton.Enabled = true;
                MoveButtonContainer.RemoveAll();
            }
            else
            {
                MoveButton.Enabled = false;
                MoveButtonContainer.SetToolTip(moveCmd.ToolTipText);
            }
        }
Example #7
0
        private void RefreshButtons()
        {
            bool srLocked = sr == null || sr.Locked;
            SelectedItemCollection vdis = SelectedVDIs;

            // Delete button
            DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis);

            // User has visibility that this disk is related to all it's VM. Allow deletion with multiple VBDs (non default behaviour),
            // but don't allow them to delete if a running vm is using the disk (default behaviour).
            deleteCmd.AllowMultipleVBDDelete = true;
            if (deleteCmd.CanExecute())
            {
                RemoveButton.Enabled = true;
                RemoveButtonContainer.RemoveAll();
            }
            else
            {
                RemoveButton.Enabled = false;
                RemoveButtonContainer.SetToolTip(deleteCmd.ToolTipText);
            }

            // Move button
            Command moveCmd = MoveMigrateCommand(vdis);

            if (moveCmd.CanExecute())
            {
                buttonMove.Enabled = true;
                toolTipContainerMove.RemoveAll();
            }
            else
            {
                buttonMove.Enabled = false;
                toolTipContainerMove.SetToolTip(moveCmd.ToolTipText);
            }

            // Rescan button
            if (srLocked)
            {
                buttonRefresh.Enabled = false;
            }
            else if (HelpersGUI.BeingScanned(sr))
            {
                buttonRefresh.Enabled = false;
                toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP);
            }
            else
            {
                buttonRefresh.Enabled = true;
                toolTipContainerRescan.RemoveAll();
            }

            // Add VDI button
            addVirtualDiskButton.Enabled = !srLocked;

            // Properties button
            if (vdis.Count == 1)
            {
                VDI vdi = vdis.AsXenObjects <VDI>()[0];
                EditButton.Enabled = !srLocked && !vdi.is_a_snapshot && !vdi.Locked;
            }
            else
            {
                EditButton.Enabled = false;
            }

            // Remove drop down button
            removeDropDownButton.Enabled = deleteCmd.CanExecute();
        }
Example #8
0
        private void RefreshButtons()
        {
            SelectedItemCollection vdis = SelectedVDIs;

            // Delete button
            // The user can see that this disk is attached to more than one VMs. Allow deletion of multiple VBDs (non default behaviour),
            // but don't allow them to be deleted if a running vm is using the disk (default behaviour).

            DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis)
            {
                AllowMultipleVBDDelete = true
            };

            if (deleteCmd.CanExecute())
            {
                RemoveButton.Enabled = true;
                RemoveButtonContainer.RemoveAll();
            }
            else
            {
                RemoveButton.Enabled = false;
                RemoveButtonContainer.SetToolTip(deleteCmd.ToolTipText);
            }

            // Move button
            Command moveCmd = MoveVirtualDiskDialog.MoveMigrateCommand(Program.MainWindow, vdis);

            if (moveCmd.CanExecute())
            {
                buttonMove.Enabled = true;
                toolTipContainerMove.RemoveAll();
            }
            else
            {
                buttonMove.Enabled = false;
                toolTipContainerMove.SetToolTip(moveCmd.ToolTipText);
            }

            // Rescan button
            if (sr == null || sr.Locked)
            {
                buttonRescan.Enabled = false;
            }
            else if (HelpersGUI.BeingScanned(sr))
            {
                buttonRescan.Enabled = false;
                toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP);
            }
            else
            {
                buttonRescan.Enabled = true;
                toolTipContainerRescan.RemoveAll();
            }

            // Add VDI button
            addVirtualDiskButton.Enabled = sr != null && !sr.Locked;

            // Properties button
            if (vdis.Count == 1)
            {
                VDI vdi = vdis.AsXenObjects <VDI>()[0];
                EditButton.Enabled = sr != null && !sr.Locked && !vdi.is_a_snapshot && !vdi.Locked;
            }
            else
            {
                EditButton.Enabled = false;
            }
        }