Compare commits
No commits in common. "master" and "hopglass" have entirely different histories.
|
@ -45,26 +45,16 @@ class NodeHierarchy(object):
|
||||||
for nodeID, nodeValue in self.__hopglass.nodes.items():
|
for nodeID, nodeValue in self.__hopglass.nodes.items():
|
||||||
if nodeValue['nodeinfo']['node_id']:
|
if nodeValue['nodeinfo']['node_id']:
|
||||||
print('Create Node object #',len(nodes), '\r',end = '')
|
print('Create Node object #',len(nodes), '\r',end = '')
|
||||||
nodes[nodeID] = Node(self.__prepareNodeData__(nodeValue))
|
nodes[nodeID] = Node(nodeValue)
|
||||||
print('')
|
print('')
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
def __prepareNodeData__(self, nodeValue):
|
|
||||||
if self.__args__.site_to_target_prefix:
|
|
||||||
pref = self.__args__.site_to_target_prefix.split(',')
|
|
||||||
try:
|
|
||||||
nodeValue['nodeinfo']['system']['site_code'] = nodeValue['nodeinfo']['system']['site_code'].replace(pref[0],pref[1])
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return nodeValue
|
|
||||||
|
|
||||||
def __createLinkObjects__(self):
|
def __createLinkObjects__(self):
|
||||||
links = []
|
links = []
|
||||||
for linkParID, linkPar in self.__hopglass.links.items():
|
for linkParID, linkPar in self.__hopglass.links.items():
|
||||||
for linkID, link in linkPar.items():
|
for linkID, link in linkPar.items():
|
||||||
print('Create Link object #',len(links), '\r',end = '')
|
print('Create Link object #',len(links), '\r',end = '')
|
||||||
if linkParID[0] != 'null' and linkParID[1] != 'null':
|
links.append(Link(link, (self.nodes[linkParID[0]], self.nodes[linkParID[1]])))
|
||||||
links.append(Link(link, (self.nodes[linkParID[0]], self.nodes[linkParID[1]])))
|
|
||||||
print('')
|
print('')
|
||||||
return links
|
return links
|
||||||
|
|
||||||
|
@ -76,10 +66,9 @@ class NodeHierarchy(object):
|
||||||
parser.add_argument('-r', '--raw-json', required=False, default='https://karte.freifunk-muensterland.de/data/raw.json', help='Location of raw.json file (can be local folder or remote URL).')
|
parser.add_argument('-r', '--raw-json', required=False, default='https://karte.freifunk-muensterland.de/data/raw.json', help='Location of raw.json file (can be local folder or remote URL).')
|
||||||
parser.add_argument('-s', '--shapes-path', required=False, default='https://freifunk-muensterland.de/md-fw-dl/shapes/', help='Path of shapefiles (can be local folder or remote URL).')
|
parser.add_argument('-s', '--shapes-path', required=False, default='https://freifunk-muensterland.de/md-fw-dl/shapes/', help='Path of shapefiles (can be local folder or remote URL).')
|
||||||
parser.add_argument('-t', '--targets', nargs='+', required=True, help='List of targets which should be proceeded. Example: -t citya cityb ...')
|
parser.add_argument('-t', '--targets', nargs='+', required=True, help='List of targets which should be proceeded. Example: -t citya cityb ...')
|
||||||
parser.add_argument('-sttp', '--site-to-target-prefix', required=False, help='Used to match site and target also when prefixes are different. Example: -sttp "ffmsd,domaene"')
|
|
||||||
parser.add_argument('-o', '--out-file', default='./webserver-configuration', required=False, help='Filename where the generated Output should stored.')
|
parser.add_argument('-o', '--out-file', default='./webserver-configuration', required=False, help='Filename where the generated Output should stored.')
|
||||||
parser.add_argument('-v', '--debug', required=False, action='store_true', help='Enable debugging output.')
|
parser.add_argument('-v', '--debug', required=False, action='store_true', help='Enable debugging output.')
|
||||||
parser.add_argument('-f', '--filters', nargs='*', required=False, choices=('exclude_clouds_with_lan_links', 'no_lan', 'domain_transitions_only'), help='Filter out nodes and local clouds based on filter rules.')
|
parser.add_argument('-f', '--filters', nargs='*', required=False, choices=('exclude_clouds_with_lan_links', 'no_lan'), help='Filter out nodes and local clouds based on filter rules.')
|
||||||
parser.add_argument('-i', '--info', nargs='*', required=False, choices=('get_offline_nodes','offline'), help='Get infos about the graph, links and nodes.')
|
parser.add_argument('-i', '--info', nargs='*', required=False, choices=('get_offline_nodes','offline'), help='Get infos about the graph, links and nodes.')
|
||||||
parser.add_argument('-if', '--info-filters', nargs='*', required=False, help='Filter info results. Currently supported: min_age:TIME_RANGE, max_age:TIME_RANGE. Examples: -if min_age:1d max_age:2w')
|
parser.add_argument('-if', '--info-filters', nargs='*', required=False, help='Filter info results. Currently supported: min_age:TIME_RANGE, max_age:TIME_RANGE. Examples: -if min_age:1d max_age:2w')
|
||||||
parser.add_argument('-iop', '--info-out-path', required=False, default='./', help='Folder where info files should be written. Default: ./')
|
parser.add_argument('-iop', '--info-out-path', required=False, default='./', help='Folder where info files should be written. Default: ./')
|
||||||
|
|
16
README.md
16
README.md
|
@ -29,9 +29,8 @@ Die Hilfe liefert folgendes:
|
||||||
```
|
```
|
||||||
$ ./NodeHierarchy.py --help
|
$ ./NodeHierarchy.py --help
|
||||||
usage: NodeHierarchy.py [-h] [-r RAW_JSON] [-s SHAPES_PATH] -t TARGETS
|
usage: NodeHierarchy.py [-h] [-r RAW_JSON] [-s SHAPES_PATH] -t TARGETS
|
||||||
[TARGETS ...] [-sttp SITE_TO_TARGET_PREFIX]
|
[TARGETS ...] [-o OUT_FILE] [-v]
|
||||||
[-o OUT_FILE] [-v]
|
[-f [{exclude_clouds_with_lan_links,no_lan} [{exclude_clouds_with_lan_links,no_lan} ...]]]
|
||||||
[-f [{exclude_clouds_with_lan_links,no_lan,domain_transitions_only} [{exclude_clouds_with_lan_links,no_lan,domain_transitions_only} ...]]]
|
|
||||||
[-i [{get_offline_nodes,offline} [{get_offline_nodes,offline} ...]]]
|
[-i [{get_offline_nodes,offline} [{get_offline_nodes,offline} ...]]]
|
||||||
[-if [INFO_FILTERS [INFO_FILTERS ...]]]
|
[-if [INFO_FILTERS [INFO_FILTERS ...]]]
|
||||||
[-iop INFO_OUT_PATH]
|
[-iop INFO_OUT_PATH]
|
||||||
|
@ -44,20 +43,18 @@ optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-r RAW_JSON, --raw-json RAW_JSON
|
-r RAW_JSON, --raw-json RAW_JSON
|
||||||
Location of raw.json file (can be local folder or
|
Location of raw.json file (can be local folder or
|
||||||
remote URL).
|
remote URL). Default: https://karte.freifunk-
|
||||||
|
muensterland.de/data/raw.json
|
||||||
-s SHAPES_PATH, --shapes-path SHAPES_PATH
|
-s SHAPES_PATH, --shapes-path SHAPES_PATH
|
||||||
Path of shapefiles (can be local folder or remote
|
Path of shapefiles (can be local folder or remote
|
||||||
URL).
|
URL).
|
||||||
-t TARGETS [TARGETS ...], --targets TARGETS [TARGETS ...]
|
-t TARGETS [TARGETS ...], --targets TARGETS [TARGETS ...]
|
||||||
List of targets which should be proceeded. Example: -t
|
List of targets which should be proceeded. Example: -t
|
||||||
citya cityb ...
|
citya cityb ...
|
||||||
-sttp SITE_TO_TARGET_PREFIX, --site-to-target-prefix SITE_TO_TARGET_PREFIX
|
|
||||||
Used to match site and target also when prefixes are
|
|
||||||
different. Example: -sttp "ffmsd,domaene"
|
|
||||||
-o OUT_FILE, --out-file OUT_FILE
|
-o OUT_FILE, --out-file OUT_FILE
|
||||||
Filename where the generated Output should stored.
|
Filename where the generated Output should stored.
|
||||||
-v, --debug Enable debugging output.
|
-v, --debug Enable debugging output.
|
||||||
-f [{exclude_clouds_with_lan_links,no_lan,domain_transitions_only} [{exclude_clouds_with_lan_links,no_lan,domain_transitions_only} ...]], --filters [{exclude_clouds_with_lan_links,no_lan,domain_transitions_only} [{exclude_clouds_with_lan_links,no_lan,domain_transitions_only} ...]]
|
-f [{exclude_clouds_with_lan_links,no_lan} [{exclude_clouds_with_lan_links,no_lan} ...]], --filters [{exclude_clouds_with_lan_links,no_lan} [{exclude_clouds_with_lan_links,no_lan} ...]]
|
||||||
Filter out nodes and local clouds based on filter
|
Filter out nodes and local clouds based on filter
|
||||||
rules.
|
rules.
|
||||||
-i [{get_offline_nodes,offline} [{get_offline_nodes,offline} ...]], --info [{get_offline_nodes,offline} [{get_offline_nodes,offline} ...]]
|
-i [{get_offline_nodes,offline} [{get_offline_nodes,offline} ...]], --info [{get_offline_nodes,offline} [{get_offline_nodes,offline} ...]]
|
||||||
|
@ -93,8 +90,7 @@ Weitere Filterungen lassen sich über das ``--filters`` Attribut aktivieren.
|
||||||
|
|
||||||
Folgende Filter sind derzeit implementiert (zukünftig folgen noch weitere):
|
Folgende Filter sind derzeit implementiert (zukünftig folgen noch weitere):
|
||||||
|
|
||||||
- ``exclude_clouds_with_lan_links`` bzw. ``no_lan`` filtert alle lokalen Wolken aus, in denen sich mindestens ein Mesh-on-LAN Link befindet
|
- ``exclude_clouds_with_lan_links`` bzw. ``no_lan`` Filtert alle lokalen Wolken aus, in denen sich mindestens ein Mesh-on-LAN Link befindet
|
||||||
- ``domain_transitions_only`` filtert alle Knoten aus, die sich bereits in der richtigen Domäne befinden / die Firmware der richtigen Domäne besitzen
|
|
||||||
|
|
||||||
|
|
||||||
## Nginx Konfiguration
|
## Nginx Konfiguration
|
||||||
|
|
|
@ -10,7 +10,7 @@ class NodeInit(object):
|
||||||
self.autoupdaterBranch = self.__getBranch__()
|
self.autoupdaterBranch = self.__getBranch__()
|
||||||
self.isOnline = self.__jsonObject__['nodeinfo']['isOnline']
|
self.isOnline = self.__jsonObject__['nodeinfo']['isOnline']
|
||||||
self.publicIPv6Addresses = self.__getPublicAddresses__()
|
self.publicIPv6Addresses = self.__getPublicAddresses__()
|
||||||
self.domName = self.__getSiteCode__()
|
self.domID = self.__getSiteCode__()
|
||||||
|
|
||||||
def __getInterfaces__(self):
|
def __getInterfaces__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -31,22 +31,19 @@ class NodeInit(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __getGeo__(self):
|
def __getGeo__(self):
|
||||||
try:
|
geo = {}
|
||||||
return {
|
if 'location' in self.__jsonObject__['nodeinfo'] and 'latitude' in self.__jsonObject__['nodeinfo']['location'] and 'longitude' in self.__jsonObject__['nodeinfo']['location']:
|
||||||
'lat' : self.__jsonObject__['nodeinfo']['location']['latitude'],
|
geo['lat'] = self.__jsonObject__['nodeinfo']['location']['latitude']
|
||||||
'lon' : self.__jsonObject__['nodeinfo']['location']['longitude']
|
geo['lon'] = self.__jsonObject__['nodeinfo']['location']['longitude']
|
||||||
}
|
return geo
|
||||||
except:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
def __getPublicAddresses__(self):
|
def __getPublicAddresses__(self):
|
||||||
addresses = []
|
addresses = []
|
||||||
try:
|
if 'addresses' in self.__jsonObject__['nodeinfo']['network']:
|
||||||
for address in self.__jsonObject__['nodeinfo']['network']['addresses']:
|
for address in self.__jsonObject__['nodeinfo']['network']['addresses']:
|
||||||
if not address.startswith('fe80'):
|
if not address.startswith('fe80'):
|
||||||
addresses.append(address)
|
addresses.append(address)
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return addresses
|
return addresses
|
||||||
|
|
||||||
def __getSiteCode__(self):
|
def __getSiteCode__(self):
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Filter(object):
|
||||||
self.__args__ = args
|
self.__args__ = args
|
||||||
self.__filters__ = self.__getFilters()
|
self.__filters__ = self.__getFilters()
|
||||||
|
|
||||||
def filterLocalGraphs(self, domain, localGraphs):
|
def filterLocalGraphs(self, localGraphs):
|
||||||
filteredGraphs = []
|
filteredGraphs = []
|
||||||
for localGraph in localGraphs:
|
for localGraph in localGraphs:
|
||||||
if localGraph.isAutoupdaterEnabledOnAllNodes() == False:
|
if localGraph.isAutoupdaterEnabledOnAllNodes() == False:
|
||||||
|
@ -21,14 +21,8 @@ class Filter(object):
|
||||||
def __getFilters(self):
|
def __getFilters(self):
|
||||||
return [] if self.__args__.filters == None else self.__args__.filters
|
return [] if self.__args__.filters == None else self.__args__.filters
|
||||||
|
|
||||||
def filterNodes(self, domain, nodes):
|
def filterNodes(self, nodes):
|
||||||
filteredNodes = []
|
filteredNodes = []
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
if 'domain_transitions_only' in self.__filters__:
|
|
||||||
try:
|
|
||||||
if domain.name == node.domName:
|
|
||||||
continue
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
filteredNodes.append(node)
|
filteredNodes.append(node)
|
||||||
return filteredNodes
|
return filteredNodes
|
||||||
|
|
|
@ -17,9 +17,9 @@ class NginxConfGen(object):
|
||||||
|
|
||||||
def __genDomain__(self, domain):
|
def __genDomain__(self, domain):
|
||||||
nodes = {}
|
nodes = {}
|
||||||
for localGraph in self.__filter__.filterLocalGraphs(domain, domain.localGraphs):
|
for localGraph in self.__filter__.filterLocalGraphs(domain.localGraphs):
|
||||||
try:
|
try:
|
||||||
for node in self.__filter__.filterNodes(domain, localGraph.getNodesWithNoDependencies()):
|
for node in self.__filter__.filterNodes(localGraph.getNodesWithNoDependencies()):
|
||||||
nodes[node.nodeID] = {
|
nodes[node.nodeID] = {
|
||||||
'hostname' : node.hostname,
|
'hostname' : node.hostname,
|
||||||
'ipv6_addresses' : node.publicIPv6Addresses
|
'ipv6_addresses' : node.publicIPv6Addresses
|
||||||
|
|
|
@ -7,12 +7,6 @@ class ShapesParser(JsonParser):
|
||||||
|
|
||||||
def __createShapes__(self):
|
def __createShapes__(self):
|
||||||
shapes = []
|
shapes = []
|
||||||
if 'features' in self.__jsonData__:
|
for feature in self.__jsonData__['features']:
|
||||||
for feature in self.__jsonData__['features']:
|
shapes.append(shape(feature['geometry']))
|
||||||
if feature['geometry']:
|
|
||||||
shapes.append(shape(feature['geometry']))
|
|
||||||
elif 'geometries' in self.__jsonData__:
|
|
||||||
for geometry in self.__jsonData__['geometries']:
|
|
||||||
shapes.append(shape(geometry))
|
|
||||||
|
|
||||||
return shapes
|
return shapes
|
||||||
|
|
Loading…
Reference in a new issue