public List <(string, string)> GetNeighborsOnRunningInterfaces(IEntityReader <InterfaceEthernet> ethReader, IEntityReader <IpNeighbor> neigReader) { var interfacesToTest = new List <(string, string)>(); var runningethers = ethReader.GetAll().Where(p => p.Running == true); var neigList = neigReader.GetAll(); foreach (var ether in runningethers) { if (neigList.Count(i => i.Interface.Contains(ether.Name)) == 1) { var neig = neigList.FirstOrDefault(n => n.Interface.Contains(ether.Name)); _logger.Information("En la interface {Interface} se encuentra un equipo {Modelo} con la MAC {MacAddress}", neig.Interface, neig.Board, neig.MacAddress); if (neig.Address4 != "") { interfacesToTest.Add((neig.Interface, neig.Address4)); _logger.Information("Se agrego a la lista de interfaces a probar a la {Interface} con IP {Address}", neig.Interface, neig.Address4); } else { _logger.Error("El vecino en la {Interface} NO tiene IP y NO se agrega a la lista de pruebas", neig.Interface); } } else { _logger.Error("La interface {Interface} esta running y contiene NINGUN o VARIOS vecino/s", ether.Name); } } return(interfacesToTest); }
public List <(string iface, EthernetPoeStatus poeStatus)> GetInterfacesPoeStatus( IEntityReader <EthernetPoe> poeReader) { var results = new List <(string, EthernetPoeStatus)>(); var poes = poeReader.GetAll(); foreach (var poe in poes) { var poeStatus = poe.MonitorOnce(_connection); _logger.Information("La interface {Interface} tiene un estado Poe {PoeStatus}", poeStatus.Name, poeStatus.PoeOutStatus); results.Add((poeStatus.Name, poeStatus.PoeOutStatus)); } return(results); }
public Dictionary <string, (string iface, string mac)> GetListRoutersToConfig(IEntityReader <IpNeighbor> neighReader) { var result = new Dictionary <string, (string iface, string mac)>(); var neighList = neighReader.GetAll().ToArray(); foreach (var neigh in neighList) { if (!neigh.Interface.StartsWith("vlan") || !ValidIpAddress(neigh.Address4)) { continue; } result.Add(neigh.Address4, (neigh.Interface, neigh.MacAddress)); _logger.Information(neigh.Address4); } return(result); }
public string CheckFor260(string uplink, IEntityReader <IpNeighbor> neighReader) { var result = "No RB260"; var uplinkNeighs = neighReader.GetAll().Where(n => n.Interface == uplink); foreach (var neigh in uplinkNeighs) { if (neigh.Board != "RB260GS") { continue; } result = neigh.Address4; break; } return(result); }
GetInterfacesNegotiation(IEntityReader <InterfaceEthernet> ethReader) { var interfacesRunningNegotiation = new List <(string name, string autonegotiation, bool fullduplex, EthernetRates rate)>(); var allIfaces = ethReader.GetAll(); var allRunning = allIfaces.Where(i => i.Running); foreach (var iface in allRunning) { var negoStatus = iface.MonitorOnce(_connection); _logger.Information( "Interface {Interface}, Autonegotiation {AutoStatus}, Full Dulplex {FullStatus}, Rate {RateStatus}", negoStatus.Name, negoStatus.AutoNegotiation, negoStatus.FullDuplex, negoStatus.Rate); interfacesRunningNegotiation.Add((negoStatus.Name, negoStatus.AutoNegotiation, negoStatus.FullDuplex, negoStatus.Rate)); } return(interfacesRunningNegotiation); }
public Dictionary <string, string> GetVlanAddressList(IEntityReader <IpAddress> addressReader) { var result = new Dictionary <string, string>(); var addressList = addressReader.GetAll().ToArray(); foreach (var address in addressList) { var ip = address.Address.WhitOutNetwork(); if (!address.Interface.StartsWith("vlan2") || !ValidIpAddress(ip)) { continue; } var nextIp = ip.GetNextIpAddress(1) + "/30"; result.Add(address.Interface, nextIp); } return(result); }
public List <(string iface, string ip)> GetNeighborsOnRunningInterfaces( IEntityReader <InterfaceEthernet> ethReader, IEntityReader <IpNeighbor> neigReader) { var results = new List <(string iface, string ip)>(); var runningethers = ethReader.GetAll().Where(p => p.Running); var neigList = neigReader.GetAll(); foreach (var ether in runningethers) { var lista = neigList.Where(n => n.Interface.ToLower().Equals(ether.Name.ToLower())).ToArray(); var neig = lista.FirstOrDefault(); if (neig != null && lista.Length == 1) { _logger.Information( "En la interface {Interface} se encuentra un equipo {Modelo} con la MAC {MacAddress}", neig.Interface, neig.Board, neig.MacAddress); if (!string.IsNullOrEmpty(neig.Address4)) { results.Add((neig.Interface, neig.Address4)); _logger.Information( "Se agrego a la lista de interfaces a probar a la {Interface} con IP {Address}", neig.Interface, neig.Address4); } else { _logger.Error("El vecino en la {Interface} NO tiene IP y NO se agrega a la lista de pruebas", neig.Interface); } } else { _logger.Error("La interface {Interface} esta running y contiene NINGUN o VARIOS vecino/s", ether.Name); } } return(results); }
public string GetUpLinkInterface(IEntityReader <IpNeighbor> neighReader, IEntityReader <Interfaces> ifaceReader) { var proxyNeigh = neighReader.GetAll().Where(n => n.Identity == "Saavedra_Proxy_ARP" || n.Identity == "Saavedra_CRF2"); var neighIfaces = proxyNeigh.Select(n => n.Interface).ToArray(); var ifaces = ifaceReader.GetAll().Where(i => i.Type == "Ethernet").ToArray(); var result = ""; foreach (var neighIface in neighIfaces) { if (ifaces.FirstOrDefault(i => i.DefaultName == neighIface) == null) { continue; } result = neighIface; break; } return(result); }