public List<FibreChannelDTOResponse> GetFibreChannelInfo() { List<FibreChannelDTOResponse> fc = new List<FibreChannelDTOResponse>(); try { SelectQuery query = new SelectQuery( @"select Caption, DeviceID from Win32_SCSIController where Caption like '%Fibre Channel Adapter%' or Caption like '%HBA%'" ); ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); foreach (ManagementObject obj in searcher.Get()) { FibreChannelDTOResponse card = new FibreChannelDTOResponse(); card.Label = GetValueAsString(obj, "Caption"); string[] deviveIDParts = GetValueAsString(obj, "DeviceID").Split('&'); card.PhysicalId = deviveIDParts[deviveIDParts.Length - 1]; fc.Add(card); } } catch (ManagementException e) { Logger.Instance.LogError(e.ToString()); } return fc; }
public List<FibreChannelDTOResponse> GetFibreChannelInfo() { List<FibreChannelDTOResponse> fc = new List<FibreChannelDTOResponse>(); string fcinfoResult; try { fcinfoResult = ExecuteFcinfoCommand(); } catch (ExternalCommandExecutionException) { return fc; } string[] lines = Regex.Split(fcinfoResult, "\r\n"); FibreChannelDTOResponse card = null; string modelName = ""; for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.Length == 0) { continue; } string[] lineParts = line.Split(':'); if (lineParts.Length != 2) { continue; } if (lineParts[0].ToLower() == "adapter") { if (card != null) { if (modelName.Length > 0) { card.ModelName = modelName; } fc.Add(card); } card = new FibreChannelDTOResponse(); string[] adapterNameParts = lineParts[1].Trim().Split('-'); if (adapterNameParts.Length > 0) { card.PhysicalId = adapterNameParts[adapterNameParts.Length - 1]; } } else if (card != null) { switch (lineParts[0].ToLower()) { case "descrp": card.Label = lineParts[1].Trim(); break; case "model": if (modelName.Length > 0) { modelName = " " + lineParts[1].Trim(); } else { modelName = lineParts[1].Trim(); } break; case "manfac": if (modelName.Length > 0) { modelName = lineParts[1].Trim() + " " + modelName; } else { modelName = lineParts[1].Trim(); } break; } } } if (card != null) { fc.Add(card); } return fc; }
public List<FibreChannelDTOResponse> GetFibreChannelInfo() { List<FibreChannelDTOResponse> fc = new List<FibreChannelDTOResponse>(); string fcinfoResult; try { fcinfoResult = ExecuteFcinfoCommand("details"); } catch (ExternalCommandExecutionException e) { Logger.Instance.LogWarning( "[GetFCInfo] To get informations about FC cards or disk shares install fcinfo tool." ); Logger.Instance.LogError(e.ToString()); return fc; } string[] lines = Regex.Split(fcinfoResult, "\r\n"); FibreChannelDTOResponse card = null; string modelName = ""; for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.Length == 0) { continue; } string[] lineParts = line.Split(':'); if (lineParts.Length != 2) { continue; } if (lineParts[0].ToLower() == "adapter") { if (card != null) { if (modelName.Length > 0) { card.ModelName = SanitizeModelName(modelName); } fc.Add(card); modelName = ""; } card = new FibreChannelDTOResponse(); string[] adapterNameParts = lineParts[1].Trim().Split('-'); if (adapterNameParts.Length > 0) { card.PhysicalId = adapterNameParts[adapterNameParts.Length - 1]; } } else if (card != null) { switch (lineParts[0].ToLower()) { case "descrp": card.Label = lineParts[1].Trim(); break; case "model": if (modelName.Length > 0) { modelName = modelName + " " + lineParts[1].Trim(); } else { modelName = lineParts[1].Trim(); } break; case "manfac": if (modelName.Length > 0) { modelName = lineParts[1].Trim() + " " + modelName; } else { modelName = lineParts[1].Trim(); } break; } } } if (card != null) { if (card.ModelName == null) { card.ModelName = SanitizeModelName(modelName); } fc.Add(card); } return fc; }