Ejemplo n.º 1
0
        public override string Name()
        {
            if (IsPhysical())
            {
                bool   bond;
                string number = NICIdentifier(out bond);
                return(string.Format(bond ? Messages.PIF_BOND : Messages.PIF_NIC, number));
            }
            else if (IsTunnelAccessPIF())
            {
                // In the case of tunnel access PIFs, use the name of the corresponding transport PIF (CA-63296)
                Tunnel tunnel        = Connection.Resolve(tunnel_access_PIF_of[0]);
                PIF    transport_pif = Connection.Resolve(tunnel.transport_PIF);
                return(transport_pif.Name());
            }

            else if (IsSriovLogicalPIF())
            {
                if (Connection == null)
                {
                    return("");
                }
                Network_sriov network_s = Connection.Resolve(sriov_logical_PIF_of[0]);
                if (network_s == null)
                {
                    return("");
                }
                PIF pif = Connection.Resolve(network_s.physical_PIF);
                if (pif == null)
                {
                    return("");
                }
                return(pif.Name());
            }
            else
            {
                if (Connection == null)
                {
                    return("");
                }
                VLAN vlan = Connection.Resolve(VLAN_master_of);
                if (vlan == null)
                {
                    return("");
                }
                PIF slave = Connection.Resolve(vlan.tagged_PIF);
                if (slave == null)
                {
                    return("");
                }
                return(slave.Name());
            }
        }
Ejemplo n.º 2
0
        public LinkState LinkStatus()
        {
            if (IsTunnelAccessPIF())
            {
                Tunnel tunnel = Connection.Resolve(tunnel_access_PIF_of[0]); // can only ever be the access PIF of one tunnel
                Dictionary <string, string> status = (tunnel == null ? null : tunnel.status);
                return(status != null && status.ContainsKey("active") && status["active"] == "true"
                    ? LinkState.Connected : LinkState.Disconnected);
            }

            //if (!pif.IsPhysical && !poolwide)
            //    return Messages.SPACED_HYPHEN;

            PIF_metrics pifMetrics = PIFMetrics();

            // LinkStatus of SR-IOV network and VLAN on SR-IOV network
            if (IsSriovLogicalPIF() || VLAN >= 0)
            {
                var network_sriov = NetworkSriov();
                if (network_sriov == null && VLAN < 0)
                {
                    return(LinkState.Disconnected);
                }
                else if (network_sriov != null)
                {
                    Network_sriov network_s = Connection.Resolve(network_sriov);
                    if (pifMetrics == null)
                    {
                        return(LinkState.Unknown);
                    }
                    else if (!pifMetrics.carrier || (network_s == null || network_s.configuration_mode == sriov_configuration_mode.unknown || network_s.requires_reboot == true))
                    {
                        return(LinkState.Disconnected);
                    }
                }
            }

            return(pifMetrics == null
                ? LinkState.Unknown
                : pifMetrics.carrier?LinkState.Connected : LinkState.Disconnected);
        }