Rename net_if from router_neighbor table to netif

This includes various changes throughout the code. Additionally,
some fields are reordered.

This requires a change of the MySQL table router_neighbor!

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2017-12-29 19:23:22 +01:00
parent 39d9ddc9d0
commit 55dc7b4ad5
8 changed files with 13 additions and 13 deletions

View File

@ -117,8 +117,8 @@ def crawl(router):
continue
neighbour = {
"mac": o_mac.lower(),
"netif": o_out_if,
"quality": int(o_link_quality),
"net_if": o_out_if,
}
try:
neighbour_router = db.routers.find_one({"netifs.mac": neighbour["mac"]})

View File

@ -126,8 +126,8 @@ mysql.execute("""
CREATE TABLE router_neighbor (
`router` mediumint(8) UNSIGNED NOT NULL,
`mac` char(17) COLLATE utf8_unicode_ci NOT NULL,
`netif` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`quality` smallint(6) NOT NULL,
`net_if` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`type` varchar(10) COLLATE utf8_unicode_ci DEFAULT 'l2'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
""")

View File

@ -221,14 +221,14 @@ def import_nodewatcher_xml(mysql, mac, xml, banned, netifdict):
nbdata = []
for n in router_update["neighbours"]:
nbdata.append((router_id,n["mac"],n["quality"],n["net_if"],n["type"],))
nbdata.append((router_id,n["mac"],n["netif"],n["quality"],n["type"],))
mysql.executemany("""
INSERT INTO router_neighbor (router, mac, quality, net_if, type)
INSERT INTO router_neighbor (router, mac, netif, quality, type)
VALUES (%s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
netif=VALUES(netif),
quality=VALUES(quality),
net_if=VALUES(net_if),
type=VALUES(type)
""",nbdata)
@ -669,8 +669,8 @@ def parse_nodewatcher_xml(xml):
continue
neighbour = {
"mac": o_mac.lower(),
"netif": o_out_if,
"quality": int(o_link_quality),
"net_if": o_out_if,
"type": "l2"
}
router_update["neighbours"].append(neighbour)
@ -691,8 +691,8 @@ def get_l3_neighbours(tree):
out_if = neighbour.xpath("outgoing_interface/text()")[0]
neighbour = {
"mac": get_mac_from_v6_link_local(v6_fe80).lower(),
"netif": out_if,
"quality": -1,
"net_if": out_if,
"type": "l3"
}
l3_neighbours.append(neighbour)

View File

@ -54,7 +54,7 @@ def get_nearest_router():
""",(lat,lng,lat,))
res_router["neighbours"] = mysql.fetchall("""
SELECT nb.mac, nb.quality, nb.net_if, r.hostname, r.id
SELECT nb.mac, nb.netif, nb.quality, r.hostname, r.id
FROM router_neighbor AS nb
INNER JOIN (
SELECT router, mac FROM router_netif GROUP BY mac, router

View File

@ -107,7 +107,7 @@ def router_info(dbid):
mac = n["mac"]
router["neighbours"] = mysql.fetchall("""
SELECT nb.mac, nb.quality, nb.net_if, r.hostname, r.id
SELECT nb.mac, nb.netif, nb.quality, r.hostname, r.id
FROM router_neighbor AS nb
LEFT JOIN (
SELECT router, mac FROM router_netif GROUP BY mac, router

View File

@ -109,7 +109,7 @@ function neighbour_graph(neighbours) {
var k;
for(k=0; k<neighbours.length; k++) {
if(label == neighbours[k].name && k != j) {
label += "@" + neighbours[j].net_if;
label += "@" + neighbours[j].netif;
}
}

View File

@ -153,7 +153,7 @@ map.on('click', function(pos) {
popup_html += "<tr style=\"background-color: "+tr_color+";\">";
popup_html += '<td><a href="'+url_router_info+neighbour.id+'" title="'+escapeHTML(neighbour.mac)+'">'+escapeHTML(neighbour.hostname)+'</a></td>';
popup_html += "<td>"+neighbour.quality+"</td>";
popup_html += "<td>"+escapeHTML(neighbour.net_if)+"</td>";
popup_html += "<td>"+escapeHTML(neighbour.netif)+"</td>";
popup_html += "</tr>";
}
}

View File

@ -208,7 +208,7 @@
<td>{%- if neighbour.hostname -%}<a href="{{ url_for('router_info', dbid=neighbour.id) }}">{{ neighbour.hostname }}</a>{%- else -%}---{%- endif -%}</td>
<td>{{ neighbour.mac }}</td>
<td>{{ neighbour.quality }}</td>
<td>{{ neighbour.net_if }}</td>
<td>{{ neighbour.netif }}</td>
</tr>
{%- endfor %}
</table>
@ -344,7 +344,7 @@
var neigh_stats = {{ neighstats|statbson2json|safe }};
var neighbours = [
{%- for neighbour in router.neighbours %}
{"name": "{{ neighbour.hostname or neighbour.mac }}", "mac": "{{ neighbour.mac }}", "net_if": "{{ neighbour.net_if }}"},
{"name": "{{ neighbour.hostname or neighbour.mac }}", "mac": "{{ neighbour.mac }}", "netif": "{{ neighbour.netif }}"},
{%- endfor %}
];
$(document).ready(function() {