mirror of
https://github.com/drygdryg/netbox-plugin-interface-sync
synced 2024-11-29 18:20:52 +03:00
Improved interface type readability
This commit is contained in:
parent
cedba0b67d
commit
10ccc72c09
@ -75,7 +75,7 @@ function uncheck(event) {
|
|||||||
{{ template.name }}
|
{{ template.name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ template.type }}</td>
|
<td>{{ template.type_display }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if not interface %}
|
{% if not interface %}
|
||||||
<label class="checkbox-group">
|
<label class="checkbox-group">
|
||||||
@ -127,7 +127,7 @@ function uncheck(event) {
|
|||||||
{{ interface.name }}
|
{{ interface.name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ interface.type }}</td>
|
<td>{{ interface.type_display }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if not template %}
|
{% if not template %}
|
||||||
<label class="checkbox-group">
|
<label class="checkbox-group">
|
||||||
|
@ -23,6 +23,7 @@ class UnifiedInterface:
|
|||||||
id: int
|
id: int
|
||||||
name: str
|
name: str
|
||||||
type: str
|
type: str
|
||||||
|
type_display: str
|
||||||
is_template: bool = False
|
is_template: bool = False
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
@ -22,8 +22,9 @@ class InterfaceComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View)
|
|||||||
interfaces = list(filter(lambda i: not i.is_virtual, interfaces))
|
interfaces = list(filter(lambda i: not i.is_virtual, interfaces))
|
||||||
interface_templates = InterfaceTemplate.objects.filter(device_type=device.device_type)
|
interface_templates = InterfaceTemplate.objects.filter(device_type=device.device_type)
|
||||||
|
|
||||||
unified_interfaces = [UnifiedInterface(i.id, i.name, i.type) for i in interfaces]
|
unified_interfaces = [UnifiedInterface(i.id, i.name, i.type, i.get_type_display()) for i in interfaces]
|
||||||
unified_interface_templates = [UnifiedInterface(i.id, i.name, i.type, is_template=True) for i in interface_templates]
|
unified_interface_templates = [
|
||||||
|
UnifiedInterface(i.id, i.name, i.type, i.get_type_display(), is_template=True) for i in interface_templates]
|
||||||
|
|
||||||
# List of interfaces and interface templates presented in the unified format
|
# List of interfaces and interface templates presented in the unified format
|
||||||
overall_interfaces = list(set(unified_interface_templates + unified_interfaces))
|
overall_interfaces = list(set(unified_interface_templates + unified_interfaces))
|
||||||
@ -84,12 +85,13 @@ class InterfaceComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View)
|
|||||||
# Getting and validating a list of interfaces to rename
|
# Getting and validating a list of interfaces to rename
|
||||||
fix_name_interfaces = filter(lambda i: str(i.id) in request.POST.getlist("fix_name"), interfaces)
|
fix_name_interfaces = filter(lambda i: str(i.id) in request.POST.getlist("fix_name"), interfaces)
|
||||||
# Casting interface templates into UnifiedInterface objects for proper comparison with interfaces for renaming
|
# Casting interface templates into UnifiedInterface objects for proper comparison with interfaces for renaming
|
||||||
unified_interface_templates = [UnifiedInterface(i.id, i.name, i.type) for i in interface_templates]
|
unified_interface_templates = [
|
||||||
|
UnifiedInterface(i.id, i.name, i.type, i.get_type_display()) for i in interface_templates]
|
||||||
|
|
||||||
# Rename selected interfaces
|
# Rename selected interfaces
|
||||||
interfaces_fixed = 0
|
interfaces_fixed = 0
|
||||||
for interface in fix_name_interfaces:
|
for interface in fix_name_interfaces:
|
||||||
unified_interface = UnifiedInterface(interface.id, interface.name, interface.type)
|
unified_interface = UnifiedInterface(interface.id, interface.name, interface.type, interface.get_type_display())
|
||||||
try:
|
try:
|
||||||
# Try to extract an interface template with the corresponding name
|
# Try to extract an interface template with the corresponding name
|
||||||
corresponding_template = unified_interface_templates[unified_interface_templates.index(unified_interface)]
|
corresponding_template = unified_interface_templates[unified_interface_templates.index(unified_interface)]
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', encoding='utf-8') as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='netbox-interface-sync',
|
name='netbox-interface-sync',
|
||||||
version='0.1.2',
|
version='0.1.3',
|
||||||
description='Syncing interfaces with the interfaces from device type for NetBox devices',
|
description='Syncing interfaces with the interfaces from device type for NetBox devices',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type='text/markdown',
|
||||||
|
Loading…
Reference in New Issue
Block a user