Esempio n. 1
0
        private void hostsTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            e.DrawDefault = true;
            RepairTreeNode node = (RepairTreeNode)e.Node;

            if (node.Host != null)
            {
                string status      = Messages.REPAIR_SR_DIALOG_CONNECTION_MISSING;
                Color  statusColor = Color.Red;
                Font   statusFont  = BoldFont;

                if (node.PBD != null)
                {
                    status      = node.PBD.currently_attached ? Messages.CONNECTED : Messages.REPAIR_SR_DIALOG_UNPLUGGED;
                    statusColor = node.PBD.currently_attached ? Color.Green : Color.Red;
                    statusFont  = node.PBD.currently_attached ? Font : BoldFont;
                }

                e.Graphics.DrawString(status, statusFont, new SolidBrush(statusColor), new Rectangle(e.Bounds.Right, e.Bounds.Top, Right - e.Bounds.Right, e.Bounds.Height));
            }
        }
Esempio n. 2
0
        public void Build()
        {
            treeView.BeginUpdate();
            RepairButton.Enabled = false;
            bool firstTime      = treeView.Nodes.Count == 0;
            bool anythingBroken = false;
            bool hostsAvailable = false;

            for (int i = 0; i < _srList.Count; i++)
            {
                // persist expanded-state of node, or default to true
                bool isExpanded = true;

                if (_srList[i].IsBroken() || !_srList[i].MultipathAOK)
                {
                    anythingBroken = true;
                }

                if (firstTime)
                {
                    treeView.Nodes.Add(new RepairTreeNode(_srList[i], null, null));
                }
                else
                {
                    isExpanded = treeView.Nodes[i].IsExpanded;
                }

                RepairTreeNode srNode = (RepairTreeNode)treeView.Nodes[i];
                srNode.Nodes.Clear();


                if (imageList.Images.ContainsKey(srNode.SR.opaque_ref))
                {
                    imageList.Images.RemoveByKey(srNode.SR.opaque_ref);
                }
                imageList.Images.Add(srNode.SR.opaque_ref, Images.GetImage16For(srNode.SR));

                srNode.ImageKey = srNode.SR.opaque_ref;

                List <Host> hosts = new List <Host>(srNode.SR.Connection.Cache.Hosts);
                hosts.Sort();
                foreach (Host host in hosts)
                {
                    if (host != null)
                    {
                        Host storageHost = srNode.SR.GetStorageHost();

                        if (srNode.SR.shared || (storageHost != null && host.opaque_ref == storageHost.opaque_ref))
                        {
                            PBD pdb = null;

                            foreach (PBD p in srNode.SR.Connection.ResolveAll <PBD>(srNode.SR.PBDs))
                            {
                                if (srNode.SR.Connection.Resolve <Host>(p.host) == host)
                                {
                                    pdb = p;
                                }
                            }

                            RepairTreeNode hostNode = new RepairTreeNode(srNode.SR, host, pdb);
                            srNode.Nodes.Add(hostNode);

                            if (imageList.Images.ContainsKey(host.opaque_ref))
                            {
                                imageList.Images.RemoveByKey(host.opaque_ref);
                            }
                            imageList.Images.Add(host.opaque_ref, Images.GetImage16For(host));

                            hostNode.ImageKey = host.opaque_ref;
                            hostsAvailable    = true;
                        }
                    }
                }

                if (isExpanded)
                {
                    srNode.Expand();
                }
                else
                {
                    srNode.Collapse();
                }
            }
            // we only want to enable the repair button if
            // - there is a broken sr
            // - we have successfully found the right hosts to patch up pbds for
            // - we are not in the process of repairing already
            RepairButton.Enabled = anythingBroken && hostsAvailable && !ActionInProgress;


            treeView.EndUpdate();
        }
Esempio n. 3
0
        public void Build()
        {
            treeView.BeginUpdate();
            RepairButton.Enabled = false;
            bool firstTime = treeView.Nodes.Count == 0;
            bool anythingBroken = false;
            bool hostsAvailable = false;
            for (int i = 0; i < _srList.Count; i++)
            {
                // persist expanded-state of node, or default to true
                bool isExpanded = true;

                if (_srList[i].IsBroken() || !_srList[i].MultipathAOK)
                    anythingBroken = true;

                if (firstTime)
                {
                    treeView.Nodes.Add(new RepairTreeNode(_srList[i], null, null));
                }
                else
                {
                    isExpanded = treeView.Nodes[i].IsExpanded;
                }

                RepairTreeNode srNode = (RepairTreeNode)treeView.Nodes[i];
                srNode.Nodes.Clear();

                
                if (imageList.Images.ContainsKey(srNode.SR.opaque_ref))
                {
                    imageList.Images.RemoveByKey(srNode.SR.opaque_ref);
                }
                imageList.Images.Add(srNode.SR.opaque_ref, Images.GetImage16For(srNode.SR));

                srNode.ImageKey = srNode.SR.opaque_ref;

                List<Host> hosts = new List<Host>(srNode.SR.Connection.Cache.Hosts);
                hosts.Sort();
                foreach (Host host in hosts)
                {
                    if (host != null)
                    {
                        Host storageHost = srNode.SR.GetStorageHost();

                        if (srNode.SR.shared || (storageHost != null && host.opaque_ref == storageHost.opaque_ref))
                        {
                            PBD pdb = null;

                            foreach (PBD p in srNode.SR.Connection.ResolveAll<PBD>(srNode.SR.PBDs))
                            {
                                if (srNode.SR.Connection.Resolve<Host>(p.host) == host)
                                {
                                    pdb = p;
                                }
                            }

                            RepairTreeNode hostNode = new RepairTreeNode(srNode.SR, host, pdb);
                            srNode.Nodes.Add(hostNode);

                            if (imageList.Images.ContainsKey(host.opaque_ref))
                            {
                                imageList.Images.RemoveByKey(host.opaque_ref);
                            }
                            imageList.Images.Add(host.opaque_ref, Images.GetImage16For(host));

                            hostNode.ImageKey = host.opaque_ref;
                            hostsAvailable = true;
                        }
                    }
                }

                if (isExpanded)
                {
                    srNode.Expand();
                }
                else
                {
                    srNode.Collapse();
                }
            }
            // we only want to enable the repair button if
            // - there is a broken sr
            // - we have successfully found the right hosts to patch up pbds for
            // - we are not in the process of repairing already
            RepairButton.Enabled = anythingBroken && hostsAvailable && !ActionInProgress;


            treeView.EndUpdate();
        }