ExecuteSample( string[] args) { if (args.Length == 0 || args[0] == "/?") { Console.WriteLine("Usage: ModifySanPorts <SanName> [WWPN WWNN]*"); return; } try { string sanName = args[0]; List <string> switchPaths = new List <string>(); if (args.Length >= 3 && args.Length % 2 == 1) { for (int index = 2; index < args.Length; index += 2) { WorldWideName wwn = new WorldWideName(); wwn.PortName = args[index - 1]; wwn.NodeName = args[index]; // // Convert the WWN to the path of the corresponding Virtual FC Switch to be used // as HostResources for the ResourcePool. // switchPaths.Add(FibreChannelUtilities.GetHostResourceFromWwn(wwn)); } } else if (args.Length != 1) { Console.WriteLine("Usage: ModifySanPorts sanName [WWPN WWNN]*"); return; } ModifySanResources(sanName, switchPaths.ToArray()); } catch (Exception ex) { Console.WriteLine("Failed to modify san ports. Error message details:\n"); Console.WriteLine(ex.Message); } }
ExecuteSample( string[] args) { if (args.Length < 3 || (args.Length > 0 && args[0] == "/?")) { Console.WriteLine("Usage: CreateSan <SanName> <[WWPN WWNN]+> [SanNotes]"); return; } try { string sanName = args[0]; string sanNotes = @"Notes for virtual SAN - " + sanName; List <string> hostResources = new List <string>(); if (args.Length % 2 == 0) { sanNotes = args[args.Length - 1]; } for (int index = 2; index < args.Length; index += 2) { WorldWideName wwn = new WorldWideName(); wwn.PortName = args[index - 1]; wwn.NodeName = args[index]; // // Convert the WWN to the path of the corresponding Virtual FC Switch to be used // as HostResources for the ResourcePool. // hostResources.Add(FibreChannelUtilities.GetHostResourceFromWwn(wwn)); } CreateSan(sanName, sanNotes, hostResources.ToArray()); } catch (Exception ex) { Console.WriteLine("Failed to create san. Error message details:\n"); Console.WriteLine(ex.Message); } }
BuildPortInfo() { List <FcPortInfo> portInfoList = new List <FcPortInfo>(); ManagementScope scope = FibreChannelUtilities.GetFcScope(); using (ManagementClass portClass = new ManagementClass("Msvm_ExternalFcPort")) { portClass.Scope = scope; using (ManagementObjectCollection fcPorts = portClass.GetInstances()) { foreach (ManagementObject port in fcPorts) { WorldWideName wwn = new WorldWideName(); wwn.NodeName = (string)port["WWNN"]; wwn.PortName = (string)port["WWPN"]; FcPortInfo portInfo = new FcPortInfo(); portInfo.PortWwn = wwn; // // Convert the WWN to the path of the corresponding Virtual FC Switch to be used // as HostResources for the ResourcePool. // portInfo.HostResource = FibreChannelUtilities.GetHostResourceFromWwn(wwn); portInfo.Status = GetPortStatus(port); portInfoList.Add(portInfo); } } } if (portInfoList.Count == 0) { Console.WriteLine("No FibreChannel Ports found in the system."); } return(portInfoList); }