WIP
parent
5e514b5afc
commit
1177310f7f
|
@ -14,6 +14,7 @@ using ln.logging;
|
|||
using ln.skyscanner.entities;
|
||||
using ln.types.threads;
|
||||
using ln.types.net;
|
||||
using ln.types.odb;
|
||||
|
||||
namespace ln.skyscanner
|
||||
{
|
||||
|
|
|
@ -33,14 +33,15 @@ namespace ln.skyscanner
|
|||
|
||||
odDatabase = new ODB(BasePath);
|
||||
nodeCollection = odDatabase.GetCollection<Node>();
|
||||
interfaceCollection = odDatabase.GetCollection<NetworkInterface>();
|
||||
intfIPCollection = odDatabase.GetCollection<IntfIP>();
|
||||
//interfaceCollection = odDatabase.GetCollection<NetworkInterface>();
|
||||
//intfIPCollection = odDatabase.GetCollection<IntfIP>();
|
||||
subnetCollection = odDatabase.GetCollection<Subnet>();
|
||||
|
||||
nodeCollection.EnsureIndex("PrimaryIP");
|
||||
interfaceCollection.EnsureIndex("NodeID");
|
||||
intfIPCollection.EnsureIndex("interfaceID");
|
||||
intfIPCollection.EnsureIndex("Network");
|
||||
|
||||
//interfaceCollection.EnsureIndex("NodeID");
|
||||
//intfIPCollection.EnsureIndex("interfaceID");
|
||||
//intfIPCollection.EnsureIndex("Network");
|
||||
|
||||
GlobalNetwork = new GlobalNetwork(this);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,6 @@ namespace ln.skyscanner.crawl.tests
|
|||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (SnmpError)
|
||||
{
|
||||
|
|
|
@ -77,13 +77,13 @@ namespace ln.skyscanner.entities
|
|||
{
|
||||
HashSet<Node> nodes = new HashSet<Node>();
|
||||
|
||||
foreach (Network4 network in node.Networks)
|
||||
{
|
||||
foreach (Node neighbor in FindHostsInSubnet(network))
|
||||
{
|
||||
nodes.Add(neighbor);
|
||||
}
|
||||
}
|
||||
//foreach (Network4 network in node.Networks)
|
||||
//{
|
||||
// foreach (Node neighbor in FindHostsInSubnet(network))
|
||||
// {
|
||||
// nodes.Add(neighbor);
|
||||
// }
|
||||
//}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
@ -160,8 +160,6 @@ namespace ln.skyscanner.entities
|
|||
Logging.Log(e);
|
||||
}
|
||||
}
|
||||
|
||||
//SkyScanner.Entities.DBGlobalNetwork.SavePersistent(SkyScanner.Entities.DBGlobalNetwork.Root);
|
||||
}
|
||||
|
||||
private void Update(CrawledHost crawledHost)
|
||||
|
@ -194,12 +192,13 @@ namespace ln.skyscanner.entities
|
|||
|
||||
NetworkInterface networkInterface = node.GetInterface(fields[0]);
|
||||
if (networkInterface == null)
|
||||
{
|
||||
networkInterface = new NetworkInterface(node, fields[0]);
|
||||
node.Interfaces.Add(networkInterface);
|
||||
}
|
||||
|
||||
networkInterface.HWAddress = fields[1];
|
||||
|
||||
SkyEntities.interfaceCollection.Upsert(networkInterface);
|
||||
|
||||
IPv4[][] crawledIPs = fields[2].Split(',').Where((sip) => !String.Empty.Equals(sip))
|
||||
.Select((sip) => sip.Split('/').Select(ip => IPv4.Parse(ip)).ToArray()).ToArray();
|
||||
|
||||
|
@ -214,7 +213,7 @@ namespace ln.skyscanner.entities
|
|||
if (n == currentIPs.Length)
|
||||
{
|
||||
IntfIP miss = new IntfIP(networkInterface, crawledIP[0], new Network4(crawledIP[0], crawledIP[1]));
|
||||
SkyEntities.intfIPCollection.Upsert(miss);
|
||||
networkInterface.ConfiguredIPs.Add(miss);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +223,7 @@ namespace ln.skyscanner.entities
|
|||
|
||||
if (!crawledIPs.Select((ipl)=>ipl[0]).Contains(ip))
|
||||
{
|
||||
SkyEntities.intfIPCollection.Delete(iip);
|
||||
networkInterface.ConfiguredIPs.Remove(iip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,11 +266,6 @@ namespace ln.skyscanner.entities
|
|||
node.Vendor = "Ubiquity";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
foreach (Network4 network in node.Networks)
|
||||
EnsureSubnet(network);
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace ln.skyscanner.entities
|
|||
public string Name { get; private set; } = "";
|
||||
public string HWAddress { get; set; } = "";
|
||||
|
||||
public IEnumerable<IntfIP> ConfiguredIPs => SkyScanner.Instance.Entities.intfIPCollection.Select("interfaceID", ID);
|
||||
public List<IntfIP> ConfiguredIPs { get; private set; } = new List<IntfIP>();
|
||||
//public IEnumerable<IntfIP> ConfiguredIPs => SkyScanner.Instance.Entities.intfIPCollection.Select("interfaceID", ID);
|
||||
|
||||
private NetworkInterface()
|
||||
{ }
|
||||
|
|
|
@ -39,11 +39,9 @@ namespace ln.skyscanner.entities
|
|||
|
||||
public string ProductLine { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public IEnumerable<NetworkInterface> Interfaces => SkyScanner.Instance.Entities.interfaceCollection.Select("NodeID", ID);
|
||||
[JsonIgnore]
|
||||
public List<NetworkInterface> Interfaces { get; private set; } = new List<NetworkInterface>();
|
||||
|
||||
public IEnumerable<IPv4> IPAdresses => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.IP));
|
||||
[JsonIgnore]
|
||||
public IEnumerable<Network4> Networks => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.Network));
|
||||
|
||||
private HashSet<URI> uris = new HashSet<URI>();
|
||||
|
|
Loading…
Reference in New Issue