private static bool EnabledTargetExists(VM vm, IXenConnection connection) { //if the vm has a home server check it's enabled Host host = vm.power_state == vm_power_state.Running ? vm.Connection.Resolve(vm.resident_on) : vm.GetStorageHost(false); return Helpers.EnabledTargetExists(host, connection); }
private bool tryToConnectRDP = false; // This parameter will be set after click "TURN ON Rremote Desktop" and will connect RDP when RDP status changed. #endregion Fields #region Constructors public VNCTabView(VNCView parent, VM source, string elevatedUsername, string elevatedPassword) { Program.AssertOnEventThread(); InitializeComponent(); HostLabel.Font = Program.HeaderGradientFont; HostLabel.ForeColor = Program.HeaderGradientForeColor; multipleDvdIsoList1.LabelSingleDvdForeColor = Program.HeaderGradientForeColor; multipleDvdIsoList1.LabelNewCdForeColor = Program.HeaderGradientForeColor; multipleDvdIsoList1.LinkLabelLinkColor = Color.White; #pragma warning disable 0219 // Force the handle to be created, because resize events // could be fired before this component is placed on-screen. IntPtr _ = Handle; #pragma warning restore 0219 this.parentVNCView = parent; this.scaleCheckBox.Checked = false; this.source = source; this.guestMetrics = source.Connection.Resolve(source.guest_metrics); if (this.guestMetrics != null) guestMetrics.PropertyChanged += guestMetrics_PropertyChanged; log.DebugFormat("'{0}' console: Register Server_PropertyChanged event listener on {0}", this.source.Name); this.source.PropertyChanged += Server_PropertyChanged; Host_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(Host_CollectionChanged); VM_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(VM_CollectionChanged); source.Connection.Cache.RegisterCollectionChanged<VM>(VM_CollectionChangedWithInvoke); if (source.is_control_domain) { Host host = source.Connection.Resolve(source.resident_on); if (host != null) { log.DebugFormat("'{0}' console: Register Server_PropertyChanged event listener on {1}", this.source.Name, host.Name); host.PropertyChanged += Server_PropertyChanged; Host_metrics hostMetrics = source.Connection.Resolve(host.metrics); if (hostMetrics != null) { log.DebugFormat("'{0}' console: Register Server_PropertyChanged event listener on host metrics", this.source.Name); hostMetrics.PropertyChanged += Server_PropertyChanged; } HostLabel.Text = string.Format(source.IsControlDomainZero ? Messages.CONSOLE_HOST : Messages.CONSOLE_HOST_NUTANIX, host.Name); HostLabel.Visible = true; } } else { source.Connection.Cache.RegisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke); targetHost = source.GetStorageHost(false); foreach (Host cachedHost in source.Connection.Cache.Hosts) { log.DebugFormat("'{0}' console: Register Server_EnabledPropertyChanged event listener on {1}", source.Name, cachedHost.Name); cachedHost.PropertyChanged += Server_EnabledPropertyChanged; } HostLabel.Visible = false; } log.DebugFormat("'{0}' console: Update power state (on VNCTabView constructor)", this.source.Name); updatePowerState(); this.vncScreen = new XSVNCScreen(source, new EventHandler(RDPorVNCResizeHandler), this, elevatedUsername, elevatedPassword); ShowGpuWarningIfRequired(vncScreen.MustConnectRemoteDesktop()); vncScreen.GpuStatusChanged += ShowGpuWarningIfRequired; if (source.IsControlDomainZero || source.IsHVM && !hasRDP) //Linux HVM guests should only have one console: the console switch button vanishes altogether. { toggleConsoleButton.Visible = false; } else { toggleConsoleButton.Visible = true; this.vncScreen.OnDetectRDP = this.OnDetectRDP; this.vncScreen.OnDetectVNC = this.OnDetectVNC; this.vncScreen.UserCancelledAuth += this.OnUserCancelledAuth; this.vncScreen.VncConnectionAttemptCancelled += this.OnVncConnectionAttemptCancelled; } LastDesktopSize = vncScreen.DesktopSize; this.insKeyTimer = new System.Threading.Timer(new TimerCallback(notInsKeyPressed)); Properties.Settings.Default.PropertyChanged += Default_PropertyChanged; registerShortCutKeys(); // // Ctlr - Alt - Ins send Ctrl - Alt - Delete, and cancels and pending full screen. // KeyHandler.AddKeyHandler(ConsoleShortcutKey.CTRL_ALT_INS, cancelWaitForInsKeyAndSendCAD); this.vncScreen.Parent = this.contentPanel; this.vncScreen.Dock = DockStyle.Fill; string rdpLabel = GuessNativeConsoleLabel(source); this.toggleConsoleButton.Text = rdpLabel; UpdateFullScreenButton(); UpdateDockButton(); setupCD(); UpdateParentMinimumSize(); UpdateTooltipOfToogleButton(); UpdateOpenSSHConsoleButtonState(); toggleConsoleButton.EnabledChanged += toggleConsoleButton_EnabledChanged; //If RDP enabled and AutoSwitchToRDP selected, switch RDP connection will be done when VNC already get the correct screen resolution. //This change is only for Cream, because RDP port scan was removed in Cream. if ( Helpers.CreamOrGreater(source.Connection) && Properties.Settings.Default.AutoSwitchToRDP && RDPEnabled ) vncScreen.AutoSwitchRDPLater = true; }
public VNCTabView(VNCView parent, VM source, string elevatedUsername, string elevatedPassword) { Program.AssertOnEventThread(); InitializeComponent(); HostLabel.Font = Program.HeaderGradientFont; HostLabel.ForeColor = Program.HeaderGradientForeColor; multipleDvdIsoList1.SetTextColor(Program.HeaderGradientForeColor); #pragma warning disable 0219 // Force the handle to be created, because resize events // could be fired before this component is placed on-screen. IntPtr _ = Handle; #pragma warning restore 0219 this.parentVNCView = parent; this.scaleCheckBox.Checked = false; this.source = source; log.DebugFormat("'{0}' console: Register Server_PropertyChanged event listener on {0}", this.source.Name); this.source.PropertyChanged += Server_PropertyChanged; Host_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(Host_CollectionChanged); VM_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(VM_CollectionChanged); source.Connection.Cache.RegisterCollectionChanged<VM>(VM_CollectionChangedWithInvoke); if (source.is_control_domain) { Host host = source.Connection.Resolve(source.resident_on); if (host != null) { log.DebugFormat("'{0}' console: Register Server_PropertyChanged event listener on {1}", this.source.Name, host.Name); host.PropertyChanged += Server_PropertyChanged; Host_metrics hostMetrics = source.Connection.Resolve(host.metrics); if (hostMetrics != null) { log.DebugFormat("'{0}' console: Register Server_PropertyChanged event listener on host metrics", this.source.Name); hostMetrics.PropertyChanged += Server_PropertyChanged; } HostLabel.Text = string.Format(Messages.CONSOLE_HOST, host.Name); HostLabel.Visible = true; } } else { source.Connection.Cache.RegisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke); targetHost = source.GetStorageHost(false); foreach (Host cachedHost in source.Connection.Cache.Hosts) { log.DebugFormat("'{0}' console: Register Server_EnabledPropertyChanged event listener on {1}", source.Name, cachedHost.Name); cachedHost.PropertyChanged += Server_EnabledPropertyChanged; } HostLabel.Visible = false; } log.DebugFormat("'{0}' console: Update power state (on VNCTabView constructor)", this.source.Name); updatePowerState(); this.vncScreen = new XSVNCScreen(source, new EventHandler(RDPorVNCResizeHandler), this, elevatedUsername, elevatedPassword); ShowGpuWarningIfRequired(); if (source.is_control_domain) { toggleConsoleButton.Visible = false; } else { toggleConsoleButton.Visible = true; this.vncScreen.OnDetectRDP = this.OnDetectRDP; this.vncScreen.OnDetectVNC = this.OnDetectVNC; this.vncScreen.UserCancelledAuth += this.OnUserCancelledAuth; } LastDesktopSize = vncScreen.DesktopSize; this.insKeyTimer = new System.Threading.Timer(new TimerCallback(notInsKeyPressed)); Properties.Settings.Default.PropertyChanged += Default_PropertyChanged; registerShortCutKeys(); // // Ctlr - Alt - Ins send Ctrl - Alt - Delete, and cancels and pending full screen. // KeyHandler.AddKeyHandler(ConsoleShortcutKey.CTRL_ALT_INS, cancelWaitForInsKeyAndSendCAD); this.vncScreen.Parent = this.contentPanel; this.vncScreen.Dock = DockStyle.Fill; this.Dock = DockStyle.Fill; string rdpLabel = GuessNativeConsoleLabel(source); this.toggleConsoleButton.Text = rdpLabel; UpdateFullScreenButton(); UpdateDockButton(); setupCD(); UpdateParentMinimumSize(); toggleConsoleButton.EnabledChanged += toggleConsoleButton_EnabledChanged; }
public void SetXenObjects(IXenObject orig, IXenObject clone) { vm = clone as VM; if (vm == null) return; Host currentAffinity = vm.Connection.Resolve(vm.affinity); picker.SetAffinity(vm.Connection, currentAffinity, vm.HasNoDisksAndNoLocalCD ? null : vm.GetStorageHost(false)); }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); // if not using CD, use selected template storage host // if using CD use CD or template storage host); if (SelectedInstallMethod != InstallMethod.CD || SelectedCD == null) { if (SelectedTemplate == Template && CdAffinity == null) return; CdAffinity = null; Template = SelectedTemplate; affinityPicker1.SetAffinity(Connection, Affinity, Template.GetStorageHost(true)); } else { SR sr = Connection.Resolve(SelectedCD.SR); if (sr == null) return; Host cdAffinity = sr.GetStorageHost(); if (SelectedTemplate == Template && cdAffinity == CdAffinity) return; Template = SelectedTemplate; CdAffinity = cdAffinity; affinityPicker1.SetAffinity(Connection, Affinity, CdAffinity ?? Template.GetStorageHost(false)); } }