mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
- clean up wording for import preview - change `skip` action to `ignore` in import preview - change action to `noop` when no action is taken because of disabled ixp update - #390 fixed: Wrong IPs in exports for IX members with multiple links
This commit is contained in:
@@ -74,19 +74,19 @@ def export_ixf_ix_members(ixlans, pretty=False):
|
||||
}
|
||||
connection_list.append(connection)
|
||||
|
||||
if netixlan.ipaddr4:
|
||||
if _netixlan.ipaddr4:
|
||||
vlan_list[0]["ipv4"] = {
|
||||
"address": "{}".format(netixlan.ipaddr4),
|
||||
"routeserver": netixlan.is_rs_peer,
|
||||
"max_prefix": netixlan.network.info_prefixes4,
|
||||
"as_macro": netixlan.network.irr_as_set
|
||||
"address": "{}".format(_netixlan.ipaddr4),
|
||||
"routeserver": _netixlan.is_rs_peer,
|
||||
"max_prefix": _netixlan.network.info_prefixes4,
|
||||
"as_macro": _netixlan.network.irr_as_set
|
||||
}
|
||||
if netixlan.ipaddr6:
|
||||
if _netixlan.ipaddr6:
|
||||
vlan_list[0]["ipv6"] = {
|
||||
"address": "{}".format(netixlan.ipaddr6),
|
||||
"routeserver": netixlan.is_rs_peer,
|
||||
"max_prefix": netixlan.network.info_prefixes6,
|
||||
"as_macro": netixlan.network.irr_as_set
|
||||
"address": "{}".format(_netixlan.ipaddr6),
|
||||
"routeserver": _netixlan.is_rs_peer,
|
||||
"max_prefix": _netixlan.network.info_prefixes6,
|
||||
"as_macro": _netixlan.network.irr_as_set
|
||||
}
|
||||
|
||||
if pretty:
|
||||
|
@@ -18,8 +18,18 @@ from peeringdb_server.models import (
|
||||
|
||||
class Importer(object):
|
||||
|
||||
allowed_member_types = ["peering", "ixp", "routeserver", "probono"]
|
||||
allowed_states = ["active", "connected"]
|
||||
allowed_member_types = ["peering",
|
||||
"ixp",
|
||||
"routeserver",
|
||||
"probono",
|
||||
]
|
||||
allowed_states = ["",
|
||||
None,
|
||||
"active",
|
||||
"inactive",
|
||||
"connected",
|
||||
"operational",
|
||||
]
|
||||
|
||||
def __init__(self):
|
||||
self.reset()
|
||||
@@ -29,6 +39,7 @@ class Importer(object):
|
||||
self.netixlans = []
|
||||
self.netixlans_deleted = []
|
||||
self.ipaddresses = []
|
||||
self.asns = []
|
||||
self.ixlan = ixlan
|
||||
self.save = save
|
||||
|
||||
@@ -156,17 +167,34 @@ class Importer(object):
|
||||
their ip addresses
|
||||
|
||||
In order for a netixlan to be removed both it's ipv4 and ipv6 address
|
||||
need to be gone from the ixf data
|
||||
or it's asn need to be gone from the ixf data after validation
|
||||
"""
|
||||
for netixlan in self.ixlan.netixlan_set_active:
|
||||
ipv4 = "{}-{}".format(netixlan.asn, netixlan.ipaddr4)
|
||||
ipv6 = "{}-{}".format(netixlan.asn, netixlan.ipaddr6)
|
||||
if ipv4 not in self.ipaddresses and ipv6 not in self.ipaddresses:
|
||||
|
||||
if netixlan.asn not in self.asns:
|
||||
self.log_peer(netixlan.asn, "delete",
|
||||
_("Ip addresses no longer in data"), netixlan)
|
||||
_("ASN no longer in data"), netixlan)
|
||||
self.netixlans_deleted.append(netixlan)
|
||||
if self.save:
|
||||
netixlan.delete()
|
||||
elif ipv4 not in self.ipaddresses and ipv6 not in self.ipaddresses:
|
||||
self.log_peer(netixlan.asn, "delete",
|
||||
_("Ip addresses no longer exist in validated data or are "\
|
||||
"no longer with this asn"), netixlan)
|
||||
self.netixlans_deleted.append(netixlan)
|
||||
if self.save:
|
||||
netixlan.delete()
|
||||
elif ipv4 not in self.ipaddresses or ipv6 not in self.ipaddresses:
|
||||
if not netixlan.network.allow_ixp_update:
|
||||
self.log_peer(netixlan.asn, "delete",
|
||||
_("At least one ipaddress mismatched and "\
|
||||
"network has disabled upates"), netixlan)
|
||||
self.netixlans_deleted.append(netixlan)
|
||||
if self.save:
|
||||
netixlan.delete()
|
||||
|
||||
|
||||
@transaction.atomic()
|
||||
def archive(self):
|
||||
@@ -213,21 +241,25 @@ class Importer(object):
|
||||
# check that the as exists in pdb
|
||||
asn = member["asnum"]
|
||||
|
||||
# keep track of asns we find in the ix-f data
|
||||
if asn not in self.asns:
|
||||
self.asns.append(asn)
|
||||
|
||||
if Network.objects.filter(asn=asn).exists():
|
||||
network = Network.objects.get(asn=asn)
|
||||
if network.status != "ok":
|
||||
self.log_peer(
|
||||
asn, "skip",
|
||||
asn, "ignore",
|
||||
_("Network status is '{}'").format(network.status))
|
||||
continue
|
||||
|
||||
self.parse_connections(
|
||||
member.get("connection_list", []), network, member)
|
||||
else:
|
||||
self.log_peer(asn, "skip",
|
||||
self.log_peer(asn, "ignore",
|
||||
_("Network does not exist in peeringdb"))
|
||||
else:
|
||||
self.log_peer(asn, "skip",
|
||||
self.log_peer(asn, "ignore",
|
||||
_("Invalid member type: {}").format(member_type))
|
||||
|
||||
def parse_connections(self, connection_list, network, member):
|
||||
@@ -251,7 +283,7 @@ class Importer(object):
|
||||
connection.get("vlan_list", []), network, member,
|
||||
connection, speed)
|
||||
else:
|
||||
self.log_peer(asn, "skip",
|
||||
self.log_peer(asn, "ignore",
|
||||
_("Invalid connection state: {}").format(state))
|
||||
|
||||
def parse_vlans(self, vlan_list, network, member, connection, speed):
|
||||
@@ -274,7 +306,7 @@ class Importer(object):
|
||||
ipv4 = lan.get("ipv4", {})
|
||||
ipv6 = lan.get("ipv6", {})
|
||||
|
||||
# vlan entry has no ipaddresses set, log and skip
|
||||
# vlan entry has no ipaddresses set, log and ignore
|
||||
if not ipv4 and not ipv6:
|
||||
self.log_error(_("Could not find ipv4 or 6 address in " \
|
||||
"vlan_list entry for vlan_id {} (AS{})").format(
|
||||
@@ -319,16 +351,24 @@ class Importer(object):
|
||||
continue
|
||||
|
||||
|
||||
# if connection state is inactive we won't create or update
|
||||
if connection.get("state", "active") == "inactive":
|
||||
self.log_peer(asn, "noop",
|
||||
_("Connection is currently marked as inactive"),
|
||||
netixlan_info)
|
||||
continue
|
||||
|
||||
|
||||
# after this point we either add or modify the netixlan, so
|
||||
# now is a good time to check if the related network allows
|
||||
# such updates, bail if not
|
||||
if not network.allow_ixp_update:
|
||||
self.log_peer(asn, "skip",
|
||||
self.log_peer(asn, "noop",
|
||||
_("Network has disabled ixp updates"),
|
||||
netixlan_info)
|
||||
continue
|
||||
|
||||
|
||||
# add / modify the netixlan
|
||||
result = self.ixlan.add_netixlan(netixlan_info, save=self.save,
|
||||
save_others=self.save)
|
||||
@@ -344,7 +384,7 @@ class Importer(object):
|
||||
elif result["netixlan"]:
|
||||
self.log_peer(asn, "noop", "", result["netixlan"])
|
||||
elif result["log"]:
|
||||
self.log_peer(asn, "skip", "\n".join(result["log"]),
|
||||
self.log_peer(asn, "ignore", "\n".join(result["log"]),
|
||||
netixlan_info)
|
||||
|
||||
def parse_speed(self, if_list):
|
||||
@@ -386,7 +426,7 @@ class Importer(object):
|
||||
|
||||
Arguments:
|
||||
- asn <int>
|
||||
- action <str>: add | modify | delete | noop | skip
|
||||
- action <str>: add | modify | delete | noop | ignore
|
||||
- reason <str>
|
||||
|
||||
Keyrword Arguments:
|
||||
|
@@ -1239,7 +1239,7 @@ div[data-edit-name=ipaddr6]
|
||||
border-bottom: 1px rgba(0,0,0,0.25) solid;
|
||||
}
|
||||
|
||||
.ixf-skip {
|
||||
.ixf-ignore {
|
||||
background-color: #ffffd7;
|
||||
}
|
||||
|
||||
|
@@ -10,55 +10,133 @@
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Invalid connection state: disabled"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": true,
|
||||
"ipaddr4": "195.69.146.250",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.250",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:2"
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "noop",
|
||||
"reason": "Network has disabled ixp updates"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": true,
|
||||
"ipaddr4": "195.69.147.250",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.250",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:1"
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "noop",
|
||||
"reason": "Network has disabled ixp updates"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.251",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:5"
|
||||
},
|
||||
"action": "noop",
|
||||
"reason": "Network has disabled ixp updates"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.251",
|
||||
"is_rs_peer": true,
|
||||
"speed": 20000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:3"
|
||||
},
|
||||
"action": "noop",
|
||||
"reason": "Connection is currently marked as inactive"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.252",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:4"
|
||||
},
|
||||
"action": "noop",
|
||||
"reason": "Connection is currently marked as inactive"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Invalid member type: other"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": false,
|
||||
"ipaddr4": "195.69.146.249",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.249",
|
||||
"is_rs_peer": false,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": ""
|
||||
},
|
||||
"action": "delete",
|
||||
"reason": "Ip addresses no longer in data"
|
||||
"reason": "Ip addresses no longer exist in validated data or are no longer with this asn"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.251",
|
||||
"is_rs_peer": false,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": ""
|
||||
},
|
||||
"action": "delete",
|
||||
"reason": "At least one ipaddress mismatched and network has disabled upates"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.251",
|
||||
"is_rs_peer": false,
|
||||
"speed": 20000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": ""
|
||||
},
|
||||
"action": "delete",
|
||||
"reason": "At least one ipaddress mismatched and network has disabled upates"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.252",
|
||||
"is_rs_peer": false,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 1002,
|
||||
"ipaddr6": ""
|
||||
},
|
||||
"action": "delete",
|
||||
"reason": "ASN no longer in data"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -10,41 +10,80 @@
|
||||
"ixlan_id": 2,
|
||||
"asn": 2906
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Invalid connection state: disabled"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": true,
|
||||
"ipaddr4": "195.69.146.250",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.250",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 2,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:2"
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Ip addresses (195.69.146.250, 2001:7f8:1::a500:2906:2) do not match any prefix on this ixlan"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": true,
|
||||
"ipaddr4": "195.69.147.250",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.250",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 2,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:1"
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Ip addresses (195.69.147.250, 2001:7f8:1::a500:2906:1) do not match any prefix on this ixlan"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.251",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 2,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:5"
|
||||
},
|
||||
"action": "ignore",
|
||||
"reason": "Ip addresses (195.69.147.251, 2001:7f8:1::a500:2906:5) do not match any prefix on this ixlan"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.251",
|
||||
"is_rs_peer": true,
|
||||
"speed": 20000,
|
||||
"ixlan_id": 2,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:3"
|
||||
},
|
||||
"action": "noop",
|
||||
"reason": "Connection is currently marked as inactive"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.252",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 2,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:4"
|
||||
},
|
||||
"action": "noop",
|
||||
"reason": "Connection is currently marked as inactive"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"ixlan_id": 2,
|
||||
"asn": 2906
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Invalid member type: other"
|
||||
}
|
||||
]
|
||||
|
@@ -10,14 +10,14 @@
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Invalid connection state: disabled"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": true,
|
||||
"ipaddr4": "195.69.146.250",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.250",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
@@ -28,9 +28,9 @@
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": true,
|
||||
"ipaddr4": "195.69.147.250",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.250",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
@@ -39,26 +39,78 @@
|
||||
"action": "add",
|
||||
"reason": ""
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.251",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:5"
|
||||
},
|
||||
"action": "modify",
|
||||
"reason": ""
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.251",
|
||||
"is_rs_peer": true,
|
||||
"speed": 20000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:3"
|
||||
},
|
||||
"action": "noop",
|
||||
"reason": "Connection is currently marked as inactive"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.252",
|
||||
"is_rs_peer": true,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": "2001:7f8:1::a500:2906:4"
|
||||
},
|
||||
"action": "noop",
|
||||
"reason": "Connection is currently marked as inactive"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906
|
||||
},
|
||||
"action": "skip",
|
||||
"action": "ignore",
|
||||
"reason": "Invalid member type: other"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"is_rs_peer": false,
|
||||
"ipaddr4": "195.69.146.249",
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.146.249",
|
||||
"is_rs_peer": false,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 2906,
|
||||
"ipaddr6": ""
|
||||
},
|
||||
"action": "delete",
|
||||
"reason": "Ip addresses no longer in data"
|
||||
"reason": "Ip addresses no longer exist in validated data or are no longer with this asn"
|
||||
},
|
||||
{
|
||||
"peer": {
|
||||
"net_id": 1,
|
||||
"ipaddr4": "195.69.147.252",
|
||||
"is_rs_peer": false,
|
||||
"speed": 10000,
|
||||
"ixlan_id": 1,
|
||||
"asn": 1002,
|
||||
"ipaddr6": ""
|
||||
},
|
||||
"action": "delete",
|
||||
"reason": "ASN no longer in data"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -1,8 +1,11 @@
|
||||
{
|
||||
"timestamp": "2017-10-26T08:04:29Z",
|
||||
"timestamp": "2019-04-18T07:24:59Z",
|
||||
"version": "0.6",
|
||||
"ixp_list":[
|
||||
{ "ixp_id" : 1, "shortname" : "Test Exchange" }
|
||||
"ixp_list": [
|
||||
{
|
||||
"shortname": "Test Exchange",
|
||||
"ixp_id": 1
|
||||
}
|
||||
],
|
||||
"member_list": [
|
||||
{
|
||||
@@ -11,6 +14,50 @@
|
||||
"url": "http://netflix.com/",
|
||||
"member_type": "peering",
|
||||
"connection_list": [
|
||||
{
|
||||
"state": "active",
|
||||
"if_list": [
|
||||
{
|
||||
"if_speed": 10000
|
||||
}
|
||||
],
|
||||
"ixp_id": 1,
|
||||
"vlan_list": [
|
||||
{
|
||||
"ipv4": {
|
||||
"as_macro": "AS-NFLX",
|
||||
"address": "195.69.146.251",
|
||||
"routeserver": false,
|
||||
"max_prefix": 42
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"state": "active",
|
||||
"if_list": [
|
||||
{
|
||||
"if_speed": 10000
|
||||
}
|
||||
],
|
||||
"ixp_id": 1,
|
||||
"vlan_list": [
|
||||
{
|
||||
"ipv4": {
|
||||
"as_macro": "AS-NFLX",
|
||||
"address": "195.69.147.251",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42
|
||||
},
|
||||
"ipv6": {
|
||||
"as_macro": "AS-NFLX",
|
||||
"address": "2001:7f8:1::a500:2906:5",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"state": "active",
|
||||
"if_list": [
|
||||
@@ -48,13 +95,13 @@
|
||||
{
|
||||
"ipv4": {
|
||||
"as_macro": "AS-NFLX",
|
||||
"address": "195.69.146.250",
|
||||
"address": "195.69.147.250",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42
|
||||
},
|
||||
"ipv6": {
|
||||
"as_macro": "AS-NFLX",
|
||||
"address": "2001:7f8:1::a500:2906:2",
|
||||
"address": "2001:7f8:1::a500:2906:1",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42
|
||||
}
|
||||
|
@@ -93,6 +93,98 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "active",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 10000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"mac_address" : "00:0a:95:9d:68:16",
|
||||
"ipv4": {
|
||||
"address": "195.69.147.251",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4"
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:5",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "inactive",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 20000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"mac_address" : "00:0a:95:9d:68:16",
|
||||
"ipv4": {
|
||||
"address": "195.69.146.251",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4"
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:3",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "inactive",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 10000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"mac_address" : "00:0a:95:9d:68:16",
|
||||
"ipv4": {
|
||||
"address": "195.69.146.252",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4"
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:4",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -93,9 +93,102 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "active",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 10000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"mac_address" : "00:0a:95:9d:68:16",
|
||||
"ipv4": {
|
||||
"address": "195.69.147.251",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4"
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:5",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "inactive",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 20000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"mac_address" : "00:0a:95:9d:68:16",
|
||||
"ipv4": {
|
||||
"address": "195.69.146.251",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4"
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:3",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "inactive",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 10000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"mac_address" : "00:0a:95:9d:68:16",
|
||||
"ipv4": {
|
||||
"address": "195.69.146.252",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4"
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:4",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"member_type": "other"
|
||||
}
|
||||
|
@@ -103,6 +103,113 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "active",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 10000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"ipv4": {
|
||||
"address": "195.69.147.251",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4",
|
||||
"mac_address" : [
|
||||
"00:0a:95:9d:68:16"
|
||||
]
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:5",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6",
|
||||
"mac_address" : [
|
||||
"00:0a:95:9d:68:16"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "inactive",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 20000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"ipv4": {
|
||||
"address": "195.69.146.251",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4",
|
||||
"mac_address" : [
|
||||
"00:0a:95:9d:68:16"
|
||||
]
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:3",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6",
|
||||
"mac_address" : [
|
||||
"00:0a:95:9d:68:16"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"ixp_id": 42,
|
||||
"connected_since": "2009-02-04T00:00:00Z",
|
||||
"state": "inactive",
|
||||
"if_list": [
|
||||
{
|
||||
"switch_id": 1,
|
||||
"if_speed": 10000,
|
||||
"if_type": "LR4"
|
||||
}
|
||||
],
|
||||
"vlan_list": [
|
||||
{
|
||||
"vlan_id": 0,
|
||||
"ipv4": {
|
||||
"address": "195.69.146.252",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V4",
|
||||
"mac_address" : [
|
||||
"00:0a:95:9d:68:16"
|
||||
]
|
||||
},
|
||||
"ipv6": {
|
||||
"address": "2001:7f8:1::a500:2906:4",
|
||||
"routeserver": true,
|
||||
"max_prefix": 42,
|
||||
"as_macro": "AS-NFLX-V6",
|
||||
"mac_address" : [
|
||||
"00:0a:95:9d:68:16"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -112,6 +112,18 @@ class JsonMembersListTestCase(TestCase):
|
||||
network=cls.entities["net"][0],
|
||||
ixlan=cls.entities["ixlan"][0], asn=2906, speed=10000,
|
||||
ipaddr4="195.69.146.249", ipaddr6=None, status="ok"),
|
||||
NetworkIXLan.objects.create(
|
||||
network=cls.entities["net"][0],
|
||||
ixlan=cls.entities["ixlan"][0], asn=2906, speed=10000,
|
||||
ipaddr4="195.69.146.251", ipaddr6=None, status="ok"),
|
||||
NetworkIXLan.objects.create(
|
||||
network=cls.entities["net"][0],
|
||||
ixlan=cls.entities["ixlan"][0], asn=2906, speed=20000, is_rs_peer=False,
|
||||
ipaddr4="195.69.147.251", ipaddr6=None, status="ok"),
|
||||
NetworkIXLan.objects.create(
|
||||
network=cls.entities["net"][0],
|
||||
ixlan=cls.entities["ixlan"][0], asn=1002, speed=10000,
|
||||
ipaddr4="195.69.147.252", ipaddr6=None, status="ok"),
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
@@ -129,12 +141,12 @@ class JsonMembersListTestCase(TestCase):
|
||||
self.assertEqual(unicode(n_deleted.ipaddr4), u'195.69.146.250')
|
||||
self.assertEqual(
|
||||
unicode(n_deleted2.ipaddr6), u'2001:7f8:1::a500:2906:1')
|
||||
self.assertEqual(ixlan.netixlan_set_active.count(), 1)
|
||||
self.assertEqual(ixlan.netixlan_set_active.count(), 4)
|
||||
r, netixlans, netixlans_deleted, log = self.ixf_importer.update(ixlan, data=self.json_data)
|
||||
|
||||
self.assertLog(log, "update_01")
|
||||
self.assertEqual(len(netixlans), 2)
|
||||
self.assertEqual(len(netixlans_deleted), 1)
|
||||
self.assertEqual(len(netixlans), 3)
|
||||
self.assertEqual(len(netixlans_deleted), 2)
|
||||
|
||||
n = netixlans[0]
|
||||
self.assertEqual(unicode(n.ipaddr4), u"195.69.146.250")
|
||||
@@ -152,6 +164,11 @@ class JsonMembersListTestCase(TestCase):
|
||||
self.assertEqual(n2.ixlan, ixlan)
|
||||
self.assertEqual(n.asn, 2906)
|
||||
|
||||
# test that inactive connections had no effect
|
||||
self.assertEqual(NetworkIXLan.objects.filter(ipaddr4="195.69.146.251", speed=10000, status="ok").count(), 1)
|
||||
self.assertEqual(NetworkIXLan.objects.filter(ipaddr4="195.69.146.252").count(), 0)
|
||||
|
||||
|
||||
#self.assertEqual(IXLan.objects.get(id=ixlan.id).netixlan_set_active.count(), 2)
|
||||
|
||||
#FIXME: this is not practical until
|
||||
@@ -196,6 +213,7 @@ class JsonMembersListTestCase(TestCase):
|
||||
network.save()
|
||||
r, netixlans, netixlans_deleted, log = self.ixf_importer.update(ixlan, data=self.json_data)
|
||||
|
||||
print(json.dumps(log, indent=2))
|
||||
self.assertLog(log, "skip_disabled_networks")
|
||||
self.assertEqual(len(netixlans), 0)
|
||||
|
||||
@@ -212,7 +230,17 @@ class JsonMembersListTestCase(TestCase):
|
||||
for netixlan in netixlans:
|
||||
log_entry = ixlan.ixf_import_log_set.last().entries.get(
|
||||
netixlan=netixlan)
|
||||
self.assertEqual(log_entry.version_before, None)
|
||||
|
||||
if netixlan.id == self.entities["netixlan"][4].id:
|
||||
# netixlan was modified
|
||||
self.assertEqual(
|
||||
log_entry.version_before,
|
||||
reversion.models.Version.objects.get_for_object(netixlan)[1])
|
||||
else:
|
||||
# netixlan was added
|
||||
self.assertEqual(
|
||||
log_entry.version_before, None)
|
||||
|
||||
self.assertEqual(
|
||||
log_entry.version_after,
|
||||
reversion.models.Version.objects.get_for_object(netixlan)[0])
|
||||
@@ -274,7 +302,7 @@ class JsonMembersListTestCase(TestCase):
|
||||
ixlan = self.entities["ixlan"][0]
|
||||
r, netixlans, netixlans_deleted, log = self.ixf_importer.update(ixlan, data=self.json_data)
|
||||
|
||||
self.assertEqual(len(netixlans_deleted), 1)
|
||||
self.assertEqual(len(netixlans_deleted), 2)
|
||||
|
||||
netixlan = netixlans_deleted[0]
|
||||
other = NetworkIXLan.objects.create(
|
||||
@@ -310,6 +338,7 @@ class JsonMembersListTestCase(TestCase):
|
||||
resp = c.get("/export/ixlan/{}/ixp-member-list".format(ixlan.id))
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
data = json.loads(resp.content)
|
||||
print(json.dumps(data, indent=2))
|
||||
with open(
|
||||
os.path.join(
|
||||
os.path.dirname(__file__), "data", "json_members_list",
|
||||
|
Reference in New Issue
Block a user