netbox-ddns 1.4.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.
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-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-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]
@@ -1,134 +1,11 @@
1
- {% extends 'generic/_base.html' %}
2
- {% load buttons %}
3
- {% load custom_links %}
4
- {% load helpers %}
5
- {% load perms %}
6
- {% load plugins %}
7
- {% load tabs %}
8
- {% load i18n %}
9
-
10
- {% comment %}
11
- Blocks:
12
- - page-header: Content displayed above the primary page content
13
- - breadcrumbs: Breadcrumb list items(HTML
14
- <li> elements)
15
- - object_identifier: Unique identifier for the object
16
- - title: Page title
17
- - subtitle: Additional context displayed below the title
18
- - controls: Control elements displayed between the header and content
19
- - control-buttons: Action buttons (add/edit/delete/etc.)
20
- - extra_controls: Any additional action buttons to display
21
- - tabs: Page tabs
22
- - content: Primary page content
23
- - modals: Any pre-loaded modals
24
-
25
- Context:
26
- - object: The object being viewed
27
- {% endcomment %}
28
-
29
- {% block page-header %}
30
- <div class="container-fluid">
31
- <div class="d-flex justify-content-between align-items-center mt-2">
32
-
33
- {# Object identifier #}
34
- <code class="d-block text-muted bg-transparent px-0">
35
- {% block object_identifier %}
36
- {{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}:{{ object.pk }}
37
- {% if object.slug %}({{ object.slug }}){% endif %}
38
- {% endblock object_identifier %}
39
- </code>
40
-
41
- </div>
42
- </div>
43
- {{ block.super }}
44
- {% endblock page-header %}
45
-
46
- {% block title %}{{ object }}{% endblock %}
47
-
48
- {% block subtitle %}
49
- <div class="text-secondary fs-5">
50
- {% trans "Created" %} {{ object.created|isodatetime:"minutes" }}
51
- {% if object.last_updated %}
52
- <span class="separator">&middot;</span>
53
- {% trans "Updated" %} {{ object.last_updated|isodatetime:"minutes" }}
54
- {% endif %}
55
- </div>
56
- {% endblock subtitle %}
57
-
58
- {% block controls %}
59
- <div class="btn-list justify-content-end mb-2">
60
- {% plugin_buttons object %}
61
-
62
- {# Add/edit/delete/etc. buttons #}
63
- {% block control-buttons %}
64
-
65
- {# Extra buttons #}
66
- {% block extra_controls %}{% endblock %}
67
-
68
- {# Default buttons #}
69
- {% if perms.extras.add_bookmark and object.bookmarks %}
70
- {% bookmark_button object %}
71
- {% endif %}
72
- {% if perms.extras.add_subscription and object.subscriptions %}
73
- {% subscribe_button object %}
74
- {% endif %}
75
- {% if request.user|can_change:object %}
76
- {% load i18n %}
77
- <a href="{% url 'plugins:netbox_ddns:extradnsname_edit' ipaddress_pk=object.ip_address.pk pk=object.pk %}"
78
- class="btn btn-yellow" role="button">
79
- <i class="mdi mdi-pencil" aria-hidden="true"></i> {% trans "Edit" %}
80
- </a>
81
- {% endif %}
82
- {% if request.user|can_delete:object %}
83
- {% load i18n %}
84
- <a href="#"
85
- hx-get="{% url 'plugins:netbox_ddns:extradnsname_delete' ipaddress_pk=object.ip_address.pk pk=object.pk %}"
86
- hx-target="#htmx-modal-content"
87
- hx-swap="innerHTML"
88
- hx-select="form"
89
- class="btn btn-red"
90
- data-bs-toggle="modal"
91
- data-bs-target="#htmx-modal"
92
- >
93
- <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete" %}
94
- </a>
95
-
96
- {% endif %}
97
- {% endblock control-buttons %}
98
- </div>
99
-
100
- {# Custom links #}
101
- <div class="d-flex justify-content-end">
102
- <div class="btn-list">
103
- {% block custom-links %}
104
- {% custom_links object %}
105
- {% endblock custom-links %}
106
- </div>
107
- </div>
108
- {% endblock controls %}
109
-
110
- {% block tabs %}
111
- <ul class="nav nav-tabs" role="presentation">
112
- {# Primary tab #}
113
- <li class="nav-item">
114
- <a class="nav-link{% if not tab %} active{% endif %}" href="{{ object.get_absolute_url }}">
115
- {{ object|meta:"verbose_name"|bettertitle }}</a>
116
- </li>
117
-
118
- {# Include tabs for registered model views #}
119
- {% model_view_tabs object %}
120
- </ul>
121
- {% endblock tabs %}
122
-
123
- {% block alerts %}
124
- {% plugin_alerts object %}
125
- {% endblock alerts %}
1
+ {% extends 'generic/object.html' %}
2
+ {% load render_table from django_tables2 %}
126
3
 
127
4
  {% block content %}
128
5
  <div class="row mb-3">
129
6
  <div class="col col-md-6">
130
7
  <div class="card">
131
- <h5 class="card-header">Access List</h5>
8
+ <h5 class="card-header">Extra DNS name</h5>
132
9
  <div class="card-body">
133
10
  <table class="table table-hover attr-table">
134
11
  <tr>
@@ -158,12 +35,27 @@
158
35
  </table>
159
36
  </div>
160
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>
161
57
  {% include 'inc/panels/custom_fields.html' %}
162
58
  </div>
163
59
  <div class="col col-md-6">{% include 'inc/panels/tags.html' %}</div>
164
60
  </div>
165
- {% endblock content %}
166
-
167
- {% block modals %}
168
- {% include 'inc/htmx_modal.html' %}
169
- {% endblock modals %}
61
+ {% endblock content %}
@@ -10,7 +10,7 @@
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 %}"
13
+ <a href="{% url 'plugins:netbox_ddns:extradnsname_ip_address_create' ipaddress_pk=object.pk %}"
14
14
  class="btn btn-primary">
15
15
  <span class="mdi mdi-plus" aria-hidden="true"></span>Add extra DNS name
16
16
  </a>
@@ -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,22 +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, ExtraDNSNameView
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'),
18
-
19
- path(route='ip-addresses/<int:ipaddress_pk>/extra/<int:pk>/',
20
- view=ExtraDNSNameView.as_view(),
21
- name='extradnsname'),
32
+ name='extradnsname_ip_address_create'),
33
+
22
34
  ]