Skip to content

Commit

Permalink
Do not split AS-SET for the two IP versions.
Browse files Browse the repository at this point in the history
Consider IRR AS-SET as a single field. This is work in progress until
we actually know how we are going to handle all cases for the field.

This work is tracked in issue #1.
  • Loading branch information
gmazoyer committed Dec 26, 2017
1 parent 41cedf9 commit 40d337a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 30 deletions.
14 changes: 6 additions & 8 deletions peering/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ class AutonomousSystemForm(BootstrapMixin, forms.ModelForm):

class Meta:
model = AutonomousSystem
fields = ('asn', 'name', 'ipv6_as_set', 'ipv4_as_set',
'ipv6_max_prefixes', 'ipv4_max_prefixes', 'comment',)
fields = ('asn', 'name', 'irr_as_set', 'ipv6_max_prefixes',
'ipv4_max_prefixes', 'comment',)
labels = {
'asn': 'ASN',
'ipv6_as_set': 'IPv6 AS-SET',
'ipv4_as_set': 'IPv4 AS-SET',
'irr_as_set': 'IRR AS-SET',
'ipv6_max_prefixes': 'IPv6 Max Prefixes',
'ipv4_max_prefixes': 'IPv4 Max Prefixes',
'comment': 'Comments',
Expand All @@ -63,12 +62,11 @@ class AutonomousSystemCSVForm(forms.ModelForm):
class Meta:
model = AutonomousSystem

fields = ('asn', 'name', 'ipv6_as_set', 'ipv4_as_set',
'ipv6_max_prefixes', 'ipv4_max_prefixes', 'comment',)
fields = ('asn', 'name', 'irr_as_set', 'ipv6_max_prefixes',
'ipv4_max_prefixes', 'comment',)
labels = {
'asn': 'ASN',
'ipv6_as_set': 'IPv6 AS-SET',
'ipv4_as_set': 'IPv4 AS-SET',
'irr_as_set': 'IRR AS-SET',
'ipv6_max_prefixes': 'IPv6 Max Prefixes',
'ipv4_max_prefixes': 'IPv4 Max Prefixes',
'comment': 'Comments',
Expand Down
28 changes: 28 additions & 0 deletions peering/migrations/0009_auto_20171226_1550.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2017-12-26 14:50
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('peering', '0008_auto_20171212_2251'),
]

operations = [
migrations.RemoveField(
model_name='autonomoussystem',
name='ipv4_as_set',
),
migrations.RemoveField(
model_name='autonomoussystem',
name='ipv6_as_set',
),
migrations.AddField(
model_name='autonomoussystem',
name='irr_as_set',
field=models.CharField(blank=True, max_length=255, null=True),
),
]
3 changes: 1 addition & 2 deletions peering/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class AutonomousSystem(models.Model):
asn = ASNField()
name = models.CharField(max_length=128)
comment = models.TextField(blank=True)
ipv6_as_set = models.CharField(max_length=128, blank=True, null=True)
ipv4_as_set = models.CharField(max_length=128, blank=True, null=True)
irr_as_set = models.CharField(max_length=255, blank=True, null=True)
ipv6_max_prefixes = models.PositiveIntegerField(blank=True, null=True)
ipv4_max_prefixes = models.PositiveIntegerField(blank=True, null=True)
updated = models.DateTimeField(auto_now=True)
Expand Down
14 changes: 7 additions & 7 deletions peering/peeringdb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import unicode_literals

import json
import logging
import requests

from django.conf import settings
Expand Down Expand Up @@ -39,6 +40,7 @@ class PeeringDB(object):
This will probably be modified or even deleted when we will start using the
existing library.
"""
logger = logging.getLogger('peering.manager.peeringdb')

def lookup(self, namespace, search):
"""
Expand All @@ -52,13 +54,11 @@ def lookup(self, namespace, search):
search['depth'] = 1

# Make the request
self.logger.debug('Calling PeeringDB API: {url} | {params}'.format(
url=api_url, params=search))
response = requests.get(api_url, params=search)

# If not OK just give us none
if response.status_code != 200:
return None

return response.json()
return response.json() if response.status_code == 200 else None

def get_autonomous_system(self, asn):
search = {'asn': asn}
Expand Down Expand Up @@ -94,7 +94,7 @@ def get_ix_networks_for_asn(self, asn):
return ix_networks

def get_peers_for_ix(self, ix_id):
search = {'ix_id': ix_id, 'depth': 0}
search = {'ix_id': ix_id, 'limit': settings.PAGINATE_COUNT, 'skip': 10}
result = self.lookup(
NAMESPACES['network_internet_exchange_lan'], search)

Expand All @@ -116,7 +116,7 @@ def get_peers_for_ix(self, ix_id):
peers.append({
'asn': peer.asn,
'name': network.name,
'as_set': network.irr_as_set,
'irr_as_set': network.irr_as_set,
'ipv6_max_prefixes': network.info_prefixes6,
'ipv4_max_prefixes': network.info_prefixes4,
'ipv6_address': peer.ipaddr6,
Expand Down
9 changes: 4 additions & 5 deletions peering/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ class AutonomousSystemTable(BaseTable):
"""

asn = tables.Column(verbose_name='ASN')
ipv6_as_set = tables.Column(verbose_name='IPv6 AS-SET', orderable=False)
ipv4_as_set = tables.Column(verbose_name='IPv4 AS-SET', orderable=False)
irr_as_set = tables.Column(verbose_name='IRR AS-SET', orderable=False)
ipv6_max_prefixes = tables.Column(verbose_name='IPv6 Max Prefixes')
ipv4_max_prefixes = tables.Column(verbose_name='IPv4 Max Prefixes')
details = tables.TemplateColumn(verbose_name=' ',
template_code='<div class="pull-right"><a href="{% url \'peering:as_details\' asn=record.asn %}" class="btn btn-xs btn-info"><span class="fa fa-info-circle" aria-hidden="true"></span> Details</a></div>', orderable=False)

class Meta(BaseTable.Meta):
model = AutonomousSystem
fields = ('asn', 'name', 'ipv6_as_set', 'ipv4_as_set',
'ipv6_max_prefixes', 'ipv4_max_prefixes', 'details',)
fields = ('asn', 'name', 'irr_as_set', 'ipv6_max_prefixes',
'ipv4_max_prefixes', 'details',)


class CommunityTable(BaseTable):
Expand Down Expand Up @@ -118,7 +117,7 @@ class PeerTable(BaseTable):
ipv4_max_prefixes = tables.Column(
verbose_name='IPv4 Max Prefixes', orderable=False)
ipv6_address = tables.Column(verbose_name='IPv6 Address', orderable=False)
ipv4_address = tables.Column(verbose_name='IPv6 Address', orderable=False)
ipv4_address = tables.Column(verbose_name='IPv4 Address', orderable=False)

class Meta(BaseTable.Meta):
model = AutonomousSystem
Expand Down
17 changes: 17 additions & 0 deletions peering_manager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@
]


# Django logging
LOGGING = {
'version': 1,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'peering.manager.peeringdb': {
'handlers': ['console'],
'level': 'DEBUG',
}
}
}


# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
Expand Down
3 changes: 1 addition & 2 deletions templates/peering/as/add_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<div class="panel-body">
{% render_field form.asn %}
{% render_field form.name %}
{% render_field form.ipv6_as_set %}
{% render_field form.ipv4_as_set %}
{% render_field form.irr_as_set %}
{% render_field form.ipv6_max_prefixes %}
{% render_field form.ipv4_max_prefixes %}
</div>
Expand Down
8 changes: 2 additions & 6 deletions templates/peering/as/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ <h1>{% block title %}{{ autonomous_system }}{% endblock %}</h1>
<td>{{ autonomous_system.name }}</td>
</tr>
<tr>
<td>IPv6 AS-SET</td>
<td>{{ autonomous_system.ipv6_as_set }}</td>
</tr>
<tr>
<td>IPv4 AS-SET</td>
<td>{{ autonomous_system.ipv4_as_set }}</td>
<td>IRR AS-SET</td>
<td>{{ autonomous_system.irr_as_set }}</td>
</tr>
<tr>
<td>IPv6 Max Prefixes</td>
Expand Down

0 comments on commit 40d337a

Please sign in to comment.