예제 #1
0
        public string IPAddress()
        {
            VM vm = Connection.Resolve(this.VM);

            if (vm != null && !vm.is_a_template)
            {
                VM_guest_metrics vmGuestMetrics = Connection.Resolve(vm.guest_metrics);

                if (vmGuestMetrics != null)
                {
                    // PR-1373 - VM_guest_metrics.networks is a dictionary of IP addresses in the format:
                    // [["0/ip", <IPv4 address>], ["0/ipv6/0", <IPv6 address>], ["0/ipv6/1", <IPv6 address>]]
                    List <string> addresses = (from network in vmGuestMetrics.networks
                                               where network.Key.StartsWith(String.Format("{0}/ip", this.device))
                                               orderby network.Key
                                               select network.Value).ToList();

                    if (addresses.Count > 0)
                    {
                        return(String.Join(", ", addresses.ToArray()));
                    }
                }
                return(Messages.IP_ADDRESS_UNKNOWN);
            }
            else
            {
                return(Messages.IP_ADDRESS_UNKNOWN);
            }
        }
예제 #2
0
        public List <string> IPAddresses()
        {
            VM vm = Connection.Resolve(this.VM);

            if (vm != null && !vm.is_a_template)
            {
                VM_guest_metrics vmGuestMetrics = Connection.Resolve(vm.guest_metrics);

                if (vmGuestMetrics != null)
                {
                    // PR-1373 - VM_guest_metrics.networks is a dictionary of IP addresses in the format:
                    // [["0/ip", <IPv4 address>],
                    //  ["0/ipv4/0", <IPv4 address>], ["0/ipv4/1", <IPv4 address>],
                    //  ["0/ipv6/0", <IPv6 address>], ["0/ipv6/1", <IPv6 address>]]

                    return
                        ((from network in vmGuestMetrics.networks
                          where network.Key.StartsWith(string.Format("{0}/ip", this.device))
                          orderby network.Key
                          select network.Value).Distinct().ToList());
                }
            }

            return(new List <string>());
        }
예제 #3
0
        private static void Download_VM_guest_metrics(Session session, List <ObjectChange> changes)
        {
            Dictionary <XenRef <VM_guest_metrics>, VM_guest_metrics> records = VM_guest_metrics.get_all_records(session);

            foreach (KeyValuePair <XenRef <VM_guest_metrics>, VM_guest_metrics> entry in records)
            {
                changes.Add(new ObjectChange(typeof(VM_guest_metrics), entry.Key.opaque_ref, entry.Value));
            }
        }
예제 #4
0
파일: VIF.cs 프로젝트: ywscr/xenadmin
        public List <string> IPAddresses()
        {
            VM vm = Connection.Resolve(this.VM);

            if (vm != null && !vm.is_a_template)
            {
                VM_guest_metrics vmGuestMetrics = Connection.Resolve(vm.guest_metrics);

                if (vmGuestMetrics != null)
                {
                    return(Helpers.FindIpAddresses(vmGuestMetrics.networks, device));
                }
            }

            return(new List <string>());
        }
예제 #5
0
        private void Server_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "power_state"
                || e.PropertyName == "live"
                || e.PropertyName == "allowed_operations")
            {
                log.DebugFormat("'{0}' console: Update power state, after receiving property change notification, PropertyName='{1}'", sender.ToString(), e.PropertyName);
                updatePowerState();
            }
            else if (e.PropertyName == "VBDs")
            {
                //The CD device may have changed
                Program.Invoke(this, setupCD);
            }
            else if (e.PropertyName == "guest_metrics")
            {
                var newGuestMetrics = source.Connection.Resolve(source.guest_metrics);

                //unsubscribing from the previous instance's event
                if (this.guestMetrics != null)
                    this.guestMetrics.PropertyChanged -= guestMetrics_PropertyChanged;

                this.guestMetrics = newGuestMetrics;
                if (this.guestMetrics != null)
                    guestMetrics.PropertyChanged += guestMetrics_PropertyChanged;

                EnableRDPIfCapable();

                UpdateOpenSSHConsoleButtonState(); //guest_metrics change when there is an IP address change on a VIF
            }
            else if (e.PropertyName == "VIFs" || e.PropertyName == "PIFs")
            {
                UpdateOpenSSHConsoleButtonState();
            }

            if (source.is_control_domain && e.PropertyName == "name_label")
            {
                string text = string.Format(source.IsControlDomainZero ? Messages.CONSOLE_HOST : Messages.CONSOLE_HOST_NUTANIX, source.AffinityServerString);
                HostLabel.Text = text;

                if (parentVNCView != null && parentVNCView.undockedForm != null)
                    parentVNCView.undockedForm.Text = text;
            }
        }
예제 #6
0
        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;
        }
예제 #7
0
 protected override void ProcessRecord()
 {
     XenAPI.Session session = XenObject as XenAPI.Session;
     if (session != null)
     {
         WriteObject(new XenRef <XenAPI.Session>(session));
         return;
     }
     XenAPI.Auth auth = XenObject as XenAPI.Auth;
     if (auth != null)
     {
         WriteObject(new XenRef <XenAPI.Auth>(auth));
         return;
     }
     XenAPI.Subject subject = XenObject as XenAPI.Subject;
     if (subject != null)
     {
         WriteObject(new XenRef <XenAPI.Subject>(subject));
         return;
     }
     XenAPI.Role role = XenObject as XenAPI.Role;
     if (role != null)
     {
         WriteObject(new XenRef <XenAPI.Role>(role));
         return;
     }
     XenAPI.Task task = XenObject as XenAPI.Task;
     if (task != null)
     {
         WriteObject(new XenRef <XenAPI.Task>(task));
         return;
     }
     XenAPI.Event evt = XenObject as XenAPI.Event;
     if (evt != null)
     {
         WriteObject(new XenRef <XenAPI.Event>(evt));
         return;
     }
     XenAPI.Pool pool = XenObject as XenAPI.Pool;
     if (pool != null)
     {
         WriteObject(new XenRef <XenAPI.Pool>(pool));
         return;
     }
     XenAPI.Pool_patch pool_patch = XenObject as XenAPI.Pool_patch;
     if (pool_patch != null)
     {
         WriteObject(new XenRef <XenAPI.Pool_patch>(pool_patch));
         return;
     }
     XenAPI.Pool_update pool_update = XenObject as XenAPI.Pool_update;
     if (pool_update != null)
     {
         WriteObject(new XenRef <XenAPI.Pool_update>(pool_update));
         return;
     }
     XenAPI.VM vm = XenObject as XenAPI.VM;
     if (vm != null)
     {
         WriteObject(new XenRef <XenAPI.VM>(vm));
         return;
     }
     XenAPI.VM_metrics vm_metrics = XenObject as XenAPI.VM_metrics;
     if (vm_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VM_metrics>(vm_metrics));
         return;
     }
     XenAPI.VM_guest_metrics vm_guest_metrics = XenObject as XenAPI.VM_guest_metrics;
     if (vm_guest_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VM_guest_metrics>(vm_guest_metrics));
         return;
     }
     XenAPI.VMPP vmpp = XenObject as XenAPI.VMPP;
     if (vmpp != null)
     {
         WriteObject(new XenRef <XenAPI.VMPP>(vmpp));
         return;
     }
     XenAPI.VMSS vmss = XenObject as XenAPI.VMSS;
     if (vmss != null)
     {
         WriteObject(new XenRef <XenAPI.VMSS>(vmss));
         return;
     }
     XenAPI.VM_appliance vm_appliance = XenObject as XenAPI.VM_appliance;
     if (vm_appliance != null)
     {
         WriteObject(new XenRef <XenAPI.VM_appliance>(vm_appliance));
         return;
     }
     XenAPI.DR_task dr_task = XenObject as XenAPI.DR_task;
     if (dr_task != null)
     {
         WriteObject(new XenRef <XenAPI.DR_task>(dr_task));
         return;
     }
     XenAPI.Host host = XenObject as XenAPI.Host;
     if (host != null)
     {
         WriteObject(new XenRef <XenAPI.Host>(host));
         return;
     }
     XenAPI.Host_crashdump host_crashdump = XenObject as XenAPI.Host_crashdump;
     if (host_crashdump != null)
     {
         WriteObject(new XenRef <XenAPI.Host_crashdump>(host_crashdump));
         return;
     }
     XenAPI.Host_patch host_patch = XenObject as XenAPI.Host_patch;
     if (host_patch != null)
     {
         WriteObject(new XenRef <XenAPI.Host_patch>(host_patch));
         return;
     }
     XenAPI.Host_metrics host_metrics = XenObject as XenAPI.Host_metrics;
     if (host_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.Host_metrics>(host_metrics));
         return;
     }
     XenAPI.Host_cpu host_cpu = XenObject as XenAPI.Host_cpu;
     if (host_cpu != null)
     {
         WriteObject(new XenRef <XenAPI.Host_cpu>(host_cpu));
         return;
     }
     XenAPI.Network network = XenObject as XenAPI.Network;
     if (network != null)
     {
         WriteObject(new XenRef <XenAPI.Network>(network));
         return;
     }
     XenAPI.VIF vif = XenObject as XenAPI.VIF;
     if (vif != null)
     {
         WriteObject(new XenRef <XenAPI.VIF>(vif));
         return;
     }
     XenAPI.VIF_metrics vif_metrics = XenObject as XenAPI.VIF_metrics;
     if (vif_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VIF_metrics>(vif_metrics));
         return;
     }
     XenAPI.PIF pif = XenObject as XenAPI.PIF;
     if (pif != null)
     {
         WriteObject(new XenRef <XenAPI.PIF>(pif));
         return;
     }
     XenAPI.PIF_metrics pif_metrics = XenObject as XenAPI.PIF_metrics;
     if (pif_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.PIF_metrics>(pif_metrics));
         return;
     }
     XenAPI.Bond bond = XenObject as XenAPI.Bond;
     if (bond != null)
     {
         WriteObject(new XenRef <XenAPI.Bond>(bond));
         return;
     }
     XenAPI.VLAN vlan = XenObject as XenAPI.VLAN;
     if (vlan != null)
     {
         WriteObject(new XenRef <XenAPI.VLAN>(vlan));
         return;
     }
     XenAPI.SM sm = XenObject as XenAPI.SM;
     if (sm != null)
     {
         WriteObject(new XenRef <XenAPI.SM>(sm));
         return;
     }
     XenAPI.SR sr = XenObject as XenAPI.SR;
     if (sr != null)
     {
         WriteObject(new XenRef <XenAPI.SR>(sr));
         return;
     }
     XenAPI.LVHD lvhd = XenObject as XenAPI.LVHD;
     if (lvhd != null)
     {
         WriteObject(new XenRef <XenAPI.LVHD>(lvhd));
         return;
     }
     XenAPI.VDI vdi = XenObject as XenAPI.VDI;
     if (vdi != null)
     {
         WriteObject(new XenRef <XenAPI.VDI>(vdi));
         return;
     }
     XenAPI.VBD vbd = XenObject as XenAPI.VBD;
     if (vbd != null)
     {
         WriteObject(new XenRef <XenAPI.VBD>(vbd));
         return;
     }
     XenAPI.VBD_metrics vbd_metrics = XenObject as XenAPI.VBD_metrics;
     if (vbd_metrics != null)
     {
         WriteObject(new XenRef <XenAPI.VBD_metrics>(vbd_metrics));
         return;
     }
     XenAPI.PBD pbd = XenObject as XenAPI.PBD;
     if (pbd != null)
     {
         WriteObject(new XenRef <XenAPI.PBD>(pbd));
         return;
     }
     XenAPI.Crashdump crashdump = XenObject as XenAPI.Crashdump;
     if (crashdump != null)
     {
         WriteObject(new XenRef <XenAPI.Crashdump>(crashdump));
         return;
     }
     XenAPI.VTPM vtpm = XenObject as XenAPI.VTPM;
     if (vtpm != null)
     {
         WriteObject(new XenRef <XenAPI.VTPM>(vtpm));
         return;
     }
     XenAPI.Console console = XenObject as XenAPI.Console;
     if (console != null)
     {
         WriteObject(new XenRef <XenAPI.Console>(console));
         return;
     }
     XenAPI.User user = XenObject as XenAPI.User;
     if (user != null)
     {
         WriteObject(new XenRef <XenAPI.User>(user));
         return;
     }
     XenAPI.Data_source data_source = XenObject as XenAPI.Data_source;
     if (data_source != null)
     {
         WriteObject(new XenRef <XenAPI.Data_source>(data_source));
         return;
     }
     XenAPI.Blob blob = XenObject as XenAPI.Blob;
     if (blob != null)
     {
         WriteObject(new XenRef <XenAPI.Blob>(blob));
         return;
     }
     XenAPI.Message message = XenObject as XenAPI.Message;
     if (message != null)
     {
         WriteObject(new XenRef <XenAPI.Message>(message));
         return;
     }
     XenAPI.Secret secret = XenObject as XenAPI.Secret;
     if (secret != null)
     {
         WriteObject(new XenRef <XenAPI.Secret>(secret));
         return;
     }
     XenAPI.Tunnel tunnel = XenObject as XenAPI.Tunnel;
     if (tunnel != null)
     {
         WriteObject(new XenRef <XenAPI.Tunnel>(tunnel));
         return;
     }
     XenAPI.PCI pci = XenObject as XenAPI.PCI;
     if (pci != null)
     {
         WriteObject(new XenRef <XenAPI.PCI>(pci));
         return;
     }
     XenAPI.PGPU pgpu = XenObject as XenAPI.PGPU;
     if (pgpu != null)
     {
         WriteObject(new XenRef <XenAPI.PGPU>(pgpu));
         return;
     }
     XenAPI.GPU_group gpu_group = XenObject as XenAPI.GPU_group;
     if (gpu_group != null)
     {
         WriteObject(new XenRef <XenAPI.GPU_group>(gpu_group));
         return;
     }
     XenAPI.VGPU vgpu = XenObject as XenAPI.VGPU;
     if (vgpu != null)
     {
         WriteObject(new XenRef <XenAPI.VGPU>(vgpu));
         return;
     }
     XenAPI.VGPU_type vgpu_type = XenObject as XenAPI.VGPU_type;
     if (vgpu_type != null)
     {
         WriteObject(new XenRef <XenAPI.VGPU_type>(vgpu_type));
         return;
     }
     XenAPI.PVS_site pvs_site = XenObject as XenAPI.PVS_site;
     if (pvs_site != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_site>(pvs_site));
         return;
     }
     XenAPI.PVS_server pvs_server = XenObject as XenAPI.PVS_server;
     if (pvs_server != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_server>(pvs_server));
         return;
     }
     XenAPI.PVS_proxy pvs_proxy = XenObject as XenAPI.PVS_proxy;
     if (pvs_proxy != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_proxy>(pvs_proxy));
         return;
     }
     XenAPI.PVS_cache_storage pvs_cache_storage = XenObject as XenAPI.PVS_cache_storage;
     if (pvs_cache_storage != null)
     {
         WriteObject(new XenRef <XenAPI.PVS_cache_storage>(pvs_cache_storage));
         return;
     }
     XenAPI.Feature feature = XenObject as XenAPI.Feature;
     if (feature != null)
     {
         WriteObject(new XenRef <XenAPI.Feature>(feature));
         return;
     }
     XenAPI.SDN_controller sdn_controller = XenObject as XenAPI.SDN_controller;
     if (sdn_controller != null)
     {
         WriteObject(new XenRef <XenAPI.SDN_controller>(sdn_controller));
         return;
     }
     XenAPI.Vdi_nbd_server_info vdi_nbd_server_info = XenObject as XenAPI.Vdi_nbd_server_info;
     if (vdi_nbd_server_info != null)
     {
         WriteObject(new XenRef <XenAPI.Vdi_nbd_server_info>(vdi_nbd_server_info));
         return;
     }
     XenAPI.PUSB pusb = XenObject as XenAPI.PUSB;
     if (pusb != null)
     {
         WriteObject(new XenRef <XenAPI.PUSB>(pusb));
         return;
     }
     XenAPI.USB_group usb_group = XenObject as XenAPI.USB_group;
     if (usb_group != null)
     {
         WriteObject(new XenRef <XenAPI.USB_group>(usb_group));
         return;
     }
     XenAPI.VUSB vusb = XenObject as XenAPI.VUSB;
     if (vusb != null)
     {
         WriteObject(new XenRef <XenAPI.VUSB>(vusb));
         return;
     }
 }