/// <summary> /// Called in the 'connect new server and add to pool' action after the server has connected /// and its cache has been populated. Adds the new server to the pool. /// </summary> private void dialog_CachePopulated(object sender, CachePopulatedEventArgs e) { IXenConnection newConnection = e.Connection; // A new connection was successfully made: add the new server to its destination pool. Host hostToAdd = Helpers.GetMaster(newConnection); if (hostToAdd == null) { log.Debug("hostToAdd is null while joining host to pool in AddNewHostToPoolCommand: this should never happen!"); return; } // Check newly-connected host is not in pool Pool hostPool = Helpers.GetPool(newConnection); MainWindowCommandInterface.Invoke(delegate { if (hostPool != null) { string text = String.Format(Messages.HOST_ALREADY_IN_POOL, hostToAdd.Name, _pool.Name, hostPool.Name); string caption = Messages.POOL_JOIN_IMPOSSIBLE; new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, text, caption)).ShowDialog(Program.MainWindow); } else { new AddHostToPoolCommand(MainWindowCommandInterface, new Host[] { hostToAdd }, _pool, false).Execute(); } }); }
/// <summary> /// Called in the 'connect new server and add to pool' action after the server has connected /// and its cache has been populated. Adds the new server to the pool. /// </summary> private void dialog_CachePopulated(IXenConnection conn) { // A new connection was successfully made: add the new server to its destination pool. Host hostToAdd = Helpers.GetMaster(conn); if (hostToAdd == null) { log.Debug("hostToAdd is null while joining host to pool in AddNewHostToPoolCommand: this should never happen!"); return; } // Check newly-connected host is not in pool Pool hostPool = Helpers.GetPool(conn); MainWindowCommandInterface.Invoke(delegate { if (hostPool != null) { string text = String.Format(Messages.HOST_ALREADY_IN_POOL, hostToAdd.Name(), _pool.Name(), hostPool.Name()); using (var dlg = new WarningDialog(text) { WindowTitle = Messages.POOL_JOIN_IMPOSSIBLE }) dlg.ShowDialog(Program.MainWindow); } else { new AddHostToPoolCommand(MainWindowCommandInterface, new Host[] { hostToAdd }, _pool, false).Execute(); } }); }
protected override void ExecuteCore() { Folder targetFolder = GetTargetNodeAncestorAsXenObjectOrGroupingTag <Folder>(); if (DraggedNodes != null) { foreach (VirtualTreeNode draggedNode in DraggedNodes) { if (GetItemsNotAlreadyInTargetFolder().Contains((IXenObject)draggedNode.Tag)) { GreyAll(draggedNode); } } } new MoveToFolderAction(GetItemsNotAlreadyInTargetFolder(), targetFolder).RunAsync(); // need to now wait until the operation has finished... then we can expand the node. ThreadPool.QueueUserWorkItem(delegate { for (int i = 0; i < 20 && TargetNode.Nodes.Count == 0; i++) { Thread.Sleep(100); } MainWindowCommandInterface.Invoke(delegate { TargetNode.Expand(); }); }); }
private void InstallToolsActionCompleted(ActionBase sender) { InstallPVToolsAction action = (InstallPVToolsAction)sender; MainWindowCommandInterface.Invoke(delegate { Program.MainWindow.SelectObject(action.VM); Program.MainWindow.TheTabControl.SelectedTab = Program.MainWindow.TabPageConsole; }); }
private void dialog_CachePopulated(IXenConnection conn) { _dialog.CachePopulated -= dialog_CachePopulated; // first select the disconnected host in the tree // before the tree is populated, the opaque_ref of the disconnected host is the hostname // so use this to select the object. MainWindowCommandInterface.Invoke(() => MainWindowCommandInterface.SelectObjectInTree(new Host { opaque_ref = conn.Hostname })); MainWindowCommandInterface.TrySelectNewObjectInTree(conn, true, true, true); }
protected override void ExecuteCore(SelectedItemCollection selection) { foreach (IXenConnection connection in MainWindowCommandInterface.GetXenConnectionsCopy()) { if (connection.IsConnected) { MainWindowCommandInterface.Invoke(delegate { new DisconnectCommand(MainWindowCommandInterface, connection, true).Execute(); }); } } }
private void FirstInstallToolsActionCompleted(ActionBase sender) { InstallPVToolsAction action = (InstallPVToolsAction)sender; MainWindowCommandInterface.Invoke(delegate { // Try to select the VM on which the PV tools are to be installed if (MainWindowCommandInterface.SelectObjectInTree(action.VM)) { // Switch to the VM's console tab MainWindowCommandInterface.SwitchToTab(MainWindow.Tab.Console); } }); }
protected virtual void action_Completed(ActionBase sender) { var action = (AsyncAction)sender; if (action.Result == false.ToString()) { MainWindowCommandInterface.Invoke(() => new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, Messages.VIF_HOTPLUG_FAILED_MESSAGE, Messages.VIF_HOTPLUG_FAILED_TITLE)).ShowDialog(Program.MainWindow)); } }
private void WaitForReboot(object o) { while (true) { IXenConnection connection = (IXenConnection)o; Thread.Sleep(30 * 1000); // wait 30s for server to shutdown int i = 0; int max = 27; // giveup after 5 mins while (true) { if (i > max) { MainWindowCommandInterface.Invoke(delegate { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Exclamation, string.Format(Messages.MESSAGEBOX_RECONNECT_FAIL, connection.Hostname), Messages.MESSAGEBOX_RECONNECT_FAIL_TITLE))) { dlg.ShowDialog(Parent); } }); return; } Socket socket = new Socket(System.Net.Sockets.AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { socket.Connect(connection.Hostname, connection.Port); } catch (Exception) { } if (socket.Connected) { MainWindowCommandInterface.Invoke(delegate { XenConnectionUI.BeginConnect(connection, false, null, false); MainWindowCommandInterface.RequestRefreshTreeView(); }); return; } i++; Thread.Sleep(15 * 1000); } } }
private void RestoreAction_Completed(ActionBase sender) { HostBackupRestoreAction action = (HostBackupRestoreAction)sender; if (!action.Succeeded) { // Do nothing - failure will be reflected in the logs tab. return; } MainWindowCommandInterface.Invoke(delegate { using (var dlg = new InformationDialog(string.Format(Messages.RESTORE_FROM_BACKUP_FINALIZE, Helpers.GetName(action.Host)))) { dlg.ShowDialog(Parent); } }); }
private void WaitForReboot(object o) { while (true) { IXenConnection connection = (IXenConnection)o; Thread.Sleep(30 * 1000); // wait 30s for server to shutdown int i = 0; int max = 27; // give up after 5 mins while (true) { if (i > max) { MainWindowCommandInterface.Invoke(delegate { using (var dlg = new WarningDialog(string.Format(Messages.MESSAGEBOX_RECONNECT_FAIL, connection.Hostname)) { WindowTitle = Messages.MESSAGEBOX_RECONNECT_FAIL_TITLE }) { dlg.ShowDialog(Parent); } }); return; } Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { socket.Connect(connection.Hostname, connection.Port); } catch (Exception) { } if (socket.Connected) { MainWindowCommandInterface.Invoke(() => XenConnectionUI.BeginConnect(connection, false, Program.MainWindow, false)); return; } i++; Thread.Sleep(15 * 1000); } } }
protected override void ExecuteCore(SelectedItemCollection selection) { bool expand = MainWindowCommandInterface.GetXenConnectionsCopy().Count < 30; foreach (IXenConnection c in MainWindowCommandInterface.GetXenConnectionsCopy()) { if (!c.IsConnected && !c.InProgress) { MainWindowCommandInterface.Invoke(delegate { if (expand) { c.CachePopulated += c_CachePopulated; } XenConnectionUI.BeginConnect(c, false, null, false); }); } } }
private void RestoreAction_Completed(ActionBase sender) { HostBackupRestoreAction action = (HostBackupRestoreAction)sender; if (!action.Succeeded) { // Do nothing - failure will be reflected in the logs tab. return; } MainWindowCommandInterface.Invoke(delegate { new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, string.Format(Messages.RESTORE_FROM_BACKUP_FINALIZE, Helpers.GetName(action.Host)), Messages.XENCENTER)).ShowDialog(Parent); }); }
protected override void ExecuteCore() { Folder targetFolder = GetTargetNodeAncestorAsXenObjectOrGroupingTag <Folder>(); List <AsyncAction> actions = new List <AsyncAction>(); foreach (IXenObject draggedItem in GetItemsNotAlreadyInTargetFolder()) { actions.Add(new FolderAction(draggedItem, targetFolder, FolderAction.Kind.Move)); } if (DraggedNodes != null) { foreach (VirtualTreeNode draggedNode in DraggedNodes) { if (GetItemsNotAlreadyInTargetFolder().Contains((IXenObject)draggedNode.Tag)) { GreyAll(draggedNode); } } } MultipleActionLauncher launcher = new MultipleActionLauncher(actions, string.Format(Messages.MOVE_OBJECTS_TO_FOLDER, targetFolder.Name), Messages.MOVING, Messages.MOVED, true); launcher.Run(); // need to now wait until the operation has finished... then we can expand the node. ThreadPool.QueueUserWorkItem(delegate { for (int i = 0; i < 20 && TargetNode.Nodes.Count == 0; i++) { Thread.Sleep(100); } MainWindowCommandInterface.Invoke(delegate { TargetNode.Expand(); }); }); }