Esempio n. 1
0
 private static void AddBottomSpacing(CustomListRow header)
 {
     if (header.Children.Count != 0)
     {
         header.AddChild(new CustomListRow(header.BackColor, 5));
     }
 }
Esempio n. 2
0
        private void generateSRHABox(SR sr)
        {
            Host master = Helpers.GetMaster(sr.Connection);

            if (master == null)
            {
                return;
            }
            if (master.RestrictHAOrlando)
            {
                // Don't generate the box at all
                return;
            }

            CustomListRow header = CreateHeader(Messages.HA_CONFIGURATION_TITLE);

            customListPanel.AddRow(header);

            // We could do something here, e.g.
            // HB SR for pool: xyz
            //     latency to h1: 123
            //     latency to h2: 456
            // HB SR for pool: abc
            //     latency to j1: 123
            //     latency to j2: 456

            AddBottomSpacing(header);
        }
Esempio n. 3
0
        private static CustomListRow AddRow <T>(CustomListRow parent, string key, T obj, ToStringDelegate <T> del, bool valueBold) where T : IEquatable <T>
        {
            CustomListRow newChild = CreateNewRow(key + ": ", new ToStringWrapper <T>(obj, del), valueBold);

            parent.AddChild(newChild);
            return(newChild);
        }
Esempio n. 4
0
        private void GeneratevSwitchControllerBox()
        {
            CustomListRow row = CreateHeader(Messages.OVSC_CONFIGURE_TITLE);

            this.customListPanel.AddRow(row);
            if (_pool.other_config.ContainsKey("vswitch_controller") && !string.IsNullOrEmpty(_pool.other_config["vswitch_controller"]))
            {
                string   params_value = _pool.other_config["vswitch_controller"];
                string[] paramslist   = params_value.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                if (paramslist.Count() != 3)
                {
                    return;
                }

                AddRow(row, Messages.OVSC_CONFIGURE_IP, paramslist[1], false);
                AddRow(row, Messages.OVSC_CONFIGURE_PORT, paramslist[2], false);
                AddRow(row, Messages.OVSC_CONFIGURE_PROTOCOL, paramslist[0], false);
                if (_pool.other_config.ContainsKey("vswitch_controller_account") &&
                    !string.IsNullOrEmpty(_pool.other_config["vswitch_controller_account"]))
                {
                    AddRow(row, Messages.OVSC_CONFIGURE_USERNAME, _pool.other_config["vswitch_controller_account"], false);
                }
            }
            else
            {
                AddRow(row, Messages.OVSC_CONFIGURE_IP, Messages.UNKNOWN, false);
                AddRow(row, Messages.OVSC_CONFIGURE_PORT, Messages.UNKNOWN, false);
                AddRow(row, Messages.OVSC_CONFIGURE_PROTOCOL, Messages.UNKNOWN, false);
            }

            AddBottomSpacing(row);
        }
Esempio n. 5
0
        private CustomListRow AddRow(CustomListRow parent, string key, string value, bool valueBold)
        {
            CustomListRow row = CreateNewRow(key + ": ", value, valueBold);

            parent.AddChild(row);
            return(row);
        }
Esempio n. 6
0
        private void generateSRHABox(SR sr)
        {
            CustomListRow header = CreateHeader(Messages.HA_CONFIGURATION_TITLE);

            customListPanel.AddRow(header);

            // We could do something here, e.g.
            // HB SR for pool: xyz
            //     latency to h1: 123
            //     latency to h2: 456
            // HB SR for pool: abc
            //     latency to j1: 123
            //     latency to j2: 456

            AddBottomSpacing(header);
        }
Esempio n. 7
0
        private void GenerateBackupBox()
        {
            CustomListRow row = CreateHeader(Messages.BR_CONFIGURATION_TITLE);

            this.customListPanel.AddRow(row);
            if (this.xenModelObject is Pool)
            {
                Pool pool = this.xenModelObject as Pool;
                AddRow <Pool>(row, Messages.BR_CONFIG_STATUS, pool, new ToStringDelegate <Pool>(this.GetStatus), false);
                AddRow <Pool>(row, Messages.BR_STORAGE_IP, pool, new ToStringDelegate <Pool>(this.GetStoragePathIP), false);
                AddRow <Pool>(row, Messages.BR_STORAGE_USERNAME, pool, new ToStringDelegate <Pool>(this.GetUserName), false);
            }
            else if (this.xenModelObject is VM)
            {
                VM vm = this.xenModelObject as VM;
                AddRow <VM>(row, Messages.BR_CONFIG_STATUS, vm, new ToStringDelegate <VM>(this.GetStatus), false);
                AddRow <VM>(row, Messages.BR_STORAGE_IP, vm, new ToStringDelegate <VM>(this.GetStoragePathIP), false);
                AddRow <VM>(row, Messages.BR_STORAGE_USERNAME, vm, new ToStringDelegate <VM>(this.GetUserName), false);
            }

            AddBottomSpacing(row);
        }
Esempio n. 8
0
        private void generatePoolHABox(Pool pool)
        {
            Host master = Helpers.GetMaster(pool.Connection);

            if (master == null || master.RestrictHAOrlando)
            {
                // Don't generate the box at all
                return;
            }

            if (!pool.ha_enabled)
            {
                return;
            }

            // 'High Availability' heading
            CustomListRow header = CreateHeader(Messages.HA_CONFIGURATION_TITLE);

            customListPanel.AddRow(header);
            AddRow(header, GetFriendlyName("pool.ha_enabled"), pool, getPoolHAStatus, false);
            {
                // ntol row. May be red and bold.
                bool redBold = pool.ha_host_failures_to_tolerate == 0;

                CustomListRow newChild = CreateNewRow(Messages.HA_CONFIGURED_CAPACITY, new ToStringWrapper <Pool>(pool, getNtol), redBold);
                header.AddChild(newChild);

                if (redBold)
                {
                    newChild.Items[1].ForeColor = Color.Red;
                    ToolStripMenuItem editHa = new ToolStripMenuItem(Messages.CONFIGURE_HA_ELLIPSIS);
                    editHa.Click += delegate { EditHA(pool); };
                    newChild.MenuItems.Add(editHa);
                    newChild.DefaultMenuItem = editHa;
                }
                else
                {
                    newChild.Items[1].ForeColor = BaseTabPage.ItemValueForeColor;
                }
            }

            {
                // plan_exists_for row needs some special work: the text may be red and bold
                bool          redBold  = haStatusRed(pool);
                CustomListRow newChild = CreateNewRow(Messages.HA_CURRENT_CAPACITY, new ToStringWrapper <Pool>(pool, getPlanExistsFor), redBold);
                header.AddChild(newChild);

                if (redBold)
                {
                    newChild.Items[1].ForeColor = Color.Red;
                    ToolStripMenuItem editHa = new ToolStripMenuItem(Messages.CONFIGURE_HA_ELLIPSIS);
                    editHa.Click += delegate { EditHA(pool); };
                    newChild.MenuItems.Add(editHa);
                    newChild.DefaultMenuItem = editHa;
                }
                else
                {
                    newChild.Items[1].ForeColor = BaseTabPage.ItemValueForeColor;
                }
            }
            AddBottomSpacing(header);

            // 'Heartbeating status' heading
            header = CreateHeader(Messages.HEARTBEATING_STATUS);
            customListPanel.AddRow(header);

            // Now build the heartbeat target health table

            List <SR> heartbeatSRs = pool.GetHAHeartbeatSRs();

            // Sort heartbeat SRs using NaturalCompare
            heartbeatSRs.Sort((Comparison <SR>) delegate(SR a, SR b)
            {
                return(StringUtility.NaturalCompare(a.Name, b.Name));
            });

            List <Host> members = new List <Host>(pool.Connection.Cache.Hosts);

            // Sort pool members using NaturalCompare
            members.Sort((Comparison <Host>) delegate(Host a, Host b)
            {
                return(StringUtility.NaturalCompare(a.Name, b.Name));
            });
            int numCols = 1 + 2 + (2 * heartbeatSRs.Count); // Hostnames col, then 2 each for each HB target (network + SRs)
            int numRows = 1 + members.Count;

            // Create rows and cols
            tableLatencies.SuspendLayout();
            tableLatencies.ColumnCount = numCols;
            tableLatencies.ColumnStyles.Clear();
            for (int i = 0; i < numCols; i++)
            {
                tableLatencies.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            }
            tableLatencies.RowCount = numRows;
            tableLatencies.RowStyles.Clear();
            for (int i = 0; i < numRows; i++)
            {
                tableLatencies.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            }

            {
                // Network icon
                PictureBox p = new PictureBox();
                p.Image    = Images.GetImage16For(Icons.Network);
                p.SizeMode = PictureBoxSizeMode.AutoSize;
                p.Padding  = new Padding(0);
                tableLatencies.Controls.Add(p);
                tableLatencies.SetCellPosition(p, new TableLayoutPanelCellPosition(1, 0));
                // Network text
                Label l = new Label();
                l.Padding   = new Padding(0, 5, 5, 5);
                l.Font      = BaseTabPage.ItemLabelFont;
                l.ForeColor = BaseTabPage.ItemLabelForeColor;
                l.AutoSize  = true;
                l.Text      = Messages.NETWORK;
                tableLatencies.Controls.Add(l);
                tableLatencies.SetCellPosition(l, new TableLayoutPanelCellPosition(2, 0));
            }

            for (int i = 0; i < heartbeatSRs.Count; i++)
            {
                // SR icon
                PictureBox p = new PictureBox();
                p.Image    = Images.GetImage16For(heartbeatSRs[i].GetIcon);
                p.SizeMode = PictureBoxSizeMode.AutoSize;
                p.Padding  = new Padding(0);
                tableLatencies.Controls.Add(p);
                tableLatencies.SetCellPosition(p, new TableLayoutPanelCellPosition((2 * i) + 3, 0));
                // SR name
                Label l = new Label();
                l.Padding      = new Padding(0, 5, 5, 5);
                l.Font         = BaseTabPage.ItemLabelFont;
                l.ForeColor    = BaseTabPage.ItemLabelForeColor;
                l.AutoSize     = false;
                l.Size         = new Size(200, 25);
                l.AutoEllipsis = true;
                l.Text         = heartbeatSRs[i].Name;
                tableLatencies.Controls.Add(l);
                tableLatencies.SetCellPosition(l, new TableLayoutPanelCellPosition((2 * i) + 4, 0));
            }

            for (int i = 0; i < members.Count; i++)
            {
                // Server name label
                Label l = new Label();
                l.Padding   = new Padding(5);
                l.Font      = BaseTabPage.ItemLabelFont;
                l.ForeColor = BaseTabPage.ItemLabelForeColor;
                l.AutoSize  = true;
                l.Text      = members[i].Name.Ellipsise(30);
                tableLatencies.Controls.Add(l);
                tableLatencies.SetCellPosition(l, new TableLayoutPanelCellPosition(0, i + 1));

                // Network HB status
                l          = new Label();
                l.Padding  = new Padding(0, 5, 0, 5);
                l.Font     = BaseTabPage.ItemValueFont;
                l.AutoSize = true;
                if (members[i].ha_network_peers.Length == members.Count)
                {
                    l.ForeColor = Color.Green;
                }
                else
                {
                    l.ForeColor = BaseTabPage.ItemValueForeColor;
                }

                if (members[i].ha_network_peers.Length == 0)
                {
                    l.Text = Messages.HA_HEARTBEAT_UNHEALTHY;
                }
                else if (members[i].ha_network_peers.Length == members.Count)
                {
                    l.Text = Messages.HA_HEARTBEAT_HEALTHY;
                }
                else
                {
                    l.Text = string.Format(Messages.HA_HEARTBEAT_SERVERS, members[i].ha_network_peers.Length, members.Count);
                }
                tableLatencies.Controls.Add(l);
                tableLatencies.SetCellPosition(l, new TableLayoutPanelCellPosition(1, i + 1));
                tableLatencies.SetColumnSpan(l, 2);

                // For each heartbeat SR, show health from this host's perspective
                for (int j = 0; j < heartbeatSRs.Count; j++)
                {
                    l           = new Label();
                    l.Padding   = new Padding(0, 5, 0, 5);
                    l.Font      = BaseTabPage.ItemValueFont;
                    l.ForeColor = BaseTabPage.ItemValueForeColor;
                    l.AutoSize  = true;
                    l.Text      = Messages.HA_HEARTBEAT_UNHEALTHY;
                    foreach (string opaqueRef in members[i].ha_statefiles)
                    {
                        XenRef <VDI> vdiRef = new XenRef <VDI>(opaqueRef);
                        VDI          vdi    = pool.Connection.Resolve(vdiRef);
                        if (vdi == null)
                        {
                            continue;
                        }
                        SR sr = pool.Connection.Resolve(vdi.SR);
                        if (sr == null)
                        {
                            continue;
                        }
                        if (sr == heartbeatSRs[j])
                        {
                            l.ForeColor = Color.Green;
                            l.Text      = Messages.HA_HEARTBEAT_HEALTHY;
                            break;
                        }
                    }
                    tableLatencies.Controls.Add(l);
                    tableLatencies.SetCellPosition(l, new TableLayoutPanelCellPosition((2 * j) + 2, i + 1));
                    tableLatencies.SetColumnSpan(l, 2);
                }
            }

            tableLatencies.ResumeLayout();
            tableLatencies.PerformLayout();
        }