mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
Clean up FHRP group templates, forms
This commit is contained in:
parent
93da5a39be
commit
2cb53a0f7e
@ -1,6 +1,6 @@
|
|||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
||||||
from .choices import IPAddressRoleChoices
|
from .choices import FHRPGroupProtocolChoices, IPAddressRoleChoices
|
||||||
|
|
||||||
# BGP ASN bounds
|
# BGP ASN bounds
|
||||||
BGP_ASN_MIN = 1
|
BGP_ASN_MIN = 1
|
||||||
@ -59,6 +59,14 @@ IPADDRESS_ROLES_NONUNIQUE = (
|
|||||||
FHRPGROUPASSIGNMENT_PRIORITY_MIN = 0
|
FHRPGROUPASSIGNMENT_PRIORITY_MIN = 0
|
||||||
FHRPGROUPASSIGNMENT_PRIORITY_MAX = 255
|
FHRPGROUPASSIGNMENT_PRIORITY_MAX = 255
|
||||||
|
|
||||||
|
FHRP_PROTOCOL_ROLE_MAPPINGS = {
|
||||||
|
FHRPGroupProtocolChoices.PROTOCOL_VRRP2: IPAddressRoleChoices.ROLE_VRRP,
|
||||||
|
FHRPGroupProtocolChoices.PROTOCOL_VRRP3: IPAddressRoleChoices.ROLE_VRRP,
|
||||||
|
FHRPGroupProtocolChoices.PROTOCOL_HSRP: IPAddressRoleChoices.ROLE_HSRP,
|
||||||
|
FHRPGroupProtocolChoices.PROTOCOL_GLBP: IPAddressRoleChoices.ROLE_GLBP,
|
||||||
|
FHRPGroupProtocolChoices.PROTOCOL_CARP: IPAddressRoleChoices.ROLE_CARP,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# VLANs
|
# VLANs
|
||||||
|
@ -521,13 +521,7 @@ class FHRPGroupForm(BootstrapMixin, CustomFieldModelForm):
|
|||||||
status=self.cleaned_data['ip_status'],
|
status=self.cleaned_data['ip_status'],
|
||||||
assigned_object=instance
|
assigned_object=instance
|
||||||
)
|
)
|
||||||
ipaddress.role = {
|
ipaddress.role = FHRP_PROTOCOL_ROLE_MAPPINGS[self.cleaned_data['protocol']]
|
||||||
FHRPGroupProtocolChoices.PROTOCOL_VRRP2: IPAddressRoleChoices.ROLE_VRRP,
|
|
||||||
FHRPGroupProtocolChoices.PROTOCOL_VRRP3: IPAddressRoleChoices.ROLE_VRRP,
|
|
||||||
FHRPGroupProtocolChoices.PROTOCOL_HSRP: IPAddressRoleChoices.ROLE_HSRP,
|
|
||||||
FHRPGroupProtocolChoices.PROTOCOL_GLBP: IPAddressRoleChoices.ROLE_GLBP,
|
|
||||||
FHRPGroupProtocolChoices.PROTOCOL_CARP: IPAddressRoleChoices.ROLE_CARP,
|
|
||||||
}[self.cleaned_data['protocol']]
|
|
||||||
ipaddress.save()
|
ipaddress.save()
|
||||||
|
|
||||||
# Check that the new IPAddress conforms with any assigned object-level permissions
|
# Check that the new IPAddress conforms with any assigned object-level permissions
|
||||||
|
@ -867,6 +867,7 @@ class FHRPGroupView(generic.ObjectView):
|
|||||||
class FHRPGroupEditView(generic.ObjectEditView):
|
class FHRPGroupEditView(generic.ObjectEditView):
|
||||||
queryset = FHRPGroup.objects.all()
|
queryset = FHRPGroup.objects.all()
|
||||||
model_form = forms.FHRPGroupForm
|
model_form = forms.FHRPGroupForm
|
||||||
|
template_name = 'ipam/fhrpgroup_edit.html'
|
||||||
|
|
||||||
def get_return_url(self, request, obj=None):
|
def get_return_url(self, request, obj=None):
|
||||||
return_url = super().get_return_url(request, obj)
|
return_url = super().get_return_url(request, obj)
|
||||||
@ -909,6 +910,7 @@ class FHRPGroupBulkDeleteView(generic.BulkDeleteView):
|
|||||||
class FHRPGroupAssignmentEditView(generic.ObjectEditView):
|
class FHRPGroupAssignmentEditView(generic.ObjectEditView):
|
||||||
queryset = FHRPGroupAssignment.objects.all()
|
queryset = FHRPGroupAssignment.objects.all()
|
||||||
model_form = forms.FHRPGroupAssignmentForm
|
model_form = forms.FHRPGroupAssignmentForm
|
||||||
|
template_name = 'ipam/fhrpgroupassignment_edit.html'
|
||||||
|
|
||||||
def alter_obj(self, instance, request, args, kwargs):
|
def alter_obj(self, instance, request, args, kwargs):
|
||||||
if not instance.pk:
|
if not instance.pk:
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5 class="card-header">IP Addresses</h5>
|
<h5 class="card-header">Virtual IP Addresses</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{% if ipaddress_table.rows %}
|
{% if ipaddress_table.rows %}
|
||||||
{% render_table ipaddress_table 'inc/table.html' %}
|
{% render_table ipaddress_table 'inc/table.html' %}
|
||||||
|
40
netbox/templates/ipam/fhrpgroup_edit.html
Normal file
40
netbox/templates/ipam/fhrpgroup_edit.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{% extends 'generic/object_edit.html' %}
|
||||||
|
{% load form_helpers %}
|
||||||
|
|
||||||
|
{% block form %}
|
||||||
|
<div class="field-group my-5">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<h5 class="offset-sm-3">FHRP Group</h5>
|
||||||
|
</div>
|
||||||
|
{% render_field form.protocol %}
|
||||||
|
{% render_field form.group_id %}
|
||||||
|
{% render_field form.description %}
|
||||||
|
{% render_field form.tags %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field-group my-5">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<h5 class="offset-sm-3">Authentication</h5>
|
||||||
|
</div>
|
||||||
|
{% render_field form.auth_type %}
|
||||||
|
{% render_field form.auth_key %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if not form.instance.pk %}
|
||||||
|
<div class="field-group my-5">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<h5 class="offset-sm-3">Virtual IP Address</h5>
|
||||||
|
</div>
|
||||||
|
{% render_field form.ip_vrf %}
|
||||||
|
{% render_field form.ip_address %}
|
||||||
|
{% render_field form.ip_status %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if form.custom_fields %}
|
||||||
|
<div class="row mb-2">
|
||||||
|
<h5 class="offset-sm-3">Custom Fields</h5>
|
||||||
|
</div>
|
||||||
|
{% render_custom_fields form %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
18
netbox/templates/ipam/fhrpgroupassignment_edit.html
Normal file
18
netbox/templates/ipam/fhrpgroupassignment_edit.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{% extends 'generic/object_edit.html' %}
|
||||||
|
{% load form_helpers %}
|
||||||
|
|
||||||
|
{% block form %}
|
||||||
|
<div class="field-group my-5">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<h5 class="offset-sm-3">FHRP Group Assignment</h5>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label class="col-sm-3 col-form-label text-lg-end">Interface</label>
|
||||||
|
<div class="col">
|
||||||
|
<input class="form-control" value="{{ form.instance.object }}" disabled />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% render_field form.group %}
|
||||||
|
{% render_field form.priority %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user