protected override void ExecuteCore(SelectedItemCollection selection) { if (selection != null && selection.AllItemsAre<IXenObject>(x => x is Host || x is Pool)) MainWindowCommandInterface.ShowForm(typeof(BugToolWizard), selection.AsXenObjects<IXenObject>().ToArray()); else MainWindowCommandInterface.ShowForm(typeof(BugToolWizard)); }
protected sealed override void ExecuteCore(SelectedItemCollection selection) { ConfirmVMDeleteDialog dialog = new ConfirmVMDeleteDialog(selection.AsXenObjects<VM>()); if (MainWindowCommandInterface.RunInAutomatedTestMode || dialog.ShowDialog(Parent) == DialogResult.Yes) { CommandErrorDialog errorDialog = null; Dictionary<SelectedItem, string> cantExecuteReasons = GetCantExecuteReasons(); if (cantExecuteReasons.Count > 0) { errorDialog = new CommandErrorDialog(ErrorDialogTitle, ErrorDialogText, GetCantExecuteReasons()); } List<AsyncAction> actions = new List<AsyncAction>(); foreach (VM vm in selection.AsXenObjects<VM>(CanExecute)) { var snapshotsToDelete = dialog.DeleteSnapshots.FindAll(x => x.Connection.Resolve(x.snapshot_of) == vm); actions.Add(GetAction(vm, dialog.DeleteDisks, snapshotsToDelete)); } RunMultipleActions(actions, Messages.ACTION_VMS_DESTROYING_TITLE, Messages.ACTION_VM_DESTROYING, Messages.ACTION_VM_DESTROYED, true); if (errorDialog != null) { errorDialog.ShowDialog(Parent); } } }
protected override void ExecuteCore(SelectedItemCollection selection) { List<Folder> folders = new List<Folder>(selection.AsXenObjects<Folder>(CanExecute)); folders.RemoveAll((Predicate<Folder>)delegate(Folder folder) { // if the list contains any folders that are children to others in the list then // they will automatically get deleted, so remove them here. foreach (Folder f in folders) { if (folder.opaque_ref.StartsWith(f.opaque_ref + "/")) { return true; } } return false; }); List<AsyncAction> actions = new List<AsyncAction>(); foreach (Folder folder in folders) { actions.Add(new FolderAction((IXenObject)folder, null, FolderAction.Kind.Delete)); } RunMultipleActions(actions, Messages.DELETING_FOLDERS, Messages.DELETING_FOLDERS, Messages.DELETED_FOLDERS, true); }
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(); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (VM vm in selection.AsXenObjects<VM>()) { actions.Add(new VMSnapshotDeleteAction(vm)); } RunMultipleActions(actions, Messages.ACTION_VM_DELETE_SNAPSHOTS_TITLE, Messages.SNAPSHOT_DELETING, Messages.SNAPSHOTS_DELETED, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (SR sr in selection.AsXenObjects<SR>(CanExecute)) { actions.Add(new SrAction(SrActionKind.Destroy, sr)); } RunMultipleActions(actions, Messages.ACTION_SRS_DESTROYING, string.Empty, string.Empty, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (SR sr in selection.AsXenObjects<SR>(CanExecute)) { actions.Add(new SrAction(SrActionKind.Detach, sr)); } RunMultipleActions(actions, Messages.ACTION_SRS_DETACHING, Messages.ACTION_SRS_DETACHING, Messages.ACTION_SRS_DETACH_SUCCESSFUL, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { var actions = new List<AsyncAction>(); foreach (SR sr in selection.AsXenObjects<SR>(CanExecute)) { actions.Add(new SrTrimAction(sr.Connection, sr)); } RunMultipleActions(actions, null, Messages.ACTION_SR_TRIM_DESCRIPTION, Messages.ACTION_SR_TRIM_DONE, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (SR sr in selection.AsXenObjects<SR>(CanExecute)) { actions.Add(new SrAction(SrActionKind.UpgradeLVM, sr)); } RunMultipleActions(actions, Messages.ACTION_SRS_UPGRADE, Messages.ACTION_SRS_UPGRADING, Messages.ACTION_SRS_UPGRADED, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (SR sr in selection.AsXenObjects<SR>(CanExecute)) { actions.Add(new SrAction(SrActionKind.Forget, sr)); } RunMultipleActions(actions, Messages.ACTION_SRS_FORGETTING, Messages.FORGETTING_SRS, Messages.SRS_FORGOTTEN, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { foreach (SR sr in selection.AsXenObjects<SR>(CanExecute)) { SrShareAction action = new SrShareAction(sr.Connection, sr); ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee); dialog.ShowCancel = true; dialog.ShowDialog(Parent); } }
protected override void ExecuteCore(SelectedItemCollection selection) { if (newPoolDialog == null || newPoolDialog.IsDisposed) { newPoolDialog = new NewPoolDialog(selection.AsXenObjects<Host>()); newPoolDialog.Show(Program.MainWindow); } else { HelpersGUI.BringFormToFront(newPoolDialog); } }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (Host host in selection.AsXenObjects<Host>(CanExecute)) { MainWindowCommandInterface.CloseActiveWizards(host.Connection); RebootHostAction action = new RebootHostAction( host,AddHostToPoolCommand.NtolDialog); action.Completed += s => MainWindowCommandInterface.RequestRefreshTreeView(); actions.Add(action); } RunMultipleActions(actions, null, Messages.ACTION_HOSTS_REBOOTING, Messages.ACTION_HOSTS_REBOOTED, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (Host host in selection.AsXenObjects<Host>()) { string opaque_ref = host.opaque_ref; Pool pool = Helpers.GetPool(host.Connection); if (selection.Count == 1 && pool.master == host.opaque_ref) { // Trying to remove the master from a pool. new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.MESSAGEBOX_POOL_MASTER_REMOVE, Messages.XENCENTER)).ShowDialog(MainWindowCommandInterface.Form); return; } // Optimistically, add the ejected host as a standalone host (but don't connect to it yet) IXenConnection connection = new XenConnection(); connection.Hostname = host.address; connection.Username = host.Connection.Username; connection.Password = host.Connection.Password; connection.FriendlyName = host.Name; lock (ConnectionsManager.ConnectionsLock) { ConnectionsManager.XenConnections.Add(connection); } Program.HideObject(opaque_ref); var action = new EjectHostFromPoolAction(pool, host); action.Completed += delegate { if (action.Succeeded) { ThreadPool.QueueUserWorkItem(WaitForReboot, connection); } else { Program.ShowObject(opaque_ref); MainWindowCommandInterface.RemoveConnection(connection); } }; actions.Add(action); } RunMultipleActions(actions, Messages.REMOVING_SERVERS_FROM_POOL, Messages.POOLCREATE_REMOVING, Messages.POOLCREATE_REMOVED, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actions = new List<AsyncAction>(); foreach (Host host in selection.AsXenObjects<Host>()) { Pool pool = Helpers.GetPool(host.Connection); var action = new DestroyHostAction(pool, host); actions.Add(action); } RunMultipleActions(actions, Messages.DESTROYING_HOSTS_TITLE, Messages.DESTROYING_HOSTS_START_DESC, Messages.DESTROYING_HOSTS_END_DESC, true); }
private void editVirtualDiskToolStripMenuItem_Click(object sender, EventArgs e) { SelectedItemCollection selectedVDIs = this.SelectedVDIs; if (selectedVDIs.Count == 1) { VDI xenObject = selectedVDIs.AsXenObjects <VDI>()[0]; if (!xenObject.is_a_snapshot) { new PropertiesDialog(xenObject).ShowDialog(this); } } }
public void LaunchIfRequired(bool nag, ChangeableList <IXenConnection> connections, SelectedItemCollection selectedObjects) { if (selectedObjects != null && selectedObjects.AllItemsAre <IXenObject>(x => x is Pool || x is Host)) { List <IXenObject> itemsSelected = selectedObjects.AsXenObjects <Pool>().ConvertAll(p => p as IXenObject); itemsSelected.AddRange(selectedObjects.AsXenObjects <Host>().Where(h => Helpers.GetPool(h.Connection) == null).ToList().ConvertAll(h => h as IXenObject)); itemsSelected.AddRange(selectedObjects.AsXenObjects <Host>().Where(h => Helpers.GetPool(h.Connection) != null).ToList().ConvertAll(h => Helpers.GetPool(h.Connection)).ConvertAll(p => p as IXenObject).Distinct()); if (itemsSelected.All(xo => Helpers.ClearwaterOrGreater(xo.Connection)) || itemsSelected.All(xo => !Helpers.ClearwaterOrGreater(xo.Connection))) { LaunchIfRequired(nag, connections, itemsSelected); } else { LaunchIfRequired(nag, connections, itemsSelected.Where(xo => Helpers.ClearwaterOrGreater(xo.Connection))); } } else { LaunchIfRequired(nag, connections); } }
protected override void ExecuteCore(SelectedItemCollection selection) { var actions = new List<AsyncAction>(); var liveHosts = selection.AsXenObjects<Host>().Where(h => h.IsLive); foreach (Host host in liveHosts) { MainWindowCommandInterface.CloseActiveWizards(host.Connection); var action = new RestartToolstackAction(host); actions.Add(action); } RunMultipleActions(actions, null, Messages.ACTION_TOOLSTACK_RESTARTING, Messages.ACTION_TOOLSTACK_RESTARTED, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<VDI> vdis = selection.AsXenObjects<VDI>(); bool featureForbidden = vdis.TrueForAll(vdi => Helpers.FeatureForbidden(vdi.Connection, Host.RestrictCrossPoolMigrate)); if (featureForbidden) { ShowUpsellDialog(Parent); } else { new VDIMigrateDialog(selection.FirstAsXenObject.Connection, vdis).Show(Program.MainWindow); } }
protected override void ExecuteCore(SelectedItemCollection selection) { var dockerContainers = new List<DockerContainer>(); if (selection.AllItemsAre<DockerContainer>()) { dockerContainers = (from IXenObject obj in selection.AsXenObjects() let container = (DockerContainer)obj where CanExecute(container) select container).ToList(); } foreach (var container in dockerContainers) (new StartDockerContainerAction(container)).RunAsync(); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<SR> srList = selection.AsXenObjects<SR>(CanExecute); if (srList.Find(s => !s.MultipathAOK) != null) { new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Warning, Messages.MULTIPATH_FAILED, Messages.MULTIPATHING)).ShowDialog(Parent); } new RepairSRDialog(srList).Show(Parent); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (selection.AllItemsAre<IStorageLinkObject>()) { var connections = new List<StorageLinkConnection>(); foreach (IStorageLinkObject s in selection.AsXenObjects<IStorageLinkObject>()) { if (s.StorageLinkConnection.ConnectionState != StorageLinkConnectionState.Connected) { return false; } } return true; } return false; }
protected override void ExecuteCore(SelectedItemCollection selection) { MainWindowCommandInterface.SelectObjectInTree(null); foreach (Host host in selection.AsXenObjects<Host>()) { string msg = string.Format(Messages.MAINWINDOW_LOG_REMOVECONNECTION, host.Connection.Hostname); log.Info(msg); new ActionBase(msg, msg, false, true); MainWindowCommandInterface.CloseActiveWizards(host.Connection); host.Connection.EndConnect(); MainWindowCommandInterface.RemoveConnection(host.Connection); } MainWindowCommandInterface.SaveServerList(); MainWindowCommandInterface.RequestRefreshTreeView(); }
private void editVirtualDiskToolStripMenuItem_Click(object sender, EventArgs e) { SelectedItemCollection vdis = SelectedVDIs; if (vdis.Count != 1) { return; } VDI vdi = vdis.AsXenObjects <VDI>()[0]; if (vdi.is_a_snapshot) { return; } new PropertiesDialog(vdi).ShowDialog(this); }
private void EditSelectedVdis() { SelectedItemCollection vdis = SelectedVDIs; if (vdis.Count != 1) { return; } VDI vdi = vdis.AsXenObjects <VDI>()[0]; if (vdi.is_a_snapshot) { return; } new PropertiesDialog(vdi).ShowDialog(this); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { if (selection.AllItemsAre<VM_appliance>()) return selection.AtLeastOneXenObjectCan<VM_appliance>(CanStartAppliance); if (selection.AllItemsAre<VM>()) { var firstVm = (VM)selection.First; if (firstVm.IsAssignedToVapp) { var firstVapp = firstVm.appliance; if (selection.AsXenObjects<VM>().All(vm => vm.appliance != null && vm.appliance.opaque_ref == firstVapp.opaque_ref)) return CanStartAppliance(firstVm.Connection.Resolve(firstVapp)); } } return false; }
protected override bool CanExecuteCore(SelectedItemCollection selection) { // you can only remove a storagelink server from XC if there isn't an SR using it. List<StorageLinkConnection> slCons = new List<StorageLinkConnection>(); if (selection.AllItemsAre<IStorageLinkObject>()) { foreach (IStorageLinkObject s in selection.AsXenObjects()) { if (!slCons.Contains(s.StorageLinkConnection)) { slCons.Add(s.StorageLinkConnection); } } } return slCons.Count == 1; }
protected override void ExecuteCore(SelectedItemCollection selection) { List<VDI> vdis = selection.AsXenObjects<VDI>(); bool featureForbidden = vdis.TrueForAll(vdi => Helpers.FeatureForbidden(vdi.Connection, Host.RestrictCrossPoolMigrate)); if (featureForbidden) { string theText = HiddenFeatures.LinkLabelHidden ? Messages.MIGRATE_VDI_UPSELL_BLURB : Messages.MIGRATE_VDI_UPSELL_BLURB + Messages.MIGRATE_VDI_UPSELL_BLURB_MORE; using (var dlg = new UpsellDialog(theText, InvisibleMessages.UPSELL_LEARNMOREURL_CPM)) dlg.ShowDialog(Parent); } else { new MoveVirtualDiskDialog(selection.FirstAsXenObject.Connection, null, vdis).Show(Program.MainWindow); } }
protected override void ExecuteCore(SelectedItemCollection selection) { var connections = new List<StorageLinkConnection>(); foreach (IStorageLinkObject s in selection.AsXenObjects<IStorageLinkObject>()) { if (!connections.Contains(s.StorageLinkConnection)) { connections.Add(s.StorageLinkConnection); } } foreach (StorageLinkConnection c in connections) { string title = string.Format(Messages.REFRESH_STORAGELINK_SYSTEMS_ACTION_TITLE, c.Host); string startDes = Messages.REFRESH_STORAGELINK_SYSTEMS_ACTION_START; string endDes = Messages.REFRESH_STORAGELINK_SYSTEMS_ACTION_END; var action = new DelegatedAsyncAction(null, title, startDes, endDes, s => { c.Refresh(); // wait for refresh to finish so the user can see that // the refresh is still in progress in the logs tab. for (int i = 0; i < 60 && c.RefreshInProgress; i++) { Thread.Sleep(500); } }); foreach (IStorageLinkObject s in selection.AsXenObjects<IStorageLinkObject>()) { if (s.StorageLinkConnection == c) { action.AppliesTo.Add(s.opaque_ref); } } action.RunAsync(); } }
private void contextMenuStrip_Opening(object sender, CancelEventArgs e) { SelectedItemCollection vdis = SelectedVDIs; if (vdis.Count == 0) { return; } contextMenuStrip1.Items.Clear(); DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis); contextMenuStrip1.Items.Add(new CommandToolStripMenuItem(deleteCmd, true)); contextMenuStrip1.Items.Add(new CommandToolStripMenuItem(MoveMigrateCommand(vdis), true)); contextMenuStrip1.Items.Add(editVirtualDiskToolStripMenuItem); editVirtualDiskToolStripMenuItem.Enabled = vdis.Count == 1 && !vdis.AsXenObjects <VDI>()[0].is_a_snapshot; }
protected override void ExecuteCore(SelectedItemCollection selection) { var appsToStart = new List<VM_appliance>(); if (selection.AllItemsAre<VM_appliance>()) { appsToStart = (from IXenObject obj in selection.AsXenObjects() let app = (VM_appliance)obj where CanStartAppliance(app) select app).ToList(); } else if (selection.AllItemsAre<VM>()) { var firstVm = (VM)selection.First; appsToStart.Add(firstVm.Connection.Resolve(firstVm.appliance)); } foreach (var app in appsToStart) (new StartApplianceAction(app, false)).RunAsync(); }
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); } }
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(); }
protected override void ExecuteCore(SelectedItemCollection selection) { AssertOperationAllowsExecution(); string title = Messages.ACTION_VMS_RESUMING_ON_TITLE; string startDescription = Messages.ACTION_VM_RESUMING; string endDescription = Messages.ACTION_VM_RESUMED; List<AsyncAction> actions = new List<AsyncAction>(); if (_operation == vm_operations.pool_migrate) { title = Messages.ACTION_VMS_MIGRATING_TITLE; startDescription = Messages.ACTION_VM_MIGRATING; endDescription = Messages.ACTION_VM_MIGRATED; foreach (VM vm in selection.AsXenObjects<VM>(CanExecute)) { this.MainWindowCommandInterface.CloseActiveWizards(vm); Host host = GetHost(vm); actions.Add(new VMMigrateAction(vm, host)); } } else if (_operation == vm_operations.start_on) { title = Messages.ACTION_VMS_STARTING_ON_TITLE; startDescription = Messages.ACTION_VM_STARTING; endDescription = Messages.ACTION_VM_STARTED; foreach (VM vm in selection.AsXenObjects<VM>(CanExecute)) { Host host = GetHost(vm); actions.Add(new VMStartOnAction(vm, host,WarningDialogHAInvalidConfig, StartDiagnosisForm)); } } else if (_operation == vm_operations.resume_on) { title = Messages.ACTION_VMS_RESUMING_ON_TITLE; startDescription = Messages.ACTION_VM_RESUMING; endDescription = Messages.ACTION_VM_RESUMED; foreach (VM vm in selection.AsXenObjects<VM>(CanExecute)) { Host host = GetHost(vm); actions.Add(new VMResumeOnAction(vm, host, WarningDialogHAInvalidConfig, StartDiagnosisForm)); } } RunMultipleActions(actions, title, startDescription, endDescription, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<VM> vms = selection.AsXenObjects<VM>(CanExecute); if (vms.Count == 1) SingleVMExecute(vms[0]); else MultipleVMExecute(vms); }
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; } }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actionsToComplete = new List<AsyncAction>(); foreach (VBD vbd in selection.AsXenObjects<VBD>()) { if (vbd.Locked) continue; actionsToComplete.Add(getDeactivateVBDAction(vbd)); } if (actionsToComplete.Count > 1) RunMultipleActions(actionsToComplete, Messages.ACTION_ACTIVATING_MULTIPLE_VDIS_TITLE, Messages.ACTION_ACTIVATING_MULTIPLE_VDIS_STATUS, Messages.COMPLETED, true); else actionsToComplete[0].RunAsync(); }
private void contextMenuStrip_Opening(object sender, CancelEventArgs e) { SelectedItemCollection selectedVDIs = this.SelectedVDIs; if (selectedVDIs.Count != 0) { this.contextMenuStrip1.Items.Clear(); DeleteVirtualDiskCommand command = new DeleteVirtualDiskCommand(Program.MainWindow, selectedVDIs) { AllowRunningVMDelete = true }; this.contextMenuStrip1.Items.Add(new CommandToolStripMenuItem(command, true)); this.contextMenuStrip1.Items.Add(new CommandToolStripMenuItem(this.MoveMigrateCommand(selectedVDIs), true)); this.contextMenuStrip1.Items.Add(this.editVirtualDiskToolStripMenuItem); this.editVirtualDiskToolStripMenuItem.Enabled = (selectedVDIs.Count == 1) && !selectedVDIs.AsXenObjects <VDI>()[0].is_a_snapshot; } }
protected override void ExecuteCore(SelectedItemCollection selection) { var vdis = selection.AsXenObjects<VDI>(); new MoveVirtualDiskDialog(selection.GetConnectionOfFirstItem(), vdis, null).Show(Program.MainWindow); }
protected override void ExecuteCore(SelectedItemCollection selection) { List<AsyncAction> actionsToComplete = new List<AsyncAction>(); List<VM> deletedVMSnapshots = new List<VM>(); foreach (VDI vdi in selection.AsXenObjects<VDI>()) { if (vdi.Locked || !vdi.Show(XenAdmin.Properties.Settings.Default.ShowHiddenVMs)) continue; actionsToComplete.AddRange(getDestroyVDIAction(vdi, deletedVMSnapshots)); } if (actionsToComplete.Count > 1) RunMultipleActions(actionsToComplete, Messages.ACTION_DELETING_MULTIPLE_STORAGE_ITEMS_TITLE, Messages.ACTION_DELETING_MULTIPLE_STORAGE_ITEMS_STATUS, Messages.COMPLETED, true); else actionsToComplete[0].RunAsync(); }