mirror of
https://github.com/drygdryg/netbox-plugin-interface-sync
synced 2024-11-25 18:10: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 }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ template.type }}</td>
|
||||
<td>{{ template.type_display }}</td>
|
||||
<td>
|
||||
{% if not interface %}
|
||||
<label class="checkbox-group">
|
||||
@ -127,7 +127,7 @@ function uncheck(event) {
|
||||
{{ interface.name }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ interface.type }}</td>
|
||||
<td>{{ interface.type_display }}</td>
|
||||
<td>
|
||||
{% if not template %}
|
||||
<label class="checkbox-group">
|
||||
|
@ -23,6 +23,7 @@ class UnifiedInterface:
|
||||
id: int
|
||||
name: str
|
||||
type: str
|
||||
type_display: str
|
||||
is_template: bool = False
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -22,8 +22,9 @@ class InterfaceComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View)
|
||||
interfaces = list(filter(lambda i: not i.is_virtual, interfaces))
|
||||
interface_templates = InterfaceTemplate.objects.filter(device_type=device.device_type)
|
||||
|
||||
unified_interfaces = [UnifiedInterface(i.id, i.name, i.type) for i in interfaces]
|
||||
unified_interface_templates = [UnifiedInterface(i.id, i.name, i.type, is_template=True) for i in interface_templates]
|
||||
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, i.get_type_display(), is_template=True) for i in interface_templates]
|
||||
|
||||
# List of interfaces and interface templates presented in the unified format
|
||||
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
|
||||
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
|
||||
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
|
||||
interfaces_fixed = 0
|
||||
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 to extract an interface template with the corresponding name
|
||||
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(
|
||||
name='netbox-interface-sync',
|
||||
version='0.1.2',
|
||||
version='0.1.3',
|
||||
description='Syncing interfaces with the interfaces from device type for NetBox devices',
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
|
Loading…
Reference in New Issue
Block a user