Esempio n. 1
0
        private void AddMultipathLine(PDSection s, String title, int current, int max, int iscsiSessions)
        {
            bool bad = current < max || (iscsiSessions != -1 && max < iscsiSessions);
            string row = string.Format(Messages.MULTIPATH_STATUS, current, max);
            if (iscsiSessions != -1)
                row += string.Format(Messages.MULTIPATH_STATUS_ISCSI_SESSIONS, iscsiSessions);

            if (bad)
                s.AddEntry(title, row, Color.Red);
            else
                s.AddEntry(title, row);
        }
Esempio n. 2
0
 private void addStringEntry(PDSection s, string key, string value)
 {
     s.AddEntry(key, string.IsNullOrEmpty(value) ? Messages.NONE : value);
 }
Esempio n. 3
0
 void s_ExpandedEventHandler(PDSection pdSection)
 {
     if (pdSection != null)
     {
         //Add to the expandedSections
         List<PDSection> listSections;
         if (_expandedSections.TryGetValue(xenObject.GetType(), out listSections))
         {
             if (!listSections.Contains(pdSection) && pdSection.IsExpanded)
                 listSections.Add(pdSection);
             else if (!pdSection.IsExpanded)
                 listSections.Remove(pdSection);
         }
         else if (pdSection.IsExpanded)
         {
             List<PDSection> list = new List<PDSection>();
             list.Add(pdSection);
             _expandedSections.Add(xenObject.GetType(), list);
         }
     }
     SetStatesOfExpandingLinks();
 }
Esempio n. 4
0
        private void GenTagRow(PDSection s)
        {
            string[] tags = Tags.GetTags(xenObject);
            
            if (tags != null && tags.Length > 0)
            {
                ToolStripMenuItem goToTag = new ToolStripMenuItem(Messages.VIEW_TAG_MENU_OPTION);

                foreach (string tag in tags)
                {
                    var item = new ToolStripMenuItem(tag.Ellipsise(30));
                    item.Click += delegate { Program.MainWindow.SearchForTag(tag); };
                    goToTag.DropDownItems.Add(item);
                }

                s.AddEntry(Messages.TAGS, TagsString(), new[] { goToTag, new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)) });
                return;
            }

            s.AddEntry(Messages.TAGS, Messages.NONE, new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)));
        }
Esempio n. 5
0
 private void GenFolderRow(PDSection s)
 {
     List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();
     if (xenObject.Path != "")
     {
         var item = new ToolStripMenuItem(Messages.VIEW_FOLDER_MENU_OPTION);
         item.Click += delegate { Program.MainWindow.SearchForFolder(xenObject.Path); };
         menuItems.Add(item);
     }
     menuItems.Add(new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)));
     s.AddEntry(
         Messages.FOLDER,
         new FolderListItem(xenObject.Path, FolderListItem.AllowSearch.None, false),
         menuItems
         );
 }
Esempio n. 6
0
        private void scrollToSelectionIfNeeded(PDSection s)
        {
            if (s.HasNoSelection())
                return;

            Rectangle selectedRowBounds = s.SelectedRowBounds;

            // translate to the coordinates of the pdsection container panel (the one added for padding purposes)
            selectedRowBounds.Offset(s.Parent.Location);

            // Top edge visible?
            if (panel2.ClientRectangle.Height - selectedRowBounds.Top > 0 && selectedRowBounds.Top > 0)
            {
                // Bottom edge visible?
                if (panel2.ClientRectangle.Height - selectedRowBounds.Bottom > 0 && selectedRowBounds.Bottom > 0)
                {
                    // The entire selected row is in view, no need to move 
                    return;
                }
            }

            panel2.ForceScrollTo(s);
        }
Esempio n. 7
0
        private static void GenerateVirtualisationStatusForGeneralBox(PDSection s, VM vm)
        {
            if (vm != null && vm.Connection != null)
            {
                //For Dundee or higher Windows VMs
                if (Helpers.DundeeOrGreater(vm.Connection) && vm.IsWindows)
                {
                    var gm = vm.Connection.Resolve(vm.guest_metrics);

                    bool isIoOptimized = gm != null && gm.network_paths_optimized && gm.storage_paths_optimized;
                    bool isManagementAgentInstalled = vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED);
                    bool canInstallIoDriversAndManagementAgent = InstallToolsCommand.CanExecute(vm) && !isIoOptimized;
                    bool canInstallManagementAgentOnly = InstallToolsCommand.CanExecute(vm) && isIoOptimized && !isManagementAgentInstalled;
                    //canInstallIoDriversOnly is missing - management agent communicates with XS using the I/O drivers

                    var sb = new StringBuilder();

                    if (vm.power_state == vm_power_state.Running)
                    {
                        if (vm.virtualisation_status.HasFlag(XenAPI.VM.VirtualisationStatus.UNKNOWN))
                        {
                            s.AddEntry(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString);
                        }
                        else
                        {
                            //Row 1 : I/O Drivers
                            if (isIoOptimized)
                            {
                                sb.Append(Messages.VIRTUALIZATION_STATE_VM_IO_OPTIMIZED);
                            }
                            else
                            {
                                sb.Append(Messages.VIRTUALIZATION_STATE_VM_IO_NOT_OPTIMIZED);
                            }

                            sb.Append(Environment.NewLine);

                            //Row 2: Management Agent
                            if (isManagementAgentInstalled)
                            {
                                sb.Append(Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_INSTALLED);
                            }
                            else
                            {
                                sb.Append(Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED);
                            }
                            sb.Append(Environment.NewLine);
                        }
                    }

                    //Row 3 : vendor device - Windows Update
                    sb.Append(vm.has_vendor_device ? Messages.VIRTUALIZATION_STATE_VM_RECEIVING_UPDATES : Messages.VIRTUALIZATION_STATE_VM_NOT_RECEIVING_UPDATES);

                    // displaying Row1 - Row3
                    s.AddEntry(FriendlyName("VM.VirtualizationState"), sb.ToString());

                    if (vm.power_state == vm_power_state.Running)
                    {
                        //Row 4: Install Tools
                        string installMessage = string.Empty;
                        if (canInstallIoDriversAndManagementAgent)
                        {
                            installMessage = Messages.VIRTUALIZATION_STATE_VM_INSTALL_IO_DRIVERS_AND_MANAGEMENT_AGENT;
                        }
                        else if (canInstallManagementAgentOnly)
                        {
                            installMessage = Messages.VIRTUALIZATION_STATE_VM_INSTALL_MANAGEMENT_AGENT;
                        }

                        if (!string.IsNullOrEmpty(installMessage))
                        {
                            var installtools = new ToolStripMenuItem(installMessage);
                            installtools.Click += delegate
                            {
                                new InstallToolsCommand(Program.MainWindow, vm).Execute();
                            };
                            s.AddEntryLink(string.Empty, installMessage,
                                new[] { installtools },
                                new InstallToolsCommand(Program.MainWindow, vm));
                        }
                    }
                }

                //for everything else (All VMs on pre-Dundee hosts & All non-Windows VMs on any host)
                else if (vm.power_state == vm_power_state.Running)
                {
                    if (vm.virtualisation_status == 0 || vm.virtualisation_status.HasFlag(XenAPI.VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                    {
                        if (InstallToolsCommand.CanExecute(vm))
                        {
                            var installtools = new ToolStripMenuItem(Messages.INSTALL_XENSERVER_TOOLS_DOTS);
                            installtools.Click += delegate
                            {
                                new InstallToolsCommand(Program.MainWindow, vm).Execute();
                            };
                            s.AddEntryLink(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString,
                                new[] { installtools },
                                new InstallToolsCommand(Program.MainWindow, vm));
                        }
                        else
                        {
                            s.AddEntry(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString, Color.Red);
                        }

                    }
                    else
                    {
                        s.AddEntry(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString);
                    }
                }
            }
        }
Esempio n. 8
0
 void s_contentChangedSelection(PDSection s)
 {
     scrollToSelectionIfNeeded(s);
 }
Esempio n. 9
0
 void s_contentReceivedFocus(PDSection s)
 {
     scrollToSelectionIfNeeded(s);
 }
Esempio n. 10
0
        private static void GenerateVirtualisationStatusForGeneralBox(PDSection s, VM vm)
        {
            if (vm != null && vm.Connection != null && vm.power_state == vm_power_state.Running)
            {
                //For Dundee or higher Windows VMs
                if (Helpers.DundeeOrGreater(vm.Connection) && vm.IsWindows)
                {
                    var gm = vm.Connection.Resolve(vm.guest_metrics);

                    bool isIoOptimized = gm != null && gm.network_paths_optimized && gm.storage_paths_optimized;
                    bool isReceivingUpdates = vm.auto_update_drivers;

                    bool isXenPrepInProgress = false; //TODO in CP-13247  when XenPrep functions will be added
                    bool canTurnOnAutoUpdates = false && !isReceivingUpdates && !isXenPrepInProgress; //TODO in CP-13247: remove &&false when XenPrep functions have been added

                    bool isManagementAgentInstalled = vm.HasRDP; //HasRDP is the way to detect .Net/Management Agent

                    bool canInstallIoDriversAndManagementAgent = InstallToolsCommand.CanExecute(vm) && !isIoOptimized;
                    bool canInstallManagementAgentOnly = InstallToolsCommand.CanExecute(vm) && isIoOptimized && !isManagementAgentInstalled;
                    //canInstallIoDriversOnly is missing - management agent communicates with XS using the I/O drivers

                    if (vm.virtualisation_status == VM.VirtualisationStatus.UNKNOWN)
                    {
                        s.AddEntry(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString);
                    }
                    else
                    {
                        var sb = new StringBuilder();

                        //Row 1 : I/O Drivers
                        if (isIoOptimized)
                        {
                            sb.Append(Messages.VIRTUALIZATION_STATE_VM_IO_OPTIMIZED);
                        }
                        else
                        {
                            sb.Append(Messages.VIRTUALIZATION_STATE_VM_IO_NOT_OPTIMIZED);
                        }

                        sb.Append(Environment.NewLine);

                        //Row 2: Management Agent
                        if (isManagementAgentInstalled)
                        {
                            sb.Append(Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_INSTALLED);
                        }
                        else
                        {
                            sb.Append(Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED);
                        }

                        //Row 3 : Auto update
                        if (isReceivingUpdates)
                        {
                            sb.Append(Environment.NewLine);
                            sb.Append(Messages.VIRTUALIZATION_STATE_VM_RECEIVING_UPDATES);
                        }
                        else if (isXenPrepInProgress)
                        {
                            sb.Append(Environment.NewLine);
                            sb.Append(Messages.VIRTUALIZATION_STATE_VM_UPGRADING_VM);
                        }

                        // displaying Row1 - Row3
                        s.AddEntry(FriendlyName("VM.VirtualizationState"), sb.ToString());

                        //Row 4: Enable Auto Update link
                        if (canTurnOnAutoUpdates)
                        {
                            //implement launching XenPrep here (CP-13247)
                        }

                        //Row 4: Install Tools
                        string installMessage = string.Empty;
                        if (canInstallIoDriversAndManagementAgent)
                        {
                            installMessage = Messages.VIRTUALIZATION_STATE_VM_INSTALL_IO_DRIVERS_AND_MANAGEMENT_AGENT;
                        }
                        else if (canInstallManagementAgentOnly)
                        {
                            installMessage = Messages.VIRTUALIZATION_STATE_VM_INSTALL_MANAGEMENT_AGENT;
                        }

                        if (!string.IsNullOrEmpty(installMessage))
                        {
                            var installtools = new ToolStripMenuItem();
                            installtools.Click += delegate
                            {
                                new InstallToolsCommand(Program.MainWindow, vm).Execute();
                            };
                            s.AddEntryLink(string.Empty, installMessage,
                                new[] { installtools },
                                new InstallToolsCommand(Program.MainWindow, vm));
                        }
                    }
                }
                //for everything else (All VMs on pre-Dundee hosts & All non-Windows VMs on any host)
                else
                {
                    if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED
                        || vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)
                    {
                        if (InstallToolsCommand.CanExecute(vm))
                        {
                            var installtools = new ToolStripMenuItem(Messages.INSTALL_XENSERVER_TOOLS_DOTS);
                            installtools.Click += delegate
                            {
                                new InstallToolsCommand(Program.MainWindow, vm).Execute();
                            };
                            s.AddEntryLink(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString,
                                new[] { installtools },
                                new InstallToolsCommand(Program.MainWindow, vm));
                        }
                        else
                        {
                            s.AddEntry(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString, Color.Red);
                        }

                    }
                    else
                    {
                        s.AddEntry(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString);
                    }
                }
            }
        }
Esempio n. 11
0
        private void GenTagRow(PDSection s)
        {
            List<ToolStripMenuItem> toolStrip = new List<ToolStripMenuItem>(new ToolStripMenuItem[] { EditMenuItem("GeneralEditPage", "") });

            string[] tags = Tags.GetTags(xenObject);
            if (tags != null && tags.Length > 0)
            {
                ToolStripMenuItem goToTag = MainWindow.NewToolStripMenuItem(Messages.VIEW_TAG_MENU_OPTION);

                foreach (string tag in tags)
                {
                    goToTag.DropDownItems.Add(MainWindow.NewToolStripMenuItem(tag.Ellipsise(30),
                        delegate(object sender, EventArgs e)
                        {
                            Program.MainWindow.SearchForTag(tag);
                        }));
                }
                toolStrip.Insert(0, goToTag);
                s.AddEntry(Messages.TAGS, TagsString(), toolStrip);
                return;
            }
            s.AddEntry(Messages.TAGS, Messages.NONE, toolStrip);
        }
Esempio n. 12
0
 private void GenFolderRow(PDSection s)
 {
     List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();
     if (xenObject.Path != "")
     {
         menuItems.Add(
             MainWindow.NewToolStripMenuItem(Messages.VIEW_FOLDER_MENU_OPTION,
                 delegate(object sender, EventArgs e)
                 {
                     Program.MainWindow.SearchForFolder(xenObject.Path);
                 })
             );
     }
     menuItems.Add(EditMenuItem("GeneralEditPage", ""));
     s.AddEntry(
         Messages.FOLDER,
         new FolderListItem(xenObject.Path, FolderListItem.AllowSearch.None, false),
         menuItems
         );
 }