|
|
@@ -1,11 +1,24 @@
|
|
|
+from django.utils.translation import gettext_lazy as _
|
|
|
+
|
|
|
+from extras.ui.panels import CustomFieldsPanel, TagsPanel
|
|
|
from ipam.tables import RouteTargetTable
|
|
|
from netbox.object_actions import AddObject, BulkDelete, BulkEdit, BulkExport, BulkImport
|
|
|
+from netbox.ui import actions, layout
|
|
|
+from netbox.ui.panels import (
|
|
|
+ CommentsPanel,
|
|
|
+ ContextTablePanel,
|
|
|
+ ObjectsTablePanel,
|
|
|
+ PluginContentPanel,
|
|
|
+ RelatedObjectsPanel,
|
|
|
+ TemplatePanel,
|
|
|
+)
|
|
|
from netbox.views import generic
|
|
|
from utilities.query import count_related
|
|
|
from utilities.views import GetRelatedModelsMixin, register_model_view
|
|
|
|
|
|
from . import filtersets, forms, tables
|
|
|
from .models import *
|
|
|
+from .ui import panels
|
|
|
|
|
|
#
|
|
|
# Tunnel groups
|
|
|
@@ -25,6 +38,17 @@ class TunnelGroupListView(generic.ObjectListView):
|
|
|
@register_model_view(TunnelGroup)
|
|
|
class TunnelGroupView(GetRelatedModelsMixin, generic.ObjectView):
|
|
|
queryset = TunnelGroup.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.TunnelGroupPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ RelatedObjectsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
def get_extra_context(self, request, instance):
|
|
|
return {
|
|
|
@@ -92,6 +116,30 @@ class TunnelListView(generic.ObjectListView):
|
|
|
@register_model_view(Tunnel)
|
|
|
class TunnelView(generic.ObjectView):
|
|
|
queryset = Tunnel.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.TunnelPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ ],
|
|
|
+ bottom_panels=[
|
|
|
+ ObjectsTablePanel(
|
|
|
+ 'vpn.tunneltermination',
|
|
|
+ filters={'tunnel_id': lambda ctx: ctx['object'].pk},
|
|
|
+ actions=[
|
|
|
+ actions.AddObject(
|
|
|
+ 'vpn.tunneltermination',
|
|
|
+ url_params={'tunnel': lambda ctx: ctx['object'].pk},
|
|
|
+ label=_('Add a Termination'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ title=_('Terminations'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
|
|
|
@register_model_view(Tunnel, 'add', detail=False)
|
|
|
@@ -160,6 +208,25 @@ class TunnelTerminationListView(generic.ObjectListView):
|
|
|
@register_model_view(TunnelTermination)
|
|
|
class TunnelTerminationView(generic.ObjectView):
|
|
|
queryset = TunnelTermination.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.TunnelTerminationPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ ],
|
|
|
+ bottom_panels=[
|
|
|
+ ObjectsTablePanel(
|
|
|
+ 'vpn.tunneltermination',
|
|
|
+ filters={
|
|
|
+ 'tunnel_id': lambda ctx: ctx['object'].tunnel.pk,
|
|
|
+ 'id__n': lambda ctx: ctx['object'].pk,
|
|
|
+ },
|
|
|
+ title=_('Peer Terminations'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
|
|
|
@register_model_view(TunnelTermination, 'add', detail=False)
|
|
|
@@ -210,6 +277,23 @@ class IKEProposalListView(generic.ObjectListView):
|
|
|
@register_model_view(IKEProposal)
|
|
|
class IKEProposalView(generic.ObjectView):
|
|
|
queryset = IKEProposal.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.IKEProposalPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ ],
|
|
|
+ bottom_panels=[
|
|
|
+ ObjectsTablePanel(
|
|
|
+ 'vpn.ikepolicy',
|
|
|
+ filters={'ike_proposal_id': lambda ctx: ctx['object'].pk},
|
|
|
+ title=_('IKE Policies'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
|
|
|
@register_model_view(IKEProposal, 'add', detail=False)
|
|
|
@@ -264,8 +348,31 @@ class IKEPolicyListView(generic.ObjectListView):
|
|
|
|
|
|
|
|
|
@register_model_view(IKEPolicy)
|
|
|
-class IKEPolicyView(generic.ObjectView):
|
|
|
+class IKEPolicyView(GetRelatedModelsMixin, generic.ObjectView):
|
|
|
queryset = IKEPolicy.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.IKEPolicyPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ RelatedObjectsPanel(),
|
|
|
+ ],
|
|
|
+ bottom_panels=[
|
|
|
+ ObjectsTablePanel(
|
|
|
+ 'vpn.ikeproposal',
|
|
|
+ filters={'ike_policy_id': lambda ctx: ctx['object'].pk},
|
|
|
+ title=_('Proposals'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
+
|
|
|
+ def get_extra_context(self, request, instance):
|
|
|
+ return {
|
|
|
+ 'related_models': self.get_related_models(request, instance),
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@register_model_view(IKEPolicy, 'add', detail=False)
|
|
|
@@ -322,6 +429,23 @@ class IPSecProposalListView(generic.ObjectListView):
|
|
|
@register_model_view(IPSecProposal)
|
|
|
class IPSecProposalView(generic.ObjectView):
|
|
|
queryset = IPSecProposal.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.IPSecProposalPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ ],
|
|
|
+ bottom_panels=[
|
|
|
+ ObjectsTablePanel(
|
|
|
+ 'vpn.ipsecpolicy',
|
|
|
+ filters={'ipsec_proposal_id': lambda ctx: ctx['object'].pk},
|
|
|
+ title=_('IPSec Policies'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
|
|
|
@register_model_view(IPSecProposal, 'add', detail=False)
|
|
|
@@ -376,8 +500,31 @@ class IPSecPolicyListView(generic.ObjectListView):
|
|
|
|
|
|
|
|
|
@register_model_view(IPSecPolicy)
|
|
|
-class IPSecPolicyView(generic.ObjectView):
|
|
|
+class IPSecPolicyView(GetRelatedModelsMixin, generic.ObjectView):
|
|
|
queryset = IPSecPolicy.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.IPSecPolicyPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ RelatedObjectsPanel(),
|
|
|
+ ],
|
|
|
+ bottom_panels=[
|
|
|
+ ObjectsTablePanel(
|
|
|
+ 'vpn.ipsecproposal',
|
|
|
+ filters={'ipsec_policy_id': lambda ctx: ctx['object'].pk},
|
|
|
+ title=_('Proposals'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
+
|
|
|
+ def get_extra_context(self, request, instance):
|
|
|
+ return {
|
|
|
+ 'related_models': self.get_related_models(request, instance),
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@register_model_view(IPSecPolicy, 'add', detail=False)
|
|
|
@@ -434,6 +581,18 @@ class IPSecProfileListView(generic.ObjectListView):
|
|
|
@register_model_view(IPSecProfile)
|
|
|
class IPSecProfileView(generic.ObjectView):
|
|
|
queryset = IPSecProfile.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.IPSecProfilePanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ TemplatePanel('vpn/panels/ipsecprofile_ike_policy.html'),
|
|
|
+ TemplatePanel('vpn/panels/ipsecprofile_ipsec_policy.html'),
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
|
|
|
@register_model_view(IPSecProfile, 'add', detail=False)
|
|
|
@@ -490,6 +649,45 @@ class L2VPNListView(generic.ObjectListView):
|
|
|
@register_model_view(L2VPN)
|
|
|
class L2VPNView(generic.ObjectView):
|
|
|
queryset = L2VPN.objects.all()
|
|
|
+ layout = layout.Layout(
|
|
|
+ layout.Row(
|
|
|
+ layout.Column(
|
|
|
+ panels.L2VPNPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ PluginContentPanel('left_page'),
|
|
|
+ ),
|
|
|
+ layout.Column(
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ CommentsPanel(),
|
|
|
+ PluginContentPanel('right_page'),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ layout.Row(
|
|
|
+ layout.Column(
|
|
|
+ ContextTablePanel('import_targets_table', title=_('Import Route Targets')),
|
|
|
+ ),
|
|
|
+ layout.Column(
|
|
|
+ ContextTablePanel('export_targets_table', title=_('Export Route Targets')),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ layout.Row(
|
|
|
+ layout.Column(
|
|
|
+ ObjectsTablePanel(
|
|
|
+ 'vpn.l2vpntermination',
|
|
|
+ filters={'l2vpn_id': lambda ctx: ctx['object'].pk},
|
|
|
+ actions=[
|
|
|
+ actions.AddObject(
|
|
|
+ 'vpn.l2vpntermination',
|
|
|
+ url_params={'l2vpn': lambda ctx: ctx['object'].pk},
|
|
|
+ label=_('Add a Termination'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ title=_('Terminations'),
|
|
|
+ ),
|
|
|
+ PluginContentPanel('full_width_page'),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
|
|
|
def get_extra_context(self, request, instance):
|
|
|
import_targets_table = RouteTargetTable(
|
|
|
@@ -564,6 +762,15 @@ class L2VPNTerminationListView(generic.ObjectListView):
|
|
|
@register_model_view(L2VPNTermination)
|
|
|
class L2VPNTerminationView(generic.ObjectView):
|
|
|
queryset = L2VPNTermination.objects.all()
|
|
|
+ layout = layout.SimpleLayout(
|
|
|
+ left_panels=[
|
|
|
+ panels.L2VPNTerminationPanel(),
|
|
|
+ ],
|
|
|
+ right_panels=[
|
|
|
+ CustomFieldsPanel(),
|
|
|
+ TagsPanel(),
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
|
|
|
@register_model_view(L2VPNTermination, 'add', detail=False)
|