private void generateStatusBox() { XenAPI.SR sr = this.xenModelObject as XenAPI.SR; if (sr != null) { bool flag = (sr.IsBroken() || !sr.MultipathAOK); bool isDetached = sr.IsDetached; List <ToolStripMenuItem> contextMenuItems = new List <ToolStripMenuItem>(); ToolStripMenuItem item = new ToolStripMenuItem(Messages.GENERAL_SR_CONTEXT_REPAIR) { Image = Resources._000_StorageBroken_h32bit_16 }; item.Click += delegate { Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new RepairSRDialog(sr)); }; contextMenuItems.Add(item); if (flag && !isDetached) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.state"), sr.StatusString, Status, contextMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.state"), sr.StatusString, Status)); } foreach (Host host in this.xenModelObject.Connection.Cache.Hosts) { PBD pbd = null; foreach (PBD pbd2 in this.xenModelObject.Connection.ResolveAll <PBD>(host.PBDs)) { if (!(pbd2.SR.opaque_ref != this.xenModelObject.opaque_ref)) { pbd = pbd2; break; } } if (pbd == null) { if (sr.shared) { if (!isDetached) { GeneralDataList.Add(new GeneralDataStructure(" " + HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), Messages.REPAIR_SR_DIALOG_CONNECTION_MISSING, Status, Color.Red, contextMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(" " + HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), Messages.REPAIR_SR_DIALOG_CONNECTION_MISSING, Status, Color.Red)); } } } else { pbd.PropertyChanged -= new PropertyChangedEventHandler(this.PropertyChanged); pbd.PropertyChanged += new PropertyChangedEventHandler(this.PropertyChanged); if (!pbd.currently_attached) { if (!isDetached) { GeneralDataList.Add(new GeneralDataStructure(HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), pbd.StatusString, Status, Color.Red, contextMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), pbd.StatusString, Status, Color.Red)); } } else { GeneralDataList.Add(new GeneralDataStructure(HalsignHelpers.TrimStringIfRequired(Helpers.GetName(host), 30), pbd.StatusString, Status)); } } if (sr.GetSRType(true) == SR.SRTypes.lvmobond) { if (pbd != null) { String status; if (pbd.other_config.ContainsKey("LUN1-status")) { if (pbd.other_config.TryGetValue("LUN1-status", out status)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), status, Status)); } } if (pbd.other_config.ContainsKey("LUN2-status")) { if (pbd.other_config.TryGetValue("LUN2-status", out status)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), status, Status)); } } } } if (sr.GetSRType(true) == SR.SRTypes.lvmomirror && !sr.other_config.ContainsKey("_type")) { if (pbd != null) { String status; if (pbd.other_config.ContainsKey("LUN1-status")) { if (pbd.other_config.TryGetValue("LUN1-status", out status)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), status, Status)); } } if (pbd.other_config.ContainsKey("LUN2-status")) { if (pbd.other_config.TryGetValue("LUN2-status", out status)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), status, Status)); } } } } if (sr.GetSRType(true) == SR.SRTypes.lvmomirror && sr.other_config.ContainsKey("_type")) { if (pbd != null) { String status; if (pbd.device_config.ContainsKey("SCSIid1")) { if (pbd.device_config.TryGetValue("SCSIid1", out status)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), status, Status)); } } if (pbd.device_config.ContainsKey("SCSIid2")) { if (pbd.device_config.TryGetValue("SCSIid2", out status)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), status, Status)); } } } } }//foreach /** * if (sr.GetSRType(true) == SR.SRTypes.lvmobond) * { * if (sr.sm_config.ContainsKey("state")) * { * GeneralDataList.Add(new GeneralDataStructure(FriendlyName("RAID.state"), sr.sm_config["state"], Status)); * } * if (sr.sm_config.ContainsKey("LUN0-status")) * { * * if (sr.sm_config["LUN0-status"].Contains("removed")) * { * List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>(); * ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("Add", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e) * { * List<FibreChannelDevice> devices; * var success = LVMoBond.FiberChannelScan(this, sr.Connection, out devices); * Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddLUNDialog(sr, devices)); * }); * * ctxMenuItems.Add(itm); * GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), sr.sm_config["LUN0-status"], Status, Color.Red, ctxMenuItems)); * } * else * { * String iscsiid = sr.sm_config["LUN0-scsiid"]; * String mpath_enable = sr.sm_config["multipathable"]; * String boundsr_dev = sr.sm_config["md_device"]; * Dictionary<String, String> args = new Dictionary<string, string>(); * args.Add("scsiid", iscsiid); * args.Add("mpath_enable", mpath_enable); * args.Add("boundsr_dev", boundsr_dev); * List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>(); * ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("remove", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e) * { * try * { * AsyncAction Action = new SrRemoveLUNAction(sr.Connection, sr, args, false); * Action.RunAsync(); * } * catch (Exception ex) * { * } * }); * ctxMenuItems.Add(itm); * GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN1"), sr.sm_config["LUN0-status"], Status, ctxMenuItems)); * } * } * if (sr.sm_config.ContainsKey("LUN1-status")) * { * if (sr.sm_config["LUN1-status"].Contains("removed")) * { * List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>(); * ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("Add", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e) * { * List<FibreChannelDevice> devices; * var success = LVMoBond.FiberChannelScan(this, sr.Connection, out devices); * Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddLUNDialog(sr, devices)); * }); * * ctxMenuItems.Add(itm); * GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), sr.sm_config["LUN1-status"], Status, Color.Red, ctxMenuItems)); * } * else * { * String iscsiid = sr.sm_config["LUN1-scsiid"]; * String mpath_enable = sr.sm_config["multipathable"]; * String boundsr_dev = sr.sm_config["md_device"]; * Dictionary<String, String> args = new Dictionary<string, string>(); * args.Add("scsiid", iscsiid); * args.Add("mpath_enable", mpath_enable); * args.Add("boundsr_dev", boundsr_dev); * List<ToolStripMenuItem> ctxMenuItems = new List<ToolStripMenuItem>(); * ToolStripMenuItem itm = MainWindow.NewToolStripMenuItem("remove", Resources._000_StorageBroken_h32bit_16, delegate(object sender, EventArgs e) * { * try * { * AsyncAction Action = new SrRemoveLUNAction(sr.Connection, sr, args, false); * Action.RunAsync(); * * } * catch(Exception ex) * { * } * }); * ctxMenuItems.Add(itm); * GeneralDataList.Add(new GeneralDataStructure(FriendlyName("LUN2"), sr.sm_config["LUN1-status"], Status, ctxMenuItems)); * } * } * }**/ } }
private void generateGeneralBox() { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.name_label"), Helpers.GetName(this.xenModelObject), General)); GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.name_description"), this.xenModelObject.Description, General)); GeneralDataList.Add(new GeneralDataStructure(Messages.FOLDER, this.xenModelObject.Path, General)); GeneralDataList.Add(new GeneralDataStructure(Messages.TAGS, this.TagsString(), General)); if (this.xenModelObject is XenObject <XenAPI.SR> ) { XenAPI.SR xenObject = this.xenModelObject as XenAPI.SR; GeneralDataList.Add(new GeneralDataStructure(Messages.TYPE, xenObject.FriendlyTypeName, General)); if ((xenObject.content_type != "iso") && (xenObject.GetSRType(false) != XenAPI.SR.SRTypes.udev)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.size"), xenObject.SizeString, General)); } if (xenObject.GetScsiID() != null && xenObject.GetScsiID().Count > 0) { foreach (String scsiid in xenObject.GetScsiID()) { if (xenObject.GetSRType(true) == SR.SRTypes.lvmobond) { if (CanAddLUN(scsiid) || isLunBondRed(scsiid)) { List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>(); ToolStripMenuItem itm = new ToolStripMenuItem(Messages.ADD) { Image = Resources._000_StorageBroken_h32bit_16 }; itm.Click += delegate { List <FibreChannelDevice> devices; var success = LVMoBond.FiberChannelScan(this, xenObject.Connection, out devices); Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddLUNDialog(xenObject, devices)); }; ctxMenuItems.Add(itm); GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems)); } else if (canissciRemove()) { List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>(); ToolStripMenuItem itm = new ToolStripMenuItem(Messages.REMOVE) { Image = Resources._000_StorageBroken_h32bit_16 }; itm.Click += delegate { AsyncAction Action = new SrRemoveLUNAction(xenObject.Connection, xenObject, scsiid); ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee) { ShowCancel = true }; dialog.ShowDialog(this); }; ctxMenuItems.Add(itm); if (isLunBondRed(scsiid)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems)); } } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General)); } } else if (xenObject.GetSRType(true) == SR.SRTypes.lvmomirror && xenObject.other_config.ContainsKey("_type")) { if (CanAddMirrorLUN(scsiid)) { List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>(); ToolStripMenuItem itm = new ToolStripMenuItem(Messages.ADD) { Image = Resources._000_StorageBroken_h32bit_16 }; itm.Click += delegate { // Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddMirrorIscsiDialog(xenObject)); AddMirrorIscsiDialog dlg = new AddMirrorIscsiDialog(xenObject); dlg.ShowDialog(); }; ctxMenuItems.Add(itm); if (isMirrorRed(scsiid)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems)); } } else if (canMirrorissciRemove()) { List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>(); ToolStripMenuItem itm = new ToolStripMenuItem(Messages.REMOVE) { Image = Resources._000_StorageBroken_h32bit_16 }; itm.Click += delegate { AsyncAction Action = new SrRemoveMirrorLUNAction(xenObject.Connection, xenObject, scsiid); ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee) { ShowCancel = true }; dialog.ShowDialog(this); }; ctxMenuItems.Add(itm); if (isMirrorRed(scsiid)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems)); } } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General)); } } else if (xenObject.GetSRType(true) == SR.SRTypes.lvmomirror && !xenObject.other_config.ContainsKey("_type")) { if (CanAddMirrorLUN(scsiid)) { List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>(); ToolStripMenuItem itm = new ToolStripMenuItem(Messages.ADD) { Image = Resources._000_StorageBroken_h32bit_16 }; itm.Click += delegate { List <FibreChannelDevice> devices; var success = LVMoMirror.FiberChannelScan(this, xenObject.Connection, out devices); Program.MainWindow.ShowPerConnectionWizard(this.xenModelObject.Connection, new AddMirrorLUNDialog(xenObject, devices)); }; ctxMenuItems.Add(itm); if (isMirrorRed(scsiid)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems)); } } else if (canMirrorissciRemove()) { List <ToolStripMenuItem> ctxMenuItems = new List <ToolStripMenuItem>(); ToolStripMenuItem itm = new ToolStripMenuItem(Messages.REMOVE) { Image = Resources._000_StorageBroken_h32bit_16 }; itm.Click += delegate { AsyncAction Action = new SrRemoveMirrorLUNAction(xenObject.Connection, xenObject, scsiid); ActionProgressDialog dialog = new ActionProgressDialog(Action, ProgressBarStyle.Marquee) { ShowCancel = true }; dialog.ShowDialog(this); }; ctxMenuItems.Add(itm); if (isMirrorRed(scsiid)) { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, Color.Red, ctxMenuItems)); } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General, ctxMenuItems)); } } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General)); } } else { GeneralDataList.Add(new GeneralDataStructure(FriendlyName("SR.scsiid"), scsiid ?? Messages.UNKNOWN, General)); } } } if ((Program.MainWindow.SelectionManager.Selection.HostAncestor == null) && (Program.MainWindow.SelectionManager.Selection.PoolAncestor == null)) { IXenObject o = Helpers.GetPool(xenObject.Connection); if (o != null) { GeneralDataList.Add(new GeneralDataStructure(Messages.POOL, Helpers.GetName(o), General)); } else { o = Helpers.GetMaster(xenObject.Connection); if (o != null) { GeneralDataList.Add(new GeneralDataStructure(Messages.SERVER, Helpers.GetName(o), General)); } } } } GeneralDataList.Add(new GeneralDataStructure(FriendlyName("host.uuid"), GetUUID(this.xenModelObject), General)); }