netbox-ddns 1.3.0__py3-none-any.whl → 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. netbox_ddns/__init__.py +2 -2
  2. netbox_ddns/admin.py +0 -156
  3. netbox_ddns/api/__init__.py +0 -0
  4. netbox_ddns/api/serializers.py +35 -0
  5. netbox_ddns/api/urls.py +10 -0
  6. netbox_ddns/api/views.py +11 -0
  7. netbox_ddns/filtersets.py +30 -0
  8. netbox_ddns/forms.py +54 -3
  9. netbox_ddns/migrations/0009_alter_dnsstatus_id_alter_extradnsname_id_and_more.py +38 -0
  10. netbox_ddns/migrations/0010_extradnsname_created_extradnsname_custom_field_data_and_more.py +36 -0
  11. netbox_ddns/migrations/0011_server_created_server_custom_field_data_and_more.py +36 -0
  12. netbox_ddns/migrations/0012_zone_created_zone_custom_field_data_and_more.py +36 -0
  13. netbox_ddns/migrations/0013_reversezone_created_reversezone_custom_field_data_and_more.py +36 -0
  14. netbox_ddns/models.py +54 -14
  15. netbox_ddns/navigation.py +58 -0
  16. netbox_ddns/search.py +10 -0
  17. netbox_ddns/tables.py +34 -33
  18. netbox_ddns/template_content.py +31 -3
  19. netbox_ddns/templates/netbox_ddns/extradnsname.html +61 -0
  20. netbox_ddns/templates/netbox_ddns/ipaddress/dns_extra.html +2 -2
  21. netbox_ddns/templates/netbox_ddns/ipaddress/dns_refresh_button.html +1 -1
  22. netbox_ddns/templates/netbox_ddns/reversezone.html +51 -0
  23. netbox_ddns/templates/netbox_ddns/server.html +68 -0
  24. netbox_ddns/templates/netbox_ddns/update_reverse_zone.html +11 -0
  25. netbox_ddns/templates/netbox_ddns/update_zone.html +11 -0
  26. netbox_ddns/templates/netbox_ddns/zone.html +53 -0
  27. netbox_ddns/urls.py +26 -10
  28. netbox_ddns/views.py +255 -48
  29. {netbox_ddns-1.3.0.dist-info → netbox_ddns-1.5.0.dist-info}/METADATA +2 -2
  30. netbox_ddns-1.5.0.dist-info/RECORD +47 -0
  31. {netbox_ddns-1.3.0.dist-info → netbox_ddns-1.5.0.dist-info}/WHEEL +1 -1
  32. netbox_ddns-1.3.0.dist-info/RECORD +0 -29
  33. {netbox_ddns-1.3.0.dist-info → netbox_ddns-1.5.0.dist-info}/LICENSE.txt +0 -0
  34. {netbox_ddns-1.3.0.dist-info → netbox_ddns-1.5.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,58 @@
1
+ from netbox.plugins import PluginMenuItem, PluginMenuButton, PluginMenu
2
+
3
+ menu = PluginMenu(
4
+ label='DDNS',
5
+ groups=(
6
+ ('Configuration', (
7
+ PluginMenuItem(
8
+ link='plugins:netbox_ddns:server_list',
9
+ link_text='DDNS Servers',
10
+ buttons=[
11
+ PluginMenuButton(
12
+ link='plugins:netbox_ddns:server_add',
13
+ title='Add',
14
+ icon_class='mdi mdi-plus-thick',
15
+ )
16
+ ]
17
+ ),
18
+ PluginMenuItem(
19
+ link='plugins:netbox_ddns:zone_list',
20
+ link_text='Forward Zones',
21
+ buttons=[
22
+ PluginMenuButton(
23
+ link='plugins:netbox_ddns:zone_add',
24
+ title='Add',
25
+ icon_class='mdi mdi-plus-thick',
26
+ )
27
+ ]
28
+ ),
29
+ PluginMenuItem(
30
+ link='plugins:netbox_ddns:reversezone_list',
31
+ link_text='Reverse Zones',
32
+ buttons=[
33
+ PluginMenuButton(
34
+ link='plugins:netbox_ddns:reversezone_add',
35
+ title='Add',
36
+ icon_class='mdi mdi-plus-thick',
37
+ )
38
+ ]
39
+ ),
40
+ ),
41
+ ),
42
+ ('Extra DNS Names', (
43
+ PluginMenuItem(
44
+ link='plugins:netbox_ddns:extradnsname_list',
45
+ link_text='Extra DNS names',
46
+ buttons=[
47
+ PluginMenuButton(
48
+ link='plugins:netbox_ddns:extradnsname_add',
49
+ title='Add',
50
+ icon_class='mdi mdi-plus-thick',
51
+ )
52
+ ]
53
+ ),
54
+ ),
55
+ ),
56
+ ),
57
+ icon_class='mdi mdi-router'
58
+ )
netbox_ddns/search.py ADDED
@@ -0,0 +1,10 @@
1
+ from netbox.search import SearchIndex, register_search
2
+ from .models import ExtraDNSName
3
+
4
+
5
+ @register_search
6
+ class AccessListIndex(SearchIndex):
7
+ model = ExtraDNSName
8
+ fields = (
9
+ ('name', 100),
10
+ )
netbox_ddns/tables.py CHANGED
@@ -1,13 +1,9 @@
1
1
  import django_tables2 as tables
2
+ from django_tables2 import LinkColumn, RelatedLinkColumn
2
3
 
3
- from netbox_ddns.models import ExtraDNSName
4
- try:
5
- # NetBox >= 3.2.0
6
- from netbox.tables import BaseTable
7
- from netbox.tables.columns import ToggleColumn, DateTimeColumn
8
- except ImportError:
9
- # NetBox < 3.2.0
10
- from utilities.tables import BaseTable, ToggleColumn, DateTimeColumn
4
+ from netbox_ddns.models import ExtraDNSName, Server, ReverseZone, Zone
5
+
6
+ from netbox.tables import NetBoxTable
11
7
 
12
8
  FORWARD_DNS = """
13
9
  {% if record.forward_action is not None %}
@@ -18,33 +14,38 @@ FORWARD_DNS = """
18
14
  {% endif %}
19
15
  """
20
16
 
21
- ACTIONS = """
22
- {% if perms.netbox_ddns.change_extradnsname %}
23
- <a href="{% url 'plugins:netbox_ddns:extradnsname_edit' ipaddress_pk=record.ip_address.pk pk=record.pk %}"
24
- class="btn btn-sm btn-warning">
25
- <i class="mdi mdi-pencil" aria-hidden="true"></i>
26
- </a>
27
- {% endif %}
28
- {% if perms.netbox_ddns.delete_extradnsname %}
29
- <a href="{% url 'plugins:netbox_ddns:extradnsname_delete' ipaddress_pk=record.ip_address.pk pk=record.pk %}"
30
- class="btn btn-sm btn-danger">
31
- <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i>
32
- </a>
33
- {% endif %}
34
- """
17
+
18
+ class ReverseZoneTable(NetBoxTable):
19
+ name = LinkColumn()
20
+ server = RelatedLinkColumn()
21
+
22
+ class Meta(NetBoxTable.Meta):
23
+ model = ReverseZone
24
+ fields = ("id", "name", "prefix", "server", "ttl")
25
+
26
+
27
+ class ZoneTable(NetBoxTable):
28
+ name = LinkColumn()
29
+ server = RelatedLinkColumn()
30
+
31
+ class Meta(NetBoxTable.Meta):
32
+ model = Zone
33
+ fields = ("id", "name", "server", "ttl")
34
+
35
+
36
+ class ServerTable(NetBoxTable):
37
+ server = LinkColumn()
38
+
39
+ class Meta(NetBoxTable.Meta):
40
+ model = Server
41
+ fields = ("id", "server", "server_port", "tsig_key_name", "tsig_algorithm")
35
42
 
36
43
 
37
- class PrefixTable(BaseTable):
38
- pk = ToggleColumn()
39
- name = tables.Column()
40
- last_update = DateTimeColumn()
44
+ class ExtraDNSNameTable(NetBoxTable):
45
+ ip_address = RelatedLinkColumn()
46
+ name = LinkColumn()
41
47
  forward_dns = tables.TemplateColumn(template_code=FORWARD_DNS)
42
- actions = tables.TemplateColumn(
43
- template_code=ACTIONS,
44
- attrs={'td': {'class': 'text-right text-nowrap noprint'}},
45
- verbose_name=''
46
- )
47
48
 
48
- class Meta(BaseTable.Meta):
49
+ class Meta(NetBoxTable.Meta):
49
50
  model = ExtraDNSName
50
- fields = ('pk', 'name', 'last_update', 'forward_dns', 'actions')
51
+ fields = ('id', 'name', 'ip_address', 'last_update', 'forward_dns')
@@ -5,7 +5,34 @@ from netbox.plugins.templates import PluginTemplateExtension
5
5
  from . import tables
6
6
 
7
7
 
8
- # noinspection PyAbstractClass
8
+ class ReverseZoneRecreate(PluginTemplateExtension):
9
+ model = 'netbox_ddns.reversezone'
10
+
11
+ def buttons(self):
12
+ """
13
+ A button to force DNS re-provisioning
14
+ """
15
+ context = {
16
+ 'perms': PermWrapper(self.context['request'].user),
17
+ }
18
+ context.update(csrf(self.context['request']))
19
+ return self.render('netbox_ddns/update_reverse_zone.html', context)
20
+
21
+
22
+ class ZoneRecreate(PluginTemplateExtension):
23
+ model = 'netbox_ddns.zone'
24
+
25
+ def buttons(self):
26
+ """
27
+ A button to force DNS re-provisioning
28
+ """
29
+ context = {
30
+ 'perms': PermWrapper(self.context['request'].user),
31
+ }
32
+ context.update(csrf(self.context['request']))
33
+ return self.render('netbox_ddns/update_zone.html', context)
34
+
35
+
9
36
  class DNSInfo(PluginTemplateExtension):
10
37
  model = 'ipam.ipaddress'
11
38
 
@@ -23,7 +50,8 @@ class DNSInfo(PluginTemplateExtension):
23
50
  """
24
51
  An info-box with the status of the DNS modifications and records
25
52
  """
26
- extra_dns_name_table = tables.PrefixTable(list(self.context['object'].extradnsname_set.all()), orderable=False)
53
+ extra_dns_name_table = tables.ExtraDNSNameTable(list(self.context['object'].extradnsname_set.all()),
54
+ exclude=["id", "ip_address"], orderable=False)
27
55
 
28
56
  return (
29
57
  self.render('netbox_ddns/ipaddress/dns_info.html') +
@@ -34,4 +62,4 @@ class DNSInfo(PluginTemplateExtension):
34
62
  )
35
63
 
36
64
 
37
- template_extensions = [DNSInfo]
65
+ template_extensions = [DNSInfo, ZoneRecreate, ReverseZoneRecreate]
@@ -0,0 +1,61 @@
1
+ {% extends 'generic/object.html' %}
2
+ {% load render_table from django_tables2 %}
3
+
4
+ {% block content %}
5
+ <div class="row mb-3">
6
+ <div class="col col-md-6">
7
+ <div class="card">
8
+ <h5 class="card-header">Extra DNS name</h5>
9
+ <div class="card-body">
10
+ <table class="table table-hover attr-table">
11
+ <tr>
12
+ <th scope="row">Name</th>
13
+ <td>{{ object.name }}</td>
14
+ </tr>
15
+ <tr>
16
+ <th scope="row">IP Address</th>
17
+ <td>
18
+ <a href="{{ object.ip_address.get_absolute_url }}">{{ object.ip_address }}</a>
19
+ </td>
20
+ </tr>
21
+ <tr>
22
+ <th scope="row">Last update</th>
23
+ <td>{{ object.last_update|isodatetime }}</td>
24
+ </tr>
25
+ <tr>
26
+ <th scope="row">Forward DNS</th>
27
+ <td>
28
+ {% if object.forward_action is not None %}
29
+ {{ object.get_forward_action_display }}:
30
+ {{ object.get_forward_rcode_html_display }} {% else %}
31
+ <span class="text-muted">Not created</span>
32
+ {% endif %}
33
+ </td>
34
+ </tr>
35
+ </table>
36
+ </div>
37
+ </div>
38
+ <div class="card">
39
+ <h5 class="card-header">Managed by</h5>
40
+ <div class="card-body">
41
+ <table class="table table-hover attr-table">
42
+ <tr>
43
+ <th scope="row">DDNS Server</th>
44
+ <td>
45
+ <a href="{{ server.get_absolute_url }}">{{ server }}</a>
46
+ </td>
47
+ </tr>
48
+ <tr>
49
+ <th scope="row">Zone</th>
50
+ <td>
51
+ <a href="{{ zone.get_absolute_url }}">{{ zone }}</a>
52
+ </td>
53
+ </tr>
54
+ </table>
55
+ </div>
56
+ </div>
57
+ {% include 'inc/panels/custom_fields.html' %}
58
+ </div>
59
+ <div class="col col-md-6">{% include 'inc/panels/tags.html' %}</div>
60
+ </div>
61
+ {% endblock content %}
@@ -10,8 +10,8 @@
10
10
 
11
11
  {% if perms.netbox_ddns.add_extradnsname %}
12
12
  <div class="card-footer text-right noprint">
13
- <a href="{% url 'plugins:netbox_ddns:extradnsname_create' ipaddress_pk=object.pk %}"
14
- class="btn btn-sm btn-primary">
13
+ <a href="{% url 'plugins:netbox_ddns:extradnsname_ip_address_create' ipaddress_pk=object.pk %}"
14
+ class="btn btn-primary">
15
15
  <span class="mdi mdi-plus" aria-hidden="true"></span>Add extra DNS name
16
16
  </a>
17
17
  </div>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <button type="submit" name="_edit"
6
6
  formaction="{% url 'plugins:netbox_ddns:ipaddress_dnsname_recreate' ipaddress_pk=object.pk %}"
7
- class="btn btn-sm btn-secondary">
7
+ class="btn btn-secondary">
8
8
  <span class="mdi mdi-refresh" aria-hidden="true"></span> Recreate DNS
9
9
  </button>
10
10
  </form>
@@ -0,0 +1,51 @@
1
+ {% extends 'generic/object.html' %}
2
+ {% load render_table from django_tables2 %}
3
+
4
+ {% block content %}
5
+ <div class="row">
6
+ <div class="col col-md-6">
7
+ <div class="card">
8
+ <h2 class="card-header">Reverse Zone</h2>
9
+ <table class="table table-hover attr-table">
10
+ <tr>
11
+ <th scope="row">Name</th>
12
+ <td>
13
+ {{ object.name }}
14
+ </td>
15
+ </tr>
16
+ <tr>
17
+ <th scope="row">Prefix</th>
18
+ <td>
19
+ {{ object.prefix }}
20
+ </td>
21
+ </tr>
22
+ <tr>
23
+ <th scope="row">TTL</th>
24
+ <td>
25
+ {{ object.ttl }}
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <th scope="row">Server</th>
30
+ <td>
31
+ <a href="{{ object.server.get_absolute_url }}">
32
+ {{ object.server }}
33
+ </a>
34
+ </td>
35
+ </tr>
36
+ </table>
37
+ </div>
38
+ <div class="card">
39
+ <div class="justify-content-between card-header">
40
+ <h1 class="card-title">IP Addresses</h1>
41
+ </div>
42
+ <div class="card-body table-responsive">
43
+ {% render_table ip_address_table %}
44
+ </div>
45
+ </div>
46
+ {% include 'inc/panels/custom_fields.html' %}
47
+ {% include 'inc/panels/tags.html' %}
48
+ </div>
49
+ </div>
50
+
51
+ {% endblock content %}
@@ -0,0 +1,68 @@
1
+ {% extends 'generic/object.html' %}
2
+ {% load render_table from django_tables2 %}
3
+
4
+ {% block content %}
5
+ <div class="row">
6
+ <div class="col col-md-6">
7
+ <div class="card">
8
+ <h2 class="card-header">Configuration</h2>
9
+ <table class="table table-hover attr-table">
10
+ <tr>
11
+ <th scope="row">Server</th>
12
+ <td>
13
+ {{ object.server }}
14
+ </td>
15
+ </tr>
16
+ <tr>
17
+ <th scope="row">Server port</th>
18
+ <td>
19
+ {{ object.server_port }}
20
+ </td>
21
+ </tr>
22
+ </table>
23
+ </div>
24
+ <div class="card">
25
+ <h2 class="card-header">Authentication</h2>
26
+ <table class="table table-hover attr-table">
27
+ <tr>
28
+ <th scope="row">Name</th>
29
+ <td>
30
+ {{ object.tsig_key_name }}
31
+ </td>
32
+ </tr>
33
+ <tr>
34
+ <th scope="row">Algorithm</th>
35
+ <td>
36
+ {{ object.tsig_algorithm }}
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <th scope="row">Key</th>
41
+ <td>
42
+ {{ object.tsig_key }}
43
+ </td>
44
+ </tr>
45
+ </table>
46
+ </div>
47
+ <div class="card">
48
+ <div class="justify-content-between card-header">
49
+ <h1 class="card-title">Forward Zones</h1>
50
+ </div>
51
+ <div class="card-body table-responsive">
52
+ {% render_table zone_table %}
53
+ </div>
54
+ </div>
55
+ <div class="card">
56
+ <div class="justify-content-between card-header">
57
+ <h1 class="card-title">Reverse Zones</h1>
58
+ </div>
59
+ <div class="card-body table-responsive">
60
+ {% render_table reversezone_table %}
61
+ </div>
62
+ </div>
63
+ {% include 'inc/panels/custom_fields.html' %}
64
+ {% include 'inc/panels/tags.html' %}
65
+ </div>
66
+ </div>
67
+
68
+ {% endblock content %}
@@ -0,0 +1,11 @@
1
+ {% if perms.ipam.change_ipaddress %}
2
+ <form method="post" class="inline-block">
3
+ {% csrf_token %}
4
+
5
+ <button type="submit" name="_edit"
6
+ formaction="{% url 'plugins:netbox_ddns:reversezone_recreate_record' pk=object.pk %}"
7
+ class="btn btn-secondary">
8
+ <span class="mdi mdi-refresh" aria-hidden="true"></span> Recreate all Records
9
+ </button>
10
+ </form>
11
+ {% endif %}
@@ -0,0 +1,11 @@
1
+ {% if perms.ipam.change_ipaddress %}
2
+ <form method="post" class="inline-block">
3
+ {% csrf_token %}
4
+
5
+ <button type="submit" name="_edit"
6
+ formaction="{% url 'plugins:netbox_ddns:zone_recreate_record' pk=object.pk %}"
7
+ class="btn btn-secondary">
8
+ <span class="mdi mdi-refresh" aria-hidden="true"></span> Recreate all Records
9
+ </button>
10
+ </form>
11
+ {% endif %}
@@ -0,0 +1,53 @@
1
+ {% extends 'generic/object.html' %}
2
+ {% load render_table from django_tables2 %}
3
+
4
+ {% block content %}
5
+ <div class="row">
6
+ <div class="col col-md-6">
7
+ <div class="card">
8
+ <h2 class="card-header">Zone</h2>
9
+ <table class="table table-hover attr-table">
10
+ <tr>
11
+ <th scope="row">Name</th>
12
+ <td>
13
+ {{ object.name }}
14
+ </td>
15
+ </tr>
16
+ <tr>
17
+ <th scope="row">TTL</th>
18
+ <td>
19
+ {{ object.ttl }}
20
+ </td>
21
+ </tr>
22
+ <tr>
23
+ <th scope="row">Server</th>
24
+ <td>
25
+ <a href="{{ object.server.get_absolute_url }}">
26
+ {{ object.server }}
27
+ </a>
28
+ </td>
29
+ </tr>
30
+ </table>
31
+ </div>
32
+ <div class="card">
33
+ <div class="justify-content-between card-header">
34
+ <h1 class="card-title">IP Addresses</h1>
35
+ </div>
36
+ <div class="card-body table-responsive">
37
+ {% render_table ip_address_table %}
38
+ </div>
39
+ </div>
40
+ <div class="card">
41
+ <div class="justify-content-between card-header">
42
+ <h1 class="card-title">Extra DNS Names</h1>
43
+ </div>
44
+ <div class="card-body table-responsive">
45
+ {% render_table extra_dns_name_table %}
46
+ </div>
47
+ </div>
48
+ {% include 'inc/panels/custom_fields.html' %}
49
+ {% include 'inc/panels/tags.html' %}
50
+ </div>
51
+ </div>
52
+
53
+ {% endblock content %}
netbox_ddns/urls.py CHANGED
@@ -1,18 +1,34 @@
1
- from django.urls import path
1
+ from django.urls import path, include
2
2
 
3
- from .views import ExtraDNSNameCreateView, ExtraDNSNameDeleteView, ExtraDNSNameEditView, IPAddressDNSNameRecreateView
3
+ from utilities.urls import get_model_urls
4
+ from .views import ExtraDNSNameCreateView, IPAddressDNSNameRecreateView, \
5
+ UpdateForwardZone, UpdateReverseZone
4
6
 
5
7
  urlpatterns = [
8
+
9
+ path('extra-dns-names/', include(get_model_urls('netbox_ddns', 'extradnsname', detail=False))),
10
+ path('extra-dns-names/<int:pk>/', include(get_model_urls('netbox_ddns', 'extradnsname'))),
11
+
12
+ path('reverse-zones/', include(get_model_urls('netbox_ddns', 'reversezone', detail=False))),
13
+ path('reverse-zones/<int:pk>/', include(get_model_urls('netbox_ddns', 'reversezone'))),
14
+
15
+ path('zones/', include(get_model_urls('netbox_ddns', 'zone', detail=False))),
16
+ path('zones/<int:pk>/', include(get_model_urls('netbox_ddns', 'zone'))),
17
+
18
+ path('servers/', include(get_model_urls('netbox_ddns', 'server', detail=False))),
19
+ path('servers/<int:pk>/', include(get_model_urls('netbox_ddns', 'server'))),
20
+
21
+ path(route='zones/<int:pk>/recreate_records/',
22
+ view=UpdateForwardZone.as_view(),
23
+ name='zone_recreate_record'),
24
+ path(route='reverse-zones/<int:pk>/recreate_records/',
25
+ view=UpdateReverseZone.as_view(),
26
+ name='reversezone_recreate_record'),
6
27
  path(route='ip-addresses/<int:ipaddress_pk>/recreate/',
7
28
  view=IPAddressDNSNameRecreateView.as_view(),
8
29
  name='ipaddress_dnsname_recreate'),
9
- path(route='ip-addresses/<int:ipaddress_pk>/extra/create/',
30
+ path(route='ip-addresses/<int:ipaddress_pk>/extra-dns-name/create/',
10
31
  view=ExtraDNSNameCreateView.as_view(),
11
- name='extradnsname_create'),
12
- path(route='ip-addresses/<int:ipaddress_pk>/extra/<int:pk>/edit/',
13
- view=ExtraDNSNameEditView.as_view(),
14
- name='extradnsname_edit'),
15
- path(route='ip-addresses/<int:ipaddress_pk>/extra/<int:pk>/delete/',
16
- view=ExtraDNSNameDeleteView.as_view(),
17
- name='extradnsname_delete'),
32
+ name='extradnsname_ip_address_create'),
33
+
18
34
  ]