コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }